While hacking with the NDK and NativeActivity, I've been unable to get useful information for touch input - I just get obfuscated information for the flags.
This is a snippet of the relevant code (edited from plasma.c from the sample):
static int32_t engine_handle_input(struct android_app* app, AInputEvent* event) {
struct engine* engine = (struct engine*)app->userData;
LOGI("Event: action=%d\nkeyCode=%d\nmetaState=0x%x\nAction=0x%x\nx=%d\ny=%d"
"\nflags=0x%x\nxprec=%d\nyprec=%d\nxoff=%d\nyoff=%d\nguessX=%d\n\n",
AKeyEvent_getAction(event),
AKeyEvent_getKeyCode(event),
AKeyEvent_getMetaState(event),
AMotionEvent_getAction(event),
AMotionEvent_getX(event,0),
AMotionEvent_getY(event,0),
AMotionEvent_getFlags(event),
AMotionEvent_getXPrecision(event),
AMotionEvent_getYPrecision(event),
AMotionEvent_getXOffset(event),
AMotionEvent_getYOffset(event))
return 0;
}
This is the sort of log output I get while touching the screen:
I/libplasma(24786): Event: action=1
I/libplasma(24786): keyCode=0
I/libplasma(24786): metaState=0x0
I/libplasma(24786): Action=0x1
I/libplasma(24786): x=1074838969
I/libplasma(24786): y=1073741824
I/libplasma(24786): flags=0x408cf365
I/libplasma(24786): xprec=-2147483648
I/libplasma(24786): yprec=1081822550
I/libplasma(24786): xoff=0
I/libplasma(24786): yoff=1074839057
I/libplasma(24786):
I'm not sure how I'm supposed to extract useful information out of this junk, and I can't find a single tutorial on NDK NativeActivity input. Any NDK gurus here?