|
@@ -14,14 +14,13 @@
|
|
|
* acknowledgement, read the HID descriptor and the max-X/Y commands, select
|
|
* acknowledgement, read the HID descriptor and the max-X/Y commands, select
|
|
|
* absolute mode (0x0300) and wake the device (0x0800).
|
|
* absolute mode (0x0300) and wake the device (0x0800).
|
|
|
*
|
|
*
|
|
|
- * The clickpad has no right button, so a short stationary tap is turned into
|
|
|
|
|
- * a synthetic click: two fingers (or one finger in the bottom-right corner)
|
|
|
|
|
- * is a right click, one finger elsewhere is a left click. The press is held
|
|
|
|
|
- * briefly so ring-3 commands polling SYS_WIN_POINTER sample it. Resetting
|
|
|
|
|
- * last leaves the device silent until the next power cycle.
|
|
|
|
|
|
|
+ * Report decoding is Elan-specific; the contact behaviour (pointer deltas,
|
|
|
|
|
+ * taps, the physical-button latch and two-finger scrolling) lives in
|
|
|
|
|
+ * touchpad_gesture.c so another touchpad driver can reuse it.
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
#include "touchpad.h"
|
|
#include "touchpad.h"
|
|
|
|
|
+#include "touchpad_gesture.h"
|
|
|
#include "i2c.h"
|
|
#include "i2c.h"
|
|
|
#include "io.h"
|
|
#include "io.h"
|
|
|
#include "paging.h"
|
|
#include "paging.h"
|
|
@@ -50,25 +49,6 @@
|
|
|
#define TP_MAX_INPUT 64
|
|
#define TP_MAX_INPUT 64
|
|
|
#define TP_POLL_MS 25
|
|
#define TP_POLL_MS 25
|
|
|
|
|
|
|
|
-/* Tap gestures. The report is polled at 40 Hz, so a tap must last at least
|
|
|
|
|
- * two samples to be seen; the movement cap keeps a swipe from clicking. */
|
|
|
|
|
-#define TP_TAP_MIN_MS 40
|
|
|
|
|
-#define TP_TAP_MAX_MS 300
|
|
|
|
|
-#define TP_TAP_MOVE 60
|
|
|
|
|
-#define TP_CLICK_HOLD_MS 120
|
|
|
|
|
-
|
|
|
|
|
-/* Software right button zones: right 25% x bottom 25% of the pad. The raw
|
|
|
|
|
- * Elan Y axis grows upwards, so the bottom is the low end. */
|
|
|
|
|
-#define TP_CORNER_X_PCT 75
|
|
|
|
|
-#define TP_CORNER_Y_PCT 25
|
|
|
|
|
-
|
|
|
|
|
-enum {
|
|
|
|
|
- TP_RC_OFF = 0,
|
|
|
|
|
- TP_RC_TAP = 1,
|
|
|
|
|
- TP_RC_CORNER = 2,
|
|
|
|
|
- TP_RC_BOTH = TP_RC_TAP | TP_RC_CORNER
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
static unsigned int tp_base;
|
|
static unsigned int tp_base;
|
|
|
static unsigned int tp_addr = TP_ADDR;
|
|
static unsigned int tp_addr = TP_ADDR;
|
|
|
static int tp_present;
|
|
static int tp_present;
|
|
@@ -82,28 +62,10 @@ static int tp_max_y = TP_ABS_MAX;
|
|
|
static const char *tp_err;
|
|
static const char *tp_err;
|
|
|
static unsigned int tp_err_val;
|
|
static unsigned int tp_err_val;
|
|
|
|
|
|
|
|
-static int tp_last_x, tp_last_y, tp_acc_x, tp_acc_y;
|
|
|
|
|
-static int tp_down, tp_last_buttons;
|
|
|
|
|
|
|
+static struct tpg_state tp_gesture;
|
|
|
|
|
+static int tp_last_buttons;
|
|
|
static unsigned int tp_next_poll;
|
|
static unsigned int tp_next_poll;
|
|
|
|
|
|
|
|
-/* Gesture configuration and synthesized-click state. */
|
|
|
|
|
-static unsigned int tp_rc_mode = TP_RC_BOTH;
|
|
|
|
|
-static int tp_tapclick = 1;
|
|
|
|
|
-static int tp_phys_raw; /* clickpad bit from the last report */
|
|
|
|
|
-static int tp_phys_btn; /* latched button: 0, 0x01 or 0x02 */
|
|
|
|
|
-static unsigned int tp_click_btn;
|
|
|
|
|
-static unsigned int tp_click_release_ms;
|
|
|
|
|
-static unsigned int tp_synth_left, tp_synth_right;
|
|
|
|
|
-
|
|
|
|
|
-/* One contact sequence: from the first finger down to the last finger up. */
|
|
|
|
|
-static int tp_gesture_active;
|
|
|
|
|
-static unsigned int tp_gesture_t0;
|
|
|
|
|
-static int tp_gesture_x0, tp_gesture_y0;
|
|
|
|
|
-static int tp_gesture_started;
|
|
|
|
|
-static int tp_gesture_moved;
|
|
|
|
|
-static int tp_gesture_two;
|
|
|
|
|
-static int tp_gesture_phys;
|
|
|
|
|
-
|
|
|
|
|
/* Last report, for the `touchpad` status command. */
|
|
/* Last report, for the `touchpad` status command. */
|
|
|
static int tp_stat_fingers, tp_stat_f1, tp_stat_x, tp_stat_y;
|
|
static int tp_stat_fingers, tp_stat_f1, tp_stat_x, tp_stat_y;
|
|
|
|
|
|
|
@@ -139,16 +101,25 @@ static void print_summary(void)
|
|
|
|
|
|
|
|
static void print_status(void)
|
|
static void print_status(void)
|
|
|
{
|
|
{
|
|
|
|
|
+ unsigned int opts = tpg_options(&tp_gesture);
|
|
|
|
|
+
|
|
|
print_summary();
|
|
print_summary();
|
|
|
io_putstr("touchpad: rightclick ");
|
|
io_putstr("touchpad: rightclick ");
|
|
|
io_putstr(rc_name());
|
|
io_putstr(rc_name());
|
|
|
io_putstr(" tapclick ");
|
|
io_putstr(" tapclick ");
|
|
|
- io_putstr(tp_tapclick ? "on" : "off");
|
|
|
|
|
|
|
+ io_putstr((opts & TPG_TAPCLICK) ? "on" : "off");
|
|
|
|
|
+ io_putstr(" scroll ");
|
|
|
|
|
+ io_putstr((opts & TPG_SCROLL) ? "on" : "off");
|
|
|
|
|
+ if (opts & TPG_SCROLL) {
|
|
|
|
|
+ io_putchar(' ');
|
|
|
|
|
+ io_putstr((opts & TPG_SCROLL_INVERT) ?
|
|
|
|
|
+ "traditional" : "natural");
|
|
|
|
|
+ }
|
|
|
io_putstr(" corner x>=");
|
|
io_putstr(" corner x>=");
|
|
|
- put_dec((unsigned int)(tp_max_x * TP_CORNER_X_PCT / 100));
|
|
|
|
|
|
|
+ put_dec((unsigned int)(tp_max_x * TPG_CORNER_X_PCT / 100));
|
|
|
io_putstr(" y<=");
|
|
io_putstr(" y<=");
|
|
|
- put_dec((unsigned int)(tp_max_y * TP_CORNER_Y_PCT / 100));
|
|
|
|
|
- io_putstr("\n");
|
|
|
|
|
|
|
+ put_dec((unsigned int)(tp_max_y * TPG_CORNER_Y_PCT / 100));
|
|
|
|
|
+ io_putchar('\n');
|
|
|
io_putstr("touchpad: last f=");
|
|
io_putstr("touchpad: last f=");
|
|
|
put_dec((unsigned int)tp_stat_fingers);
|
|
put_dec((unsigned int)tp_stat_fingers);
|
|
|
if (tp_stat_f1) {
|
|
if (tp_stat_f1) {
|
|
@@ -158,9 +129,9 @@ static void print_status(void)
|
|
|
put_dec((unsigned int)tp_stat_y);
|
|
put_dec((unsigned int)tp_stat_y);
|
|
|
}
|
|
}
|
|
|
io_putstr(" taps left=");
|
|
io_putstr(" taps left=");
|
|
|
- put_dec(tp_synth_left);
|
|
|
|
|
|
|
+ put_dec(tp_gesture.taps_left);
|
|
|
io_putstr(" right=");
|
|
io_putstr(" right=");
|
|
|
- put_dec(tp_synth_right);
|
|
|
|
|
|
|
+ put_dec(tp_gesture.taps_right);
|
|
|
io_putchar('\n');
|
|
io_putchar('\n');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -222,32 +193,18 @@ static unsigned int word_len(const char *s)
|
|
|
return n;
|
|
return n;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-static int finger_count(unsigned int ti)
|
|
|
|
|
-{
|
|
|
|
|
- unsigned int mask = (ti >> 3) & 0x1f;
|
|
|
|
|
- int n = 0;
|
|
|
|
|
-
|
|
|
|
|
- while (mask) {
|
|
|
|
|
- n += (int)(mask & 1);
|
|
|
|
|
- mask >>= 1;
|
|
|
|
|
- }
|
|
|
|
|
- return n;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-static int in_corner(int x, int y)
|
|
|
|
|
-{
|
|
|
|
|
- return x >= tp_max_x * TP_CORNER_X_PCT / 100 &&
|
|
|
|
|
- y <= tp_max_y * TP_CORNER_Y_PCT / 100;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
static const char *rc_name(void)
|
|
static const char *rc_name(void)
|
|
|
{
|
|
{
|
|
|
- switch (tp_rc_mode) {
|
|
|
|
|
- case TP_RC_OFF: return "off";
|
|
|
|
|
- case TP_RC_TAP: return "tap";
|
|
|
|
|
- case TP_RC_CORNER: return "corner";
|
|
|
|
|
- default: return "both";
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ unsigned int m = tpg_options(&tp_gesture) &
|
|
|
|
|
+ (TPG_RIGHT_TAP | TPG_RIGHT_CORNER);
|
|
|
|
|
+
|
|
|
|
|
+ if (m == TPG_RIGHT_TAP)
|
|
|
|
|
+ return "tap";
|
|
|
|
|
+ if (m == TPG_RIGHT_CORNER)
|
|
|
|
|
+ return "corner";
|
|
|
|
|
+ if (m == (TPG_RIGHT_TAP | TPG_RIGHT_CORNER))
|
|
|
|
|
+ return "both";
|
|
|
|
|
+ return "off";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static int hid_read_reg(unsigned int addr, unsigned int reg,
|
|
static int hid_read_reg(unsigned int addr, unsigned int reg,
|
|
@@ -363,6 +320,7 @@ static int probe_controller(unsigned int base)
|
|
|
/* Query the limits with the device awake (Linux reads them after
|
|
/* Query the limits with the device awake (Linux reads them after
|
|
|
* initialize()/wake and before enabling reports). */
|
|
* initialize()/wake and before enabling reports). */
|
|
|
query_limits();
|
|
query_limits();
|
|
|
|
|
+ tpg_init(&tp_gesture, tp_max_x, tp_max_y, 2);
|
|
|
|
|
|
|
|
tp_present = 1;
|
|
tp_present = 1;
|
|
|
tp_err = 0;
|
|
tp_err = 0;
|
|
@@ -417,93 +375,16 @@ unsigned short touchpad_product(void)
|
|
|
return tp_product;
|
|
return tp_product;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-/* Track one contact sequence and turn a short, stationary tap into a
|
|
|
|
|
- * synthetic button press. The Elan report packs the touch info byte
|
|
|
|
|
- * (f5..f1 at bits 7..3, clickpad at bit 0) and five bytes per finger, so
|
|
|
|
|
- * the finger mask alone tells us whether this was a one- or two-finger
|
|
|
|
|
- * tap. Only finger 1 drives the pointer, and its data is valid only while
|
|
|
|
|
- * its presence bit is set. */
|
|
|
|
|
-static void touchpad_gesture(unsigned int ti, int x, int y, unsigned int now)
|
|
|
|
|
-{
|
|
|
|
|
- int fingers = finger_count(ti);
|
|
|
|
|
- int f1 = (ti & 0x08) != 0;
|
|
|
|
|
- unsigned int duration;
|
|
|
|
|
-
|
|
|
|
|
- tp_stat_fingers = fingers;
|
|
|
|
|
- tp_stat_f1 = f1;
|
|
|
|
|
- if (f1) {
|
|
|
|
|
- tp_stat_x = x;
|
|
|
|
|
- tp_stat_y = y;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (fingers) {
|
|
|
|
|
- if (!tp_gesture_active) {
|
|
|
|
|
- tp_gesture_active = 1;
|
|
|
|
|
- tp_gesture_t0 = now;
|
|
|
|
|
- tp_gesture_started = 0;
|
|
|
|
|
- tp_gesture_moved = 0;
|
|
|
|
|
- tp_gesture_two = 0;
|
|
|
|
|
- tp_gesture_phys = 0;
|
|
|
|
|
- }
|
|
|
|
|
- if (f1) {
|
|
|
|
|
- if (!tp_gesture_started) {
|
|
|
|
|
- tp_gesture_started = 1;
|
|
|
|
|
- tp_gesture_x0 = x;
|
|
|
|
|
- tp_gesture_y0 = y;
|
|
|
|
|
- } else {
|
|
|
|
|
- int ddx = x - tp_gesture_x0;
|
|
|
|
|
- int ddy = y - tp_gesture_y0;
|
|
|
|
|
-
|
|
|
|
|
- if (ddx < 0)
|
|
|
|
|
- ddx = -ddx;
|
|
|
|
|
- if (ddy < 0)
|
|
|
|
|
- ddy = -ddy;
|
|
|
|
|
- if (ddx > TP_TAP_MOVE || ddy > TP_TAP_MOVE)
|
|
|
|
|
- tp_gesture_moved = 1;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if (fingers >= 2)
|
|
|
|
|
- tp_gesture_two = 1;
|
|
|
|
|
- if (ti & 0x01)
|
|
|
|
|
- tp_gesture_phys = 1;
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (!tp_gesture_active)
|
|
|
|
|
- return;
|
|
|
|
|
-
|
|
|
|
|
- tp_gesture_active = 0;
|
|
|
|
|
- duration = now - tp_gesture_t0;
|
|
|
|
|
- if (duration < TP_TAP_MIN_MS || duration > TP_TAP_MAX_MS ||
|
|
|
|
|
- tp_gesture_moved || tp_gesture_phys)
|
|
|
|
|
- return;
|
|
|
|
|
-
|
|
|
|
|
- if (tp_gesture_two) {
|
|
|
|
|
- if (!(tp_rc_mode & TP_RC_TAP))
|
|
|
|
|
- return;
|
|
|
|
|
- tp_click_btn = 0x02;
|
|
|
|
|
- tp_synth_right++;
|
|
|
|
|
- } else if (tp_gesture_started &&
|
|
|
|
|
- (tp_rc_mode & TP_RC_CORNER) &&
|
|
|
|
|
- in_corner(tp_gesture_x0, tp_gesture_y0)) {
|
|
|
|
|
- tp_click_btn = 0x02;
|
|
|
|
|
- tp_synth_right++;
|
|
|
|
|
- } else if (tp_tapclick) {
|
|
|
|
|
- tp_click_btn = 0x01;
|
|
|
|
|
- tp_synth_left++;
|
|
|
|
|
- } else {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- /* Hold the synthetic press long enough for a ring-3 app polling
|
|
|
|
|
- * SYS_WIN_POINTER (typically every 10-16 ms) to sample it. */
|
|
|
|
|
- tp_click_release_ms = now + TP_CLICK_HOLD_MS;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-int touchpad_poll(int *buttons, int *dx, int *dy)
|
|
|
|
|
|
|
+int touchpad_poll(int *buttons, int *dx, int *dy, int *scroll)
|
|
|
{
|
|
{
|
|
|
unsigned char buf[TP_MAX_INPUT];
|
|
unsigned char buf[TP_MAX_INPUT];
|
|
|
unsigned int now, b;
|
|
unsigned int now, b;
|
|
|
|
|
+ struct tpg_result res;
|
|
|
|
|
|
|
|
|
|
+ *buttons = 0;
|
|
|
|
|
+ *dx = 0;
|
|
|
|
|
+ *dy = 0;
|
|
|
|
|
+ *scroll = 0;
|
|
|
if (!tp_present)
|
|
if (!tp_present)
|
|
|
return 0;
|
|
return 0;
|
|
|
|
|
|
|
@@ -511,10 +392,10 @@ int touchpad_poll(int *buttons, int *dx, int *dy)
|
|
|
|
|
|
|
|
/* The synthetic tap press is released by time, whether or not a new
|
|
/* The synthetic tap press is released by time, whether or not a new
|
|
|
* report arrives (the finger is already up). */
|
|
* report arrives (the finger is already up). */
|
|
|
- if (tp_click_btn && (int)(now - tp_click_release_ms) >= 0) {
|
|
|
|
|
- tp_click_btn = 0;
|
|
|
|
|
- *buttons = (unsigned int)tp_phys_btn;
|
|
|
|
|
- tp_last_buttons = *buttons;
|
|
|
|
|
|
|
+ tpg_tick(&tp_gesture, now, &res);
|
|
|
|
|
+ if (res.buttons != (unsigned int)tp_last_buttons) {
|
|
|
|
|
+ tp_last_buttons = (int)res.buttons;
|
|
|
|
|
+ *buttons = res.buttons;
|
|
|
return 1;
|
|
return 1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -529,87 +410,58 @@ int touchpad_poll(int *buttons, int *dx, int *dy)
|
|
|
* and then the report, so locate the 0x5D report ID instead of
|
|
* and then the report, so locate the 0x5D report ID instead of
|
|
|
* trusting a fixed offset. Layout after it (Linux hid-elan.c):
|
|
* trusting a fixed offset. Layout after it (Linux hid-elan.c):
|
|
|
* touch info (f5..f1 at bits 7..3, clickpad at bit 0), then 5
|
|
* touch info (f5..f1 at bits 7..3, clickpad at bit 0), then 5
|
|
|
- * bytes per active finger: x11:8/y11:9, x7:0, y7:0, size,
|
|
|
|
|
- * pressure. */
|
|
|
|
|
- for (b = 0; b < 6 && b + 4 < tp_max_in; b++)
|
|
|
|
|
|
|
+ * bytes per *active* finger (packed): x11:8/y11:9, x7:0, y7:0,
|
|
|
|
|
+ * size, pressure. */
|
|
|
|
|
+ for (b = 0; b < 6 && b + 6 < tp_max_in; b++)
|
|
|
if (buf[b] == TP_REPORT_ID)
|
|
if (buf[b] == TP_REPORT_ID)
|
|
|
break;
|
|
break;
|
|
|
- if (b >= 6 || b + 4 >= tp_max_in)
|
|
|
|
|
|
|
+ if (b >= 6 || b + 6 >= tp_max_in)
|
|
|
return 0;
|
|
return 0;
|
|
|
|
|
|
|
|
{
|
|
{
|
|
|
|
|
+ struct tpg_frame f;
|
|
|
unsigned int ti = buf[b + 1];
|
|
unsigned int ti = buf[b + 1];
|
|
|
- unsigned int xh = buf[b + 2];
|
|
|
|
|
- int x = ((int)(xh & 0xf0) << 4) | buf[b + 3];
|
|
|
|
|
- int y = ((int)(xh & 0x0f) << 8) | buf[b + 4];
|
|
|
|
|
-
|
|
|
|
|
- {
|
|
|
|
|
- int raw = (ti & 0x01) != 0;
|
|
|
|
|
- int f1 = (ti & 0x08) != 0;
|
|
|
|
|
-
|
|
|
|
|
- if (raw) {
|
|
|
|
|
- /* Latch at the leading edge: a physical
|
|
|
|
|
- * clickpad press in the bottom-right zone is
|
|
|
|
|
- * the right button, anywhere else the left
|
|
|
|
|
- * button, for the whole press (so a corner
|
|
|
|
|
- * drag stays a right drag). */
|
|
|
|
|
- if (!tp_phys_raw) {
|
|
|
|
|
- tp_phys_btn = 0x01;
|
|
|
|
|
- if ((tp_rc_mode & TP_RC_CORNER) && f1 &&
|
|
|
|
|
- in_corner(x, y))
|
|
|
|
|
- tp_phys_btn = 0x02;
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- tp_phys_btn = 0;
|
|
|
|
|
- }
|
|
|
|
|
- tp_phys_raw = raw;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- touchpad_gesture(ti, x, y, now);
|
|
|
|
|
- *buttons = (unsigned int)tp_phys_btn | tp_click_btn;
|
|
|
|
|
-
|
|
|
|
|
- if (!(ti & 0x08)) { /* finger 1 lifted */
|
|
|
|
|
- tp_down = 0;
|
|
|
|
|
- tp_acc_x = 0;
|
|
|
|
|
- tp_acc_y = 0;
|
|
|
|
|
- if (tp_last_buttons != *buttons) {
|
|
|
|
|
- tp_last_buttons = *buttons;
|
|
|
|
|
- return 1;
|
|
|
|
|
|
|
+ unsigned int off = b + 2;
|
|
|
|
|
+ unsigned int i, n = 0;
|
|
|
|
|
+
|
|
|
|
|
+ f.count = 0;
|
|
|
|
|
+ f.mask = 0;
|
|
|
|
|
+ f.button = ti & 0x01;
|
|
|
|
|
+ f.now_ms = now;
|
|
|
|
|
+ for (i = 0; i < 5; i++) {
|
|
|
|
|
+ if (!(ti & (0x08u << i)))
|
|
|
|
|
+ continue;
|
|
|
|
|
+ f.count++;
|
|
|
|
|
+ if (n < TPG_CONTACTS && off + 4 < tp_max_in) {
|
|
|
|
|
+ unsigned int xh = buf[off];
|
|
|
|
|
+
|
|
|
|
|
+ f.contact[n].x = ((int)(xh & 0xf0) << 4) |
|
|
|
|
|
+ buf[off + 1];
|
|
|
|
|
+ f.contact[n].y = ((int)(xh & 0x0f) << 8) |
|
|
|
|
|
+ buf[off + 2];
|
|
|
|
|
+ f.mask |= 1u << n;
|
|
|
|
|
+ n++;
|
|
|
}
|
|
}
|
|
|
- return 0;
|
|
|
|
|
- }
|
|
|
|
|
- if (!tp_down) {
|
|
|
|
|
- tp_down = 1;
|
|
|
|
|
- tp_last_x = x;
|
|
|
|
|
- tp_last_y = y;
|
|
|
|
|
- *dx = 0;
|
|
|
|
|
- *dy = 0;
|
|
|
|
|
- } else {
|
|
|
|
|
- tp_acc_x += x - tp_last_x;
|
|
|
|
|
- /* The Elan's Y axis increases upwards, already the
|
|
|
|
|
- * PS/2 convention: dragging up gives a positive dy. */
|
|
|
|
|
- tp_acc_y += y - tp_last_y;
|
|
|
|
|
- tp_last_x = x;
|
|
|
|
|
- tp_last_y = y;
|
|
|
|
|
- *dx = tp_acc_x / 2;
|
|
|
|
|
- tp_acc_x -= *dx * 2;
|
|
|
|
|
- *dy = tp_acc_y / 2;
|
|
|
|
|
- tp_acc_y -= *dy * 2;
|
|
|
|
|
|
|
+ off += 5;
|
|
|
}
|
|
}
|
|
|
- if (*dx > 64)
|
|
|
|
|
- *dx = 64;
|
|
|
|
|
- if (*dx < -64)
|
|
|
|
|
- *dx = -64;
|
|
|
|
|
- if (*dy > 64)
|
|
|
|
|
- *dy = 64;
|
|
|
|
|
- if (*dy < -64)
|
|
|
|
|
- *dy = -64;
|
|
|
|
|
- if (tp_last_buttons != *buttons) {
|
|
|
|
|
- tp_last_buttons = *buttons;
|
|
|
|
|
- return 1;
|
|
|
|
|
|
|
+ tp_stat_fingers = (int)f.count;
|
|
|
|
|
+ tp_stat_f1 = (f.mask & 1u) != 0;
|
|
|
|
|
+ if (f.mask & 1u) {
|
|
|
|
|
+ tp_stat_x = f.contact[0].x;
|
|
|
|
|
+ tp_stat_y = f.contact[0].y;
|
|
|
}
|
|
}
|
|
|
- return *dx || *dy;
|
|
|
|
|
|
|
+ tpg_frame(&tp_gesture, &f, &res);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ *buttons = res.buttons;
|
|
|
|
|
+ *dx = res.dx;
|
|
|
|
|
+ *dy = res.dy;
|
|
|
|
|
+ *scroll = res.scroll;
|
|
|
|
|
+ if (res.buttons != (unsigned int)tp_last_buttons) {
|
|
|
|
|
+ tp_last_buttons = (int)res.buttons;
|
|
|
|
|
+ return 1;
|
|
|
}
|
|
}
|
|
|
|
|
+ return res.dx || res.dy || res.scroll;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void program_touchpad_main(const char *arg)
|
|
void program_touchpad_main(const char *arg)
|
|
@@ -632,6 +484,8 @@ void program_touchpad_main(const char *arg)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
while (*arg) {
|
|
while (*arg) {
|
|
|
|
|
+ unsigned int opts = tpg_options(&tp_gesture);
|
|
|
|
|
+
|
|
|
if (word_is(arg, "rightclick")) {
|
|
if (word_is(arg, "rightclick")) {
|
|
|
const char *v = skip_spaces(arg + 10);
|
|
const char *v = skip_spaces(arg + 10);
|
|
|
|
|
|
|
@@ -641,18 +495,20 @@ void program_touchpad_main(const char *arg)
|
|
|
io_putchar('\n');
|
|
io_putchar('\n');
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- if (word_is(v, "off"))
|
|
|
|
|
- tp_rc_mode = TP_RC_OFF;
|
|
|
|
|
- else if (word_is(v, "tap"))
|
|
|
|
|
- tp_rc_mode = TP_RC_TAP;
|
|
|
|
|
- else if (word_is(v, "corner"))
|
|
|
|
|
- tp_rc_mode = TP_RC_CORNER;
|
|
|
|
|
- else if (word_is(v, "both"))
|
|
|
|
|
- tp_rc_mode = TP_RC_BOTH;
|
|
|
|
|
- else {
|
|
|
|
|
|
|
+ opts &= ~(TPG_RIGHT_TAP | TPG_RIGHT_CORNER);
|
|
|
|
|
+ if (word_is(v, "off")) {
|
|
|
|
|
+ /* keep both bits clear */
|
|
|
|
|
+ } else if (word_is(v, "tap")) {
|
|
|
|
|
+ opts |= TPG_RIGHT_TAP;
|
|
|
|
|
+ } else if (word_is(v, "corner")) {
|
|
|
|
|
+ opts |= TPG_RIGHT_CORNER;
|
|
|
|
|
+ } else if (word_is(v, "both")) {
|
|
|
|
|
+ opts |= TPG_RIGHT_TAP | TPG_RIGHT_CORNER;
|
|
|
|
|
+ } else {
|
|
|
io_putstr("touchpad: rightclick off|tap|corner|both\n");
|
|
io_putstr("touchpad: rightclick off|tap|corner|both\n");
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
+ tpg_set_options(&tp_gesture, opts);
|
|
|
io_putstr("touchpad: rightclick ");
|
|
io_putstr("touchpad: rightclick ");
|
|
|
io_putstr(rc_name());
|
|
io_putstr(rc_name());
|
|
|
io_putchar('\n');
|
|
io_putchar('\n');
|
|
@@ -662,24 +518,63 @@ void program_touchpad_main(const char *arg)
|
|
|
|
|
|
|
|
if (!*v) {
|
|
if (!*v) {
|
|
|
io_putstr("touchpad: tapclick ");
|
|
io_putstr("touchpad: tapclick ");
|
|
|
- io_putstr(tp_tapclick ? "on" : "off");
|
|
|
|
|
|
|
+ io_putstr((opts & TPG_TAPCLICK) ? "on" : "off");
|
|
|
io_putchar('\n');
|
|
io_putchar('\n');
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
if (word_is(v, "on"))
|
|
if (word_is(v, "on"))
|
|
|
- tp_tapclick = 1;
|
|
|
|
|
|
|
+ opts |= TPG_TAPCLICK;
|
|
|
else if (word_is(v, "off"))
|
|
else if (word_is(v, "off"))
|
|
|
- tp_tapclick = 0;
|
|
|
|
|
|
|
+ opts &= ~TPG_TAPCLICK;
|
|
|
else {
|
|
else {
|
|
|
io_putstr("touchpad: tapclick on|off\n");
|
|
io_putstr("touchpad: tapclick on|off\n");
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
+ tpg_set_options(&tp_gesture, opts);
|
|
|
io_putstr("touchpad: tapclick ");
|
|
io_putstr("touchpad: tapclick ");
|
|
|
- io_putstr(tp_tapclick ? "on" : "off");
|
|
|
|
|
|
|
+ io_putstr((opts & TPG_TAPCLICK) ? "on" : "off");
|
|
|
|
|
+ io_putchar('\n');
|
|
|
|
|
+ arg = skip_spaces(v + word_len(v));
|
|
|
|
|
+ } else if (word_is(arg, "scroll")) {
|
|
|
|
|
+ const char *v = skip_spaces(arg + 6);
|
|
|
|
|
+
|
|
|
|
|
+ if (!*v) {
|
|
|
|
|
+ io_putstr("touchpad: scroll ");
|
|
|
|
|
+ io_putstr((opts & TPG_SCROLL) ? "on" : "off");
|
|
|
|
|
+ if (opts & TPG_SCROLL) {
|
|
|
|
|
+ io_putchar(' ');
|
|
|
|
|
+ io_putstr((opts & TPG_SCROLL_INVERT) ?
|
|
|
|
|
+ "traditional" : "natural");
|
|
|
|
|
+ }
|
|
|
|
|
+ io_putchar('\n');
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (word_is(v, "on")) {
|
|
|
|
|
+ opts |= TPG_SCROLL;
|
|
|
|
|
+ } else if (word_is(v, "off")) {
|
|
|
|
|
+ opts &= ~TPG_SCROLL;
|
|
|
|
|
+ } else if (word_is(v, "natural")) {
|
|
|
|
|
+ opts |= TPG_SCROLL;
|
|
|
|
|
+ opts &= ~TPG_SCROLL_INVERT;
|
|
|
|
|
+ } else if (word_is(v, "traditional")) {
|
|
|
|
|
+ opts |= TPG_SCROLL;
|
|
|
|
|
+ opts |= TPG_SCROLL_INVERT;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ io_putstr("touchpad: scroll on|off|natural|traditional\n");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ tpg_set_options(&tp_gesture, opts);
|
|
|
|
|
+ io_putstr("touchpad: scroll ");
|
|
|
|
|
+ io_putstr((opts & TPG_SCROLL) ? "on" : "off");
|
|
|
|
|
+ if (opts & TPG_SCROLL) {
|
|
|
|
|
+ io_putchar(' ');
|
|
|
|
|
+ io_putstr((opts & TPG_SCROLL_INVERT) ?
|
|
|
|
|
+ "traditional" : "natural");
|
|
|
|
|
+ }
|
|
|
io_putchar('\n');
|
|
io_putchar('\n');
|
|
|
arg = skip_spaces(v + word_len(v));
|
|
arg = skip_spaces(v + word_len(v));
|
|
|
} else {
|
|
} else {
|
|
|
- io_putstr("touchpad: usage: touchpad [rightclick off|tap|corner|both | tapclick on|off]\n");
|
|
|
|
|
|
|
+ io_putstr("touchpad: usage: touchpad [rightclick off|tap|corner|both | tapclick on|off | scroll on|off|natural|traditional]\n");
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|