[Scummvm-git-logs] scummvm master -> cd8a40487fe6fa3c4b33acd1e4166a3e29e6abd2

antoniou79 noreply at scummvm.org
Wed Mar 22 20:05:19 UTC 2023


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
16f626401e ANDROID: Support FireTV remote
cd8a40487f ANDROID: Fix another deprecated Handler() usage


Commit: 16f626401e8e37b0e111adae91d6e190a7059dbc
    https://github.com/scummvm/scummvm/commit/16f626401e8e37b0e111adae91d6e190a7059dbc
Author: Antoniou Athanasios (a.antoniou79 at gmail.com)
Date: 2023-03-22T21:46:48+02:00

Commit Message:
ANDROID: Support FireTV remote

Changed paths:
    backends/keymapper/hardware-input.cpp
    backends/platform/android/android.cpp
    backends/platform/android/events.cpp
    backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java
    common/events.h


diff --git a/backends/keymapper/hardware-input.cpp b/backends/keymapper/hardware-input.cpp
index 0b888a92eae..5ff07264cb6 100644
--- a/backends/keymapper/hardware-input.cpp
+++ b/backends/keymapper/hardware-input.cpp
@@ -267,6 +267,7 @@ const HardwareInputTableEntry defaultJoystickButtons[] = {
 	{ "JOY_DOWN",           JOYSTICK_BUTTON_DPAD_DOWN,      _s("D-pad Down")     },
 	{ "JOY_LEFT",           JOYSTICK_BUTTON_DPAD_LEFT,      _s("D-pad Left")     },
 	{ "JOY_RIGHT",          JOYSTICK_BUTTON_DPAD_RIGHT,     _s("D-pad Right")    },
+	{ "JOY_CENTER",         JOYSTICK_BUTTON_DPAD_CENTER,    _s("D-pad Center")   },
 	{ nullptr,              0,                              nullptr              }
 };
 
diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp
index 5e38b82a125..c320633f6f5 100644
--- a/backends/platform/android/android.cpp
+++ b/backends/platform/android/android.cpp
@@ -623,6 +623,22 @@ Common::KeymapperDefaultBindings *OSystem_Android::getKeymapperDefaultBindings()
 	// See: backends/keymapper/remap-widget.cpp:	kCloseCmd        = 'CLOS'
 	keymapperDefaultBindings->setDefaultBinding(Common::kGuiKeymapName, "CLOS", "AC_BACK");
 
+	// By default DPAD directions will be used for virtual mouse in GUI context
+	// If the user wants to remap them, they will be able to navigate to Global Options -> Keymaps and do so.
+	// In some devices (eg. Android TV) with only the remote control as input, it is impossible to navigate the launcher GUI,
+	// if the DPAD actions are mapped to "up", "down", "left", "right" directions.
+	// TODO If full key-based (ie. non-mouse) navigation of the ScummVM GUI is implemented,
+	// we can revert back to the core behavior of DPAD being mapped to "up", "down", "left", "right" directions.
+	keymapperDefaultBindings->setDefaultBinding(Common::kGlobalKeymapName, "VMOUSEUP", "JOY_UP");
+	keymapperDefaultBindings->setDefaultBinding(Common::kGlobalKeymapName, "VMOUSEDOWN", "JOY_DOWN");
+	keymapperDefaultBindings->setDefaultBinding(Common::kGlobalKeymapName, "VMOUSELEFT", "JOY_LEFT");
+	keymapperDefaultBindings->setDefaultBinding(Common::kGlobalKeymapName, "VMOUSERIGHT", "JOY_RIGHT");
+	//keymapperDefaultBindings->setDefaultBinding(Common::kGuiKeymapName, Common::kStandardActionInteract, "JOY_CENTER");
+	keymapperDefaultBindings->setDefaultBinding(Common::kGuiKeymapName, Common::kStandardActionMoveUp, nullptr);
+	keymapperDefaultBindings->setDefaultBinding(Common::kGuiKeymapName, Common::kStandardActionMoveDown, nullptr);
+	keymapperDefaultBindings->setDefaultBinding(Common::kGuiKeymapName, Common::kStandardActionMoveLeft, nullptr);
+	keymapperDefaultBindings->setDefaultBinding(Common::kGuiKeymapName, Common::kStandardActionMoveRight, nullptr);
+
 	return keymapperDefaultBindings;
 }
 
diff --git a/backends/platform/android/events.cpp b/backends/platform/android/events.cpp
index 038c5e33507..7237cb7f896 100644
--- a/backends/platform/android/events.cpp
+++ b/backends/platform/android/events.cpp
@@ -76,6 +76,7 @@ enum {
 	JE_BMB_UP = 19,
 	JE_FMB_DOWN = 20,
 	JE_FMB_UP = 21,
+	JE_TV_REMOTE = 22,
 	JE_QUIT = 0x1000,
 	JE_MENU = 0x1001
 };
@@ -551,6 +552,7 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
 		case AKEYCODE_DPAD_LEFT:
 		// fall through
 		case AKEYCODE_DPAD_RIGHT:
+			// Treat as mouse movement
 			if (arg1 != AKEY_EVENT_ACTION_DOWN)
 				return;
 
@@ -586,6 +588,7 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
 			return;
 
 		case AKEYCODE_DPAD_CENTER:
+			// Treat as mouse click (left click)
 			switch (arg1) {
 			case AKEY_EVENT_ACTION_DOWN:
 				e.type = Common::EVENT_LBUTTONDOWN;
@@ -607,6 +610,73 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
 			return;
 		}
 
+	case JE_TV_REMOTE:
+		switch (arg1) {
+		case AKEY_EVENT_ACTION_DOWN:
+			e.type = Common::EVENT_KEYDOWN;
+			break;
+
+		case AKEY_EVENT_ACTION_UP:
+			e.type = Common::EVENT_KEYUP;
+			break;
+
+		default:
+			LOGE("unhandled jaction on key: %d", arg1);
+			return;
+		}
+
+		switch (arg2) {
+		case AKEYCODE_MEDIA_FAST_FORWARD:
+		// fall through
+		case AKEYCODE_MEDIA_REWIND:
+		// fall through
+		case AKEYCODE_MEDIA_PLAY_PAUSE:
+		// Treat as keyboard presses, since they have equivalent hardware keyboard keys
+			e.kbd.keycode = jkeymap[arg2];
+			if (arg5 > 0) {
+				e.kbdRepeat = true;
+			}
+			break;
+
+
+		// Unfortunately CHANNEL_UP or CHANNEL_DOWN do not trigger for the FireStick remote (3rd gen)
+		// despite the documentation (https://developer.amazon.com/docs/fire-tv/remote-input.html)
+		// so there's no way as of yet to test this. Also, using Channel up/down as mouse up/down
+		// is not very useful anyway
+//		case AKEYCODE_CHANNEL_UP:
+//		// fall through
+//		case AKEYCODE_CHANNEL_DOWN:
+//			// Treat as mouse movement - only on Y axis
+//			if (arg1 != AKEY_EVENT_ACTION_DOWN)
+//				return;
+//
+//			e.type = Common::EVENT_MOUSEMOVE;
+//
+//			e.mouse = dynamic_cast<AndroidCommonGraphics *>(_graphicsManager)->getMousePosition();
+//
+//			{
+//				int16 *c;
+//				int s;
+//
+//				c = &e.mouse.y;
+//				s = _eventScaleY;
+//
+//				// the longer the button held, the faster the pointer is
+//				// TODO put these values in some option dlg?
+//				int f = CLIP(arg5, 1, 8) * _dpad_scale * 100 / s;
+//
+//				if (arg2 == AKEYCODE_CHANNEL_UP) {
+//					*c -= f;
+//				} else {
+//					*c += f;
+//				}
+//			}
+//			break;
+		}
+
+		pushEvent(e);
+		return;
+
 	case JE_DOWN:
 //		LOGD("JE_DOWN");
 		_touch_pt_down = dynamic_cast<AndroidCommonGraphics *>(_graphicsManager)->getMousePosition();
@@ -1161,6 +1231,26 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
 			e.joystick.button = Common::JOYSTICK_BUTTON_RIGHT_STICK;
 			break;
 
+		case AKEYCODE_DPAD_UP:
+			e.joystick.button = Common::JOYSTICK_BUTTON_DPAD_UP;
+			break;
+
+		case AKEYCODE_DPAD_DOWN:
+			e.joystick.button = Common::JOYSTICK_BUTTON_DPAD_DOWN;
+			break;
+
+		case AKEYCODE_DPAD_LEFT:
+			e.joystick.button = Common::JOYSTICK_BUTTON_DPAD_LEFT;
+			break;
+
+		case AKEYCODE_DPAD_RIGHT:
+			e.joystick.button = Common::JOYSTICK_BUTTON_DPAD_RIGHT;
+			break;
+
+		case AKEYCODE_DPAD_CENTER:
+			e.joystick.button = Common::JOYSTICK_BUTTON_DPAD_CENTER;
+			break;
+
 		default:
 			LOGW("unmapped gamepad key: %d", arg2);
 			return;
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java b/backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java
index d91cff529fd..d20a121ca4c 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMEventsBase.java
@@ -48,6 +48,9 @@ public class ScummVMEventsBase implements
 	public static final int JE_BMB_UP = 19;
 	public static final int JE_FMB_DOWN = 20;
 	public static final int JE_FMB_UP = 21;
+
+	public static final int JE_TV_REMOTE = 22;
+
 	public static final int JE_QUIT = 0x1000;
 	public static final int JE_MENU = 0x1001;
 
@@ -369,17 +372,29 @@ public class ScummVMEventsBase implements
 		case KeyEvent.KEYCODE_VOLUME_UP:
 			// We ignore these so that they can be handled by Android.
 			return false;
+
+//		case KeyEvent.KEYCODE_CHANNEL_UP:
+//		case KeyEvent.KEYCODE_CHANNEL_DOWN:
+		case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
+		case KeyEvent.KEYCODE_MEDIA_REWIND:
+		case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
+			type = JE_TV_REMOTE;
+			break;
+
 		case KeyEvent.KEYCODE_DPAD_UP:
 		case KeyEvent.KEYCODE_DPAD_DOWN:
 		case KeyEvent.KEYCODE_DPAD_LEFT:
 		case KeyEvent.KEYCODE_DPAD_RIGHT:
 		case KeyEvent.KEYCODE_DPAD_CENTER:
-			if (e.getSource() == InputDevice.SOURCE_DPAD) {
-				type = JE_DPAD;
-			} else {
-				type = JE_KEY;
-			}
-			break;
+//			if (e.getSource() == InputDevice.SOURCE_DPAD) {
+//				// When interpreted as JE_DPAD it will work as a mouse (translated in Android backend, events.cpp)
+//				// TODO ASDF is this interfering with Joystick on-screen control?
+//				type = JE_DPAD;
+//			} else {
+//				// When interpreted as JE_GAMEPAD it will be forwarder to ScummVM's keymapper
+//				type = JE_GAMEPAD;
+//			}
+//			break;
 		case KeyEvent.KEYCODE_BUTTON_A:
 		case KeyEvent.KEYCODE_BUTTON_B:
 		case KeyEvent.KEYCODE_BUTTON_C:
@@ -397,6 +412,7 @@ public class ScummVMEventsBase implements
 		case KeyEvent.KEYCODE_BUTTON_MODE:
 			type = JE_GAMEPAD;
 			break;
+
 		case KeyEvent.KEYCODE_BUTTON_1:
 		case KeyEvent.KEYCODE_BUTTON_2:
 		case KeyEvent.KEYCODE_BUTTON_3:
@@ -404,6 +420,7 @@ public class ScummVMEventsBase implements
 			// These are oddly detected with SOURCE_KEYBOARD for joystick so don't bother checking the e.getSource()
 			type = JE_JOYSTICK;
 			break;
+
 		default:
 			if (e.isSystem()) {
 				type = JE_SYS_KEY;
@@ -414,6 +431,7 @@ public class ScummVMEventsBase implements
 		}
 
 		//_scummvm.displayMessageOnOSD("GetKey: " + keyCode + " unic=" + eventUnicodeChar+ " arg3= " + (eventUnicodeChar& KeyCharacterMap.COMBINING_ACCENT_MASK) + " meta: " + e.getMetaState());
+		//_scummvm.displayMessageOnOSD("GetKey: " + keyCode + " type=" + type + " source=" + e.getSource() + " action= " + action + " arg5= " + e.getRepeatCount());
 		//Log.d(ScummVM.LOG_TAG,"GetKey: " + keyCode + " unic=" + eventUnicodeChar+ " arg3= " + (eventUnicodeChar& KeyCharacterMap.COMBINING_ACCENT_MASK) + " meta: " + e.getMetaState());
 
 		// look in events.cpp for how this is handled
diff --git a/common/events.h b/common/events.h
index b9dab2888a0..a976a31b229 100644
--- a/common/events.h
+++ b/common/events.h
@@ -158,7 +158,8 @@ enum JoystickButton {
 	JOYSTICK_BUTTON_DPAD_UP,
 	JOYSTICK_BUTTON_DPAD_DOWN,
 	JOYSTICK_BUTTON_DPAD_LEFT,
-	JOYSTICK_BUTTON_DPAD_RIGHT
+	JOYSTICK_BUTTON_DPAD_RIGHT,
+	JOYSTICK_BUTTON_DPAD_CENTER
 };
 
 /**


Commit: cd8a40487fe6fa3c4b33acd1e4166a3e29e6abd2
    https://github.com/scummvm/scummvm/commit/cd8a40487fe6fa3c4b33acd1e4166a3e29e6abd2
Author: antoniou79 (a.antoniou79 at gmail.com)
Date: 2023-03-22T22:04:42+02:00

Commit Message:
ANDROID: Fix another deprecated Handler() usage

Changed paths:
    backends/platform/android/org/scummvm/scummvm/ScummVMEventsModern.java


diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMEventsModern.java b/backends/platform/android/org/scummvm/scummvm/ScummVMEventsModern.java
index ed57fe50934..b614c6aef3a 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMEventsModern.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMEventsModern.java
@@ -2,6 +2,7 @@ package org.scummvm.scummvm;
 
 import android.content.Context;
 import android.os.Handler;
+import android.os.Looper;
 import android.os.Message;
 import android.util.Log;
 import android.view.MotionEvent;
@@ -33,6 +34,7 @@ public class ScummVMEventsModern extends ScummVMEventsBase {
 		private final WeakReference<ScummVMEventsModern> mListenerReference;
 
 		public ScummVMEventsModernHandler(ScummVMEventsModern listener) {
+			super(Looper.getMainLooper());
 			mListenerReference = new WeakReference<>(listener);
 		}
 




More information about the Scummvm-git-logs mailing list