23#include <wayland-util.h>
25#include <uwac/uwac-tools.h>
26#include <winpr/wtypes.h>
28struct uwac_touch_automata
33void UwacTouchAutomataInit(UwacTouchAutomata* automata)
35 wl_array_init(&automata->tp);
38void UwacTouchAutomataReset(UwacTouchAutomata* automata)
40 automata->tp.size = 0;
43bool UwacTouchAutomataInjectEvent(UwacTouchAutomata* automata, UwacEvent* event)
46 UwacTouchPoint* tp =
nullptr;
50 case UWAC_EVENT_TOUCH_FRAME_BEGIN:
53 case UWAC_EVENT_TOUCH_UP:
55 UwacTouchUp* touchUp = &
event->touchUp;
56 size_t toMove = automata->tp.size -
sizeof(UwacTouchPoint);
58 wl_array_for_each(tp, &automata->tp)
60 if ((int64_t)tp->id == touchUp->id)
63 memmove(tp, tp + 1, toMove);
67 toMove -=
sizeof(UwacTouchPoint);
72 case UWAC_EVENT_TOUCH_DOWN:
74 UwacTouchDown* touchDown = &
event->touchDown;
76 wl_array_for_each(tp, &automata->tp)
78 if ((int64_t)tp->id == touchDown->id)
86 tp = wl_array_add(&automata->tp,
sizeof(UwacTouchPoint));
90 if (touchDown->id < 0)
93 tp->id = (uint32_t)touchDown->id;
99 case UWAC_EVENT_TOUCH_FRAME_END: