(Android Phoenix) Cleanups - reuse instance from MainMenuActivity to get application
info stuff (Android Phoenix) TV Mode now creates a default config file if one wasn't there already - makes it work from startup
This commit is contained in:
parent
4d8e9df03d
commit
39edc5379b
|
@ -5,12 +5,9 @@ import org.retroarch.R;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
import android.content.*;
|
import android.content.*;
|
||||||
import android.annotation.TargetApi;
|
|
||||||
import android.app.*;
|
import android.app.*;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.media.AudioTrack;
|
|
||||||
import android.os.*;
|
import android.os.*;
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.widget.*;
|
import android.widget.*;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
@ -27,38 +24,6 @@ public class CoreSelection extends Activity implements
|
||||||
static private String libretro_path;
|
static private String libretro_path;
|
||||||
static private final String TAG = "CoreSelection";
|
static private final String TAG = "CoreSelection";
|
||||||
|
|
||||||
private final double getDisplayRefreshRate() {
|
|
||||||
// Android is *very* likely to screw this up.
|
|
||||||
// It is rarely a good value to use, so make sure it's not
|
|
||||||
// completely wrong. Some phones return refresh rates that are completely bogus
|
|
||||||
// (like 0.3 Hz, etc), so try to be very conservative here.
|
|
||||||
final WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
|
|
||||||
final Display display = wm.getDefaultDisplay();
|
|
||||||
double rate = display.getRefreshRate();
|
|
||||||
if (rate > 61.0 || rate < 58.0)
|
|
||||||
rate = 59.95;
|
|
||||||
return rate;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final double getRefreshRate() {
|
|
||||||
double rate = 0;
|
|
||||||
SharedPreferences prefs = PreferenceManager
|
|
||||||
.getDefaultSharedPreferences(getBaseContext());
|
|
||||||
String refresh_rate = prefs.getString("video_refresh_rate", "");
|
|
||||||
if (!refresh_rate.isEmpty()) {
|
|
||||||
try {
|
|
||||||
rate = Double.parseDouble(refresh_rate);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
Log.e(TAG, "Cannot parse: " + refresh_rate + " as a double!");
|
|
||||||
rate = getDisplayRefreshRate();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
rate = getDisplayRefreshRate();
|
|
||||||
}
|
|
||||||
|
|
||||||
Log.i(TAG, "Using refresh rate: " + rate + " Hz.");
|
|
||||||
return rate;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String readCPUInfo() {
|
private String readCPUInfo() {
|
||||||
String result = "";
|
String result = "";
|
||||||
|
@ -109,7 +74,7 @@ public class CoreSelection extends Activity implements
|
||||||
setTitle("Select Libretro core");
|
setTitle("Select Libretro core");
|
||||||
|
|
||||||
// Populate the list
|
// Populate the list
|
||||||
final String modulePath = getApplicationInfo().nativeLibraryDir;
|
final String modulePath = MainMenuActivity.getInstance().getApplicationInfo().nativeLibraryDir;
|
||||||
final File[] libs = new File(modulePath).listFiles();
|
final File[] libs = new File(modulePath).listFiles();
|
||||||
for (final File lib : libs) {
|
for (final File lib : libs) {
|
||||||
String libName = lib.getName();
|
String libName = lib.getName();
|
||||||
|
@ -163,147 +128,11 @@ public class CoreSelection extends Activity implements
|
||||||
startActivityForResult(myIntent, ACTIVITY_LOAD_ROM);
|
startActivityForResult(myIntent, ACTIVITY_LOAD_ROM);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getDefaultConfigPath() {
|
|
||||||
String internal = System.getenv("INTERNAL_STORAGE");
|
|
||||||
String external = System.getenv("EXTERNAL_STORAGE");
|
|
||||||
|
|
||||||
if (external != null) {
|
|
||||||
String confPath = external + File.separator + "retroarch.cfg";
|
|
||||||
if (new File(confPath).exists())
|
|
||||||
return confPath;
|
|
||||||
} else if (internal != null) {
|
|
||||||
String confPath = internal + File.separator + "retroarch.cfg";
|
|
||||||
if (new File(confPath).exists())
|
|
||||||
return confPath;
|
|
||||||
} else {
|
|
||||||
String confPath = "/mnt/extsd/retroarch.cfg";
|
|
||||||
if (new File(confPath).exists())
|
|
||||||
return confPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (internal != null && new File(internal + File.separator + "retroarch.cfg").canWrite())
|
|
||||||
return internal + File.separator + "retroarch.cfg";
|
|
||||||
else if (external != null && new File(internal + File.separator + "retroarch.cfg").canWrite())
|
|
||||||
return external + File.separator + "retroarch.cfg";
|
|
||||||
else if ((getApplicationInfo().dataDir) != null)
|
|
||||||
return (getApplicationInfo().dataDir) + File.separator + "retroarch.cfg";
|
|
||||||
else // emergency fallback, all else failed
|
|
||||||
return "/mnt/sd/retroarch.cfg";
|
|
||||||
}
|
|
||||||
|
|
||||||
@TargetApi(17)
|
|
||||||
private int getLowLatencyOptimalSamplingRate() {
|
|
||||||
AudioManager manager = (AudioManager)getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
|
|
||||||
return Integer.parseInt(manager.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE));
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getOptimalSamplingRate() {
|
|
||||||
int ret;
|
|
||||||
if (android.os.Build.VERSION.SDK_INT >= 17)
|
|
||||||
ret = getLowLatencyOptimalSamplingRate();
|
|
||||||
else
|
|
||||||
ret = AudioTrack.getNativeOutputSampleRate(AudioManager.STREAM_MUSIC);
|
|
||||||
|
|
||||||
Log.i(TAG, "Using sampling rate: " + ret + " Hz");
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateConfigFile() {
|
|
||||||
ConfigFile config;
|
|
||||||
try {
|
|
||||||
config = new ConfigFile(new File(getDefaultConfigPath()));
|
|
||||||
} catch (IOException e) {
|
|
||||||
config = new ConfigFile();
|
|
||||||
}
|
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
|
|
||||||
config.setBoolean("audio_rate_control", prefs.getBoolean("audio_rate_control", true));
|
|
||||||
config.setInt("audio_out_rate", getOptimalSamplingRate());
|
|
||||||
config.setInt("audio_latency", prefs.getBoolean("audio_high_latency", false) ? 160 : 64);
|
|
||||||
config.setBoolean("audio_enable", prefs.getBoolean("audio_enable", true));
|
|
||||||
config.setBoolean("video_smooth", prefs.getBoolean("video_smooth", true));
|
|
||||||
config.setBoolean("video_allow_rotate", prefs.getBoolean("video_allow_rotate", true));
|
|
||||||
config.setBoolean("savestate_auto_load", prefs.getBoolean("savestate_auto_load", true));
|
|
||||||
config.setBoolean("savestate_auto_save", prefs.getBoolean("savestate_auto_save", false));
|
|
||||||
config.setBoolean("rewind_enable", prefs.getBoolean("rewind_enable", false));
|
|
||||||
config.setBoolean("video_vsync", prefs.getBoolean("video_vsync", true));
|
|
||||||
config.setBoolean("input_autodetect_enable", prefs.getBoolean("input_autodetect_enable", true));
|
|
||||||
config.setBoolean("input_debug_enable", prefs.getBoolean("input_debug_enable", false));
|
|
||||||
config.setInt("input_back_behavior", Integer.valueOf(prefs.getString("input_back_behavior", "0")));
|
|
||||||
config.setInt("input_autodetect_icade_profile_pad1", Integer.valueOf(prefs.getString("input_autodetect_icade_profile_pad1", "0")));
|
|
||||||
config.setInt("input_autodetect_icade_profile_pad2", Integer.valueOf(prefs.getString("input_autodetect_icade_profile_pad2", "0")));
|
|
||||||
config.setInt("input_autodetect_icade_profile_pad3", Integer.valueOf(prefs.getString("input_autodetect_icade_profile_pad3", "0")));
|
|
||||||
config.setInt("input_autodetect_icade_profile_pad4", Integer.valueOf(prefs.getString("input_autodetect_icade_profile_pad4", "0")));
|
|
||||||
|
|
||||||
config.setDouble("video_refresh_rate", getRefreshRate());
|
|
||||||
config.setBoolean("video_threaded", prefs.getBoolean("video_threaded", true));
|
|
||||||
|
|
||||||
String aspect = prefs.getString("video_aspect_ratio", "auto");
|
|
||||||
if (aspect.equals("full")) {
|
|
||||||
config.setBoolean("video_force_aspect", false);
|
|
||||||
} else if (aspect.equals("auto")) {
|
|
||||||
config.setBoolean("video_force_aspect", true);
|
|
||||||
config.setBoolean("video_force_aspect_auto", true);
|
|
||||||
config.setDouble("video_aspect_ratio", -1.0);
|
|
||||||
} else if (aspect.equals("square")) {
|
|
||||||
config.setBoolean("video_force_aspect", true);
|
|
||||||
config.setBoolean("video_force_aspect_auto", false);
|
|
||||||
config.setDouble("video_aspect_ratio", -1.0);
|
|
||||||
} else {
|
|
||||||
double aspect_ratio = Double.parseDouble(aspect);
|
|
||||||
config.setBoolean("video_force_aspect", true);
|
|
||||||
config.setDouble("video_aspect_ratio", aspect_ratio);
|
|
||||||
}
|
|
||||||
|
|
||||||
config.setBoolean("video_scale_integer", prefs.getBoolean("video_scale_integer", false));
|
|
||||||
|
|
||||||
String shaderPath = prefs.getString("video_shader", "");
|
|
||||||
config.setString("video_shader", shaderPath);
|
|
||||||
config.setBoolean("video_shader_enable",
|
|
||||||
prefs.getBoolean("video_shader_enable", false)
|
|
||||||
&& new File(shaderPath).exists());
|
|
||||||
|
|
||||||
boolean useOverlay = prefs.getBoolean("input_overlay_enable", true);
|
|
||||||
if (useOverlay) {
|
|
||||||
String overlayPath = prefs.getString("input_overlay", (getApplicationInfo().dataDir) + "/overlays/snes-landscape.cfg");
|
|
||||||
config.setString("input_overlay", overlayPath);
|
|
||||||
config.setDouble("input_overlay_opacity", prefs.getFloat("input_overlay_opacity", 1.0f));
|
|
||||||
} else {
|
|
||||||
config.setString("input_overlay", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
config.setString("savefile_directory", prefs.getBoolean("savefile_directory_enable", false) ?
|
|
||||||
prefs.getString("savefile_directory", "") : "");
|
|
||||||
config.setString("savestate_directory", prefs.getBoolean("savestate_directory_enable", false) ?
|
|
||||||
prefs.getString("savestate_directory", "") : "");
|
|
||||||
config.setString("system_directory", prefs.getBoolean("system_directory_enable", false) ?
|
|
||||||
prefs.getString("system_directory", "") : "");
|
|
||||||
|
|
||||||
config.setBoolean("video_font_enable", prefs.getBoolean("video_font_enable", true));
|
|
||||||
|
|
||||||
for (int i = 1; i <= 4; i++)
|
|
||||||
{
|
|
||||||
final String btns[] = {"up", "down", "left", "right", "a", "b", "x", "y", "start", "select", "l", "r", "l2", "r2", "l3", "r3" };
|
|
||||||
for (String b : btns)
|
|
||||||
{
|
|
||||||
String p = "input_player" + String.valueOf(i) + "_" + b + "_btn";
|
|
||||||
config.setInt(p, prefs.getInt(p, 0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String confPath = getDefaultConfigPath();
|
|
||||||
try {
|
|
||||||
config.write(new File(confPath));
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log.e(TAG, "Failed to save config file to: " + confPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
Intent myIntent;
|
Intent myIntent;
|
||||||
String current_ime = Settings.Secure.getString(getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
|
String current_ime = Settings.Secure.getString(getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
|
||||||
|
|
||||||
updateConfigFile();
|
MainMenuActivity.updateConfigFile();
|
||||||
|
|
||||||
switch (requestCode) {
|
switch (requestCode) {
|
||||||
case ACTIVITY_LOAD_ROM:
|
case ACTIVITY_LOAD_ROM:
|
||||||
|
@ -314,7 +143,7 @@ public class CoreSelection extends Activity implements
|
||||||
myIntent = new Intent(this, RetroActivity.class);
|
myIntent = new Intent(this, RetroActivity.class);
|
||||||
myIntent.putExtra("ROM", data.getStringExtra("PATH"));
|
myIntent.putExtra("ROM", data.getStringExtra("PATH"));
|
||||||
myIntent.putExtra("LIBRETRO", libretro_path);
|
myIntent.putExtra("LIBRETRO", libretro_path);
|
||||||
myIntent.putExtra("CONFIGFILE", getDefaultConfigPath());
|
myIntent.putExtra("CONFIGFILE", MainMenuActivity.getDefaultConfigPath());
|
||||||
myIntent.putExtra("IME", current_ime);
|
myIntent.putExtra("IME", current_ime);
|
||||||
startActivity(myIntent);
|
startActivity(myIntent);
|
||||||
finish();
|
finish();
|
||||||
|
|
|
@ -11,24 +11,31 @@ import java.io.InputStream;
|
||||||
|
|
||||||
import org.retroarch.R;
|
import org.retroarch.R;
|
||||||
|
|
||||||
|
import android.annotation.TargetApi;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.content.res.AssetManager;
|
import android.content.res.AssetManager;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
|
import android.media.AudioTrack;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceActivity;
|
import android.preference.PreferenceActivity;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.Display;
|
||||||
|
import android.view.WindowManager;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
public class MainMenuActivity extends PreferenceActivity {
|
public class MainMenuActivity extends PreferenceActivity {
|
||||||
|
private static MainMenuActivity instance = null;
|
||||||
static private final String TAG = "MainMenu";
|
static private final String TAG = "MainMenu";
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
instance = this;
|
||||||
addPreferencesFromResource(R.xml.prefs);
|
addPreferencesFromResource(R.xml.prefs);
|
||||||
PreferenceManager.setDefaultValues(this, R.xml.prefs, false);
|
PreferenceManager.setDefaultValues(this, R.xml.prefs, false);
|
||||||
this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
|
this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
|
||||||
|
@ -66,6 +73,179 @@ public class MainMenuActivity extends PreferenceActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static MainMenuActivity getInstance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final double getDisplayRefreshRate() {
|
||||||
|
// Android is *very* likely to screw this up.
|
||||||
|
// It is rarely a good value to use, so make sure it's not
|
||||||
|
// completely wrong. Some phones return refresh rates that are completely bogus
|
||||||
|
// (like 0.3 Hz, etc), so try to be very conservative here.
|
||||||
|
final WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
|
||||||
|
final Display display = wm.getDefaultDisplay();
|
||||||
|
double rate = display.getRefreshRate();
|
||||||
|
if (rate > 61.0 || rate < 58.0)
|
||||||
|
rate = 59.95;
|
||||||
|
return rate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final double getRefreshRate() {
|
||||||
|
double rate = 0;
|
||||||
|
SharedPreferences prefs = PreferenceManager
|
||||||
|
.getDefaultSharedPreferences(MainMenuActivity.getInstance().getBaseContext());
|
||||||
|
String refresh_rate = prefs.getString("video_refresh_rate", "");
|
||||||
|
if (!refresh_rate.isEmpty()) {
|
||||||
|
try {
|
||||||
|
rate = Double.parseDouble(refresh_rate);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
Log.e(TAG, "Cannot parse: " + refresh_rate + " as a double!");
|
||||||
|
rate = MainMenuActivity.getInstance().getDisplayRefreshRate();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
rate = MainMenuActivity.getInstance().getDisplayRefreshRate();
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.i(TAG, "Using refresh rate: " + rate + " Hz.");
|
||||||
|
return rate;
|
||||||
|
}
|
||||||
|
|
||||||
|
@TargetApi(17)
|
||||||
|
public static int getLowLatencyOptimalSamplingRate() {
|
||||||
|
AudioManager manager = (AudioManager)MainMenuActivity.getInstance().getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
|
||||||
|
return Integer.parseInt(manager.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getOptimalSamplingRate() {
|
||||||
|
int ret;
|
||||||
|
if (android.os.Build.VERSION.SDK_INT >= 17)
|
||||||
|
ret = getLowLatencyOptimalSamplingRate();
|
||||||
|
else
|
||||||
|
ret = AudioTrack.getNativeOutputSampleRate(AudioManager.STREAM_MUSIC);
|
||||||
|
|
||||||
|
Log.i(TAG, "Using sampling rate: " + ret + " Hz");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getDefaultConfigPath() {
|
||||||
|
String internal = System.getenv("INTERNAL_STORAGE");
|
||||||
|
String external = System.getenv("EXTERNAL_STORAGE");
|
||||||
|
|
||||||
|
if (external != null) {
|
||||||
|
String confPath = external + File.separator + "retroarch.cfg";
|
||||||
|
if (new File(confPath).exists())
|
||||||
|
return confPath;
|
||||||
|
} else if (internal != null) {
|
||||||
|
String confPath = internal + File.separator + "retroarch.cfg";
|
||||||
|
if (new File(confPath).exists())
|
||||||
|
return confPath;
|
||||||
|
} else {
|
||||||
|
String confPath = "/mnt/extsd/retroarch.cfg";
|
||||||
|
if (new File(confPath).exists())
|
||||||
|
return confPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (internal != null && new File(internal + File.separator + "retroarch.cfg").canWrite())
|
||||||
|
return internal + File.separator + "retroarch.cfg";
|
||||||
|
else if (external != null && new File(internal + File.separator + "retroarch.cfg").canWrite())
|
||||||
|
return external + File.separator + "retroarch.cfg";
|
||||||
|
else if ((MainMenuActivity.getInstance().getApplicationInfo().dataDir) != null)
|
||||||
|
return (MainMenuActivity.getInstance().getApplicationInfo().dataDir) + File.separator + "retroarch.cfg";
|
||||||
|
else // emergency fallback, all else failed
|
||||||
|
return "/mnt/sd/retroarch.cfg";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void updateConfigFile() {
|
||||||
|
ConfigFile config;
|
||||||
|
try {
|
||||||
|
config = new ConfigFile(new File(getDefaultConfigPath()));
|
||||||
|
} catch (IOException e) {
|
||||||
|
config = new ConfigFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainMenuActivity.getInstance().getBaseContext());
|
||||||
|
config.setBoolean("audio_rate_control", prefs.getBoolean("audio_rate_control", true));
|
||||||
|
config.setInt("audio_out_rate", MainMenuActivity.getOptimalSamplingRate());
|
||||||
|
config.setInt("audio_latency", prefs.getBoolean("audio_high_latency", false) ? 160 : 64);
|
||||||
|
config.setBoolean("audio_enable", prefs.getBoolean("audio_enable", true));
|
||||||
|
config.setBoolean("video_smooth", prefs.getBoolean("video_smooth", true));
|
||||||
|
config.setBoolean("video_allow_rotate", prefs.getBoolean("video_allow_rotate", true));
|
||||||
|
config.setBoolean("savestate_auto_load", prefs.getBoolean("savestate_auto_load", true));
|
||||||
|
config.setBoolean("savestate_auto_save", prefs.getBoolean("savestate_auto_save", false));
|
||||||
|
config.setBoolean("rewind_enable", prefs.getBoolean("rewind_enable", false));
|
||||||
|
config.setBoolean("video_vsync", prefs.getBoolean("video_vsync", true));
|
||||||
|
config.setBoolean("input_autodetect_enable", prefs.getBoolean("input_autodetect_enable", true));
|
||||||
|
config.setBoolean("input_debug_enable", prefs.getBoolean("input_debug_enable", false));
|
||||||
|
config.setInt("input_back_behavior", Integer.valueOf(prefs.getString("input_back_behavior", "0")));
|
||||||
|
config.setInt("input_autodetect_icade_profile_pad1", Integer.valueOf(prefs.getString("input_autodetect_icade_profile_pad1", "0")));
|
||||||
|
config.setInt("input_autodetect_icade_profile_pad2", Integer.valueOf(prefs.getString("input_autodetect_icade_profile_pad2", "0")));
|
||||||
|
config.setInt("input_autodetect_icade_profile_pad3", Integer.valueOf(prefs.getString("input_autodetect_icade_profile_pad3", "0")));
|
||||||
|
config.setInt("input_autodetect_icade_profile_pad4", Integer.valueOf(prefs.getString("input_autodetect_icade_profile_pad4", "0")));
|
||||||
|
|
||||||
|
config.setDouble("video_refresh_rate", MainMenuActivity.getRefreshRate());
|
||||||
|
config.setBoolean("video_threaded", prefs.getBoolean("video_threaded", true));
|
||||||
|
|
||||||
|
String aspect = prefs.getString("video_aspect_ratio", "auto");
|
||||||
|
if (aspect.equals("full")) {
|
||||||
|
config.setBoolean("video_force_aspect", false);
|
||||||
|
} else if (aspect.equals("auto")) {
|
||||||
|
config.setBoolean("video_force_aspect", true);
|
||||||
|
config.setBoolean("video_force_aspect_auto", true);
|
||||||
|
config.setDouble("video_aspect_ratio", -1.0);
|
||||||
|
} else if (aspect.equals("square")) {
|
||||||
|
config.setBoolean("video_force_aspect", true);
|
||||||
|
config.setBoolean("video_force_aspect_auto", false);
|
||||||
|
config.setDouble("video_aspect_ratio", -1.0);
|
||||||
|
} else {
|
||||||
|
double aspect_ratio = Double.parseDouble(aspect);
|
||||||
|
config.setBoolean("video_force_aspect", true);
|
||||||
|
config.setDouble("video_aspect_ratio", aspect_ratio);
|
||||||
|
}
|
||||||
|
|
||||||
|
config.setBoolean("video_scale_integer", prefs.getBoolean("video_scale_integer", false));
|
||||||
|
|
||||||
|
String shaderPath = prefs.getString("video_shader", "");
|
||||||
|
config.setString("video_shader", shaderPath);
|
||||||
|
config.setBoolean("video_shader_enable",
|
||||||
|
prefs.getBoolean("video_shader_enable", false)
|
||||||
|
&& new File(shaderPath).exists());
|
||||||
|
|
||||||
|
boolean useOverlay = prefs.getBoolean("input_overlay_enable", true);
|
||||||
|
if (useOverlay) {
|
||||||
|
String overlayPath = prefs.getString("input_overlay", (MainMenuActivity.getInstance().getApplicationInfo().dataDir) + "/overlays/snes-landscape.cfg");
|
||||||
|
config.setString("input_overlay", overlayPath);
|
||||||
|
config.setDouble("input_overlay_opacity", prefs.getFloat("input_overlay_opacity", 1.0f));
|
||||||
|
} else {
|
||||||
|
config.setString("input_overlay", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
config.setString("savefile_directory", prefs.getBoolean("savefile_directory_enable", false) ?
|
||||||
|
prefs.getString("savefile_directory", "") : "");
|
||||||
|
config.setString("savestate_directory", prefs.getBoolean("savestate_directory_enable", false) ?
|
||||||
|
prefs.getString("savestate_directory", "") : "");
|
||||||
|
config.setString("system_directory", prefs.getBoolean("system_directory_enable", false) ?
|
||||||
|
prefs.getString("system_directory", "") : "");
|
||||||
|
|
||||||
|
config.setBoolean("video_font_enable", prefs.getBoolean("video_font_enable", true));
|
||||||
|
|
||||||
|
for (int i = 1; i <= 4; i++)
|
||||||
|
{
|
||||||
|
final String btns[] = {"up", "down", "left", "right", "a", "b", "x", "y", "start", "select", "l", "r", "l2", "r2", "l3", "r3" };
|
||||||
|
for (String b : btns)
|
||||||
|
{
|
||||||
|
String p = "input_player" + String.valueOf(i) + "_" + b + "_btn";
|
||||||
|
config.setInt(p, prefs.getInt(p, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String confPath = getDefaultConfigPath();
|
||||||
|
try {
|
||||||
|
config.write(new File(confPath));
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.e(TAG, "Failed to save config file to: " + confPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private byte[] loadAsset(String asset) throws IOException {
|
private byte[] loadAsset(String asset) throws IOException {
|
||||||
String path = asset;
|
String path = asset;
|
||||||
InputStream stream = getAssets().open(path);
|
InputStream stream = getAssets().open(path);
|
||||||
|
|
|
@ -1,47 +1,21 @@
|
||||||
package org.retroarch.browser;
|
package org.retroarch.browser;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
|
||||||
public class RetroTVMode extends Activity {
|
public class RetroTVMode extends Activity {
|
||||||
private String getDefaultConfigPath() {
|
|
||||||
String internal = System.getenv("INTERNAL_STORAGE");
|
|
||||||
String external = System.getenv("EXTERNAL_STORAGE");
|
|
||||||
|
|
||||||
if (external != null) {
|
|
||||||
String confPath = external + File.separator + "retroarch.cfg";
|
|
||||||
if (new File(confPath).exists())
|
|
||||||
return confPath;
|
|
||||||
} else if (internal != null) {
|
|
||||||
String confPath = internal + File.separator + "retroarch.cfg";
|
|
||||||
if (new File(confPath).exists())
|
|
||||||
return confPath;
|
|
||||||
} else {
|
|
||||||
String confPath = "/mnt/extsd/retroarch.cfg";
|
|
||||||
if (new File(confPath).exists())
|
|
||||||
return confPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (internal != null && new File(internal + File.separator + "retroarch.cfg").canWrite())
|
|
||||||
return internal + File.separator + "retroarch.cfg";
|
|
||||||
else if (external != null && new File(internal + File.separator + "retroarch.cfg").canWrite())
|
|
||||||
return external + File.separator + "retroarch.cfg";
|
|
||||||
else if ((getApplicationInfo().dataDir) != null)
|
|
||||||
return (getApplicationInfo().dataDir) + File.separator + "retroarch.cfg";
|
|
||||||
else // emergency fallback, all else failed
|
|
||||||
return "/mnt/sd/retroarch.cfg";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
MainMenuActivity.updateConfigFile();
|
||||||
|
|
||||||
Intent myIntent = new Intent(this, RetroActivity.class);
|
Intent myIntent = new Intent(this, RetroActivity.class);
|
||||||
String current_ime = Settings.Secure.getString(getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
|
String current_ime = Settings.Secure.getString(getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
|
||||||
myIntent.putExtra("CONFIGFILE", getDefaultConfigPath());
|
myIntent.putExtra("CONFIGFILE", MainMenuActivity.getDefaultConfigPath());
|
||||||
myIntent.putExtra("IME", current_ime);
|
myIntent.putExtra("IME", current_ime);
|
||||||
startActivity(myIntent);
|
startActivity(myIntent);
|
||||||
finish();
|
finish();
|
||||||
|
|
Loading…
Reference in New Issue