Jelajahi Sumber

add save state notify broadcast for main apk.

wangyongj 1 tahun lalu
induk
melakukan
eb8a933639

+ 2 - 2
app/build.gradle

@@ -47,8 +47,8 @@ android {
         debug {
             keyAlias 'system'
             keyPassword 'xugame888'
-//            storeFile file('../s905_system.jks')
-            storeFile file('../3588_ma_system.jks')
+            storeFile file('../s905_system.jks')
+//            storeFile file('../3588_ma_system.jks')
 //            storeFile file('../android_4.4_haisi_zou_system.jks')//android4.4
 //            storeFile file('../q5_t509_system.jks')
 //            storeFile file('../q5_t509_system.jks')

+ 47 - 41
app/src/main/java/com/xugame/gameconsole/emulator/RetroArchEmulatorActivity.java

@@ -143,6 +143,10 @@ public class RetroArchEmulatorActivity extends RetroActivityCamera
             @Override
             public void saveStateCallback(int error) {
                 Log.i("EnvironmentCallback", "saveStateCallback: " + error);
+                Intent intent = new Intent();
+                intent.setAction(EmulatorMonitor.EMULATOR_SAVE_STATE_RESULT_ACTION);
+                intent.putExtra("save_state_flag", error == 0);
+                sendBroadcast(intent);
             }
         };
         mEmulatorMonitor = new EmulatorMonitor(this, this);
@@ -436,6 +440,7 @@ public class RetroArchEmulatorActivity extends RetroActivityCamera
 
     @Override
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+        DebugUtil.i(TAG,"requestCode="+requestCode+"resultCode="+resultCode);
         if (requestCode == 200) {
             if (resultCode == 201) {//继续游戏
                 gameDialogClosed();
@@ -449,50 +454,50 @@ public class RetroArchEmulatorActivity extends RetroActivityCamera
                         int screen = data.getIntExtra("screen", 0);
                         DebugUtil.i(TAG, "scanline=" + scanLine + "screen=" + screen);
 //                        if (mScreen != screen) {
-                            mScreen = screen;
-                            if (screen >= 0 && screen < 3) {
-                                DebugUtil.i(TAG, "设置screen" + screen);
-                                switch (screen) {
+                        mScreen = screen;
+                        if (screen >= 0 && screen < 3) {
+                            DebugUtil.i(TAG, "设置screen" + screen);
+                            switch (screen) {
 
-                                    case 0:
-                                        setAspectRatio(AspectRatio.ASPECT_RATIO_CORE.getValue());
+                                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;
-
-                                }
+                                    break;
+                                case 1:
+                                    setAspectRatio(AspectRatio.ASPECT_RATIO_4_3.getValue());
+                                    break;
+                                case 2:
+                                    setAspectRatio(AspectRatio.ASPECT_RATIO_FULL.getValue());
+                                    break;
+
                             }
+                        }
 //                        }
 //                        if (mScanline != scanLine) {
-                            mScanline = scanLine;
-                            if (scanLine >= 0 && scanLine < 4) {
-                                DebugUtil.i(TAG, "设置scanLine" + scanLine + ScreenType.values()[scanLine]);
-
-                                switch (ScreenType.values()[scanLine]) {
-                                    case NORMAL:
-                                        switchFilter(null);
-                                        break;
-                                    case SAI_2X:
-                                        switchFilter("/data/user/0/com.xugame.gameconsole/filters/video/Scale2x.filt");
-                                        break;
-                                    case SCANLINE:
-                                        switchFilter("/data/user/0/com.xugame.gameconsole/filters/video/Scanline2x.filt");
-                                        break;
-                                    case EPX:
-                                        switchFilter("/data/user/0/com.xugame.gameconsole/filters/video/EPX.filt");
-                                        break;
-                                }
+                        mScanline = scanLine;
+                        if (scanLine >= 0 && scanLine < 4) {
+                            DebugUtil.i(TAG, "设置scanLine" + scanLine + ScreenType.values()[scanLine]);
+
+                            switch (ScreenType.values()[scanLine]) {
+                                case NORMAL:
+                                    switchFilter(null);
+                                    break;
+                                case SAI_2X:
+                                    switchFilter("/data/user/0/com.xugame.gameconsole/filters/video/Scale2x.filt");
+                                    break;
+                                case SCANLINE:
+                                    switchFilter("/data/user/0/com.xugame.gameconsole/filters/video/Scanline2x.filt");
+                                    break;
+                                case EPX:
+                                    switchFilter("/data/user/0/com.xugame.gameconsole/filters/video/EPX.filt");
+                                    break;
                             }
+                        }
 //                        }
                     } else {
                         int multiple = data.getIntExtra("multiple", -1);
-                        mScanline=-1;
-                        mScreen=-1;
+                        mScanline = -1;
+                        mScreen = -1;
                         DebugUtil.i(TAG, "multiple=" + multiple);
                         if (multiple >= 2 && multiple <= 5) {
                             resetScreenForPerfect(multiple);
@@ -693,12 +698,13 @@ public class RetroArchEmulatorActivity extends RetroActivityCamera
     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);
-            }
+            saveState(index);
+//            if (saveState(index)) {
+//                Intent intent = new Intent();
+//                intent.setAction(EmulatorMonitor.EMULATOR_SAVE_STATE_ACTION);
+//                intent.putExtra("save_state_flag", true);
+//                this.sendBroadcast(intent);
+//            }
         }
     }
 

+ 2 - 0
app/src/main/java/com/xugame/gameconsole/monitor/EmulatorMonitor.java

@@ -14,6 +14,8 @@ public class EmulatorMonitor {
     public static final String EMULATOR_SAVE_STATE_ACTION = "EMULATOR_SAVE_STATE_ACTION";
     public static final String EMULATOR_LOAD_STATE_ACTION = "EMULATOR_LOAD_STATE_ACTION";
 
+    public static final String EMULATOR_SAVE_STATE_RESULT_ACTION = "EMULATOR_SAVE_STATE_RESULT_ACTION";//用于存档结果回调
+
 
     private static final String SYSTEM_REASON = "reason";
     private static final String SYSTEM_HOME_KEY = "homekey";

+ 1 - 1
app/src/main/java/com/xugame/gameconsole/util/DebugUtil.java

@@ -4,7 +4,7 @@ import android.util.Log;
 
 
 public class DebugUtil {
-    static private boolean DEBUG = false;
+    static private boolean DEBUG = true;
 
     public static void d(String tag, String msg) {
         if (DEBUG)