summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2010-09-21 11:00:11 +0200
committerHenrik Rydberg <rydberg@euromail.se>2010-09-21 12:56:17 +0200
commitcd1812c4d8bca7ffc0c27fc16561c40a935ab6c2 (patch)
treee0d20e2b92fcaccd76fe3eea50d0f4c7931b6d25 /src
parent62ca64fe2e64d1ee09c4821a35d8616c0ac0e270 (diff)
Reorganize input event emulation code
Inject the emulated events into the event buffer instead, and move the pointer logic into the emulation handler. Introduces no logical changes, but reveals the bug in the position event frequency. Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'src')
-rw-r--r--src/grail-api.c57
1 files changed, 23 insertions, 34 deletions
diff --git a/src/grail-api.c b/src/grail-api.c
index 9503889..9490659 100644
--- a/src/grail-api.c
+++ b/src/grail-api.c
@@ -55,42 +55,34 @@ static void tp_event(struct touch_dev *dev,
55 evbuf_put(&x->evbuf, ev); 55 evbuf_put(&x->evbuf, ev);
56} 56}
57 57
58static int handle_abs_events(struct grail *ge, 58static void evput(struct grail_impl *x, struct timeval time,
59 const struct input_event *syn, 59 unsigned type, unsigned code, int value)
60 int pointer)
61{ 60{
61 struct input_event ev = { time, type, code, value };
62 evbuf_put(&x->evbuf, &ev);
63}
64
65static void handle_abs_events(struct grail *ge, const struct input_event *syn)
66{
67 static const int fm_mask = 0x03;
62 struct grail_impl *impl = ge->impl; 68 struct grail_impl *impl = ge->impl;
63 struct input_event ev = *syn; 69 struct gesture_inserter *gin = ge->gin;
64 int nevent = 0; 70 struct gesture_recognizer *gru = ge->gru;
71 struct move_model *move = &gru->move;
72 struct tapping_model *tap = &gru->tapping;
73 int used_move = grail_mask_count(gin->types, sizeof(gin->types));
74 int ismove = move->single && (move->active & fm_mask) && !used_move;
75 int ishold = move->single && tap->active && !used_move;
76 int pointer = ismove || ishold;
77
65 if (pointer != impl->pointer_status) { 78 if (pointer != impl->pointer_status) {
66 ev.type = EV_KEY; 79 evput(impl, syn->time, EV_KEY, BTN_TOUCH, pointer);
67 ev.code = BTN_TOUCH;
68 ev.value = pointer;
69 ge->event(ge, &ev);
70 impl->pointer_status = pointer; 80 impl->pointer_status = pointer;
71 nevent++;
72 } 81 }
73 if (pointer) { 82 if (pointer) {
74 ev.type = EV_ABS; 83 evput(impl, syn->time, EV_ABS, ABS_X, impl->pointer_x);
75 ev.code = ABS_X; 84 evput(impl, syn->time, EV_ABS, ABS_Y, impl->pointer_y);
76 ev.value = impl->pointer_x;
77 ge->event(ge, &ev);
78 nevent++;
79 ev.type = EV_ABS;
80 ev.code = ABS_Y;
81 ev.value = impl->pointer_y;
82 ge->event(ge, &ev);
83 nevent++;
84 } 85 }
85 return nevent;
86}
87
88static int pointer_active(const struct grail *ge)
89{
90 static const int fm_mask = 0x03;
91 const struct move_model *move = &ge->gru->move;
92 const struct tapping_model *tap = &ge->gru->tapping;
93 return move->single && ((move->active & fm_mask) || tap->active);
94} 86}
95 87
96static void tp_sync(struct touch_dev *dev, 88static void tp_sync(struct touch_dev *dev,
@@ -99,21 +91,18 @@ static void tp_sync(struct touch_dev *dev,
99 struct input_event ev; 91 struct input_event ev;
100 struct grail *ge = dev->priv; 92 struct grail *ge = dev->priv;
101 struct grail_impl *impl = ge->impl; 93 struct grail_impl *impl = ge->impl;
102 struct gesture_inserter *gin = ge->gin;
103 struct touch_frame *frame = &dev->frame; 94 struct touch_frame *frame = &dev->frame;
104 int pointer, used_move, nevent = 0; 95 int nevent = 0;
105 gin_frame_begin(ge, frame); 96 gin_frame_begin(ge, frame);
106 gru_recognize(ge, frame); 97 gru_recognize(ge, frame);
107 gin_frame_end(ge, frame); 98 gin_frame_end(ge, frame);
108 used_move = grail_mask_count(gin->types, sizeof(gin->types));
109 pointer = pointer_active(ge) && !used_move;
110 99
111 if (!ge->event) { 100 if (!ge->event) {
112 evbuf_clear(&impl->evbuf); 101 evbuf_clear(&impl->evbuf);
113 return; 102 return;
114 } 103 }
115 if (!impl->filter_abs) 104 if (!impl->filter_abs)
116 nevent += handle_abs_events(ge, syn, pointer); 105 handle_abs_events(ge, syn);
117 while (!evbuf_empty(&impl->evbuf)) { 106 while (!evbuf_empty(&impl->evbuf)) {
118 evbuf_get(&impl->evbuf, &ev); 107 evbuf_get(&impl->evbuf, &ev);
119 ge->event(ge, &ev); 108 ge->event(ge, &ev);