|
@@ -5,12 +5,17 @@ import android.content.Context;
|
|
|
import android.content.Intent;
|
|
|
import android.hardware.input.InputManager;
|
|
|
import android.os.Build;
|
|
|
+import android.os.Bundle;
|
|
|
import android.util.Log;
|
|
|
import android.view.KeyEvent;
|
|
|
import android.view.View;
|
|
|
import android.view.WindowManager;
|
|
|
|
|
|
import com.retroarch.browser.retroactivity.AspectRatio;
|
|
|
+import com.xugame.app.AppSystem;
|
|
|
+import com.xugame.app.EnvironmentCallback;
|
|
|
+import com.xugame.bean.InputCode;
|
|
|
+import com.xugame.bean.InputDescriptorBean;
|
|
|
import com.xugame.gameconsole.dialog.gamemenu.GameMenuDialog;
|
|
|
import com.xugame.gameconsole.dialog.gamemenu.GameMenuDialogListener;
|
|
|
import com.xugame.gameconsole.preferences.ConfigFile;
|
|
@@ -35,6 +40,78 @@ public class RetroArchEmulatorActivity extends RetroActivityCamera {
|
|
|
// If set to true then Retroarch will completely exit when it loses focus
|
|
|
private boolean quitfocus = false;
|
|
|
|
|
|
+ private AppSystem system = null;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onCreate(Bundle savedInstanceState) {
|
|
|
+ super.onCreate(savedInstanceState);
|
|
|
+
|
|
|
+ system = new AppSystem();
|
|
|
+
|
|
|
+ callback = new EnvironmentCallback() {
|
|
|
+ @Override
|
|
|
+ public void setInputDescriptors(InputDescriptorBean[] descriptors) {
|
|
|
+ for (int i = 0; i < descriptors.length; i++) {
|
|
|
+ Log.i(
|
|
|
+ "EnvironmentCallback",
|
|
|
+ "i: " + i
|
|
|
+ + ", port: " + descriptors[i].getPort()
|
|
|
+ + ", device: " + descriptors[i].getDevice()
|
|
|
+ + ", index: " + descriptors[i].getIndex()
|
|
|
+ + ", id: " + descriptors[i].getId()
|
|
|
+ + ", desc: " + descriptors[i].getDescription()
|
|
|
+ );
|
|
|
+
|
|
|
+ if (descriptors[i].getPort() >= AppSystem.MAX_USERS)
|
|
|
+ continue;
|
|
|
+
|
|
|
+ if (descriptors[i].getId() >= 16)
|
|
|
+ continue;
|
|
|
+
|
|
|
+ if (descriptors[i].getDevice() == AppSystem.DEVICE_JOYPAD) {
|
|
|
+ system.inputDescriptors[descriptors[i].getPort()]
|
|
|
+ [descriptors[i].getId()] = descriptors[i].getDescription();
|
|
|
+ } else if (descriptors[i].getDevice() == AppSystem.DEVICE_ANALOG) {
|
|
|
+ if (descriptors[i].getId() == AppSystem.DEVICE_ID_ANALOG_X) {
|
|
|
+ if (descriptors[i].getIndex() == AppSystem.DEVICE_INDEX_ANALOG_LEFT) {
|
|
|
+ system.inputDescriptors[descriptors[i].getPort()]
|
|
|
+ [InputCode.ANALOG_LEFT_X_PLUS] = descriptors[i].getDescription();
|
|
|
+ system.inputDescriptors[descriptors[i].getPort()]
|
|
|
+ [InputCode.ANALOG_LEFT_X_MINUS] = descriptors[i].getDescription();
|
|
|
+ } else if (descriptors[i].getIndex() == AppSystem.DEVICE_INDEX_ANALOG_RIGHT) {
|
|
|
+ system.inputDescriptors[descriptors[i].getPort()]
|
|
|
+ [InputCode.ANALOG_RIGHT_X_PLUS] = descriptors[i].getDescription();
|
|
|
+ system.inputDescriptors[descriptors[i].getPort()]
|
|
|
+ [InputCode.ANALOG_RIGHT_X_MINUS] = descriptors[i].getDescription();
|
|
|
+ }
|
|
|
+ } else if (descriptors[i].getId() == AppSystem.DEVICE_ID_ANALOG_Y) {
|
|
|
+ if (descriptors[i].getIndex() == AppSystem.DEVICE_INDEX_ANALOG_LEFT) {
|
|
|
+ system.inputDescriptors[descriptors[i].getPort()]
|
|
|
+ [InputCode.ANALOG_LEFT_Y_PLUS] = descriptors[i].getDescription();
|
|
|
+ system.inputDescriptors[descriptors[i].getPort()]
|
|
|
+ [InputCode.ANALOG_LEFT_Y_MINUS] = descriptors[i].getDescription();
|
|
|
+ } else if (descriptors[i].getIndex() == AppSystem.DEVICE_INDEX_ANALOG_RIGHT) {
|
|
|
+ system.inputDescriptors[descriptors[i].getPort()]
|
|
|
+ [InputCode.ANALOG_RIGHT_Y_PLUS] = descriptors[i].getDescription();
|
|
|
+ system.inputDescriptors[descriptors[i].getPort()]
|
|
|
+ [InputCode.ANALOG_RIGHT_Y_MINUS] = descriptors[i].getDescription();
|
|
|
+ }
|
|
|
+ } else if (descriptors[i].getId() == AppSystem.DEVICE_ID_JOYPAD_L2
|
|
|
+ || descriptors[i].getId() == AppSystem.DEVICE_ID_JOYPAD_R2
|
|
|
+ ) {
|
|
|
+ if (descriptors[i].getIndex() == AppSystem.DEVICE_INDEX_ANALOG_BUTTON) {
|
|
|
+ system.inputDescriptors[descriptors[i].getPort()]
|
|
|
+ [descriptors[i].getId()] = descriptors[i].getDescription();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ system.hasInputDescriptors = true;
|
|
|
+ }
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void showLocalExitDialog() {
|
|
|
runOnUiThread(new Runnable() {
|