module input_events
import mnit::input
-import android
+import android::game
in "C header" `{
#include <android/log.h>
`}
fun action: AMotionEventAction `{ return AMotionEvent_getAction(self); `}
+
+ fun native_down_time: Int `{ return AMotionEvent_getDownTime(self); `}
end
private extern class AMotionEventAction `{ int32_t `}
return null
end
end
+
+ # Time when the user originally pressed down to start a stream of position events
+ #
+ # The return value is in the `java.lang.System.nanoTime()` time base.
+ fun down_time: Int do return native.native_down_time
end
# A pointer event
motion_event.just_went_down
# Unique id of this pointer since the beginning of the gesture
- fun pointer_id: Int do return native_pointer_id(motion_event.native, pointer_index)
+ redef fun pointer_id do return native_pointer_id(motion_event.native, pointer_index)
private fun native_pointer_id(motion_event: NativeAndroidMotionEvent, pointer_index: Int): Int `{
return AMotionEvent_getPointerId(motion_event, pointer_index);
# Hardware code of the key raising this event
fun key_code: Int `{ return AKeyEvent_getKeyCode(self); `}
- redef fun to_c `{
+ redef fun to_c
+ do
+ var i = native_to_c
+ if i == 0 then return null
+ return i.code_point
+ end
+
+ private fun native_to_c: Int `{
int code = AKeyEvent_getKeyCode(self);
if (code >= AKEYCODE_0 && code <= AKEYCODE_9)
return '0'+code-AKEYCODE_0;