aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2010-03-21 14:18:56 +0100
committerHenrik Rydberg <rydberg@euromail.se>2010-03-21 14:57:59 +0100
commitc7ed4cec501f10479a98e380d760670312101136 (patch)
tree3e42dc0e2f7d152044555bc178ab47d324aaa277
parentd5b3178ca184dee4b3116e5b569745d43dbe37ef (diff)
downloadxorg-input-kobomultitouch-c7ed4cec501f10479a98e380d760670312101136.tar.gz
xorg-input-kobomultitouch-c7ed4cec501f10479a98e380d760670312101136.tar.bz2
xorg-input-kobomultitouch-c7ed4cec501f10479a98e380d760670312101136.zip
Comply with MT syncronization protocol
The latest semantic clarifications in the kernel MT protocol allow SYN_MT_REPORT to be sent without actually sending any finger data. Add a mask to the hardware data so that the data actually read can be tracked. Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
-rw-r--r--src/hwdata.c49
-rw-r--r--src/hwdata.h22
-rw-r--r--src/state.c9
3 files changed, 59 insertions, 21 deletions
diff --git a/src/hwdata.c b/src/hwdata.c
index 9e384dc..e76bcd8 100644
--- a/src/hwdata.c
+++ b/src/hwdata.c
@@ -26,17 +26,42 @@ void init_hwdata(struct HWData *hw)
memset(hw, 0, sizeof(struct HWData));
}
+static void set_value(struct HWData *hw, int code, int value)
+{
+ if (hw->nread < DIM_FINGER) {
+ (&hw->finger[hw->nread].touch_major)[code] = value;
+ SETBIT(hw->mread[hw->nread], code);
+ }
+}
+
+static void accept_finger(struct HWData *hw)
+{
+ if (hw->nread < DIM_FINGER &&
+ GETBIT(hw->mread[hw->nread], BIT_MT_POSITION_X) &&
+ GETBIT(hw->mread[hw->nread], BIT_MT_POSITION_Y)) {
+ hw->mask[hw->nread] = hw->mread[hw->nread];
+ hw->nfinger = ++hw->nread;
+ }
+ if (hw->nread < DIM_FINGER)
+ hw->mread[hw->nread] = 0;
+}
+
+static void accept_packet(struct HWData *hw)
+{
+ hw->nread = 0;
+ hw->mread[hw->nread] = 0;
+}
+
int read_hwdata(struct HWData *hw, const struct input_event* ev)
{
switch (ev->type) {
case EV_SYN:
switch (ev->code) {
case SYN_REPORT:
- hw->nread = 0;
+ accept_packet(hw);
return 1;
case SYN_MT_REPORT:
- hw->nread++;
- hw->nfinger = hw->nread;
+ accept_finger(hw);
break;
}
break;
@@ -63,32 +88,30 @@ int read_hwdata(struct HWData *hw, const struct input_event* ev)
}
break;
case EV_ABS:
- if (hw->nread == DIM_FINGER)
- break;
switch (ev->code) {
case ABS_MT_TOUCH_MAJOR:
- hw->finger[hw->nread].touch_major = ev->value;
+ set_value(hw, BIT_MT_TOUCH_MAJOR, ev->value);
break;
case ABS_MT_TOUCH_MINOR:
- hw->finger[hw->nread].touch_minor = ev->value;
+ set_value(hw, BIT_MT_TOUCH_MINOR, ev->value);
break;
case ABS_MT_WIDTH_MAJOR:
- hw->finger[hw->nread].width_major = ev->value;
+ set_value(hw, BIT_MT_WIDTH_MAJOR, ev->value);
break;
case ABS_MT_WIDTH_MINOR:
- hw->finger[hw->nread].width_minor = ev->value;
+ set_value(hw, BIT_MT_WIDTH_MINOR, ev->value);
break;
case ABS_MT_ORIENTATION:
- hw->finger[hw->nread].orientation = ev->value;
+ set_value(hw, BIT_MT_ORIENTATION, ev->value);
break;
case ABS_MT_PRESSURE:
- hw->finger[hw->nread].pressure = ev->value;
+ set_value(hw, BIT_MT_PRESSURE, ev->value);
break;
case ABS_MT_POSITION_X:
- hw->finger[hw->nread].position_x = ev->value;
+ set_value(hw, BIT_MT_POSITION_X, ev->value);
break;
case ABS_MT_POSITION_Y:
- hw->finger[hw->nread].position_y = ev->value;
+ set_value(hw, BIT_MT_POSITION_Y, ev->value);
break;
}
break;
diff --git a/src/hwdata.h b/src/hwdata.h
index 38ffc6b..aa589e0 100644
--- a/src/hwdata.h
+++ b/src/hwdata.h
@@ -34,6 +34,16 @@
#define MT_BUTTON_HWHEEL_LEFT 5
#define MT_BUTTON_HWHEEL_RIGHT 6
+#define BIT_MT_TOUCH_MAJOR 0
+#define BIT_MT_TOUCH_MINOR 1
+#define BIT_MT_WIDTH_MAJOR 2
+#define BIT_MT_WIDTH_MINOR 3
+#define BIT_MT_ORIENTATION 4
+#define BIT_MT_PRESSURE 5
+#define BIT_MT_POSITION_X 6
+#define BIT_MT_POSITION_Y 7
+#define BIT_MT_CNT 8
+
struct FingerData {
int touch_major, touch_minor;
int width_major, width_minor;
@@ -41,8 +51,20 @@ struct FingerData {
int position_x, position_y;
};
+/**
+ * struct HWData - hardware reads
+ *
+ * @finger: finger data
+ * @mask: bits corresponding to data actually read (readonly)
+ * @mread: bits corresponding to data in progress (writeonly)
+ * @button: bitmask of buttons
+ * @nfinger: number of fingers actually read (readonly)
+ * @nread: number of fingers in progress (writeonly)
+ *
+ */
struct HWData {
struct FingerData finger[DIM_FINGER];
+ unsigned mask[DIM_FINGER], mread[DIM_FINGER];
unsigned button;
int nfinger, nread;
};
diff --git a/src/state.c b/src/state.c
index 774828a..31eca70 100644
--- a/src/state.c
+++ b/src/state.c
@@ -36,16 +36,9 @@ static int fincmp(const void *a, const void *b)
return ((struct FingerState *)a)->id - ((struct FingerState *)b)->id;
}
-/* seander@cs.stanford.edu */
-inline unsigned abs32(int x)
-{
- int const m = x >> 31;
- return (x + m) ^ m;
-}
-
inline int abs15(int x)
{
- return 32767 & abs32(x);
+ return 32767 & (x < 0 ? -x : x);
}
/* abslute scale is assumed to fit in 15 bits */