From f3fde0654838ec16181b86eef5bee9361a8f4d6e Mon Sep 17 00:00:00 2001 From: TwistedUmbrella Date: Tue, 9 Sep 2014 23:32:25 -0400 Subject: [PATCH 1/2] Unlink custom from JS-Dpad, Rename appropriately The preference name was a little misleading. The preference has the same functionality, but was named to imply an inverse functionality. It is now disabled by default, which may need to be reversed if the number of games requiring the feature to split the two controls is outweighed by the number for which the feature disables joystick functionality. --- .../android/src/com/reicast/emulator/GL2JNIActivity.java | 6 +----- shell/android/src/com/reicast/emulator/GL2JNINative.java | 6 +----- .../com/reicast/emulator/config/InputModFragment.java | 9 ++------- .../android/src/com/reicast/emulator/periph/Gamepad.java | 4 ++-- 4 files changed, 6 insertions(+), 19 deletions(-) diff --git a/shell/android/src/com/reicast/emulator/GL2JNIActivity.java b/shell/android/src/com/reicast/emulator/GL2JNIActivity.java index b180bea4e..cea32c99c 100644 --- a/shell/android/src/com/reicast/emulator/GL2JNIActivity.java +++ b/shell/android/src/com/reicast/emulator/GL2JNIActivity.java @@ -150,11 +150,7 @@ public class GL2JNIActivity extends Activity { String id = pad.portId[playerNum]; pad.custom[playerNum] = prefs.getBoolean(Gamepad.pref_js_modified + id, false); pad.compat[playerNum] = prefs.getBoolean(Gamepad.pref_js_compat + id, false); - if (pad.custom[playerNum] || pad.compat[playerNum]) { - pad.joystick[playerNum] = prefs.getBoolean(Gamepad.pref_js_separate + id, false); - } else { - pad.joystick[playerNum] = true; - } + pad.joystick[playerNum] = prefs.getBoolean(Gamepad.pref_js_merged + id, false); if (InputDevice.getDevice(joy).getName() .contains(Gamepad.controllers_gamekey)) { if (pad.custom[playerNum]) { diff --git a/shell/android/src/com/reicast/emulator/GL2JNINative.java b/shell/android/src/com/reicast/emulator/GL2JNINative.java index 8d69f40cc..b48de67d4 100644 --- a/shell/android/src/com/reicast/emulator/GL2JNINative.java +++ b/shell/android/src/com/reicast/emulator/GL2JNINative.java @@ -162,11 +162,7 @@ public class GL2JNINative extends NativeActivity { String id = pad.portId[playerNum]; pad.custom[playerNum] = prefs.getBoolean(Gamepad.pref_js_modified + id, false); pad.compat[playerNum] = prefs.getBoolean(Gamepad.pref_js_compat + id, false); - if (pad.custom[playerNum] || pad.compat[playerNum]) { - pad.joystick[playerNum] = prefs.getBoolean(Gamepad.pref_js_separate + id, false); - } else { - pad.joystick[playerNum] = true; - } + pad.joystick[playerNum] = prefs.getBoolean(Gamepad.pref_js_merged + id, false); if (InputDevice.getDevice(joy).getName() .contains(Gamepad.controllers_gamekey)) { // if (pad.custom[playerNum]) { diff --git a/shell/android/src/com/reicast/emulator/config/InputModFragment.java b/shell/android/src/com/reicast/emulator/config/InputModFragment.java index aa75564fc..2a4d131bd 100644 --- a/shell/android/src/com/reicast/emulator/config/InputModFragment.java +++ b/shell/android/src/com/reicast/emulator/config/InputModFragment.java @@ -105,7 +105,7 @@ public class InputModFragment extends Fragment { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { mPrefs.edit() - .putBoolean(Gamepad.pref_js_separate + player, + .putBoolean(Gamepad.pref_js_merged + player, isChecked).commit(); } }; @@ -118,11 +118,6 @@ public class InputModFragment extends Fragment { mPrefs.edit() .putBoolean(Gamepad.pref_js_modified + player, isChecked).commit(); - if (isChecked) { - switchJoystickDpadEnabled.setEnabled(true); - } else if (!switchCompatibilityEnabled.isChecked()) { - switchJoystickDpadEnabled.setEnabled(false); - } } }; @@ -576,7 +571,7 @@ public class InputModFragment extends Fragment { private void updateController(String player) { switchJoystickDpadEnabled.setChecked(mPrefs.getBoolean( - Gamepad.pref_js_separate + player, false)); + Gamepad.pref_js_merged + player, false)); switchModifiedLayoutEnabled.setChecked(mPrefs.getBoolean( Gamepad.pref_js_modified + player, false)); switchCompatibilityEnabled.setChecked(mPrefs.getBoolean( diff --git a/shell/android/src/com/reicast/emulator/periph/Gamepad.java b/shell/android/src/com/reicast/emulator/periph/Gamepad.java index 02a81eff5..116c43f5e 100644 --- a/shell/android/src/com/reicast/emulator/periph/Gamepad.java +++ b/shell/android/src/com/reicast/emulator/periph/Gamepad.java @@ -21,7 +21,7 @@ public class Gamepad { public static final String pref_js_modified = "modified_key_layout"; public static final String pref_js_compat = "controller_compat"; - public static final String pref_js_separate = "separate_joystick"; + public static final String pref_js_merged = "merged_joystick"; public static final String pref_js_rbuttons = "right_buttons"; public static final String pref_button_a = "a_button"; @@ -226,7 +226,7 @@ public class Gamepad { for (int n = 0; n < 4; n++) { if (compat[n]) { String id = portId[n]; - joystick[n] = prefs.getBoolean(Gamepad.pref_js_separate + id, false); + joystick[n] = prefs.getBoolean(Gamepad.pref_js_merged + id, false); getCompatibilityMap(n, portId[n], prefs); initJoyStickLayout(n); } From 0b2494b568961c60f92976a84504d9ade1618231 Mon Sep 17 00:00:00 2001 From: TwistedUmbrella Date: Thu, 11 Sep 2014 01:13:16 -0400 Subject: [PATCH 2/2] Fix onscreen control layout on layout change Addresses https://github.com/reicast/reicast-emulator/issues/531 --- .../android/src/com/reicast/emulator/emu/GL2JNIView.java | 5 ++++- .../src/com/reicast/emulator/periph/MOGAInput.java | 8 +++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/shell/android/src/com/reicast/emulator/emu/GL2JNIView.java b/shell/android/src/com/reicast/emulator/emu/GL2JNIView.java index 45c4f9480..dfaf026d3 100644 --- a/shell/android/src/com/reicast/emulator/emu/GL2JNIView.java +++ b/shell/android/src/com/reicast/emulator/emu/GL2JNIView.java @@ -122,6 +122,7 @@ public class GL2JNIView extends GLSurfaceView SYSTEM_UI_FLAG_IMMERSIVE_STICKY | SYSTEM_UI_FLAG_FULLSCREEN | SYSTEM_UI_FLAG_HIDE_NAVIGATION); + requestLayout(); } } }); @@ -741,7 +742,9 @@ public class GL2JNIView extends GLSurfaceView | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN - | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);} + | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); + requestLayout(); + } } private boolean takeScreenshot = false; diff --git a/shell/android/src/com/reicast/emulator/periph/MOGAInput.java b/shell/android/src/com/reicast/emulator/periph/MOGAInput.java index 5ad99674e..5023f9fae 100644 --- a/shell/android/src/com/reicast/emulator/periph/MOGAInput.java +++ b/shell/android/src/com/reicast/emulator/periph/MOGAInput.java @@ -6,15 +6,18 @@ package com.reicast.emulator.periph; import java.util.Arrays; import android.app.Activity; +import android.app.Instrumentation; +import android.content.Context; import android.content.SharedPreferences; import android.os.Build; import android.os.Handler; +import android.os.SystemClock; import android.preference.PreferenceManager; import android.util.Log; +import com.bda.controller.KeyEvent; import com.bda.controller.Controller; import com.bda.controller.ControllerListener; -import com.bda.controller.KeyEvent; import com.bda.controller.MotionEvent; import com.bda.controller.StateEvent; import com.reicast.emulator.R; @@ -131,11 +134,14 @@ public final class MOGAInput public void onKeyEvent(KeyEvent event) { // Handled by the primary controller interface +// act.dispatchKeyEvent(new android.view.KeyEvent(0, 0, event.getAction(), +// event.getKeyCode(), 0)); } public void onMotionEvent(MotionEvent event) { // Handled by the primary controller interface + } private void getCompatibilityMap(int playerNum, String id) {