return (a & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
else return -1;
`}
+
+ private fun action: AMotionEventAction `{ return AMotionEvent_getAction(recv); `}
+end
+
+extern class AMotionEventAction `{ int32_t `}
+ protected fun action: Int `{ return recv & AMOTION_EVENT_ACTION_MASK; `}
+ fun is_down: Bool do return action == 0
+ fun is_up: Bool do return action == 1
+ fun is_move: Bool do return action == 2
+ fun is_cancel: Bool do return action == 3
+ fun is_outside: Bool do return action == 4
+ fun is_pointer_down: Bool do return action == 5
+ fun is_pointer_up: Bool do return action == 6
end
interface AndroidInputEvent
return AMotionEvent_getPressure(motion_event, pointer_id);
`}
- redef fun pressed do return true
- redef fun depressed do return false
+ redef fun pressed
+ do
+ var action = motion_event.inner_event.action
+ return action.is_down or action.is_move
+ end
+
+ redef fun depressed do return not pressed
end
extern AndroidKeyEvent in "C" `{AInputEvent *`}
return handled
end
- redef fun main_loop is extern import full_frame, save, pause, resume, gained_focus, lost_focus, init_window, term_window, extern_input_key, extern_input_motion `{
+ redef fun main_loop is extern import full_frame, generate_input `{
LOGI("nitni loop");
nit_app = recv;
mnit_java_app->onInputEvent = mnit_handle_input;
while (1) {
- int ident;
- int events;
- static int block = 0;
- struct android_poll_source* source;
-
- while ((ident=ALooper_pollAll(0, NULL, &events,
- (void**)&source)) >= 0) { /* first 0 is for non-blocking */
-
- // Process this event.
- if (source != NULL)
- source->process(mnit_java_app, source);
-
- // Check if we are exiting.
- if (mnit_java_app->destroyRequested != 0) {
- mnit_term_display();
- return;
- }
- }
+ App_generate_input(recv);
+
+ if (mnit_java_app->destroyRequested != 0) return;
if (mnit_animating == 1) {
mnit_frame();
/* App_exit(); // this is unreachable anyway*/
`}
+
+ redef fun generate_input import save, pause, resume, gained_focus, lost_focus, init_window, term_window, extern_input_key, extern_input_motion `{
+ int ident;
+ int events;
+ static int block = 0;
+ struct android_poll_source* source;
+
+ while ((ident=ALooper_pollAll(0, NULL, &events,
+ (void**)&source)) >= 0) { /* first 0 is for non-blocking */
+
+ // Process this event.
+ if (source != NULL)
+ source->process(mnit_java_app, source);
+
+ // Check if we are exiting.
+ if (mnit_java_app->destroyRequested != 0) {
+ mnit_term_display();
+ return;
+ }
+ }
+ `}
end