diff options
author | Sylvain Becker <sylvain.becker@gmail.com> | 2019-01-17 16:30:19 +0100 |
---|---|---|
committer | Sylvain Becker <sylvain.becker@gmail.com> | 2019-01-17 16:30:19 +0100 |
commit | 9b47e84e5f45ead49f12e51dee4828397e0d97fb (patch) | |
tree | 7032062d1c5dd87ccc86ab9326198829d45719bf | |
parent | 9fe9f944c4caa2e84775d92855f4f70e71d035c9 (diff) |
Android: remove duplicate code in SDLGenericMotionListener_API24
and use parent method
-rw-r--r-- | android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java | 53 |
1 files changed, 13 insertions, 40 deletions
diff --git a/android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java b/android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java index cccc6462fb..d3329c9447 100644 --- a/android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java +++ b/android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java @@ -620,51 +620,24 @@ class SDLGenericMotionListener_API24 extends SDLGenericMotionListener_API12 { @Override public boolean onGenericMotion(View v, MotionEvent event) { - float x, y; - int action; - - switch ( event.getSource() ) { - case InputDevice.SOURCE_JOYSTICK: - case InputDevice.SOURCE_GAMEPAD: - case InputDevice.SOURCE_DPAD: - return SDLControllerManager.handleJoystickMotionEvent(event); - case InputDevice.SOURCE_MOUSE: - if (!SDLActivity.mSeparateMouseAndTouch) { - break; - } - action = event.getActionMasked(); - switch (action) { - case MotionEvent.ACTION_SCROLL: - x = event.getAxisValue(MotionEvent.AXIS_HSCROLL, 0); - y = event.getAxisValue(MotionEvent.AXIS_VSCROLL, 0); - SDLActivity.onNativeMouse(0, action, x, y, false); - return true; - - case MotionEvent.ACTION_HOVER_MOVE: - if (mRelativeModeEnabled) { - x = event.getAxisValue(MotionEvent.AXIS_RELATIVE_X); - y = event.getAxisValue(MotionEvent.AXIS_RELATIVE_Y); - } - else { - x = event.getX(0); - y = event.getY(0); - } - - SDLActivity.onNativeMouse(0, action, x, y, mRelativeModeEnabled); + // Handle relative mouse mode + if (mRelativeModeEnabled) { + if (event.getSource() == InputDevice.SOURCE_MOUSE) { + if (SDLActivity.mSeparateMouseAndTouch) { + int action = event.getActionMasked(); + if (action == MotionEvent.ACTION_HOVER_MOVE) { + float x = event.getAxisValue(MotionEvent.AXIS_RELATIVE_X); + float y = event.getAxisValue(MotionEvent.AXIS_RELATIVE_Y); + SDLActivity.onNativeMouse(0, action, x, y, true); return true; - - default: - break; + } } - break; - - default: - break; + } } - // Event was not managed - return false; + // Event was not managed, call SDLGenericMotionListener_API12 method + return super.onGenericMotion(v, event); } @Override |