Add widescreen emu toggle, Get current config on app load
This commit is contained in:
parent
5ca3b4e3dc
commit
83b94874a3
|
@ -42,6 +42,7 @@ extern "C"
|
|||
JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_vmuSwap(JNIEnv *env,jobject obj) __attribute__((visibility("default")));
|
||||
|
||||
JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_frameskip(JNIEnv *env,jobject obj, jint frames) __attribute__((visibility("default")));
|
||||
JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_widescreen(JNIEnv *env,jobject obj, jint stretch) __attribute__((visibility("default")));
|
||||
};
|
||||
|
||||
|
||||
|
@ -326,6 +327,11 @@ JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_frameskip(JNIEnv *env,job
|
|||
settings.pvr.ta_skip = frames;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_widescreen(JNIEnv *env,jobject obj, jint stretch)
|
||||
{
|
||||
settings.rend.WideScreen = stretch;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_rendinit(JNIEnv * env, jobject obj, jint w,jint h)
|
||||
{
|
||||
screen_width = w;
|
||||
|
|
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 6.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 6.2 KiB |
|
@ -43,15 +43,15 @@ public class ConfigureFragment extends Fragment {
|
|||
TextView mainFrames;
|
||||
OnClickListener mCallback;
|
||||
|
||||
boolean dynarecopt = true;
|
||||
boolean unstableopt = false;
|
||||
int dcregion = 3;
|
||||
boolean limitfps = true;
|
||||
boolean mipmaps = true;
|
||||
boolean widescreen = false;
|
||||
int frameskip = 0;
|
||||
boolean pvrrender = false;
|
||||
String cheatdisk = "null";
|
||||
public static boolean dynarecopt = true;
|
||||
public static boolean unstableopt = false;
|
||||
public static int dcregion = 3;
|
||||
public static boolean limitfps = true;
|
||||
public static boolean mipmaps = true;
|
||||
public static boolean widescreen = false;
|
||||
public static int frameskip = 0;
|
||||
public static boolean pvrrender = false;
|
||||
public static String cheatdisk = "null";
|
||||
|
||||
private SharedPreferences mPrefs;
|
||||
private File sdcard = Environment.getExternalStorageDirectory();
|
||||
|
@ -84,65 +84,7 @@ public class ConfigureFragment extends Fragment {
|
|||
mPrefs = PreferenceManager.getDefaultSharedPreferences(parentActivity);
|
||||
home_directory = mPrefs.getString("home_directory", home_directory);
|
||||
|
||||
try {
|
||||
File config = new File(home_directory, "emu.cfg");
|
||||
if (config.exists()) {
|
||||
Scanner scanner = new Scanner(config);
|
||||
String currentLine;
|
||||
while (scanner.hasNextLine()) {
|
||||
currentLine = scanner.nextLine();
|
||||
|
||||
// Check if the existing emu.cfg has the setting and get
|
||||
// current value
|
||||
|
||||
if (StringUtils.containsIgnoreCase(currentLine,
|
||||
"Dynarec.Enabled")) {
|
||||
dynarecopt = currentLine.replace(
|
||||
"Dynarec.Enabled=", "").equals("1");
|
||||
}
|
||||
if (StringUtils.containsIgnoreCase(currentLine,
|
||||
"Dynarec.unstable-opt")) {
|
||||
unstableopt = currentLine.replace(
|
||||
"Dynarec.unstable-opt=", "").equals("1");
|
||||
}
|
||||
if (StringUtils.containsIgnoreCase(currentLine,
|
||||
"Dreamcast.Region")) {
|
||||
dcregion = Integer.valueOf(currentLine.replace(
|
||||
"Dreamcast.Region=", ""));
|
||||
}
|
||||
if (StringUtils.containsIgnoreCase(currentLine,
|
||||
"aica.LimitFPS")) {
|
||||
limitfps = currentLine.replace(
|
||||
"aica.LimitFPS=", "").equals("1");
|
||||
}
|
||||
if (StringUtils.containsIgnoreCase(currentLine,
|
||||
"rend.UseMipmaps")) {
|
||||
mipmaps = currentLine.replace(
|
||||
"rend.UseMipmaps=", "").equals("1");
|
||||
}
|
||||
if (StringUtils.containsIgnoreCase(currentLine,
|
||||
"rend.WideScreen")) {
|
||||
widescreen = currentLine.replace(
|
||||
"rend.WideScreen=", "").equals("1");
|
||||
}
|
||||
if (StringUtils.containsIgnoreCase(currentLine, "ta.skip")) {
|
||||
frameskip = Integer.valueOf(currentLine.replace(
|
||||
"ta.skip=", ""));
|
||||
}
|
||||
if (StringUtils.containsIgnoreCase(currentLine, "pvr.rend")) {
|
||||
pvrrender = currentLine.replace(
|
||||
"pvr.rend=", "").equals("1");
|
||||
}
|
||||
if (StringUtils.containsIgnoreCase(currentLine, "image")) {
|
||||
cheatdisk = currentLine.replace("image=", "");
|
||||
}
|
||||
|
||||
}
|
||||
scanner.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.d("reicast", "Exception: " + e);
|
||||
}
|
||||
getCurrentConfiguration(home_directory);
|
||||
|
||||
// Generate the menu options and fill in existing settings
|
||||
Switch force_gpu_opt = (Switch) getView().findViewById(
|
||||
|
@ -399,6 +341,68 @@ public class ConfigureFragment extends Fragment {
|
|||
mGenerateLogs.execute(home_directory);
|
||||
}
|
||||
}
|
||||
|
||||
public static void getCurrentConfiguration(String home_directory) {
|
||||
try {
|
||||
File config = new File(home_directory, "emu.cfg");
|
||||
if (config.exists()) {
|
||||
Scanner scanner = new Scanner(config);
|
||||
String currentLine;
|
||||
while (scanner.hasNextLine()) {
|
||||
currentLine = scanner.nextLine();
|
||||
|
||||
// Check if the existing emu.cfg has the setting and get
|
||||
// current value
|
||||
|
||||
if (StringUtils.containsIgnoreCase(currentLine,
|
||||
"Dynarec.Enabled")) {
|
||||
dynarecopt = currentLine.replace(
|
||||
"Dynarec.Enabled=", "").equals("1");
|
||||
}
|
||||
if (StringUtils.containsIgnoreCase(currentLine,
|
||||
"Dynarec.unstable-opt")) {
|
||||
unstableopt = currentLine.replace(
|
||||
"Dynarec.unstable-opt=", "").equals("1");
|
||||
}
|
||||
if (StringUtils.containsIgnoreCase(currentLine,
|
||||
"Dreamcast.Region")) {
|
||||
dcregion = Integer.valueOf(currentLine.replace(
|
||||
"Dreamcast.Region=", ""));
|
||||
}
|
||||
if (StringUtils.containsIgnoreCase(currentLine,
|
||||
"aica.LimitFPS")) {
|
||||
limitfps = currentLine.replace(
|
||||
"aica.LimitFPS=", "").equals("1");
|
||||
}
|
||||
if (StringUtils.containsIgnoreCase(currentLine,
|
||||
"rend.UseMipmaps")) {
|
||||
mipmaps = currentLine.replace(
|
||||
"rend.UseMipmaps=", "").equals("1");
|
||||
}
|
||||
if (StringUtils.containsIgnoreCase(currentLine,
|
||||
"rend.WideScreen")) {
|
||||
widescreen = currentLine.replace(
|
||||
"rend.WideScreen=", "").equals("1");
|
||||
}
|
||||
if (StringUtils.containsIgnoreCase(currentLine, "ta.skip")) {
|
||||
frameskip = Integer.valueOf(currentLine.replace(
|
||||
"ta.skip=", ""));
|
||||
}
|
||||
if (StringUtils.containsIgnoreCase(currentLine, "pvr.rend")) {
|
||||
pvrrender = currentLine.replace(
|
||||
"pvr.rend=", "").equals("1");
|
||||
}
|
||||
if (StringUtils.containsIgnoreCase(currentLine, "image")) {
|
||||
cheatdisk = currentLine.replace("image=", "");
|
||||
}
|
||||
|
||||
}
|
||||
scanner.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.d("reicast", "Exception: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
public void executeAppendConfig(String identifier, String value) {
|
||||
File config = new File(home_directory, "emu.cfg");
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.reicast.emulator;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
||||
|
@ -13,6 +14,7 @@ import android.content.res.Configuration;
|
|||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
|
@ -45,8 +47,12 @@ public class GL2JNIActivity extends Activity {
|
|||
float[] globalLS_X = new float[4], globalLS_Y = new float[4],
|
||||
previousLS_X = new float[4], previousLS_Y = new float[4];
|
||||
|
||||
int userFrames;
|
||||
private File sdcard = Environment.getExternalStorageDirectory();
|
||||
private String home_directory = sdcard + "/dc";
|
||||
private boolean frameskipping = false;
|
||||
private boolean widescreen;
|
||||
private View frameskip;
|
||||
private View fullscreen;
|
||||
|
||||
public static HashMap<Integer, String> deviceId_deviceDescriptor = new HashMap<Integer, String>();
|
||||
public static HashMap<String, Integer> deviceDescriptor_PlayerNum = new HashMap<String, Integer>();
|
||||
|
@ -137,11 +143,28 @@ public class GL2JNIActivity extends Activity {
|
|||
popUp.dismiss();
|
||||
}
|
||||
}), params);
|
||||
View frameskip;
|
||||
if (!widescreen) {
|
||||
fullscreen = addbut(R.drawable.widescreen, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
JNIdc.widescreen(1);
|
||||
popUp.dismiss();
|
||||
widescreen = true;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
fullscreen = addbut(R.drawable.normal_view, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
JNIdc.widescreen(0);
|
||||
popUp.dismiss();
|
||||
widescreen = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
hlay.addView(fullscreen, params);
|
||||
if (!frameskipping) {
|
||||
frameskip = addbut(R.drawable.fast_forward, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
JNIdc.frameskip((userFrames + 1) * 5);
|
||||
JNIdc.frameskip((ConfigureFragment.frameskip + 1) * 5);
|
||||
popUp.dismiss();
|
||||
frameskipping = true;
|
||||
}
|
||||
|
@ -149,7 +172,7 @@ public class GL2JNIActivity extends Activity {
|
|||
} else {
|
||||
frameskip = addbut(R.drawable.normal_play, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
JNIdc.frameskip(userFrames);
|
||||
JNIdc.frameskip(ConfigureFragment.frameskip);
|
||||
popUp.dismiss();
|
||||
frameskipping = false;
|
||||
}
|
||||
|
@ -167,7 +190,6 @@ public class GL2JNIActivity extends Activity {
|
|||
moga.onCreate(this);
|
||||
|
||||
prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
userFrames = prefs.getInt("frame_skip", 0);
|
||||
createPopup();
|
||||
/*
|
||||
* try { //int rID =
|
||||
|
@ -178,6 +200,9 @@ public class GL2JNIActivity extends Activity {
|
|||
* syms = new byte[(int) is.available()]; is.read(syms); is.close(); }
|
||||
* catch (IOException e) { e.getMessage(); e.printStackTrace(); }
|
||||
*/
|
||||
home_directory = prefs.getString("home_directory", home_directory);
|
||||
ConfigureFragment.getCurrentConfiguration(home_directory);
|
||||
widescreen = ConfigureFragment.widescreen;
|
||||
|
||||
String fileName = null;
|
||||
|
||||
|
@ -672,6 +697,42 @@ public class GL2JNIActivity extends Activity {
|
|||
|
||||
private boolean showMenu() {
|
||||
if (!popUp.isShowing()) {
|
||||
if (!frameskipping) {
|
||||
frameskip = addbut(R.drawable.fast_forward, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
JNIdc.frameskip((ConfigureFragment.frameskip + 1) * 5);
|
||||
popUp.dismiss();
|
||||
frameskipping = true;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
frameskip = addbut(R.drawable.normal_play, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
JNIdc.frameskip(ConfigureFragment.frameskip);
|
||||
popUp.dismiss();
|
||||
frameskipping = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
frameskip.invalidate();
|
||||
if (!widescreen) {
|
||||
fullscreen = addbut(R.drawable.widescreen, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
JNIdc.widescreen(1);
|
||||
popUp.dismiss();
|
||||
widescreen = true;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
fullscreen = addbut(R.drawable.normal_view, new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
JNIdc.widescreen(0);
|
||||
popUp.dismiss();
|
||||
widescreen = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
fullscreen.invalidate();
|
||||
if (MainActivity.force_gpu) {
|
||||
popUp.showAtLocation(mView6, Gravity.BOTTOM, 0, 0);
|
||||
} else {
|
||||
|
|
|
@ -27,6 +27,7 @@ public class JNIdc
|
|||
public static native void vmuSwap();
|
||||
|
||||
public static native void frameskip(int frames);
|
||||
public static native void widescreen(int stretch);
|
||||
|
||||
public static void show_osd() {
|
||||
JNIdc.vjoy(13, 1,0,0,0);
|
||||
|
|
Loading…
Reference in New Issue