Extend application for global functionality

Rather than attempt to locate each vector reference, it was best to extend the application for global support. This created a good place to handle native options that are separate from UI config

Clean up formatting and remove whitespace

Android Sudio does not verify global variables well

Conflicts:
	shell/android-studio/app/src/main/java/com/reicast/emulator/GL2JNINative.java
This commit is contained in:
TwistedUmbrella 2018-03-28 01:53:12 -04:00
parent 7ab6e9f0c4
commit 03834ad48b
14 changed files with 197 additions and 241 deletions

View File

@ -39,6 +39,7 @@
android:required="false" /> android:required="false" />
<application <application
android:name=".Emulator"
android:icon="@drawable/ic_launcher" android:icon="@drawable/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:theme="@style/AppTheme" android:theme="@style/AppTheme"

View File

@ -0,0 +1,100 @@
package com.reicast.emulator;
import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.support.v7.app.AppCompatDelegate;
import com.android.util.DreamTime;
import com.reicast.emulator.emu.JNIdc;
public class Emulator extends Application {
public static final String pref_nativeact = "enable_native";
public static final String pref_dynarecopt = "dynarec_opt";
public static final String pref_unstable = "unstable_opt";
public static final String pref_cable = "dc_cable";
public static final String pref_dcregion = "dc_region";
public static final String pref_broadcast = "dc_broadcast";
public static final String pref_limitfps = "limit_fps";
public static final String pref_nosound = "sound_disabled";
public static final String pref_mipmaps = "use_mipmaps";
public static final String pref_widescreen = "stretch_view";
public static final String pref_frameskip = "frame_skip";
public static final String pref_pvrrender = "pvr_render";
public static final String pref_syncedrender = "synced_render";
public static final String pref_cheatdisk = "cheat_disk";
public static final String pref_usereios = "use_reios";
public static boolean dynarecopt = true;
public static boolean idleskip = true;
public static boolean unstableopt = false;
public static int cable = 3;
public static int dcregion = 3;
public static int broadcast = 4;
public static boolean limitfps = true;
public static boolean nobatch = false;
public static boolean nosound = false;
public static boolean mipmaps = true;
public static boolean widescreen = false;
public static boolean subdivide = false;
public static int frameskip = 0;
public static boolean pvrrender = false;
public static boolean syncedrender = false;
public static String cheatdisk = "null";
public static boolean usereios = false;
public static boolean nativeact = false;
/**
* Load the user configuration from preferences
*
*/
public void getConfigurationPrefs(Context mContext) {
SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(mContext);
Emulator.dynarecopt = mPrefs.getBoolean(pref_dynarecopt, dynarecopt);
Emulator.unstableopt = mPrefs.getBoolean(pref_unstable, unstableopt);
Emulator.cable = mPrefs.getInt(pref_cable, cable);
Emulator.dcregion = mPrefs.getInt(pref_dcregion, dcregion);
Emulator.broadcast = mPrefs.getInt(pref_broadcast, broadcast);
Emulator.limitfps = mPrefs.getBoolean(pref_limitfps, limitfps);
Emulator.nosound = mPrefs.getBoolean(pref_nosound, nosound);
Emulator.mipmaps = mPrefs.getBoolean(pref_mipmaps, mipmaps);
Emulator.widescreen = mPrefs.getBoolean(pref_widescreen, widescreen);
Emulator.frameskip = mPrefs.getInt(pref_frameskip, frameskip);
Emulator.pvrrender = mPrefs.getBoolean(pref_pvrrender, pvrrender);
Emulator.syncedrender = mPrefs.getBoolean(pref_syncedrender, syncedrender);
Emulator.cheatdisk = mPrefs.getString(pref_cheatdisk, cheatdisk);
Emulator.usereios = mPrefs.getBoolean(pref_usereios, usereios);
Emulator.nativeact = mPrefs.getBoolean(pref_nativeact, nativeact);
}
/**
* Write configuration settings to the emulator
*
*/
public void loadConfigurationPrefs() {
JNIdc.dynarec(Emulator.dynarecopt ? 1 : 0);
JNIdc.idleskip(Emulator.idleskip ? 1 : 0);
JNIdc.unstable(Emulator.unstableopt ? 1 : 0);
JNIdc.cable(Emulator.cable);
JNIdc.region(Emulator.dcregion);
JNIdc.broadcast(Emulator.broadcast);
JNIdc.limitfps(Emulator.limitfps ? 1 : 0);
JNIdc.nobatch(Emulator.nobatch ? 1 : 0);
JNIdc.nosound(Emulator.nosound ? 1 : 0);
JNIdc.mipmaps(Emulator.mipmaps ? 1 : 0);
JNIdc.widescreen(Emulator.widescreen ? 1 : 0);
JNIdc.subdivide(Emulator.subdivide ? 1 : 0);
JNIdc.frameskip(Emulator.frameskip);
JNIdc.pvrrender(Emulator.pvrrender ? 1 : 0);
JNIdc.syncedrender(Emulator.syncedrender ? 1 : 0);
JNIdc.usereios(Emulator.usereios ? 1 : 0);
JNIdc.cheatdisk(Emulator.cheatdisk);
JNIdc.dreamtime(DreamTime.getDreamtime());
}
static {
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
}

View File

@ -1,6 +1,5 @@
package com.reicast.emulator; package com.reicast.emulator;
import android.annotation.TargetApi;
import android.app.Activity; import android.app.Activity;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Configuration; import android.content.res.Configuration;
@ -45,7 +44,6 @@ public class GL2JNIActivity extends Activity {
MOGAInput moga = new MOGAInput(); MOGAInput moga = new MOGAInput();
private SharedPreferences prefs; private SharedPreferences prefs;
private Config config;
private Gamepad pad = new Gamepad(); private Gamepad pad = new Gamepad();
public static byte[] syms; public static byte[] syms;
@ -59,8 +57,8 @@ public class GL2JNIActivity extends Activity {
WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED); WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
} }
config = new Config(GL2JNIActivity.this); Emulator app = (Emulator)getApplicationContext();
config.getConfigurationPrefs(); app.getConfigurationPrefs(GL2JNIActivity.this);
menu = new OnScreenMenu(GL2JNIActivity.this, prefs); menu = new OnScreenMenu(GL2JNIActivity.this, prefs);
pad.isXperiaPlay = pad.IsXperiaPlay(); pad.isXperiaPlay = pad.IsXperiaPlay();
@ -198,14 +196,14 @@ public class GL2JNIActivity extends Activity {
pad.fullCompatibilityMode(prefs); pad.fullCompatibilityMode(prefs);
} }
config.loadConfigurationPrefs(); app.loadConfigurationPrefs();
// When viewing a resource, pass its URI to the native code for opening // When viewing a resource, pass its URI to the native code for opening
if (getIntent().getAction().equals("com.reicast.EMULATOR")) if (getIntent().getAction().equals("com.reicast.EMULATOR"))
fileName = Uri.decode(getIntent().getData().toString()); fileName = Uri.decode(getIntent().getData().toString());
// Create the actual GLES view // Create the actual GLES view
mView = new GL2JNIView(GL2JNIActivity.this, config, fileName, false, mView = new GL2JNIView(GL2JNIActivity.this, fileName, false,
prefs.getInt(Config.pref_renderdepth, 24), 0, false); prefs.getInt(Config.pref_renderdepth, 24), 0, false);
setContentView(mView); setContentView(mView);

View File

@ -47,7 +47,6 @@ public class GL2JNINative extends NativeActivity {
MOGAInput moga = new MOGAInput(); MOGAInput moga = new MOGAInput();
private SharedPreferences prefs; private SharedPreferences prefs;
private Config config;
private Gamepad pad = new Gamepad(); private Gamepad pad = new Gamepad();
public static byte[] syms; public static byte[] syms;
@ -76,8 +75,8 @@ public class GL2JNINative extends NativeActivity {
RegisterNative(pad.isXperiaPlay); RegisterNative(pad.isXperiaPlay);
config = new Config(GL2JNINative.this); Emulator app = (Emulator)getApplicationContext();
config.getConfigurationPrefs(); app.getConfigurationPrefs(GL2JNINative.this);
menu = new OnScreenMenu(GL2JNINative.this, prefs); menu = new OnScreenMenu(GL2JNINative.this, prefs);
String fileName = null; String fileName = null;
@ -214,14 +213,14 @@ public class GL2JNINative extends NativeActivity {
} }
} }
config.loadConfigurationPrefs(); app.loadConfigurationPrefs();
// When viewing a resource, pass its URI to the native code for opening // When viewing a resource, pass its URI to the native code for opening
if (getIntent().getAction().equals("com.reicast.EMULATOR")) if (getIntent().getAction().equals("com.reicast.EMULATOR"))
fileName = Uri.decode(getIntent().getData().toString()); fileName = Uri.decode(getIntent().getData().toString());
// Create the actual GLES view // Create the actual GLES view
mView = new GL2JNIView(getApplication(), config, fileName, false, mView = new GL2JNIView(getApplication(), fileName, false,
prefs.getInt(Config.pref_renderdepth, 24), 0, false); prefs.getInt(Config.pref_renderdepth, 24), 0, false);
setContentView(mView); setContentView(mView);

View File

@ -259,9 +259,9 @@ public class MainActivity extends AppCompatActivity implements
if (msg != null) { if (msg != null) {
launchBIOSdetection(); launchBIOSdetection();
} else { } else {
Config.nativeact = PreferenceManager.getDefaultSharedPreferences( Emulator.nativeact = PreferenceManager.getDefaultSharedPreferences(
getApplicationContext()).getBoolean(Config.pref_nativeact, Config.nativeact); getApplicationContext()).getBoolean(Emulator.pref_nativeact, Emulator.nativeact);
if (Config.nativeact) { if (Emulator.nativeact) {
startActivity(new Intent("com.reicast.EMULATOR", uri, getApplicationContext(), startActivity(new Intent("com.reicast.EMULATOR", uri, getApplicationContext(),
GL2JNINative.class)); GL2JNINative.class));
} else { } else {

View File

@ -1,12 +1,5 @@
package com.reicast.emulator.config; package com.reicast.emulator.config;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import com.android.util.DreamTime;
import com.reicast.emulator.emu.JNIdc;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
@ -18,52 +11,20 @@ public class Config {
public static final String pref_theme = "button_theme"; public static final String pref_theme = "button_theme";
public static final String pref_gamedetails = "game_details"; public static final String pref_gamedetails = "game_details";
public static final String pref_nativeact = "enable_native";
public static final String pref_dynarecopt = "dynarec_opt";
public static final String pref_unstable = "unstable_opt";
public static final String pref_cable = "dc_cable";
public static final String pref_dcregion = "dc_region";
public static final String pref_broadcast = "dc_broadcast";
public static final String pref_limitfps = "limit_fps";
public static final String pref_nosound = "sound_disabled";
public static final String pref_mipmaps = "use_mipmaps";
public static final String pref_widescreen = "stretch_view";
public static final String pref_frameskip = "frame_skip";
public static final String pref_pvrrender = "pvr_render";
public static final String pref_syncedrender = "synced_render";
public static final String pref_cheatdisk = "cheat_disk";
public static final String pref_usereios = "use_reios";
public static final String pref_showfps = "show_fps"; public static final String pref_showfps = "show_fps";
public static final String pref_forcegpu = "force_gpu";
public static final String pref_rendertype = "render_type"; public static final String pref_rendertype = "render_type";
public static final String pref_renderdepth = "depth_render"; public static final String pref_renderdepth = "depth_render";
public static final String pref_forcegpu = "force_gpu";
public static final String pref_touchvibe = "touch_vibration_enabled"; public static final String pref_touchvibe = "touch_vibration_enabled";
public static final String pref_vibrationDuration = "vibration_duration"; public static final String pref_vibrationDuration = "vibration_duration";
public static int vibrationDuration = 20;
public static final String pref_mic = "mic_plugged_in"; public static final String pref_mic = "mic_plugged_in";
public static final String pref_vmu = "vmu_floating"; public static final String pref_vmu = "vmu_floating";
public static boolean dynarecopt = true;
public static boolean idleskip = true;
public static boolean unstableopt = false;
public static int cable = 3;
public static int dcregion = 3;
public static int broadcast = 4;
public static boolean limitfps = true;
public static boolean nobatch = false;
public static boolean nosound = false;
public static boolean mipmaps = true;
public static boolean widescreen = false;
public static boolean subdivide = false;
public static int frameskip = 0;
public static boolean pvrrender = false;
public static boolean syncedrender = false;
public static String cheatdisk = "null";
public static boolean usereios = false;
public static boolean nativeact = false;
public static int vibrationDuration = 20;
public static String git_api = "https://api.github.com/repos/reicast/reicast-emulator/commits"; public static String git_api = "https://api.github.com/repos/reicast/reicast-emulator/commits";
public static String git_issues = "https://github.com/reicast/reicast-emulator/issues/"; public static String git_issues = "https://github.com/reicast/reicast-emulator/issues/";
public static String log_url = "http://loungekatt.sytes.net:3194/ReicastBot/report/submit.php"; public static String log_url = "http://loungekatt.sytes.net:3194/ReicastBot/report/submit.php";
@ -71,59 +32,6 @@ public class Config {
public static boolean externalIntent = false; public static boolean externalIntent = false;
private SharedPreferences mPrefs;
public Config(Context mContext) {
mPrefs = PreferenceManager.getDefaultSharedPreferences(mContext);
}
/**
* Load the user configuration from preferences
*
*/
public void getConfigurationPrefs() {
Config.dynarecopt = mPrefs.getBoolean(pref_dynarecopt, dynarecopt);
Config.unstableopt = mPrefs.getBoolean(pref_unstable, unstableopt);
Config.cable = mPrefs.getInt(pref_cable, cable);
Config.dcregion = mPrefs.getInt(pref_dcregion, dcregion);
Config.broadcast = mPrefs.getInt(pref_broadcast, broadcast);
Config.limitfps = mPrefs.getBoolean(pref_limitfps, limitfps);
Config.nosound = mPrefs.getBoolean(pref_nosound, nosound);
Config.mipmaps = mPrefs.getBoolean(pref_mipmaps, mipmaps);
Config.widescreen = mPrefs.getBoolean(pref_widescreen, widescreen);
Config.frameskip = mPrefs.getInt(pref_frameskip, frameskip);
Config.pvrrender = mPrefs.getBoolean(pref_pvrrender, pvrrender);
Config.syncedrender = mPrefs.getBoolean(pref_syncedrender, syncedrender);
Config.cheatdisk = mPrefs.getString(pref_cheatdisk, cheatdisk);
Config.usereios = mPrefs.getBoolean(pref_usereios, usereios);
Config.nativeact = mPrefs.getBoolean(pref_nativeact, nativeact);
}
/**
* Write configuration settings to the emulator
*
*/
public void loadConfigurationPrefs() {
JNIdc.dynarec(Config.dynarecopt ? 1 : 0);
JNIdc.idleskip(Config.idleskip ? 1 : 0);
JNIdc.unstable(Config.unstableopt ? 1 : 0);
JNIdc.cable(Config.cable);
JNIdc.region(Config.dcregion);
JNIdc.broadcast(Config.broadcast);
JNIdc.limitfps(Config.limitfps ? 1 : 0);
JNIdc.nobatch(Config.nobatch ? 1 : 0);
JNIdc.nosound(Config.nosound ? 1 : 0);
JNIdc.mipmaps(Config.mipmaps ? 1 : 0);
JNIdc.widescreen(Config.widescreen ? 1 : 0);
JNIdc.subdivide(Config.subdivide ? 1 : 0);
JNIdc.frameskip(Config.frameskip);
JNIdc.pvrrender(Config.pvrrender ? 1 : 0);
JNIdc.syncedrender(Config.syncedrender ? 1 : 0);
JNIdc.usereios(Config.usereios ? 1 : 0);
JNIdc.cheatdisk(Config.cheatdisk);
JNIdc.dreamtime(DreamTime.getDreamtime());
}
/** /**
* Read the output of a shell command * Read the output of a shell command
* *

View File

@ -1,6 +1,5 @@
package com.reicast.emulator.config; package com.reicast.emulator.config;
import android.annotation.TargetApi;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
@ -19,6 +18,7 @@ import android.widget.ImageView.ScaleType;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.PopupWindow; import android.widget.PopupWindow;
import com.reicast.emulator.Emulator;
import com.reicast.emulator.MainActivity; import com.reicast.emulator.MainActivity;
import com.reicast.emulator.R; import com.reicast.emulator.R;
import com.reicast.emulator.emu.GL2JNIView; import com.reicast.emulator.emu.GL2JNIView;
@ -32,8 +32,6 @@ public class EditVJoyActivity extends Activity {
PopupWindow popUp; PopupWindow popUp;
LayoutParams params; LayoutParams params;
private Config config;
private float[][] vjoy_d_cached; private float[][] vjoy_d_cached;
View addbut(int x, OnClickListener ocl) { View addbut(int x, OnClickListener ocl) {
@ -57,11 +55,11 @@ public class EditVJoyActivity extends Activity {
SharedPreferences prefs = PreferenceManager SharedPreferences prefs = PreferenceManager
.getDefaultSharedPreferences(this); .getDefaultSharedPreferences(this);
config = new Config(EditVJoyActivity.this); Emulator app = (Emulator)getApplicationContext();
config.getConfigurationPrefs(); app.getConfigurationPrefs(EditVJoyActivity.this);
// Create the actual GLES view // Create the actual GLES view
mView = new GL2JNIView(EditVJoyActivity.this, config, null, false, mView = new GL2JNIView(EditVJoyActivity.this, null, false,
prefs.getInt(Config.pref_renderdepth, 24), 0, true); prefs.getInt(Config.pref_renderdepth, 24), 0, true);
mView.setFpsDisplay(null); mView.setFpsDisplay(null);
setContentView(mView); setContentView(mView);

View File

@ -28,7 +28,9 @@ import android.widget.Spinner;
import android.widget.Toast; import android.widget.Toast;
import com.android.util.FileUtils; import com.android.util.FileUtils;
import com.reicast.emulator.Emulator;
import com.reicast.emulator.FileBrowser; import com.reicast.emulator.FileBrowser;
import com.reicast.emulator.GL2JNIActivity;
import com.reicast.emulator.R; import com.reicast.emulator.R;
import com.reicast.emulator.emu.GL2JNIView; import com.reicast.emulator.emu.GL2JNIView;
import com.reicast.emulator.emu.JNIdc; import com.reicast.emulator.emu.JNIdc;
@ -44,7 +46,7 @@ import java.util.List;
public class OptionsFragment extends Fragment { public class OptionsFragment extends Fragment {
private Config config; private Emulator app;
private Button mainBrowse; private Button mainBrowse;
private Button gameBrowse; private Button gameBrowse;
@ -102,8 +104,8 @@ public class OptionsFragment extends Fragment {
} }
home_directory = mPrefs.getString(Config.pref_home, home_directory); home_directory = mPrefs.getString(Config.pref_home, home_directory);
config = new Config(getActivity()); app = (Emulator) getActivity().getApplicationContext();
config.getConfigurationPrefs(); app.getConfigurationPrefs(getActivity());
// Generate the menu options and fill in existing settings // Generate the menu options and fill in existing settings
@ -150,12 +152,12 @@ public class OptionsFragment extends Fragment {
public void onCheckedChanged(CompoundButton buttonView, public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) { boolean isChecked) {
mPrefs.edit().putBoolean(Config.pref_usereios, isChecked).commit(); mPrefs.edit().putBoolean(Emulator.pref_usereios, isChecked).commit();
} }
}; };
CompoundButton reios_opt = (CompoundButton) getView().findViewById( CompoundButton reios_opt = (CompoundButton) getView().findViewById(
R.id.reios_option); R.id.reios_option);
reios_opt.setChecked(mPrefs.getBoolean(Config.pref_usereios, false)); reios_opt.setChecked(mPrefs.getBoolean(Emulator.pref_usereios, false));
reios_opt.setOnCheckedChangeListener(reios_options); reios_opt.setOnCheckedChangeListener(reios_options);
OnCheckedChangeListener details_options = new OnCheckedChangeListener() { OnCheckedChangeListener details_options = new OnCheckedChangeListener() {
@ -241,39 +243,39 @@ public class OptionsFragment extends Fragment {
public void onCheckedChanged(CompoundButton buttonView, public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) { boolean isChecked) {
mPrefs.edit().putBoolean(Config.pref_nativeact, isChecked).commit(); mPrefs.edit().putBoolean(Emulator.pref_nativeact, isChecked).commit();
Config.nativeact = isChecked; Emulator.nativeact = isChecked;
} }
}; };
CompoundButton native_opt = (CompoundButton) getView().findViewById( CompoundButton native_opt = (CompoundButton) getView().findViewById(
R.id.native_option); R.id.native_option);
native_opt.setChecked(Config.nativeact); native_opt.setChecked(Emulator.nativeact);
native_opt.setOnCheckedChangeListener(native_options); native_opt.setOnCheckedChangeListener(native_options);
OnCheckedChangeListener dynarec_options = new OnCheckedChangeListener() { OnCheckedChangeListener dynarec_options = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) { boolean isChecked) {
mPrefs.edit().putBoolean(Config.pref_dynarecopt, isChecked).commit(); mPrefs.edit().putBoolean(Emulator.pref_dynarecopt, isChecked).commit();
Config.dynarecopt = isChecked; Emulator.dynarecopt = isChecked;
} }
}; };
CompoundButton dynarec_opt = (CompoundButton) getView().findViewById( CompoundButton dynarec_opt = (CompoundButton) getView().findViewById(
R.id.dynarec_option); R.id.dynarec_option);
dynarec_opt.setChecked(Config.dynarecopt); dynarec_opt.setChecked(Emulator.dynarecopt);
dynarec_opt.setOnCheckedChangeListener(dynarec_options); dynarec_opt.setOnCheckedChangeListener(dynarec_options);
OnCheckedChangeListener unstable_option = new OnCheckedChangeListener() { OnCheckedChangeListener unstable_option = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) { boolean isChecked) {
mPrefs.edit().putBoolean(Config.pref_unstable, isChecked).commit(); mPrefs.edit().putBoolean(Emulator.pref_unstable, isChecked).commit();
Config.unstableopt = isChecked; Emulator.unstableopt = isChecked;
} }
}; };
CompoundButton unstable_opt = (CompoundButton) getView().findViewById( CompoundButton unstable_opt = (CompoundButton) getView().findViewById(
R.id.unstable_option); R.id.unstable_option);
if (Config.unstableopt) { if (Emulator.unstableopt) {
unstable_opt.setChecked(true); unstable_opt.setChecked(true);
} else { } else {
unstable_opt.setChecked(false); unstable_opt.setChecked(false);
@ -290,14 +292,14 @@ public class OptionsFragment extends Fragment {
.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
cable_spnr.setAdapter(cableAdapter); cable_spnr.setAdapter(cableAdapter);
cable_spnr.setSelection(Config.cable - 1, true); cable_spnr.setSelection(Emulator.cable - 1, true);
cable_spnr.setOnItemSelectedListener(new OnItemSelectedListener() { cable_spnr.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view, public void onItemSelected(AdapterView<?> parent, View view,
int pos, long id) { int pos, long id) {
mPrefs.edit().putInt(Config.pref_cable, pos + 1).commit(); mPrefs.edit().putInt(Emulator.pref_cable, pos + 1).commit();
Config.cable = pos + 1; Emulator.cable = pos + 1;
} }
public void onNothingSelected(AdapterView<?> arg0) { public void onNothingSelected(AdapterView<?> arg0) {
@ -316,11 +318,11 @@ public class OptionsFragment extends Fragment {
getActivity(), R.layout.spinner_selected, regions); getActivity(), R.layout.spinner_selected, regions);
regionAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); regionAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
region_spnr.setAdapter(regionAdapter); region_spnr.setAdapter(regionAdapter);
region_spnr.setSelection(Config.dcregion, true); region_spnr.setSelection(Emulator.dcregion, true);
region_spnr.setOnItemSelectedListener(new OnItemSelectedListener() { region_spnr.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
mPrefs.edit().putInt(Config.pref_dcregion, pos).commit(); mPrefs.edit().putInt(Emulator.pref_dcregion, pos).commit();
Config.dcregion = pos; Emulator.dcregion = pos;
} }
@ -337,7 +339,7 @@ public class OptionsFragment extends Fragment {
broadcast_spnr.setAdapter(broadcastAdapter); broadcast_spnr.setAdapter(broadcastAdapter);
int select = 0; int select = 0;
String cast = String.valueOf(Config.broadcast); String cast = String.valueOf(Emulator.broadcast);
for (int i = 0; i < broadcasts.length; i++) { for (int i = 0; i < broadcasts.length; i++) {
if (broadcasts[i].startsWith(cast + " - ")) if (broadcasts[i].startsWith(cast + " - "))
select = i; select = i;
@ -350,9 +352,9 @@ public class OptionsFragment extends Fragment {
String item = parent.getItemAtPosition(pos).toString(); String item = parent.getItemAtPosition(pos).toString();
String selection = item.substring(0, item.indexOf(" - ")); String selection = item.substring(0, item.indexOf(" - "));
mPrefs.edit() mPrefs.edit()
.putInt(Config.pref_broadcast, Integer.parseInt(selection)) .putInt(Emulator.pref_broadcast, Integer.parseInt(selection))
.commit(); .commit();
Config.broadcast = Integer.parseInt(selection); Emulator.broadcast = Integer.parseInt(selection);
} }
@ -364,41 +366,41 @@ public class OptionsFragment extends Fragment {
OnCheckedChangeListener limitfps_option = new OnCheckedChangeListener() { OnCheckedChangeListener limitfps_option = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mPrefs.edit().putBoolean(Config.pref_limitfps, isChecked).commit(); mPrefs.edit().putBoolean(Emulator.pref_limitfps, isChecked).commit();
Config.limitfps = isChecked; Emulator.limitfps = isChecked;
} }
}; };
CompoundButton limit_fps = (CompoundButton) getView().findViewById(R.id.limitfps_option); CompoundButton limit_fps = (CompoundButton) getView().findViewById(R.id.limitfps_option);
limit_fps.setChecked(Config.limitfps); limit_fps.setChecked(Emulator.limitfps);
limit_fps.setOnCheckedChangeListener(limitfps_option); limit_fps.setOnCheckedChangeListener(limitfps_option);
OnCheckedChangeListener mipmaps_option = new OnCheckedChangeListener() { OnCheckedChangeListener mipmaps_option = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mPrefs.edit().putBoolean(Config.pref_mipmaps, isChecked).commit(); mPrefs.edit().putBoolean(Emulator.pref_mipmaps, isChecked).commit();
Config.mipmaps = isChecked; Emulator.mipmaps = isChecked;
} }
}; };
CompoundButton mipmap_opt = (CompoundButton) getView().findViewById(R.id.mipmaps_option); CompoundButton mipmap_opt = (CompoundButton) getView().findViewById(R.id.mipmaps_option);
mipmap_opt.setChecked(Config.mipmaps); mipmap_opt.setChecked(Emulator.mipmaps);
mipmap_opt.setOnCheckedChangeListener(mipmaps_option); mipmap_opt.setOnCheckedChangeListener(mipmaps_option);
OnCheckedChangeListener full_screen = new OnCheckedChangeListener() { OnCheckedChangeListener full_screen = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mPrefs.edit().putBoolean(Config.pref_widescreen, isChecked).commit(); mPrefs.edit().putBoolean(Emulator.pref_widescreen, isChecked).commit();
Config.widescreen = isChecked; Emulator.widescreen = isChecked;
} }
}; };
CompoundButton stretch_view = (CompoundButton) getView().findViewById(R.id.stretch_option); CompoundButton stretch_view = (CompoundButton) getView().findViewById(R.id.stretch_option);
stretch_view.setChecked(Config.widescreen); stretch_view.setChecked(Emulator.widescreen);
stretch_view.setOnCheckedChangeListener(full_screen); stretch_view.setOnCheckedChangeListener(full_screen);
final EditText mainFrames = (EditText) getView().findViewById(R.id.current_frames); final EditText mainFrames = (EditText) getView().findViewById(R.id.current_frames);
mainFrames.setText(String.valueOf(Config.frameskip)); mainFrames.setText(String.valueOf(Emulator.frameskip));
final SeekBar frameSeek = (SeekBar) getView().findViewById(R.id.frame_seekbar); final SeekBar frameSeek = (SeekBar) getView().findViewById(R.id.frame_seekbar);
frameSeek.setProgress(Config.frameskip); frameSeek.setProgress(Emulator.frameskip);
frameSeek.setIndeterminate(false); frameSeek.setIndeterminate(false);
frameSeek.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { frameSeek.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
@ -411,8 +413,8 @@ public class OptionsFragment extends Fragment {
public void onStopTrackingTouch(SeekBar seekBar) { public void onStopTrackingTouch(SeekBar seekBar) {
int progress = seekBar.getProgress(); int progress = seekBar.getProgress();
mPrefs.edit().putInt(Config.pref_frameskip, progress).commit(); mPrefs.edit().putInt(Emulator.pref_frameskip, progress).commit();
Config.frameskip = progress; Emulator.frameskip = progress;
} }
}); });
mainFrames.addTextChangedListener(new TextWatcher() { mainFrames.addTextChangedListener(new TextWatcher() {
@ -421,8 +423,8 @@ public class OptionsFragment extends Fragment {
if (frameText != null) { if (frameText != null) {
int frames = Integer.parseInt(frameText); int frames = Integer.parseInt(frameText);
frameSeek.setProgress(frames); frameSeek.setProgress(frames);
mPrefs.edit().putInt(Config.pref_frameskip, frames).commit(); mPrefs.edit().putInt(Emulator.pref_frameskip, frames).commit();
Config.frameskip = frames; Emulator.frameskip = frames;
} }
} }
@ -436,26 +438,26 @@ public class OptionsFragment extends Fragment {
OnCheckedChangeListener pvr_rendering = new OnCheckedChangeListener() { OnCheckedChangeListener pvr_rendering = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mPrefs.edit().putBoolean(Config.pref_pvrrender, isChecked).commit(); mPrefs.edit().putBoolean(Emulator.pref_pvrrender, isChecked).commit();
Config.pvrrender = isChecked; Emulator.pvrrender = isChecked;
} }
}; };
CompoundButton pvr_render = (CompoundButton) getView().findViewById(R.id.render_option); CompoundButton pvr_render = (CompoundButton) getView().findViewById(R.id.render_option);
pvr_render.setChecked(Config.pvrrender); pvr_render.setChecked(Emulator.pvrrender);
pvr_render.setOnCheckedChangeListener(pvr_rendering); pvr_render.setOnCheckedChangeListener(pvr_rendering);
OnCheckedChangeListener synchronous = new OnCheckedChangeListener() { OnCheckedChangeListener synchronous = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mPrefs.edit().putBoolean(Config.pref_syncedrender, isChecked).commit(); mPrefs.edit().putBoolean(Emulator.pref_syncedrender, isChecked).commit();
Config.syncedrender = isChecked; Emulator.syncedrender = isChecked;
} }
}; };
CompoundButton synced_render = (CompoundButton) getView().findViewById(R.id.syncrender_option); CompoundButton synced_render = (CompoundButton) getView().findViewById(R.id.syncrender_option);
synced_render.setChecked(Config.syncedrender); synced_render.setChecked(Emulator.syncedrender);
synced_render.setOnCheckedChangeListener(synchronous); synced_render.setOnCheckedChangeListener(synchronous);
final EditText cheatEdit = (EditText) getView().findViewById(R.id.cheat_disk); final EditText cheatEdit = (EditText) getView().findViewById(R.id.cheat_disk);
String disk = Config.cheatdisk; String disk = Emulator.cheatdisk;
if (disk != null && disk.contains("/")) { if (disk != null && disk.contains("/")) {
cheatEdit.setText(disk.substring(disk.lastIndexOf("/"), cheatEdit.setText(disk.substring(disk.lastIndexOf("/"),
disk.length())); disk.length()));
@ -473,8 +475,8 @@ public class OptionsFragment extends Fragment {
} else { } else {
cheatEdit.setText(disk); cheatEdit.setText(disk);
} }
mPrefs.edit().putString(Config.pref_cheatdisk, disk).commit(); mPrefs.edit().putString(Emulator.pref_cheatdisk, disk).commit();
Config.cheatdisk = disk; Emulator.cheatdisk = disk;
} }
} }
@ -540,11 +542,11 @@ public class OptionsFragment extends Fragment {
OnCheckedChangeListener emu_sound = new OnCheckedChangeListener() { OnCheckedChangeListener emu_sound = new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mPrefs.edit().putBoolean(Config.pref_nosound, isChecked).commit(); mPrefs.edit().putBoolean(Emulator.pref_nosound, isChecked).commit();
Config.nosound = isChecked; Emulator.nosound = isChecked;
} }
}; };
boolean sound = mPrefs.getBoolean(Config.pref_nosound, false); boolean sound = mPrefs.getBoolean(Emulator.pref_nosound, false);
sound_opt.setChecked(sound); sound_opt.setChecked(sound);
sound_opt.setOnCheckedChangeListener(emu_sound); sound_opt.setOnCheckedChangeListener(emu_sound);

View File

@ -27,6 +27,7 @@ import android.view.WindowManager;
import android.widget.Toast; import android.widget.Toast;
import com.android.util.FileUtils; import com.android.util.FileUtils;
import com.reicast.emulator.Emulator;
import com.reicast.emulator.GL2JNIActivity; import com.reicast.emulator.GL2JNIActivity;
import com.reicast.emulator.GL2JNINative; import com.reicast.emulator.GL2JNINative;
import com.reicast.emulator.MainActivity; import com.reicast.emulator.MainActivity;
@ -114,7 +115,7 @@ public class GL2JNIView extends GLSurfaceView
} }
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @TargetApi(Build.VERSION_CODES.HONEYCOMB)
public GL2JNIView(Context context, Config config, String newFileName, public GL2JNIView(Context context, String newFileName,
boolean translucent, int depth, int stencil, boolean editVjoyMode) { boolean translucent, int depth, int stencil, boolean editVjoyMode) {
super(context); super(context);
this.context = context; this.context = context;
@ -151,7 +152,7 @@ public class GL2JNIView extends GLSurfaceView
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
ethd = new EmuThread(!Config.nosound); ethd = new EmuThread(!Emulator.nosound);
touchVibrationEnabled = prefs.getBoolean(Config.pref_touchvibe, true); touchVibrationEnabled = prefs.getBoolean(Config.pref_touchvibe, true);
vibrationDuration = prefs.getInt(Config.pref_vibrationDuration, 20); vibrationDuration = prefs.getInt(Config.pref_vibrationDuration, 20);
@ -172,8 +173,6 @@ public class GL2JNIView extends GLSurfaceView
} }
} }
// config.loadConfigurationPrefs();
vjoy_d_custom = VJoy.readCustomVjoyValues(context); vjoy_d_custom = VJoy.readCustomVjoyValues(context);
scaleGestureDetector = new ScaleGestureDetector(context, new OscOnScaleGestureListener()); scaleGestureDetector = new ScaleGestureDetector(context, new OscOnScaleGestureListener());
@ -181,7 +180,7 @@ public class GL2JNIView extends GLSurfaceView
// This is the game we are going to run // This is the game we are going to run
fileName = newFileName; fileName = newFileName;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD && Config.nativeact) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD && Emulator.nativeact) {
if (GL2JNINative.syms != null) if (GL2JNINative.syms != null)
JNIdc.data(1, GL2JNINative.syms); JNIdc.data(1, GL2JNINative.syms);
} else { } else {

View File

@ -17,6 +17,7 @@ import android.widget.PopupWindow;
import android.widget.ScrollView; import android.widget.ScrollView;
import android.widget.TextView; import android.widget.TextView;
import com.reicast.emulator.Emulator;
import com.reicast.emulator.GL2JNIActivity; import com.reicast.emulator.GL2JNIActivity;
import com.reicast.emulator.GL2JNINative; import com.reicast.emulator.GL2JNINative;
import com.reicast.emulator.MainActivity; import com.reicast.emulator.MainActivity;
@ -39,9 +40,9 @@ public class OnScreenMenu {
private File sdcard = Environment.getExternalStorageDirectory(); private File sdcard = Environment.getExternalStorageDirectory();
private String home_directory = sdcard + "/dc"; private String home_directory = sdcard + "/dc";
private int frames = Config.frameskip; private int frames = Emulator.frameskip;
private boolean screen = Config.widescreen; private boolean screen = Emulator.widescreen;
private boolean limit = Config.limitfps; private boolean limit = Emulator.limitfps;
private boolean audio; private boolean audio;
private boolean masteraudio; private boolean masteraudio;
private boolean boosted = false; private boolean boosted = false;
@ -58,9 +59,9 @@ public class OnScreenMenu {
if (prefs != null) { if (prefs != null) {
this.prefs = prefs; this.prefs = prefs;
home_directory = prefs.getString(Config.pref_home, home_directory); home_directory = prefs.getString(Config.pref_home, home_directory);
masteraudio = !Config.nosound; masteraudio = !Emulator.nosound;
audio = masteraudio; audio = masteraudio;
syncedrender = Config.syncedrender; syncedrender = Emulator.syncedrender;
} }
vmuLcd = new VmuLcd(mContext); vmuLcd = new VmuLcd(mContext);
vmuLcd.setOnClickListener(new OnClickListener() { vmuLcd.setOnClickListener(new OnClickListener() {

View File

@ -7,7 +7,7 @@
</shape> </shape>
</item> </item>
<item> <item>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android" <bitmap
android:gravity="center" android:gravity="center"
app:srcCompat="@drawable/menutile" app:srcCompat="@drawable/menutile"
android:tileMode="repeat" /> android:tileMode="repeat" />

View File

@ -6,7 +6,6 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout
android:id="@+id/childview" android:id="@+id/childview"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -1,49 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/child_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="@+id/childview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_centerInParent="true"
android:clickable="true"
android:focusable="true"
android:background="@drawable/game_selector" >
<ImageView
android:id="@+id/item_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_gravity="center"
android:tint="@color/ice_light"
app:srcCompat="@drawable/ic_folder_black_24dp" />
<TextView
android:id="@+id/item_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-light"
android:paddingBottom="18dp"
android:paddingTop="18dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:textSize="@dimen/primary_text_material"
android:textColor="@color/ice_light"
android:text="@string/disk_loading" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="73dp"
android:background="?android:attr/listDivider"/>
</LinearLayout>