|
@@ -15,11 +15,14 @@ import android.util.Log;
|
|
import android.view.KeyEvent;
|
|
import android.view.KeyEvent;
|
|
import android.view.View;
|
|
import android.view.View;
|
|
import android.view.WindowManager;
|
|
import android.view.WindowManager;
|
|
|
|
+import android.widget.Toast;
|
|
|
|
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.Nullable;
|
|
|
|
|
|
import com.xugame.gameconsole.MainActivity;
|
|
import com.xugame.gameconsole.MainActivity;
|
|
import com.xugame.gameconsole.R;
|
|
import com.xugame.gameconsole.R;
|
|
|
|
+import com.xugame.gameconsole.dialog.gamemenu.GameMenuDialog;
|
|
|
|
+import com.xugame.gameconsole.dialog.gamemenu.GameMenuDialogListener;
|
|
import com.xugame.gameconsole.preferences.ConfigFile;
|
|
import com.xugame.gameconsole.preferences.ConfigFile;
|
|
import com.xugame.gameconsole.preferences.UserPreferences;
|
|
import com.xugame.gameconsole.preferences.UserPreferences;
|
|
import com.xugame.gameconsole.util.DebugUtil;
|
|
import com.xugame.gameconsole.util.DebugUtil;
|
|
@@ -36,6 +39,7 @@ import java.lang.reflect.Method;
|
|
// }
|
|
// }
|
|
public class RetroArchEmulatorActivity extends RetroActivityCamera {
|
|
public class RetroArchEmulatorActivity extends RetroActivityCamera {
|
|
private static final String TAG = "RetroArchEmulatorActivityTAG";
|
|
private static final String TAG = "RetroArchEmulatorActivityTAG";
|
|
|
|
+ private Context mCotext;
|
|
|
|
|
|
// If set to true then Retroarch will completely exit when it loses focus
|
|
// If set to true then Retroarch will completely exit when it loses focus
|
|
private boolean quitfocus = false;
|
|
private boolean quitfocus = false;
|
|
@@ -71,7 +75,7 @@ public class RetroArchEmulatorActivity extends RetroActivityCamera {
|
|
String refresh = retro.getStringExtra("REFRESH");
|
|
String refresh = retro.getStringExtra("REFRESH");
|
|
|
|
|
|
// If REFRESH parameter is provided then try to set refreshrate accordingly
|
|
// If REFRESH parameter is provided then try to set refreshrate accordingly
|
|
- if(refresh != null) {
|
|
|
|
|
|
+ if (refresh != null) {
|
|
WindowManager.LayoutParams params = getWindow().getAttributes();
|
|
WindowManager.LayoutParams params = getWindow().getAttributes();
|
|
params.preferredRefreshRate = Integer.parseInt(refresh);
|
|
params.preferredRefreshRate = Integer.parseInt(refresh);
|
|
getWindow().setAttributes(params);
|
|
getWindow().setAttributes(params);
|
|
@@ -105,18 +109,20 @@ public class RetroArchEmulatorActivity extends RetroActivityCamera {
|
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
|
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
|
|
// Check for NVIDIA extensions and minimum SDK version
|
|
// Check for NVIDIA extensions and minimum SDK version
|
|
Method mInputManager_setCursorVisibility;
|
|
Method mInputManager_setCursorVisibility;
|
|
- try { mInputManager_setCursorVisibility =
|
|
|
|
- InputManager.class.getMethod("setCursorVisibility", boolean.class);
|
|
|
|
- }
|
|
|
|
- catch (NoSuchMethodException ex) {
|
|
|
|
|
|
+ try {
|
|
|
|
+ mInputManager_setCursorVisibility =
|
|
|
|
+ InputManager.class.getMethod("setCursorVisibility", boolean.class);
|
|
|
|
+ } catch (NoSuchMethodException ex) {
|
|
return; // Extensions were not available so do nothing
|
|
return; // Extensions were not available so do nothing
|
|
}
|
|
}
|
|
|
|
|
|
// Hide the mouse cursor
|
|
// Hide the mouse cursor
|
|
InputManager inputManager = (InputManager) getSystemService(Context.INPUT_SERVICE);
|
|
InputManager inputManager = (InputManager) getSystemService(Context.INPUT_SERVICE);
|
|
- try { mInputManager_setCursorVisibility.invoke(inputManager, false); }
|
|
|
|
- catch (InvocationTargetException ite) { }
|
|
|
|
- catch (IllegalAccessException iae) { }
|
|
|
|
|
|
+ try {
|
|
|
|
+ mInputManager_setCursorVisibility.invoke(inputManager, false);
|
|
|
|
+ } catch (InvocationTargetException ite) {
|
|
|
|
+ } catch (IllegalAccessException iae) {
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -130,9 +136,9 @@ public class RetroArchEmulatorActivity extends RetroActivityCamera {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public boolean dispatchKeyEvent(KeyEvent event) {
|
|
public boolean dispatchKeyEvent(KeyEvent event) {
|
|
- DebugUtil.i(TAG,""+event.getKeyCode());
|
|
|
|
- if(event.getKeyCode()==KeyEvent.KEYCODE_BACK
|
|
|
|
- &&event.getAction()==KeyEvent.ACTION_DOWN){
|
|
|
|
|
|
+ DebugUtil.i(TAG, "" + event.getKeyCode());
|
|
|
|
+ if (event.getKeyCode() == KeyEvent.KEYCODE_BACK
|
|
|
|
+ && event.getAction() == KeyEvent.ACTION_DOWN) {
|
|
showDialog();
|
|
showDialog();
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -141,27 +147,42 @@ public class RetroArchEmulatorActivity extends RetroActivityCamera {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
- DebugUtil.i(TAG,"onKeyDown="+event.getKeyCode());
|
|
|
|
|
|
+ DebugUtil.i(TAG, "onKeyDown=" + event.getKeyCode());
|
|
return super.onKeyDown(keyCode, event);
|
|
return super.onKeyDown(keyCode, event);
|
|
}
|
|
}
|
|
|
|
|
|
private void showDialog() {
|
|
private void showDialog() {
|
|
- AlertDialog.Builder alertDialog = new ProgressDialog.Builder(this)
|
|
|
|
- .setTitle("Yes/No")
|
|
|
|
- .setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
|
|
|
- @Override
|
|
|
|
- public void onClick(DialogInterface dialog, int which) {
|
|
|
|
- clickBack();
|
|
|
|
- dialog.dismiss();
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- .setNegativeButton("No", new DialogInterface.OnClickListener() {
|
|
|
|
- @Override
|
|
|
|
- public void onClick(DialogInterface dialog, int which) {
|
|
|
|
- dialog.dismiss();
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- .setMessage("退出游戏?");
|
|
|
|
- alertDialog.show();
|
|
|
|
|
|
+ GameMenuDialog menuDialog = new GameMenuDialog(this, new GameMenuDialogListener() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onExitGame() {
|
|
|
|
+ clickBack();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onResumeGame(GameMenuDialog.SCREEN_TYPE type, int archiveIndex) {
|
|
|
|
+ Toast.makeText(RetroArchEmulatorActivity.this, "画面设置为:" + type + "读取存档Index=" + archiveIndex, Toast.LENGTH_SHORT).show();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ menuDialog.setCanceledOnTouchOutside(true);
|
|
|
|
+ menuDialog.show();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+// AlertDialog.Builder alertDialog = new ProgressDialog.Builder(this)
|
|
|
|
+// .setTitle("Yes/No")
|
|
|
|
+// .setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
|
|
|
+// @Override
|
|
|
|
+// public void onClick(DialogInterface dialog, int which) {
|
|
|
|
+// clickBack();
|
|
|
|
+// dialog.dismiss();
|
|
|
|
+// }
|
|
|
|
+// })
|
|
|
|
+// .setNegativeButton("No", new DialogInterface.OnClickListener() {
|
|
|
|
+// @Override
|
|
|
|
+// public void onClick(DialogInterface dialog, int which) {
|
|
|
|
+// dialog.dismiss();
|
|
|
|
+// }
|
|
|
|
+// })
|
|
|
|
+// .setMessage("退出游戏?");
|
|
|
|
+// alertDialog.show();
|
|
}
|
|
}
|
|
}
|
|
}
|