|
@@ -20,6 +20,8 @@ import com.xugame.bean.SystemAVInfo;
|
|
|
import com.xugame.gameconsole.dialog.LoadingDialog;
|
|
|
import com.xugame.gameconsole.dialog.gamemenu.GameMenuDialog;
|
|
|
import com.xugame.gameconsole.dialog.gamemenu.GameMenuDialogListener;
|
|
|
+import com.xugame.gameconsole.monitor.EmulatorMonitor;
|
|
|
+import com.xugame.gameconsole.monitor.EmulatorMonitorListener;
|
|
|
import com.xugame.gameconsole.preferences.ConfigFile;
|
|
|
import com.xugame.gameconsole.preferences.UserPreferences;
|
|
|
import com.xugame.gameconsole.util.DebugUtil;
|
|
@@ -38,7 +40,8 @@ import java.util.Arrays;
|
|
|
// libsPath = intent.getStringExtra("lib_path");
|
|
|
// configPath = intent.getStringExtra("config_path");
|
|
|
// }
|
|
|
-public class RetroArchEmulatorActivity extends RetroActivityCamera {
|
|
|
+public class RetroArchEmulatorActivity extends RetroActivityCamera
|
|
|
+ implements EmulatorMonitorListener {
|
|
|
private static final String TAG = "RetroArchEmulatorActivityTAG";
|
|
|
private ScreenType mScreenType = ScreenType.NORMAL;
|
|
|
private boolean mUpdateScreen = false;
|
|
@@ -48,13 +51,15 @@ public class RetroArchEmulatorActivity extends RetroActivityCamera {
|
|
|
private AppSystem system = null;
|
|
|
private boolean isBusy = false;
|
|
|
private LoadingDialog mLoadingDialog;
|
|
|
+ private EmulatorMonitor mEmulatorMonitor;
|
|
|
+ private String mRomPath;
|
|
|
|
|
|
@Override
|
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
|
system = new AppSystem();
|
|
|
-
|
|
|
+ mRomPath = getIntent().getStringExtra("ROM");
|
|
|
callback = new EnvironmentCallback() {
|
|
|
@Override
|
|
|
public void setInputDescriptors(InputDescriptorBean[] descriptors) {
|
|
@@ -134,6 +139,7 @@ public class RetroArchEmulatorActivity extends RetroActivityCamera {
|
|
|
Log.i("EnvironmentCallback", "Content Loaded");
|
|
|
}
|
|
|
};
|
|
|
+ mEmulatorMonitor = new EmulatorMonitor(this, this);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -165,6 +171,7 @@ public class RetroArchEmulatorActivity extends RetroActivityCamera {
|
|
|
}
|
|
|
ComponentName componentName = new ComponentName("com.xugame.gameconsoleMenu",
|
|
|
"com.xugame.gameconsole.dialog.localgamesetting.LocalGameSettingDialog");
|
|
|
+ intent.putExtra("rompath", mRomPath);
|
|
|
intent.setComponent(componentName);
|
|
|
startActivityForResult(intent, 200);
|
|
|
DebugUtil.i(TAG, "showLocalExitDialog");
|
|
@@ -255,6 +262,14 @@ public class RetroArchEmulatorActivity extends RetroActivityCamera {
|
|
|
Log.w("Key doesn't exist yet.", e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onDestroy() {
|
|
|
+ super.onDestroy();
|
|
|
+ if (mEmulatorMonitor != null)
|
|
|
+ mEmulatorMonitor.unregister();
|
|
|
}
|
|
|
|
|
|
public void hideMouseCursor() {
|
|
@@ -418,6 +433,7 @@ public class RetroArchEmulatorActivity extends RetroActivityCamera {
|
|
|
if (requestCode == 200) {
|
|
|
if (resultCode == 201) {//继续游戏
|
|
|
gameDialogClosed();
|
|
|
+// testSetKey();
|
|
|
if (data != null) {
|
|
|
//增加完美像素单独开关,避免混淆
|
|
|
boolean isPixelPerfect = data.getBooleanExtra("is_pixelperfect", false);
|
|
@@ -426,26 +442,30 @@ public class RetroArchEmulatorActivity extends RetroActivityCamera {
|
|
|
int scanLine = data.getIntExtra("scanLine", 0);
|
|
|
int screen = data.getIntExtra("screen", 0);
|
|
|
DebugUtil.i(TAG, "scanline=" + scanLine + "screen=" + screen);
|
|
|
- if (mScreen != screen) {
|
|
|
- mScreen = screen;
|
|
|
- if (screen >= 0 && screen < 3) {
|
|
|
- switch (screen) {
|
|
|
- case 0:
|
|
|
- setAspectRatio(AspectRatio.ASPECT_RATIO_CUSTOM.getValue());
|
|
|
- setCustomViewPort(Util.getSize(420), Util.getSize(87), Util.getSize(1080), Util.getSize(810));
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- setAspectRatio(AspectRatio.ASPECT_RATIO_CORE.getValue());
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- setAspectRatio(AspectRatio.ASPECT_RATIO_FULL.getValue());
|
|
|
- break;
|
|
|
+// if (mScreen != screen) {
|
|
|
+ mScreen = screen;
|
|
|
+ if (screen >= 0 && screen < 3) {
|
|
|
+ DebugUtil.i(TAG, "设置screen" + screen);
|
|
|
+ switch (screen) {
|
|
|
+
|
|
|
+ case 0:
|
|
|
+ setAspectRatio(AspectRatio.ASPECT_RATIO_CORE.getValue());
|
|
|
+// setCustomViewPort(Util.getSize(420), Util.getSize(87), Util.getSize(1080), Util.getSize(810));
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ setAspectRatio(AspectRatio.ASPECT_RATIO_4_3.getValue());
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ setAspectRatio(AspectRatio.ASPECT_RATIO_FULL.getValue());
|
|
|
+ break;
|
|
|
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
+// }
|
|
|
if (mScanline != scanLine) {
|
|
|
if (scanLine >= 0 && scanLine < 4) {
|
|
|
+ DebugUtil.i(TAG, "设置scanLine" + scanLine + ScreenType.values()[scanLine]);
|
|
|
+
|
|
|
switch (ScreenType.values()[scanLine]) {
|
|
|
case NORMAL:
|
|
|
switchFilter(null);
|
|
@@ -464,7 +484,7 @@ public class RetroArchEmulatorActivity extends RetroActivityCamera {
|
|
|
}
|
|
|
} else {
|
|
|
int multiple = data.getIntExtra("multiple", -1);
|
|
|
- DebugUtil.i(TAG,"multiple="+multiple);
|
|
|
+ DebugUtil.i(TAG, "multiple=" + multiple);
|
|
|
if (multiple >= 2 && multiple <= 5) {
|
|
|
resetScreenForPerfect(multiple);
|
|
|
}
|
|
@@ -479,6 +499,46 @@ public class RetroArchEmulatorActivity extends RetroActivityCamera {
|
|
|
super.onActivityResult(requestCode, resultCode, data);
|
|
|
}
|
|
|
|
|
|
+ private void testSetKey() {
|
|
|
+ int[] javaKey = {
|
|
|
+ InputCode.JoypadBindKeySet.JOYPAD_BTN_A,//轻拳
|
|
|
+ InputCode.JoypadBindKeySet.JOYPAD_BTN_B,//重拳
|
|
|
+ 108,
|
|
|
+ 109,
|
|
|
+ InputCode.JoypadBindKeySet.JOYPAD_AXIS_X_PLUS,
|
|
|
+ InputCode.JoypadBindKeySet.JOYPAD_AXIS_X_MINIS,
|
|
|
+ InputCode.JoypadBindKeySet.JOYPAD_AXIS_Y_PLUS,
|
|
|
+ InputCode.JoypadBindKeySet.JOYPAD_AXIS_Y_MINIS,
|
|
|
+ 99,//轻脚
|
|
|
+ 100,//重脚
|
|
|
+ 98,
|
|
|
+ 101,
|
|
|
+ 103,
|
|
|
+ 104,
|
|
|
+ 105,
|
|
|
+ 106
|
|
|
+ };
|
|
|
+ int[] emulatorKey = {
|
|
|
+ InputCode.JoypadBindSet.JOYPAD_B,
|
|
|
+ InputCode.JoypadBindSet.JOYPAD_Y,
|
|
|
+ InputCode.JoypadBindSet.JOYPAD_SELECT,
|
|
|
+ InputCode.JoypadBindSet.JOYPAD_START,
|
|
|
+ InputCode.JoypadBindSet.JOYPAD_UP,
|
|
|
+ InputCode.JoypadBindSet.JOYPAD_DOWN,
|
|
|
+ InputCode.JoypadBindSet.JOYPAD_LEFT,
|
|
|
+ InputCode.JoypadBindSet.JOYPAD_RIGHT,
|
|
|
+ InputCode.JoypadBindSet.JOYPAD_A,
|
|
|
+ InputCode.JoypadBindSet.JOYPAD_X,
|
|
|
+ InputCode.JoypadBindSet.JOYPAD_L,
|
|
|
+ InputCode.JoypadBindSet.JOYPAD_R,
|
|
|
+ InputCode.JoypadBindSet.JOYPAD_L2,
|
|
|
+ InputCode.JoypadBindSet.JOYPAD_R2,
|
|
|
+ InputCode.JoypadBindSet.JOYPAD_L3,
|
|
|
+ InputCode.JoypadBindSet.JOYPAD_R3,
|
|
|
+ };
|
|
|
+ setJoystickBindNative(0, javaKey, emulatorKey);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
private void resetScreenForPerfect(int multiple) {
|
|
|
if (system != null && system.systemAVInfo != null) {
|
|
@@ -560,4 +620,40 @@ public class RetroArchEmulatorActivity extends RetroActivityCamera {
|
|
|
//
|
|
|
// }
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onHomeClick() {
|
|
|
+ DebugUtil.i(TAG, "onHomeClick");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onRecentClick() {
|
|
|
+ DebugUtil.i(TAG, "onRecentClick");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onMenuSaveState(int index) {
|
|
|
+ DebugUtil.i(TAG, "saveState" + index);
|
|
|
+ if (index >= 0 && index < 10) {
|
|
|
+ if (saveState(index)) {
|
|
|
+ Intent intent = new Intent();
|
|
|
+ intent.setAction(EmulatorMonitor.EMULATOR_SAVE_STATE_ACTION);
|
|
|
+ intent.putExtra("save_state_flag", true);
|
|
|
+ this.sendBroadcast(intent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onMenuLoadState(int index) {
|
|
|
+ DebugUtil.i(TAG, "loadState" + index);
|
|
|
+ if (index >= 0 && index < 10) {
|
|
|
+ if (loadState(index)) {
|
|
|
+ Intent intent = new Intent();
|
|
|
+ intent.setAction(EmulatorMonitor.EMULATOR_LOAD_STATE_ACTION);
|
|
|
+ intent.putExtra("load_state_flag", true);
|
|
|
+ this.sendBroadcast(intent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|