Merge pull request #1334 from reicast/lk/abandoned

Extend per-game configuration options
This commit is contained in:
Abandoned Cart 2018-08-26 14:31:29 -04:00 committed by GitHub
commit 38f9c58804
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 598 additions and 299 deletions

View File

@ -129,7 +129,13 @@ void* webui_th(void* p)
cThread webui_thd(&webui_th,0);
#endif
#if defined(_ANDROID)
int reios_init_value;
void reios_init(int argc,wchar* argv[])
#else
int dc_init(int argc,wchar* argv[])
#endif
{
setbuf(stdin,0);
setbuf(stdout,0);
@ -137,7 +143,12 @@ int dc_init(int argc,wchar* argv[])
if (!_vmem_reserve())
{
printf("Failed to alloc mem\n");
#if defined(_ANDROID)
reios_init_value = -1;
return;
#else
return -1;
#endif
}
#if !defined(TARGET_NO_WEBUI)
@ -146,19 +157,29 @@ int dc_init(int argc,wchar* argv[])
if(ParseCommandLine(argc,argv))
{
return 69;
#if defined(_ANDROID)
reios_init_value = 69;
return;
#else
return 69;
#endif
}
if(!cfgOpen())
{
msgboxf("Unable to open config file",MBX_ICONERROR);
#if defined(_ANDROID)
reios_init_value = -4;
return;
#else
return -4;
#endif
}
LoadSettings();
#ifndef _ANDROID
os_CreateWindow();
#endif
int rv= 0;
int rv = 0;
#if HOST_OS != OS_DARWIN
#define DATA_PATH "/data/"
@ -169,11 +190,34 @@ int dc_init(int argc,wchar* argv[])
if (settings.bios.UseReios || !LoadRomFiles(get_readonly_data_path(DATA_PATH)))
{
if (!LoadHle(get_readonly_data_path(DATA_PATH)))
{
#if defined(_ANDROID)
reios_init_value = -4;
return;
#else
return -3;
#endif
}
else
{
printf("Did not load bios, using reios\n");
}
}
plugins_Init();
#if defined(_ANDROID)
}
int dc_init()
{
int rv = 0;
if (reios_init_value != 0)
return reios_init_value;
#else
LoadCustom();
#endif
#if FEAT_SHREC != DYNAREC_NONE
if(settings.dynarec.Enable)
{
@ -192,8 +236,6 @@ int dc_init(int argc,wchar* argv[])
sh4_cpu.Init();
mem_Init();
plugins_Init();
mem_map_default();
#if DC_PLATFORM == DC_PLATFORM_DREAMCAST
@ -206,10 +248,6 @@ int dc_init(int argc,wchar* argv[])
mem_Reset(false);
sh4_cpu.Reset(false);
#ifndef _ANDROID
LoadCustom();
#endif
return rv;
}
@ -248,28 +286,28 @@ void dc_stop()
void LoadSettings()
{
#ifndef _ANDROID
settings.dynarec.Enable = cfgLoadInt("config","Dynarec.Enabled", 1)!=0;
settings.dynarec.idleskip = cfgLoadInt("config","Dynarec.idleskip",1)!=0;
settings.dynarec.unstable_opt = cfgLoadInt("config","Dynarec.unstable-opt",0);
settings.dynarec.safemode = cfgLoadInt("config","Dynarec.safemode",0);
settings.dynarec.Enable = cfgLoadInt("config", "Dynarec.Enabled", 1) != 0;
settings.dynarec.idleskip = cfgLoadInt("config", "Dynarec.idleskip", 1) != 0;
settings.dynarec.unstable_opt = cfgLoadInt("config", "Dynarec.unstable-opt", 0);
settings.dynarec.safemode = cfgLoadInt("config", "Dynarec.safemode", 0);
//disable_nvmem can't be loaded, because nvmem init is before cfg load
settings.dreamcast.cable = cfgLoadInt("config","Dreamcast.Cable",3);
settings.dreamcast.RTC = cfgLoadInt("config","Dreamcast.RTC",GetRTC_now());
settings.dreamcast.region = cfgLoadInt("config","Dreamcast.Region",3);
settings.dreamcast.broadcast = cfgLoadInt("config","Dreamcast.Broadcast",4);
settings.aica.LimitFPS = cfgLoadInt("config","aica.LimitFPS",1);
settings.aica.NoBatch = cfgLoadInt("config","aica.NoBatch",0);
settings.aica.NoSound = cfgLoadInt("config","aica.NoSound",0);
settings.aica.InterruptHack = cfgLoadInt("config","aica.InterruptHack",0);
settings.rend.UseMipmaps = cfgLoadInt("config","rend.UseMipmaps",1);
settings.rend.WideScreen = cfgLoadInt("config","rend.WideScreen",0);
settings.rend.ModifierVolumes = cfgLoadInt("config","rend.ModifierVolumes",1);
settings.rend.Clipping = cfgLoadInt("config","rend.Clipping",1);
settings.dreamcast.cable = cfgLoadInt("config", "Dreamcast.Cable", 3);
settings.dreamcast.RTC = cfgLoadInt("config", "Dreamcast.RTC", GetRTC_now());
settings.dreamcast.region = cfgLoadInt("config", "Dreamcast.Region", 3);
settings.dreamcast.broadcast = cfgLoadInt("config", "Dreamcast.Broadcast", 4);
settings.aica.LimitFPS = cfgLoadInt("config", "aica.LimitFPS", 1);
settings.aica.NoBatch = cfgLoadInt("config", "aica.NoBatch", 0);
settings.aica.NoSound = cfgLoadInt("config", "aica.NoSound", 0);
settings.aica.InterruptHack = cfgLoadInt("config", "aica.InterruptHack", 0);
settings.rend.UseMipmaps = cfgLoadInt("config", "rend.UseMipmaps", 1);
settings.rend.WideScreen = cfgLoadInt("config", "rend.WideScreen", 0);
settings.rend.ModifierVolumes = cfgLoadInt("config", "rend.ModifierVolumes", 1);
settings.rend.Clipping = cfgLoadInt("config", "rend.Clipping", 1);
settings.pvr.subdivide_transp = cfgLoadInt("config","pvr.Subdivide",0);
settings.pvr.subdivide_transp = cfgLoadInt("config", "pvr.Subdivide", 0);
settings.pvr.ta_skip = cfgLoadInt("config","ta.skip",0);
settings.pvr.rend = cfgLoadInt("config","pvr.rend",0);
settings.pvr.ta_skip = cfgLoadInt("config", "ta.skip", 0);
settings.pvr.rend = cfgLoadInt("config", "pvr.rend", 0);
settings.pvr.MaxThreads = cfgLoadInt("config", "pvr.MaxThreads", 3);
settings.pvr.SynchronousRender = cfgLoadInt("config", "pvr.SynchronousRendering", 0);
@ -316,6 +354,7 @@ void LoadCustom()
char *reios_id = reios_disk_id();
cfgSaveStr(reios_id, "software.name", reios_software_name);
settings.dynarec.Enable = cfgLoadInt(reios_id,"Dynarec.Enabled", settings.dynarec.Enable ? 1 : 0) != 0;
settings.dynarec.idleskip = cfgGameInt(reios_id,"Dynarec.idleskip", settings.dynarec.idleskip ? 1 : 0) != 0;
settings.dynarec.unstable_opt = cfgGameInt(reios_id,"Dynarec.unstable-opt", settings.dynarec.unstable_opt);
settings.dynarec.safemode = cfgGameInt(reios_id,"Dynarec.safemode", settings.dynarec.safemode);

View File

@ -9,7 +9,6 @@ import android.net.Uri;
import android.os.Environment;
import android.preference.PreferenceManager;
import com.reicast.emulator.MainActivity;
import com.reicast.emulator.config.Config;
import java.io.File;

View File

@ -110,6 +110,7 @@ public class Emulator extends Application {
public void loadGameConfiguration(String gameId) {
SharedPreferences mPrefs = getSharedPreferences(gameId, Activity.MODE_PRIVATE);
JNIdc.dynarec(mPrefs.getBoolean(pref_dynarecopt, dynarecopt) ? 1 : 0);
JNIdc.unstable(mPrefs.getBoolean(pref_unstable, unstableopt) ? 1 : 0);
JNIdc.safemode(mPrefs.getBoolean(pref_dynsafemode, dynsafemode) ? 1 : 0);
JNIdc.interrupthack(mPrefs.getBoolean(pref_interrupt, interrupt) ? 1 : 0);

View File

@ -238,6 +238,10 @@ public class GL2JNIActivity extends Activity {
}
}
public Gamepad getPad() {
return pad;
}
public void displayFPS() {
fpsPop.showAtLocation(mView, Gravity.TOP | Gravity.LEFT, 20, 20);
fpsPop.update(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

View File

@ -238,6 +238,10 @@ public class GL2JNINative extends NativeActivity {
}
}
public Gamepad getPad() {
return pad;
}
public void displayFPS() {
fpsPop.showAtLocation(mView, Gravity.TOP | Gravity.LEFT, 20, 20);
fpsPop.update(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

View File

@ -33,9 +33,9 @@ import android.view.WindowManager;
import android.widget.TextView;
import com.reicast.emulator.config.Config;
import com.reicast.emulator.config.PGConfigFragment;
import com.reicast.emulator.config.InputFragment;
import com.reicast.emulator.config.OptionsFragment;
import com.reicast.emulator.config.PGConfigFragment;
import com.reicast.emulator.debug.GenerateLogs;
import com.reicast.emulator.emu.JNIdc;
import com.reicast.emulator.periph.Gamepad;

View File

@ -6,7 +6,6 @@ import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.PorterDuff;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.ConnectivityManager;
@ -23,6 +22,7 @@ import android.widget.TextView;
import com.reicast.emulator.FileBrowser.OnItemSelectedListener;
import com.reicast.emulator.config.Config;
import org.apache.commons.io.FilenameUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@ -40,6 +40,7 @@ import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import java.lang.ref.WeakReference;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
@ -55,26 +56,24 @@ public class XMLParser extends AsyncTask<String, Integer, String> {
private SharedPreferences mPrefs;
private File game;
private int index;
private View childview;
private OnItemSelectedListener mCallback;
private Context mContext;
private String game_name;
private Drawable game_icon;
private String gameId;
private String game_details;
private String game_index = "http://legacy.thegamesdb.net/api/GetGamesList.php?platform=sega+dreamcast&name=";
private String game_id = "http://legacy.thegamesdb.net/api/GetGame.php?platform=sega+dreamcast&id=";
private WeakReference<Context> mContext;
private WeakReference<View> childview;
public XMLParser(File game, int index, SharedPreferences mPrefs) {
XMLParser(File game, int index, SharedPreferences mPrefs) {
this.mPrefs = mPrefs;
this.game = game;
this.index = index;
}
public void setViewParent(Context mContext, View childview, OnItemSelectedListener mCallback) {
this.mContext = mContext;
this.childview = childview;
public void setViewParent(Context reference, View childview, OnItemSelectedListener mCallback) {
this.mContext = new WeakReference<>(reference);
this.childview = new WeakReference<>(childview);
this.mCallback = mCallback;
initializeDefaults();
}
@ -89,7 +88,7 @@ public class XMLParser extends AsyncTask<String, Integer, String> {
if (isNetworkAvailable() && mPrefs.getBoolean(Config.pref_gamedetails, false)) {
String xmlUrl = "";
if (gameId != null) {
xmlUrl = game_id + gameId;
xmlUrl = "http://legacy.thegamesdb.net/api/GetGame.php?platform=sega+dreamcast&id=" + gameId;
} else {
filename = filename.substring(0, filename.lastIndexOf("."));
try {
@ -97,7 +96,7 @@ public class XMLParser extends AsyncTask<String, Integer, String> {
} catch (UnsupportedEncodingException e) {
filename = filename.replace(" ", "+");
}
xmlUrl = game_index + filename;
xmlUrl = "http://legacy.thegamesdb.net/api/GetGamesList.php?platform=sega+dreamcast&name=" + filename;
}
try {
@ -117,9 +116,9 @@ public class XMLParser extends AsyncTask<String, Integer, String> {
in.close();
return responseStrBuilder.toString();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
return null;
@ -134,11 +133,13 @@ public class XMLParser extends AsyncTask<String, Integer, String> {
Element root = (Element) doc.getElementsByTagName("Game").item(0);
if (gameId == null) {
XMLParser xmlParser = new XMLParser(game, index, mPrefs);
xmlParser.setViewParent(mContext, childview, mCallback);
xmlParser.setViewParent(mContext.get(), childview.get(), mCallback);
xmlParser.setGameID(getValue(root, "id"));
xmlParser.execute(game_name);
} else {
game_name = getValue(root, "GameTitle");
game_name = getValue(root, "GameTitle") + " ["
+ FilenameUtils.getExtension(game.getName())
.toUpperCase(Locale.getDefault()) + "]";
game_details = getValue(root, "Overview");
Element images = (Element) root.getElementsByTagName("Images").item(0);
Element boxart = null;
@ -155,35 +156,40 @@ public class XMLParser extends AsyncTask<String, Integer, String> {
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
((TextView) childview.findViewById(R.id.item_name)).setText(game_name);
if (childview.get() != null)
((TextView) childview.get().findViewById(R.id.item_name)).setText(game_name);
if (mPrefs.getBoolean(Config.pref_gamedetails, false)) {
childview.findViewById(R.id.childview).setOnLongClickListener(
childview.get().findViewById(R.id.childview).setOnLongClickListener(
new OnLongClickListener() {
public boolean onLongClick(View view) {
final AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
final AlertDialog.Builder builder = new AlertDialog.Builder(mContext.get());
builder.setCancelable(true);
builder.setTitle(mContext.getString(R.string.game_details, game_name));
builder.setTitle(mContext.get().getString(R.string.game_details, game_name));
builder.setMessage(game_details);
builder.setIcon(game_icon);
builder.setNegativeButton("Close",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
return;
}
});
builder.setPositiveButton("Launch",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
mCallback.onGameSelected(game != null ? Uri.fromFile(game) : Uri.EMPTY);
((Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE)).vibrate(250);
return;
mCallback.onGameSelected(game != null
? Uri.fromFile(game) : Uri.EMPTY);
try {
((Vibrator) mContext.get().getSystemService(
Context.VIBRATOR_SERVICE)).vibrate(250);
} catch (Exception e) {
// Vibration unavailable
}
}
});
builder.create().show();
@ -192,32 +198,32 @@ public class XMLParser extends AsyncTask<String, Integer, String> {
});
}
childview.setTag(game_name);
childview.get().setTag(game_name);
}
private void initializeDefaults() {
game_details = mContext.getString(R.string.info_unavailable);
game_details = mContext.get().getString(R.string.info_unavailable);
final String nameLower = game.getName().toLowerCase(Locale.getDefault());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
game_icon = mContext.getResources().getDrawable(
game_icon = mContext.get().getResources().getDrawable(
game.isDirectory() ? R.drawable.open_folder
: nameLower.endsWith(".gdi") ? R.mipmap.disk_gdi
: nameLower.endsWith(".chd") ? R.mipmap.disk_chd
: nameLower.endsWith(".cdi") ? R.mipmap.disk_cdi
: R.mipmap.disk_unknown);
} else {
game_icon = mContext.getResources().getDrawable(
game_icon = mContext.get().getResources().getDrawable(
game.isDirectory() ? R.drawable.open_folder
: nameLower.endsWith(".gdi") ? R.drawable.gdi
: nameLower.endsWith(".chd") ? R.drawable.chd
: nameLower.endsWith(".cdi") ? R.drawable.cdi
: R.drawable.disk_unknown);
}
((ImageView) childview.findViewById(R.id.item_icon)).setImageDrawable(game_icon);
((ImageView) childview.get().findViewById(R.id.item_icon)).setImageDrawable(game_icon);
}
public boolean isNetworkAvailable() {
ConnectivityManager connectivityManager = (ConnectivityManager) mContext
private boolean isNetworkAvailable() {
ConnectivityManager connectivityManager = (ConnectivityManager) mContext.get()
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo mWifi = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
NetworkInfo mMobile = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
@ -241,7 +247,7 @@ public class XMLParser extends AsyncTask<String, Integer, String> {
return game_details;
}
public Document getDomElement(String xml) {
private Document getDomElement(String xml) {
Document doc = null;
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {
@ -266,12 +272,12 @@ public class XMLParser extends AsyncTask<String, Integer, String> {
return doc;
}
public String getValue(Element item, String str) {
private String getValue(Element item, String str) {
NodeList n = item.getElementsByTagName(str);
return this.getElementValue(n.item(0));
}
public final String getElementValue(Node elem) {
private String getElementValue(Node elem) {
Node child;
if (elem != null) {
if (elem.hasChildNodes()) {
@ -290,8 +296,10 @@ public class XMLParser extends AsyncTask<String, Integer, String> {
@Override
protected Bitmap doInBackground(String... params) {
try {
String index = params[0].substring(params[0].lastIndexOf("/") + 1, params[0].lastIndexOf("."));
File file = new File(mContext.getExternalFilesDir(null) + "/images", index + ".png");
String index = params[0].substring(params[0].lastIndexOf(
"/") + 1, params[0].lastIndexOf("."));
File file = new File(mContext.get().getExternalFilesDir(
null) + "/images", index + ".png");
if (file.exists()) {
return BitmapFactory.decodeFile(file.getAbsolutePath());
} else {
@ -346,14 +354,14 @@ public class XMLParser extends AsyncTask<String, Integer, String> {
protected void onPostExecute(Bitmap gameImage) {
if (gameImage != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
((ImageView) childview.findViewById(R.id.item_icon)).setImageTintList(null);
((ImageView) childview.get().findViewById(R.id.item_icon)).setImageTintList(null);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
game_icon = new BitmapDrawable(mContext.getResources(), gameImage);
game_icon = new BitmapDrawable(mContext.get().getResources(), gameImage);
} else {
game_icon = new BitmapDrawable(gameImage);
}
((ImageView) childview.findViewById(R.id.item_icon)).setImageDrawable(game_icon);
((ImageView) childview.get().findViewById(R.id.item_icon)).setImageDrawable(game_icon);
}
}
}

View File

@ -32,9 +32,15 @@ import android.widget.TextView;
import com.android.util.FileUtils;
import com.reicast.emulator.Emulator;
import com.reicast.emulator.R;
import com.reicast.emulator.periph.Gamepad;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.ref.WeakReference;
import java.util.Collection;
import java.util.HashMap;
@ -45,6 +51,8 @@ public class PGConfigFragment extends Fragment {
private Spinner mSpnrConfigs;
private CompoundButton switchJoystickDpadEnabled;
private CompoundButton dynarec_opt;
private CompoundButton unstable_opt;
private CompoundButton safemode_opt;
private EditText mainFrames;
@ -82,6 +90,9 @@ public class PGConfigFragment extends Fragment {
new LocateConfigs(PGConfigFragment.this).execute("/data/data/"
+ getActivity().getPackageName() + "/shared_prefs/");
switchJoystickDpadEnabled = (CompoundButton) getView().findViewById(
R.id.switchJoystickDpadEnabled);
dynarec_opt = (CompoundButton) getView().findViewById(R.id.dynarec_option);
unstable_opt = (CompoundButton) getView().findViewById(R.id.unstable_option);
safemode_opt = (CompoundButton) getView().findViewById(R.id.dynarec_safemode);
mainFrames = (EditText) getView().findViewById(R.id.current_frames);
@ -94,7 +105,10 @@ public class PGConfigFragment extends Fragment {
}
private void saveSettings(SharedPreferences mPrefs) {
mPrefs.edit().putBoolean(Emulator.pref_unstable, unstable_opt.isChecked())
mPrefs.edit()
.putBoolean(Gamepad.pref_js_merged + "_A", switchJoystickDpadEnabled.isChecked())
.putBoolean(Emulator.pref_dynarecopt, dynarec_opt.isChecked())
.putBoolean(Emulator.pref_unstable, unstable_opt.isChecked())
.putBoolean(Emulator.pref_dynsafemode, safemode_opt.isChecked())
.putInt(Emulator.pref_frameskip, frameSeek.getProgress())
.putBoolean(Emulator.pref_pvrrender, pvr_render.isChecked())
@ -102,13 +116,31 @@ public class PGConfigFragment extends Fragment {
.putBoolean(Emulator.pref_queuerender, queue_render.isChecked())
.putBoolean(Emulator.pref_modvols, modifier_volumes.isChecked())
.putBoolean(Emulator.pref_interrupt, interrupt_opt.isChecked()).apply();
showToastMessage(getActivity().getString(R.string.pgconfig_saved),
Snackbar.LENGTH_SHORT);
showToastMessage(getActivity().getString(R.string.pgconfig_saved), Snackbar.LENGTH_SHORT);
}
private void configureViewByGame(String gameId) {
private void clearSettings(SharedPreferences mPrefs, String gameId) {
mPrefs.edit() // Prevent clear() removing title
.remove(Gamepad.pref_js_merged + "_A")
.remove(Emulator.pref_dynarecopt)
.remove(Emulator.pref_unstable)
.remove(Emulator.pref_dynsafemode)
.remove(Emulator.pref_frameskip)
.remove(Emulator.pref_pvrrender)
.remove(Emulator.pref_syncedrender)
.remove(Emulator.pref_queuerender)
.remove(Emulator.pref_modvols)
.remove(Emulator.pref_interrupt).apply();
showToastMessage(getActivity().getString(R.string.pgconfig_cleared), Snackbar.LENGTH_SHORT);
configureViewByGame(gameId);
}
private void configureViewByGame(final String gameId) {
final SharedPreferences mPrefs = getActivity()
.getSharedPreferences(gameId, Activity.MODE_PRIVATE);
switchJoystickDpadEnabled.setChecked(mPrefs.getBoolean(
Gamepad.pref_js_merged + "_A", false));
dynarec_opt.setChecked(mPrefs.getBoolean(Emulator.pref_dynarecopt, Emulator.dynarecopt));
unstable_opt.setChecked(mPrefs.getBoolean(Emulator.pref_unstable, Emulator.unstableopt));
safemode_opt.setChecked(mPrefs.getBoolean(Emulator.pref_dynsafemode, Emulator.dynsafemode));
@ -158,6 +190,73 @@ public class PGConfigFragment extends Fragment {
saveSettings(mPrefs);
}
});
Button importPGC = (Button) getView().findViewById(R.id.import_pg_btn);
importPGC.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
try {
copy(new File(getActivity().getExternalFilesDir(null), gameId
+ ".xml"), new File("/data/data/" + getActivity()
.getPackageName(),"/shared_prefs/" + gameId + ".xml"));
showToastMessage(getActivity().getString(
R.string.pgconfig_imported), Snackbar.LENGTH_SHORT);
configureViewByGame(gameId);
} catch (Exception e) {
e.printStackTrace();
}
}
});
Button exportPGC = (Button) getView().findViewById(R.id.export_pg_btn);
exportPGC.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
try {
copy(new File("/data/data/" + getActivity().getPackageName(),
"/shared_prefs/" + gameId + ".xml"), new File(getActivity()
.getExternalFilesDir(null), gameId + ".xml"));
showToastMessage(getActivity().getString(
R.string.pgconfig_exported), Snackbar.LENGTH_SHORT);
} catch (Exception e) {
e.printStackTrace();
}
}
});
Button clearPGC = (Button) getView().findViewById(R.id.clear_pg_btn);
clearPGC.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
clearSettings(mPrefs, gameId);
}
});
}
private void copy(File src, File dst) throws IOException {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
try (InputStream in = new FileInputStream(src)) {
try (OutputStream out = new FileOutputStream(dst)) {
// Transfer bytes from in to out
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
}
}
} else {
InputStream in = new FileInputStream(src);
OutputStream out = new FileOutputStream(dst);
try {
// Transfer bytes from in to out
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
} finally {
in.close();
out.close();
}
}
}
private static class LocateConfigs extends AsyncTask<String, Integer, List<File>> {

View File

@ -3,8 +3,8 @@ package com.reicast.emulator.debug;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.support.constraint.ConstraintLayout;
@ -13,7 +13,6 @@ import android.support.graphics.drawable.VectorDrawableCompat;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import com.reicast.emulator.R;
import com.reicast.emulator.config.Config;

View File

@ -30,6 +30,7 @@ import com.reicast.emulator.GL2JNIActivity;
import com.reicast.emulator.GL2JNINative;
import com.reicast.emulator.config.Config;
import com.reicast.emulator.emu.OnScreenMenu.FpsPopup;
import com.reicast.emulator.periph.Gamepad;
import com.reicast.emulator.periph.VJoy;
import java.io.UnsupportedEncodingException;
@ -156,7 +157,6 @@ public class GL2JNIView extends GLSurfaceView
if (GL2JNIActivity.syms != null)
JNIdc.data(1, GL2JNIActivity.syms);
}
JNIdc.init(fileName);
JNIdc.query(ethd);
@ -675,9 +675,14 @@ public class GL2JNIView extends GLSurfaceView
SharedPreferences mPrefs = context.getSharedPreferences(gameId, Activity.MODE_PRIVATE);
Emulator app = (Emulator) context.getApplicationContext();
app.loadGameConfiguration(gameId);
if (context instanceof GL2JNIActivity)
((GL2JNIActivity) context).getPad().joystick[0] = mPrefs.getBoolean(
Gamepad.pref_js_merged + "_A", ((GL2JNIActivity) context).getPad().joystick[0]);
if (context instanceof GL2JNINative)
((GL2JNINative) context).getPad().joystick[0] = mPrefs.getBoolean(
Gamepad.pref_js_merged + "_A", ((GL2JNINative) context).getPad().joystick[0]);
mPrefs.edit().putString(Config.game_title, reiosSoftware.trim()).apply();
}
}
public void onDestroy() {

View File

@ -6,7 +6,6 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Environment;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
@ -25,7 +24,6 @@ import com.reicast.emulator.R;
import com.reicast.emulator.config.Config;
import com.reicast.emulator.periph.VmuLcd;
import java.io.File;
import java.util.Vector;
public class OnScreenMenu {

View File

@ -5,7 +5,6 @@ import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.os.Build;
import android.util.SparseArray;
import android.util.SparseIntArray;
import android.view.KeyEvent;

View File

@ -10,7 +10,6 @@
#include <GLES2/gl2.h>
#include <types.h>
#include "types.h"
#include "hw/maple/maple_cfg.h"
#include "profiler/profiler.h"
#include "rend/TexCache.h"
@ -182,7 +181,8 @@ JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_dreamtime(JNIEnv *env
void egl_stealcntx();
void SetApplicationPath(wchar *path);
int dc_init(int argc,wchar* argv[]);
void reios_init(int argc,wchar* argv[]);
int dc_init();
void dc_run();
void dc_pause();
void dc_term();
@ -239,7 +239,7 @@ static void *ThreadHandler(void *UserData)
}
// Run nullDC emulator
dc_init(Args[2]? 3:1,Args);
reios_init(Args[2]? 3:1,Args);
return 0;
}
@ -380,6 +380,8 @@ JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_query(JNIEnv *env,job
jstring reios_name = env->NewStringUTF(name);
env->CallVoidMethod(emu_thread, reiosInfoMid, reios_id, reios_name);
dc_init();
}
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_run(JNIEnv *env,jobject obj,jobject emu_thread)

View File

@ -273,34 +273,6 @@
</LinearLayout>
</TableRow>
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >
<TextView
android:id="@+id/safemode_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:ems="10"
android:gravity="center_vertical|left"
android:text="@string/select_safemode" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:orientation="vertical" >
<Switch
android:id="@+id/dynarec_safemode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true" />
</LinearLayout>
</TableRow>
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >
@ -575,6 +547,34 @@
android:focusable="true" />
</LinearLayout>
</TableRow>
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >
<TextView
android:id="@+id/safemode_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:ems="10"
android:gravity="center_vertical|left"
android:text="@string/select_safemode" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:orientation="vertical" >
<Switch
android:id="@+id/dynarec_safemode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true" />
</LinearLayout>
</TableRow>
<TableRow
android:layout_marginTop="10dp"

View File

@ -18,43 +18,71 @@
android:gravity="center"
android:text="@string/pgc_doc" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:layout_marginTop="20dp"
android:orientation="vertical" >
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:layout_weight="1"
android:text="@string/pgc_select_game" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Spinner
android:id="@+id/config_spinner"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10" >
<requestFocus />
</Spinner>
</LinearLayout>
</LinearLayout>
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:stretchColumns="*" >
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:ems="10"
android:gravity="center_vertical|left"
android:text="@string/pgc_select_game" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:orientation="vertical" >
<Spinner
android:id="@+id/config_spinner"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:ems="10" >
<requestFocus />
</Spinner>
</LinearLayout>
</TableRow>
<TableRow
android:layout_marginTop="25dp"
android:gravity="center_vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:ems="10"
android:gravity="center_vertical|left"
android:text="@string/joystick_layout" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:orientation="vertical" >
<Switch
android:id="@+id/switchJoystickDpadEnabled"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true" />
</LinearLayout>
</TableRow>
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >
@ -83,34 +111,6 @@
</LinearLayout>
</TableRow>
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >
<TextView
android:id="@+id/safemode_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:ems="10"
android:gravity="center_vertical|left"
android:text="@string/select_safemode" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:orientation="vertical" >
<Switch
android:id="@+id/dynarec_safemode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true" />
</LinearLayout>
</TableRow>
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >
@ -170,6 +170,62 @@
android:layout_height="2dp"
android:background="@drawable/list_item_border" />
<TableRow
android:layout_marginTop="20dp"
android:gravity="center_vertical" >
<TextView
android:id="@+id/dynarec_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:ems="10"
android:gravity="center_vertical|left"
android:text="@string/select_dynarec" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:orientation="vertical" >
<Switch
android:id="@+id/dynarec_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true" />
</LinearLayout>
</TableRow>
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >
<TextView
android:id="@+id/safemode_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:ems="10"
android:gravity="center_vertical|left"
android:text="@string/select_safemode" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:orientation="vertical" >
<Switch
android:id="@+id/dynarec_safemode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true" />
</LinearLayout>
</TableRow>
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >
@ -312,30 +368,42 @@
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >
android:gravity="center_vertical"
android:layout_marginRight="6dp" >
<TextView
android:id="@+id/apply_pg_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:ems="10"
android:gravity="center_vertical|left"
android:text="@string/save_pgc_title" />
<LinearLayout
android:layout_width="wrap_content"
<Button
android:id="@+id/clear_pg_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:orientation="vertical" >
android:text="@string/clear_pgc" />
<Button
android:id="@+id/save_pg_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/write_pgc" />
</LinearLayout>
<Button
android:id="@+id/save_pg_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/save_pgc" />
</TableRow>
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:layout_marginRight="6dp" >
<Button
android:id="@+id/import_pg_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/import_pgc" />
<Button
android:id="@+id/export_pg_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/export_pgc" />
</TableRow>
</TableLayout>
</LinearLayout>

View File

@ -273,34 +273,6 @@
</LinearLayout>
</TableRow>
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >
<TextView
android:id="@+id/safemode_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:ems="10"
android:gravity="center_vertical|left"
android:text="@string/select_safemode" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:orientation="vertical" >
<Checkbox
android:id="@+id/dynarec_safemode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true" />
</LinearLayout>
</TableRow>
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >
@ -575,6 +547,34 @@
android:focusable="true" />
</LinearLayout>
</TableRow>
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >
<TextView
android:id="@+id/safemode_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:ems="10"
android:gravity="center_vertical|left"
android:text="@string/select_safemode" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:orientation="vertical" >
<Checkbox
android:id="@+id/dynarec_safemode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true" />
</LinearLayout>
</TableRow>
<TableRow
android:layout_marginTop="10dp"

View File

@ -18,43 +18,71 @@
android:gravity="center"
android:text="@string/pgc_doc" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:layout_marginTop="20dp"
android:orientation="vertical" >
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:layout_weight="1"
android:text="@string/pgc_select_game" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Spinner
android:id="@+id/config_spinner"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10" >
<requestFocus />
</Spinner>
</LinearLayout>
</LinearLayout>
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:stretchColumns="*" >
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:ems="10"
android:gravity="center_vertical|left"
android:text="@string/pgc_select_game" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:orientation="vertical" >
<Spinner
android:id="@+id/config_spinner"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:ems="10" >
<requestFocus />
</Spinner>
</LinearLayout>
</TableRow>
<TableRow
android:layout_marginTop="25dp"
android:gravity="center_vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:ems="10"
android:gravity="center_vertical|left"
android:text="@string/joystick_layout" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:orientation="vertical" >
<Checkbox
android:id="@+id/switchJoystickDpadEnabled"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true" />
</LinearLayout>
</TableRow>
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >
@ -83,34 +111,6 @@
</LinearLayout>
</TableRow>
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >
<TextView
android:id="@+id/safemode_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:ems="10"
android:gravity="center_vertical|left"
android:text="@string/select_safemode" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:orientation="vertical" >
<Checkbox
android:id="@+id/dynarec_safemode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true" />
</LinearLayout>
</TableRow>
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >
@ -170,6 +170,62 @@
android:layout_height="2dp"
android:background="@drawable/list_item_border" />
<TableRow
android:layout_marginTop="20dp"
android:gravity="center_vertical" >
<TextView
android:id="@+id/dynarec_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:ems="10"
android:gravity="center_vertical|left"
android:text="@string/select_dynarec" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:orientation="vertical" >
<Checkbox
android:id="@+id/dynarec_option"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true" />
</LinearLayout>
</TableRow>
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >
<TextView
android:id="@+id/safemode_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:ems="10"
android:gravity="center_vertical|left"
android:text="@string/select_safemode" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:orientation="vertical" >
<Checkbox
android:id="@+id/dynarec_safemode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="true" />
</LinearLayout>
</TableRow>
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >
@ -312,31 +368,44 @@
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical" >
android:gravity="center_vertical"
android:layout_marginRight="6dp" >
<TextView
android:id="@+id/apply_pg_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:ems="10"
android:gravity="center_vertical|left"
android:text="@string/save_pgc_title" />
<LinearLayout
android:layout_width="wrap_content"
<Button
android:id="@+id/clear_pg_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:orientation="vertical" >
android:text="@string/clear_pgc" />
<Button
android:id="@+id/save_pg_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/write_pgc" />
</LinearLayout>
<Button
android:id="@+id/save_pg_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/save_pgc" />
</TableRow>
<TableRow
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:layout_marginRight="6dp" >
<Button
android:id="@+id/import_pg_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/import_pgc" />
<Button
android:id="@+id/export_pg_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/export_pgc" />
</TableRow>
</TableLayout>
</LinearLayout>

View File

@ -62,10 +62,15 @@
<string name="reset_emu_details">Warning: Emulator settings will be cleared. Folder and input settings are not included. This cannot be undone.\nAre you sure you want to continue?</string>
<string name="pgc_doc">Per-Game Configuration\nThese options will override the default settings.\nTo add a game, launch it from the main game list\nGames will appear when returning to this window\nAfter changing settings, make sure to \"Save PCG\"</string>
<string name="pgc_select_game">Select Game</string>
<string name="save_pgc_title">Save Per-Game Config</string>
<string name="write_pgc">Save PGC</string>
<string name="pgc_select_game">PGC Game</string>
<string name="save_pgc">Save PGC</string>
<string name="pgconfig_saved">Configuration Saved</string>
<string name="clear_pgc">Clear PGC</string>
<string name="pgconfig_cleared">Configuration Cleared</string>
<string name="import_pgc">Import PGC</string>
<string name="pgconfig_imported">Configuration Imported</string>
<string name="export_pgc">Export PGC</string>
<string name="pgconfig_exported">Configuration Exported</string>
<string name="games_listing">Game List</string>
<string name="search_hint">Game (ie. Crazy Taxi)</string>