summaryrefslogtreecommitdiff
path: root/src/hwdata.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/hwdata.c')
-rw-r--r--src/hwdata.c49
1 files changed, 36 insertions, 13 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)
26 memset(hw, 0, sizeof(struct HWData)); 26 memset(hw, 0, sizeof(struct HWData));
27} 27}
28 28
29static void set_value(struct HWData *hw, int code, int value)
30{
31 if (hw->nread < DIM_FINGER) {
32 (&hw->finger[hw->nread].touch_major)[code] = value;
33 SETBIT(hw->mread[hw->nread], code);
34 }
35}
36
37static void accept_finger(struct HWData *hw)
38{
39 if (hw->nread < DIM_FINGER &&
40 GETBIT(hw->mread[hw->nread], BIT_MT_POSITION_X) &&
41 GETBIT(hw->mread[hw->nread], BIT_MT_POSITION_Y)) {
42 hw->mask[hw->nread] = hw->mread[hw->nread];
43 hw->nfinger = ++hw->nread;
44 }
45 if (hw->nread < DIM_FINGER)
46 hw->mread[hw->nread] = 0;
47}
48
49static void accept_packet(struct HWData *hw)
50{
51 hw->nread = 0;
52 hw->mread[hw->nread] = 0;
53}
54
29int read_hwdata(struct HWData *hw, const struct input_event* ev) 55int read_hwdata(struct HWData *hw, const struct input_event* ev)
30{ 56{
31 switch (ev->type) { 57 switch (ev->type) {
32 case EV_SYN: 58 case EV_SYN:
33 switch (ev->code) { 59 switch (ev->code) {
34 case SYN_REPORT: 60 case SYN_REPORT:
35 hw->nread = 0; 61 accept_packet(hw);
36 return 1; 62 return 1;
37 case SYN_MT_REPORT: 63 case SYN_MT_REPORT:
38 hw->nread++; 64 accept_finger(hw);
39 hw->nfinger = hw->nread;
40 break; 65 break;
41 } 66 }
42 break; 67 break;
@@ -63,32 +88,30 @@ int read_hwdata(struct HWData *hw, const struct input_event* ev)
63 } 88 }
64 break; 89 break;
65 case EV_ABS: 90 case EV_ABS:
66 if (hw->nread == DIM_FINGER)
67 break;
68 switch (ev->code) { 91 switch (ev->code) {
69 case ABS_MT_TOUCH_MAJOR: 92 case ABS_MT_TOUCH_MAJOR:
70 hw->finger[hw->nread].touch_major = ev->value; 93 set_value(hw, BIT_MT_TOUCH_MAJOR, ev->value);
71 break; 94 break;
72 case ABS_MT_TOUCH_MINOR: 95 case ABS_MT_TOUCH_MINOR:
73 hw->finger[hw->nread].touch_minor = ev->value; 96 set_value(hw, BIT_MT_TOUCH_MINOR, ev->value);
74 break; 97 break;
75 case ABS_MT_WIDTH_MAJOR: 98 case ABS_MT_WIDTH_MAJOR:
76 hw->finger[hw->nread].width_major = ev->value; 99 set_value(hw, BIT_MT_WIDTH_MAJOR, ev->value);
77 break; 100 break;
78 case ABS_MT_WIDTH_MINOR: 101 case ABS_MT_WIDTH_MINOR:
79 hw->finger[hw->nread].width_minor = ev->value; 102 set_value(hw, BIT_MT_WIDTH_MINOR, ev->value);
80 break; 103 break;
81 case ABS_MT_ORIENTATION: 104 case ABS_MT_ORIENTATION:
82 hw->finger[hw->nread].orientation = ev->value; 105 set_value(hw, BIT_MT_ORIENTATION, ev->value);
83 break; 106 break;
84 case ABS_MT_PRESSURE: 107 case ABS_MT_PRESSURE:
85 hw->finger[hw->nread].pressure = ev->value; 108 set_value(hw, BIT_MT_PRESSURE, ev->value);
86 break; 109 break;
87 case ABS_MT_POSITION_X: 110 case ABS_MT_POSITION_X:
88 hw->finger[hw->nread].position_x = ev->value; 111 set_value(hw, BIT_MT_POSITION_X, ev->value);
89 break; 112 break;
90 case ABS_MT_POSITION_Y: 113 case ABS_MT_POSITION_Y:
91 hw->finger[hw->nread].position_y = ev->value; 114 set_value(hw, BIT_MT_POSITION_Y, ev->value);
92 break; 115 break;
93 } 116 }
94 break; 117 break;