diff --git a/shell/android/res/layout/configure_fragment.xml b/shell/android/res/layout/configure_fragment.xml index afd31cd17..406174f12 100644 --- a/shell/android/res/layout/configure_fragment.xml +++ b/shell/android/res/layout/configure_fragment.xml @@ -317,6 +317,34 @@ + + + + + + + + + + diff --git a/shell/android/res/values/strings.xml b/shell/android/res/values/strings.xml index 6019146e0..3a5fa4960 100644 --- a/shell/android/res/values/strings.xml +++ b/shell/android/res/values/strings.xml @@ -25,6 +25,7 @@ Widescreen Mode Frameskip Value PVR Rendering (does nothing for now) + Force Software Rendering Force v6 GPU Config Set Default Disk Show BIOS Debug Tools diff --git a/shell/android/src/com/reicast/emulator/ConfigureFragment.java b/shell/android/src/com/reicast/emulator/ConfigureFragment.java index 2dd1c5c75..7dfe43061 100644 --- a/shell/android/src/com/reicast/emulator/ConfigureFragment.java +++ b/shell/android/src/com/reicast/emulator/ConfigureFragment.java @@ -87,7 +87,7 @@ public class ConfigureFragment extends Fragment { getCurrentConfiguration(home_directory); // Generate the menu options and fill in existing settings - Switch force_gpu_opt = (Switch) getView().findViewById( + final Switch force_gpu_opt = (Switch) getView().findViewById( R.id.force_gpu_option); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { OnCheckedChangeListener force_gpu_options = new OnCheckedChangeListener() { @@ -108,6 +108,32 @@ public class ConfigureFragment extends Fragment { force_gpu_opt.setEnabled(false); } + Switch force_software_opt = (Switch) getView().findViewById( + R.id.software_option); + OnCheckedChangeListener force_software = new OnCheckedChangeListener() { + + public void onCheckedChanged(CompoundButton buttonView, + boolean isChecked) { + mPrefs.edit().putInt("render_type", isChecked ? 1 : 2).commit(); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { + if (isChecked) { + force_gpu_opt.setEnabled(false); + mPrefs.edit().putBoolean("force_gpu", false).commit(); + MainActivity.force_gpu = false; + } else { + force_gpu_opt.setEnabled(true); + } + } + } + }; + int software = mPrefs.getInt("render_type", GL2JNIView.LAYER_TYPE_HARDWARE); + if (software == GL2JNIView.LAYER_TYPE_SOFTWARE) { + force_software_opt.setChecked(true); + } else { + force_software_opt.setChecked(false); + } + force_software_opt.setOnCheckedChangeListener(force_software); + OnCheckedChangeListener dynarec_options = new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, diff --git a/shell/android/src/com/reicast/emulator/GL2JNIView.java b/shell/android/src/com/reicast/emulator/GL2JNIView.java index 1506ffbc7..87c9679e5 100644 --- a/shell/android/src/com/reicast/emulator/GL2JNIView.java +++ b/shell/android/src/com/reicast/emulator/GL2JNIView.java @@ -1,6 +1,9 @@ package com.reicast.emulator; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + import javax.microedition.khronos.egl.EGL10; import javax.microedition.khronos.egl.EGLConfig; import javax.microedition.khronos.egl.EGLContext; @@ -10,6 +13,7 @@ import javax.microedition.khronos.opengles.GL10; import android.content.Context; import android.content.SharedPreferences; import android.content.res.Configuration; +import android.graphics.Paint; import android.graphics.PixelFormat; import android.media.AudioFormat; import android.media.AudioManager; @@ -61,6 +65,9 @@ class GL2JNIView extends GLSurfaceView private static final int key_CONT_Y = 0x0200; private static final int key_CONT_X = 0x0400; + public static final int LAYER_TYPE_SOFTWARE = 1; + public static final int LAYER_TYPE_HARDWARE = 2; + Vibrator vib; private boolean editVjoyMode = false; @@ -215,10 +222,24 @@ class GL2JNIView extends GLSurfaceView Runtime.getRuntime().freeMemory(); System.gc(); + + Thread.currentThread().setPriority(Thread.MAX_PRIORITY); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); touchVibrationEnabled = prefs.getBoolean("touch_vibration_enabled", true); + int rederType = prefs.getInt("render_type", LAYER_TYPE_HARDWARE); + try { + Method setLayerType = this.getClass().getMethod( + "setLayerType", new Class[] { int.class, Paint.class }); + if (setLayerType != null) + setLayerType.invoke(this, new Object[] { rederType, null }); + } catch (NoSuchMethodException e) { + } catch (IllegalArgumentException e) { + } catch (IllegalAccessException e) { + } catch (InvocationTargetException e) { + } + vjoy_d_custom = readCustomVjoyValues(context); scaleGestureDetector = new ScaleGestureDetector(context, new OscOnScaleGestureListener()); diff --git a/shell/android/src/com/reicast/emulator/GL2JNIViewV6.java b/shell/android/src/com/reicast/emulator/GL2JNIViewV6.java index 7abb54d6b..43f230f9c 100644 --- a/shell/android/src/com/reicast/emulator/GL2JNIViewV6.java +++ b/shell/android/src/com/reicast/emulator/GL2JNIViewV6.java @@ -217,6 +217,8 @@ class GL2JNIViewV6 extends GLSurfaceView Runtime.getRuntime().freeMemory(); System.gc(); + + Thread.currentThread().setPriority(Thread.MAX_PRIORITY); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); touchVibrationEnabled = prefs.getBoolean("touch_vibration_enabled", true);