From 386a28e79f7a7d3fabc61a105e13e2ef061708eb Mon Sep 17 00:00:00 2001 From: TwistedUmbrella Date: Thu, 27 Feb 2014 20:17:10 -0500 Subject: [PATCH] The Moga interface doesn't really need to mirror the primary --- .../com/reicast/emulator/GL2JNIActivity.java | 9 +- .../com/reicast/emulator/GL2JNINative.java | 7 +- .../reicast/emulator/periph/MOGAInput.java | 98 +------------------ 3 files changed, 8 insertions(+), 106 deletions(-) diff --git a/shell/android/src/com/reicast/emulator/GL2JNIActivity.java b/shell/android/src/com/reicast/emulator/GL2JNIActivity.java index d9194efe2..51caad58e 100644 --- a/shell/android/src/com/reicast/emulator/GL2JNIActivity.java +++ b/shell/android/src/com/reicast/emulator/GL2JNIActivity.java @@ -257,7 +257,7 @@ public class GL2JNIActivity extends Activity { if (playerNum == null || playerNum == -1) return false; - if (!pad.compat[playerNum] && !pad.isActiveMoga[playerNum]) { + if (!pad.compat[playerNum]) { // Joystick if ((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) { @@ -332,9 +332,6 @@ public class GL2JNIActivity extends Activity { if (kc == pad.getSelectButtonCode()) { return false; } - if (pad.isActiveMoga[playerNum]) { - return false; - } boolean rav = false; for (int i = 0; i < pad.map[playerNum].length; i += 2) { @@ -420,7 +417,7 @@ public class GL2JNIActivity extends Activity { playerNum = -1; } - if (playerNum != null && playerNum != -1 && !pad.isActiveMoga[playerNum]) { + if (playerNum != null && playerNum != -1) { if (pad.compat[playerNum] || pad.custom[playerNum]) { String id = pad.portId[playerNum]; if (keyCode == prefs.getInt("l_button" + id, @@ -445,7 +442,7 @@ public class GL2JNIActivity extends Activity { playerNum = -1; } - if (playerNum != null && playerNum != -1 && !pad.isActiveMoga[playerNum]) { + if (playerNum != null && playerNum != -1) { if (pad.compat[playerNum] || pad.custom[playerNum]) { String id = pad.portId[playerNum]; if (keyCode == prefs.getInt("l_button" + id, KeyEvent.KEYCODE_BUTTON_L1)) { diff --git a/shell/android/src/com/reicast/emulator/GL2JNINative.java b/shell/android/src/com/reicast/emulator/GL2JNINative.java index 6745ec520..fef0bb99a 100644 --- a/shell/android/src/com/reicast/emulator/GL2JNINative.java +++ b/shell/android/src/com/reicast/emulator/GL2JNINative.java @@ -350,8 +350,7 @@ public class GL2JNINative extends NativeActivity { if (playerNum == null || playerNum == -1) { return false; } - if (!pad.compat[playerNum] && !pad.isActiveMoga[playerNum]) { - // TODO: Moga should handle this locally + if (!pad.compat[playerNum]) { // Joystick if ((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) { @@ -468,7 +467,7 @@ public class GL2JNINative extends NativeActivity { public boolean OnNativeKeyPress(int device, int keyCode, int action, int metaState) { Integer playerNum = pad.playerNumX.get(device); - if (playerNum != null && playerNum != -1 && !pad.isActiveMoga[playerNum]) { + if (playerNum != null && playerNum != -1) { String id = pad.portId[playerNum]; if (action == KeyEvent.ACTION_DOWN) { if (keyCode == prefs.getInt("l_button" + id, KeyEvent.KEYCODE_BUTTON_L1)) { @@ -499,7 +498,7 @@ public class GL2JNINative extends NativeActivity { if (newEvent && source == Gamepad.Xperia_Touchpad) { // Source is Xperia Play touchpad Integer playerNum = pad.playerNumX.get(device); - if (playerNum != null && playerNum != -1 && !pad.isActiveMoga[playerNum]) { + if (playerNum != null && playerNum != -1) { Log.d("reidc", playerNum + " - " + device + ": " + source); if (action == MotionEvent.ACTION_UP) { x = 0; diff --git a/shell/android/src/com/reicast/emulator/periph/MOGAInput.java b/shell/android/src/com/reicast/emulator/periph/MOGAInput.java index f447371f7..7d067c4de 100644 --- a/shell/android/src/com/reicast/emulator/periph/MOGAInput.java +++ b/shell/android/src/com/reicast/emulator/periph/MOGAInput.java @@ -3,12 +3,8 @@ package com.reicast.emulator.periph; /******************************************************************************/ -import java.util.Arrays; - -import tv.ouya.console.api.OuyaController; import android.app.Activity; import android.content.SharedPreferences; -import android.os.Build; import android.os.Handler; import android.preference.PreferenceManager; import android.widget.Toast; @@ -18,9 +14,7 @@ import com.bda.controller.ControllerListener; import com.bda.controller.KeyEvent; import com.bda.controller.MotionEvent; import com.bda.controller.StateEvent; -import com.reicast.emulator.GL2JNIActivity; import com.reicast.emulator.R; -import com.reicast.emulator.emu.GL2JNIView; import com.reicast.emulator.emu.JNIdc; /******************************************************************************/ @@ -135,100 +129,12 @@ public class MOGAInput { public void onKeyEvent(KeyEvent event) { - Integer playerNum = Arrays.asList(pad.name).indexOf(event.getControllerId()); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD && playerNum == -1) { - playerNum = pad.deviceDescriptor_PlayerNum - .get(pad.deviceId_deviceDescriptor.get(event.getControllerId())); - } else { - playerNum = -1; - } - if (playerNum == null || playerNum == -1) - return; - if (playerNum != null && playerNum != -1) { - String id = pad.portId[playerNum]; - if (event.getAction() == KeyEvent.ACTION_DOWN) { - if (event.getKeyCode() == prefs.getInt("l_button" + id, KeyEvent.KEYCODE_BUTTON_L1)) { - simulatedTouchEvent(playerNum, 1.0f, 0.0f); - } else if (event.getKeyCode() == prefs.getInt("r_button" + id, KeyEvent.KEYCODE_BUTTON_R1)) { - simulatedTouchEvent(playerNum, 0.0f, 1.0f); - } else if (((GL2JNIActivity) act).handle_key(playerNum, event.getKeyCode(), true)) { - if (playerNum == 0) - JNIdc.hide_osd(); - } - } - if (event.getAction() == KeyEvent.ACTION_UP) { - if (event.getKeyCode() == prefs.getInt("l_button" + id, - KeyEvent.KEYCODE_BUTTON_L1) - || event.getKeyCode() == prefs.getInt("r_button" + id, - KeyEvent.KEYCODE_BUTTON_R1)) { - simulatedTouchEvent(playerNum, 0.0f, 0.0f); - } else { - ((GL2JNIActivity) act).handle_key(playerNum, event.getKeyCode(), false); - } - } - } + // Handled by the primary controller interface } public void onMotionEvent(MotionEvent event) { - Integer playerNum = Arrays.asList(pad.name).indexOf(event.getControllerId()); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD && playerNum == -1) { - playerNum = pad.deviceDescriptor_PlayerNum - .get(pad.deviceId_deviceDescriptor.get(event.getControllerId())); - } else { - playerNum = -1; - } - if (playerNum == null || playerNum == -1) - return; - if (!pad.compat[playerNum]) { - // Joystick - // do other things with joystick - float LS_X = event.getAxisValue(OuyaController.AXIS_LS_X); - float LS_Y = event.getAxisValue(OuyaController.AXIS_LS_Y); - float RS_X = event.getAxisValue(OuyaController.AXIS_RS_X); - float RS_Y = event.getAxisValue(OuyaController.AXIS_RS_Y); - float L2 = event.getAxisValue(OuyaController.AXIS_L2); - float R2 = event.getAxisValue(OuyaController.AXIS_R2); - - pad.previousLS_X[playerNum] = pad.globalLS_X[playerNum]; - pad.previousLS_Y[playerNum] = pad.globalLS_Y[playerNum]; - pad.globalLS_X[playerNum] = LS_X; - pad.globalLS_Y[playerNum] = LS_Y; - - GL2JNIView.lt[playerNum] = (int) (L2 * 255); - GL2JNIView.rt[playerNum] = (int) (R2 * 255); - - GL2JNIView.jx[playerNum] = (int) (LS_X * 126); - GL2JNIView.jy[playerNum] = (int) (LS_Y * 126); - - if (prefs.getBoolean("right_buttons", true)) { - if (RS_Y > 0.5) { - ((GL2JNIActivity) act).handle_key(playerNum, pad.map[playerNum][0]/* A */, true); - pad.wasKeyStick[playerNum] = true; - } else if (RS_Y < 0.5) { - ((GL2JNIActivity) act).handle_key(playerNum, pad.map[playerNum][1]/* B */, true); - pad.wasKeyStick[playerNum] = true; - } else if (pad.wasKeyStick[playerNum]){ - ((GL2JNIActivity) act).handle_key(playerNum, pad.map[playerNum][0], false); - ((GL2JNIActivity) act).handle_key(playerNum, pad.map[playerNum][1], false); - pad.wasKeyStick[playerNum] = false; - } - } else { - if (RS_Y > 0.5) { - GL2JNIView.rt[playerNum] = (int) (RS_Y * 255); - } else if (RS_Y < 0.5) { - GL2JNIView.lt[playerNum] = (int) (-(RS_Y) * 255); - } - } - ((GL2JNIActivity) act).getGameView().pushInput(); - } - } - - public boolean simulatedTouchEvent(int playerNum, float L2, float R2) { - GL2JNIView.lt[playerNum] = (int) (L2 * 255); - GL2JNIView.rt[playerNum] = (int) (R2 * 255); - ((GL2JNIActivity) act).getGameView().pushInput(); - return true; + // Handled by the primary controller interface } public void onStateEvent(StateEvent event)