1 #include <msp/graphics/window_private.h>
2 #include "touchscreen.h"
7 bool Touchscreen::is_available()
12 void Touchscreen::input_event(const Graphics::Window::Event &event)
14 int action = AMotionEvent_getAction(event.aevent);
15 int action_pointer = (action&AMOTION_EVENT_ACTION_POINTER_INDEX_MASK)>>AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
16 action &= AMOTION_EVENT_ACTION_MASK;
18 int pointer_count = AMotionEvent_getPointerCount(event.aevent);
19 for(int i=0; i<pointer_count; ++i)
21 int pointer = AMotionEvent_getPointerId(event.aevent, i);
22 float x = AMotionEvent_getX(event.aevent, i);
23 float y = AMotionEvent_getY(event.aevent, i);
24 touch_move(pointer, x*2/window.get_width()-1, 1-y*2/window.get_height());
29 case AMOTION_EVENT_ACTION_DOWN:
30 case AMOTION_EVENT_ACTION_POINTER_DOWN:
31 touch_down(AMotionEvent_getPointerId(event.aevent, action_pointer));
33 case AMOTION_EVENT_ACTION_UP:
34 case AMOTION_EVENT_ACTION_POINTER_UP:
35 touch_up(AMotionEvent_getPointerId(event.aevent, action_pointer));