@@ -297,7 +297,7 @@ static JNIEnv* getJNIEnvFromJavaVM(JavaVM* vm)
297297 assert (vm);
298298 JNIEnv* env = nullptr ;
299299 jint ret = vm->GetEnv ((void **)&env, JNI_VERSION_1_6);
300- if (ret == JNI_EDETACHED)
300+ if (ret == JNI_EDETACHED)
301301 {
302302 JavaVMAttachArgs args = {JNI_VERSION_1_6, " NativeActivityThread" , nullptr };
303303 ret = vm->AttachCurrentThread (&env, &args);
@@ -322,7 +322,7 @@ void KeyboardMap::initializeKeyCharacterMap(void* vm)
322322 if (!env)
323323 return ;
324324
325- jclass KeyCharacterMap = env->FindClass (" android/view/KeyCharacterMap" ); // Since API level 1
325+ jclass KeyCharacterMap = env->FindClass (" android/view/KeyCharacterMap" ); // Since API level 1
326326 assert (KeyCharacterMap);
327327
328328 classKeyCharacterMap = (jclass)env->NewGlobalRef (KeyCharacterMap);
@@ -338,7 +338,7 @@ void KeyboardMap::releaseKeyCharacterMap()
338338 if (classKeyCharacterMap)
339339 {
340340 JNIEnv* env = getJNIEnvFromJavaVM (javaVM);
341- if (env)
341+ if (env)
342342 {
343343 env->DeleteGlobalRef (classKeyCharacterMap);
344344 classKeyCharacterMap = nullptr ;
@@ -350,14 +350,14 @@ void KeyboardMap::releaseKeyCharacterMap()
350350
351351int32_t KeyboardMap::getUnicodeChar (int32_t keyCode, int32_t metaState)
352352{
353- if (!javaVM || !classKeyCharacterMap || !methodLoad || !methodGet)
353+ if (!javaVM || !classKeyCharacterMap || !methodLoad || !methodGet)
354354 {
355355 vsg::warn (" JNI not initialized" );
356356 return 0 ;
357357 }
358358
359359 JNIEnv* env = getJNIEnvFromJavaVM (javaVM);
360- if (!env)
360+ if (!env)
361361 return 0 ;
362362
363363 jobject kcmInstance = env->CallStaticObjectMethod (classKeyCharacterMap, methodLoad, 0 );
@@ -446,7 +446,7 @@ void Android_Window::resize()
446446bool Android_Window::handleAndroidInputEvent (AInputEvent* anEvent)
447447{
448448 int32_t eventType = AInputEvent_getType (anEvent);
449- if (eventType == AINPUT_EVENT_TYPE_MOTION)
449+ if (eventType == AINPUT_EVENT_TYPE_MOTION)
450450 {
451451 int32_t action = AMotionEvent_getAction (anEvent);
452452 int32_t actionMasked = action & AMOTION_EVENT_ACTION_MASK;
@@ -456,48 +456,45 @@ bool Android_Window::handleAndroidInputEvent(AInputEvent* anEvent)
456456 int64_t timeMs = timeNs / 1000'000 ;
457457 vsg::clock::time_point time = _first_android_time_point + std::chrono::milliseconds (timeMs - _uptimeMs);
458458
459- switch (actionMasked)
459+ switch (actionMasked)
460460 {
461- case AMOTION_EVENT_ACTION_DOWN:
462- case AMOTION_EVENT_ACTION_POINTER_DOWN:
461+ case AMOTION_EVENT_ACTION_DOWN:
462+ case AMOTION_EVENT_ACTION_POINTER_DOWN: {
463+ float x = AMotionEvent_getX (anEvent, actionIndex);
464+ float y = AMotionEvent_getY (anEvent, actionIndex);
465+ uint32_t id = AMotionEvent_getPointerId (anEvent, actionIndex);
466+ bufferedEvents.emplace_back (vsg::TouchDownEvent::create (this , time, x, y, id));
467+ break ;
468+ }
469+ case AMOTION_EVENT_ACTION_MOVE:
470+ for (size_t p = 0 ; p < pointerCount; ++p)
463471 {
464- float x = AMotionEvent_getX (anEvent, actionIndex);
465- float y = AMotionEvent_getY (anEvent, actionIndex);
466- uint32_t id = AMotionEvent_getPointerId (anEvent, actionIndex);
467- bufferedEvents.emplace_back (vsg::TouchDownEvent::create (this , time, x, y, id));
468- break ;
472+ float x = AMotionEvent_getX (anEvent, p);
473+ float y = AMotionEvent_getY (anEvent, p);
474+ uint32_t id = AMotionEvent_getPointerId (anEvent, p);
475+ bufferedEvents.emplace_back (vsg::TouchMoveEvent::create (this , time, x, y, id));
469476 }
470- case AMOTION_EVENT_ACTION_MOVE:
471- for ( size_t p = 0 ; p < pointerCount; ++p)
472- {
473- float x = AMotionEvent_getX (anEvent, p );
474- float y = AMotionEvent_getY (anEvent, p );
475- uint32_t id = AMotionEvent_getPointerId (anEvent, p );
476- bufferedEvents.emplace_back (vsg::TouchMoveEvent ::create (this , time, x, y, id));
477- }
478- break ;
479- case AMOTION_EVENT_ACTION_UP :
480- case AMOTION_EVENT_ACTION_POINTER_UP:
477+ break ;
478+ case AMOTION_EVENT_ACTION_UP:
479+ case AMOTION_EVENT_ACTION_POINTER_UP: {
480+ float x = AMotionEvent_getX (anEvent, actionIndex );
481+ float y = AMotionEvent_getY (anEvent, actionIndex );
482+ uint32_t id = AMotionEvent_getPointerId (anEvent, actionIndex );
483+ bufferedEvents.emplace_back (vsg::TouchUpEvent ::create (this , time, x, y, id));
484+ break ;
485+ }
486+ case AMOTION_EVENT_ACTION_CANCEL :
487+ for ( size_t p = 0 ; p < pointerCount; ++p)
481488 {
482- float x = AMotionEvent_getX (anEvent, actionIndex );
483- float y = AMotionEvent_getY (anEvent, actionIndex );
484- uint32_t id = AMotionEvent_getPointerId (anEvent, actionIndex );
489+ float x = AMotionEvent_getX (anEvent, p );
490+ float y = AMotionEvent_getY (anEvent, p );
491+ uint32_t id = AMotionEvent_getPointerId (anEvent, p );
485492 bufferedEvents.emplace_back (vsg::TouchUpEvent::create (this , time, x, y, id));
486- break ;
487493 }
488- case AMOTION_EVENT_ACTION_CANCEL:
489- for (size_t p = 0 ; p < pointerCount; ++p)
490- {
491- float x = AMotionEvent_getX (anEvent, p);
492- float y = AMotionEvent_getY (anEvent, p);
493- uint32_t id = AMotionEvent_getPointerId (anEvent, p);
494- bufferedEvents.emplace_back (vsg::TouchUpEvent::create (this , time, x, y, id));
495- }
496- break ;
497- default :
498- // vsg::info("unhandled touch action: %d", actionMasked);
499- break ;
500-
494+ break ;
495+ default :
496+ // vsg::info("unhandled touch action: %d", actionMasked);
497+ break ;
501498 }
502499 return true ;
503500 }
0 commit comments