1 #include <msp/graphics/window_private.h>
2 #include "touchscreen.h"
7 void Touchscreen::input_event(const Graphics::Window::Event &event)
9 int action = AMotionEvent_getAction(event.aevent);
10 int action_pointer = (action&AMOTION_EVENT_ACTION_POINTER_INDEX_MASK)>>AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
11 action &= AMOTION_EVENT_ACTION_MASK;
13 int pointer_count = AMotionEvent_getPointerCount(event.aevent);
14 for(int i=0; i<pointer_count; ++i)
16 int pointer = AMotionEvent_getPointerId(event.aevent, i);
17 float x = AMotionEvent_getX(event.aevent, i);
18 float y = AMotionEvent_getY(event.aevent, i);
19 touch_move(pointer, x*2/window.get_width()-1, 1-y*2/window.get_height());
24 case AMOTION_EVENT_ACTION_DOWN:
25 case AMOTION_EVENT_ACTION_POINTER_DOWN:
26 touch_down(AMotionEvent_getPointerId(event.aevent, action_pointer));
28 case AMOTION_EVENT_ACTION_UP:
29 case AMOTION_EVENT_ACTION_POINTER_UP:
30 touch_up(AMotionEvent_getPointerId(event.aevent, action_pointer));