summaryrefslogtreecommitdiff
path: root/src/hwdata.c
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2008-11-06 14:03:42 +0100
committerHenrik Rydberg <rydberg@euromail.se>2008-11-06 14:03:42 +0100
commita773c79d6d767ddfe574ad513ab0276bdd13a717 (patch)
tree8d879fe396dab810bf5632c9777c3931c08eb396 /src/hwdata.c
parent030a3c8a38a81ea882fa0a3b0bfce61ded50a20d (diff)
Driver stages in place - should one support multiple
device instances by moving the private alloc to init/close? Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'src/hwdata.c')
-rw-r--r--src/hwdata.c90
1 files changed, 90 insertions, 0 deletions
diff --git a/src/hwdata.c b/src/hwdata.c
new file mode 100644
index 0000000..212e860
--- /dev/null
+++ b/src/hwdata.c
@@ -0,0 +1,90 @@
1#include "hwdata.h"
2#include <errno.h>
3
4/******************************************************/
5
6static int parse_event(struct HWData *hw)
7{
8 const struct input_event *ev = hw->event + hw->at++;
9 bool on = ev->value != 0;
10 switch (ev->type) {
11 case EV_SYN:
12 switch (ev->code) {
13 case SYN_REPORT:
14 return 0;
15 }
16 break;
17 case EV_KEY:
18 switch (ev->code) {
19 case BTN_LEFT:
20 hw->left = on;
21 break;
22 case BTN_MIDDLE:
23 hw->middle = on;
24 break;
25 case BTN_RIGHT:
26 hw->right = on;
27 break;
28 case BTN_MT_REPORT_PACKET:
29 if (on)
30 hw->nfinger = 0;
31 break;
32 case BTN_MT_REPORT_FINGER:
33 if (!on && hw->nfinger < DIM_FINGER)
34 hw->nfinger++;
35 break;
36 }
37 break;
38 case EV_ABS:
39 switch (ev->code) {
40 case ABS_MT_TOUCH_MAJOR:
41 hw->finger[hw->nfinger].touch_major = ev->value;
42 break;
43 case ABS_MT_TOUCH_MINOR:
44 hw->finger[hw->nfinger].touch_minor = ev->value;
45 break;
46 case ABS_MT_WIDTH_MAJOR:
47 hw->finger[hw->nfinger].width_major = ev->value;
48 break;
49 case ABS_MT_WIDTH_MINOR:
50 hw->finger[hw->nfinger].width_minor = ev->value;
51 break;
52 case ABS_MT_ORIENTATION:
53 hw->finger[hw->nfinger].orientation = ev->value;
54 break;
55 case ABS_MT_POSITION_X:
56 hw->finger[hw->nfinger].position_x = ev->value;
57 break;
58 case ABS_MT_POSITION_Y:
59 hw->finger[hw->nfinger].position_y = ev->value;
60 break;
61 }
62 break;
63 }
64 return -EAGAIN;
65}
66
67/******************************************************/
68
69int read_hwdata(struct HWData *hw, int fd)
70{
71 int n;
72 do {
73 while (hw->at < hw->nev)
74 if (!parse_event(hw))
75 return 0;
76 n = read(fd, hw->event, sizeof(hw->event));
77 hw->at = 0;
78 hw->nev = n / sizeof(struct input_event);
79 xf86Msg(X_INFO, "multitouch: read: %d %d\n", n, hw->nev);
80 } while (n > 0);
81 return -EIO;
82};
83
84/******************************************************/
85
86void output_hwdata(const struct HWData *hw)
87{
88}
89
90/******************************************************/