|
@@ -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() {
|
|
@@ -44,7 +121,7 @@ public class RetroArchEmulatorActivity extends RetroActivityCamera {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- DebugUtil.i(TAG,"showLocalExitDialog");
|
|
|
+ DebugUtil.i(TAG, "showLocalExitDialog");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -92,8 +169,8 @@ public class RetroArchEmulatorActivity extends RetroActivityCamera {
|
|
|
// This requires NVIDIA Android extensions (available on NVIDIA Shield), if they are not
|
|
|
// available then nothing will be done
|
|
|
if (retro.hasExtra("HIDEMOUSE")) hideMouseCursor();
|
|
|
- int screenMode=retro.getIntExtra("screenMode",0);
|
|
|
- if(screenMode>=0&&screenMode<3){
|
|
|
+ int screenMode = retro.getIntExtra("screenMode", 0);
|
|
|
+ if (screenMode >= 0 && screenMode < 3) {
|
|
|
switch (screenMode) {
|
|
|
case 0:
|
|
|
setAspectRatio(AspectRatio.ASPECT_RATIO_CORE.getValue());
|
|
@@ -158,11 +235,11 @@ public class RetroArchEmulatorActivity extends RetroActivityCamera {
|
|
|
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK
|
|
|
&& event.getAction() == KeyEvent.ACTION_DOWN) {
|
|
|
// showDialog();
|
|
|
- Intent intent=new Intent();//调出主菜单UI
|
|
|
- ComponentName componentName=new ComponentName("com.xugame.gameconsoleMenu",
|
|
|
+ Intent intent = new Intent();//调出主菜单UI
|
|
|
+ ComponentName componentName = new ComponentName("com.xugame.gameconsoleMenu",
|
|
|
"com.xugame.gameconsole.dialog.localgamesetting.LocalGameSettingDialog");
|
|
|
- intent.setComponent(componentName);
|
|
|
- startActivityForResult(intent,200);
|
|
|
+ intent.setComponent(componentName);
|
|
|
+ startActivityForResult(intent, 200);
|
|
|
return super.dispatchKeyEvent(event);
|
|
|
}
|
|
|
|
|
@@ -275,7 +352,7 @@ public class RetroArchEmulatorActivity extends RetroActivityCamera {
|
|
|
if (data != null) {
|
|
|
int scanLine = data.getIntExtra("scanLine", 0);
|
|
|
int screen = data.getIntExtra("screen", 0);
|
|
|
- DebugUtil.i(TAG,"scanline="+scanLine+"screen="+screen);
|
|
|
+ DebugUtil.i(TAG, "scanline=" + scanLine + "screen=" + screen);
|
|
|
|
|
|
if (screen >= 0 && screen < 3) {
|
|
|
switch (screen) {
|