23 #include <wayland-util.h>
25 #include <uwac/uwac-tools.h>
27 struct uwac_touch_automata
32 void UwacTouchAutomataInit(UwacTouchAutomata* automata)
34 wl_array_init(&automata->tp);
37 void UwacTouchAutomataReset(UwacTouchAutomata* automata)
39 automata->tp.size = 0;
42 bool UwacTouchAutomataInjectEvent(UwacTouchAutomata* automata, UwacEvent* event)
45 UwacTouchPoint* tp = NULL;
49 case UWAC_EVENT_TOUCH_FRAME_BEGIN:
52 case UWAC_EVENT_TOUCH_UP:
54 UwacTouchUp* touchUp = &
event->touchUp;
55 size_t toMove = automata->tp.size -
sizeof(UwacTouchPoint);
57 wl_array_for_each(tp, &automata->tp)
59 if ((int64_t)tp->id == touchUp->id)
62 memmove(tp, tp + 1, toMove);
66 toMove -=
sizeof(UwacTouchPoint);
71 case UWAC_EVENT_TOUCH_DOWN:
73 UwacTouchDown* touchDown = &
event->touchDown;
75 wl_array_for_each(tp, &automata->tp)
77 if ((int64_t)tp->id == touchDown->id)
85 tp = wl_array_add(&automata->tp,
sizeof(UwacTouchPoint));
89 if (touchDown->id < 0)
92 tp->id = (uint32_t)touchDown->id;
98 case UWAC_EVENT_TOUCH_FRAME_END: