diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/Emulator.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/Emulator.java index 916cdc2b0..35b24f75b 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/Emulator.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/Emulator.java @@ -2,9 +2,7 @@ package com.reicast.emulator; import android.app.Activity; 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; @@ -110,27 +108,16 @@ public class Emulator extends Application { JNIdc.dreamtime(DreamTime.getDreamtime()); } - public void getGameConfiguration(String gameId) { + public void loadGameConfiguration(String gameId) { SharedPreferences mPrefs = getSharedPreferences(gameId, Activity.MODE_PRIVATE); - Emulator.unstableopt = mPrefs.getBoolean(pref_unstable, unstableopt); - Emulator.dynsafemode = mPrefs.getBoolean(pref_dynsafemode, dynsafemode); - Emulator.interrupt = mPrefs.getBoolean(pref_interrupt, interrupt); - Emulator.frameskip = mPrefs.getInt(pref_frameskip, frameskip); - Emulator.pvrrender = mPrefs.getBoolean(pref_pvrrender, pvrrender); - Emulator.syncedrender = mPrefs.getBoolean(pref_syncedrender, syncedrender); - Emulator.queuerender = mPrefs.getBoolean(pref_queuerender, queuerender); - Emulator.modvols = mPrefs.getBoolean(pref_modvols, modvols); - } - - public void loadGameConfiguration() { - JNIdc.unstable(Emulator.unstableopt ? 1 : 0); - JNIdc.safemode(Emulator.dynsafemode ? 1 : 0); - JNIdc.interrupthack(Emulator.interrupt ? 1 : 0); - JNIdc.frameskip(Emulator.frameskip); - JNIdc.pvrrender(Emulator.pvrrender ? 1 : 0); - JNIdc.syncedrender(Emulator.syncedrender ? 1 : 0); - JNIdc.queuerender(Emulator.queuerender ? 1 : 0); - JNIdc.modvols(Emulator.modvols ? 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); + JNIdc.frameskip(mPrefs.getInt(pref_frameskip, frameskip)); + JNIdc.pvrrender(mPrefs.getBoolean(pref_pvrrender, pvrrender) ? 1 : 0); + JNIdc.syncedrender(mPrefs.getBoolean(pref_syncedrender, syncedrender) ? 1 : 0); + JNIdc.queuerender(mPrefs.getBoolean(pref_queuerender, queuerender) ? 1 : 0); + JNIdc.modvols(mPrefs.getBoolean(pref_modvols, modvols) ? 1 : 0); } static { diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/Config.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/Config.java index cb526be8c..d0b21c1b0 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/Config.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/Config.java @@ -17,6 +17,8 @@ public class Config { public static final String pref_touchvibe = "touch_vibration_enabled"; public static final String pref_vibrationDuration = "vibration_duration"; + public static final String game_title = "game_title"; + public static int vibrationDuration = 20; public static final String pref_vmu = "vmu_floating"; diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/InputModFragment.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/InputModFragment.java index 7267135f4..55c25a90b 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/InputModFragment.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/InputModFragment.java @@ -60,6 +60,8 @@ public class InputModFragment extends Fragment { private TextView dpad_right_text; private TextView start_button_text; private TextView select_button_text; + private TextView vert_axis_text; + private TextView horz_axis_text; private String player = "_A"; private int sS = 2; @@ -518,43 +520,22 @@ public class InputModFragment extends Fragment { return keyCode; } - public boolean dispatchTouchEvent(MotionEvent ev) { + private void mapAxis(View view, final int axis) { if (isMapping) { - if ((ev.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) { - if (ev.getAxisValue(MotionEvent.AXIS_HAT_X) != 0) { - + view.setOnGenericMotionListener(new View.OnGenericMotionListener() { + @Override + public boolean onGenericMotion(View view, MotionEvent event) { + if ((event.getSource() & InputDevice.SOURCE_JOYSTICK) == + InputDevice.SOURCE_JOYSTICK && + event.getAction() == MotionEvent.ACTION_MOVE) { + mPrefs.edit().putInt(axis + player, event.getActionIndex ()).apply(); + isMapping = false; + return true; + } + return false; } - if (ev.getAxisValue(MotionEvent.AXIS_HAT_Y) != 0) { - - } - if (ev.getAxisValue(MotionEvent.AXIS_Z) != 0) { - - } - if (ev.getAxisValue(MotionEvent.AXIS_RZ) != 0) { - - } - if (ev.getAxisValue(MotionEvent.AXIS_RTRIGGER) != 0) { - - } - if (ev.getAxisValue(MotionEvent.AXIS_LTRIGGER) != 0) { - - } - if (ev.getAxisValue(MotionEvent.AXIS_THROTTLE) != 0) { - - } - if (ev.getAxisValue(MotionEvent.AXIS_BRAKE) != 0) { - - } - String label = output.getText().toString(); - if (label.contains(":")) { - label = label.substring(0, label.indexOf(":")); - } - - output.setText(label + ": " + ev.getAction()); - } - + }); } - return dispatchTouchEvent(ev); } } diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/PGConfigFragment.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/PGConfigFragment.java index 01f32f846..562b00788 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/PGConfigFragment.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/PGConfigFragment.java @@ -1,9 +1,7 @@ package com.reicast.emulator.config; import android.app.Activity; -import android.app.AlertDialog; import android.content.Context; -import android.content.DialogInterface; import android.content.SharedPreferences; import android.graphics.drawable.Drawable; import android.os.AsyncTask; @@ -16,6 +14,7 @@ import android.support.graphics.drawable.VectorDrawableCompat; import android.support.v4.app.Fragment; import android.text.Editable; import android.text.TextWatcher; +import android.util.Log; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; @@ -24,7 +23,6 @@ import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.CompoundButton; -import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.EditText; import android.widget.SeekBar; import android.widget.SeekBar.OnSeekBarChangeListener; @@ -35,15 +33,8 @@ import com.android.util.FileUtils; import com.reicast.emulator.Emulator; import com.reicast.emulator.R; -import org.apache.commons.lang3.StringUtils; - -import java.io.BufferedReader; import java.io.File; -import java.io.FileNotFoundException; import java.io.FilenameFilter; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; import java.lang.ref.WeakReference; import java.util.Collection; import java.util.HashMap; @@ -88,8 +79,8 @@ public class PGConfigFragment extends Fragment { app.getConfigurationPrefs(PreferenceManager.getDefaultSharedPreferences(getActivity())); mSpnrConfigs = (Spinner) getView().findViewById(R.id.config_spinner); - new LocateConfigs(PGConfigFragment.this).execute( - getActivity().getFilesDir().getAbsolutePath()); + new LocateConfigs(PGConfigFragment.this).execute("/data/data/" + + getActivity().getPackageName() + "/shared_prefs/"); unstable_opt = (CompoundButton) getView().findViewById(R.id.unstable_option); safemode_opt = (CompoundButton) getView().findViewById(R.id.dynarec_safemode); @@ -179,21 +170,13 @@ public class PGConfigFragment extends Fragment { @Override protected List doInBackground(String... paths) { File storage = new File(paths[0]); - String[] mediaTypes = options.get().getResources().getStringArray(R.array.configs); - FilenameFilter[] filter = new FilenameFilter[mediaTypes.length]; - int i = 0; - for (final String type : mediaTypes) { - filter[i] = new FilenameFilter() { - public boolean accept(File dir, String name) { - if (dir.getName().startsWith(".") || name.startsWith(".")) { - return false; - } else { - return StringUtils.endsWithIgnoreCase(name, "." + type); - } - } - }; - i++; - } + Log.d("Files", storage.getAbsolutePath()); + FilenameFilter[] filter = new FilenameFilter[1]; + filter[0] = new FilenameFilter() { + public boolean accept(File dir, String name) { + return !name.endsWith("_preferences.xml"); + } + }; FileUtils fileUtils = new FileUtils(); Collection files = fileUtils.listFiles(storage, filter, 0); return (List) files; @@ -206,26 +189,11 @@ public class PGConfigFragment extends Fragment { String[] titles = new String[items.size()]; for (int i = 0; i < items.size(); i ++) { String filename = items.get(i).getName(); - try { - InputStream iS = options.get().getActivity().openFileInput(filename); - - if (iS != null) { - InputStreamReader iSR = new InputStreamReader(iS); - BufferedReader bR = new BufferedReader(iSR); - String readString = ""; - StringBuilder stringBuilder = new StringBuilder(); - - while ( (readString = bR.readLine()) != null ) { - stringBuilder.append(readString); - } - - iS.close(); - titles[i] = stringBuilder.toString(); - gameMap.put(titles[i], filename.substring(0, filename.length() - 4)); - } - } catch (IOException e) { - // TODO: Appropriate error message - } + String gameFile = filename.substring(0, filename.length() - 4); + SharedPreferences mPrefs = options.get().getActivity() + .getSharedPreferences(gameFile, Activity.MODE_PRIVATE); + titles[i] = mPrefs.getString(Config.game_title, "Title Unavailable"); + gameMap.put(titles[i], gameFile); } ArrayAdapter configAdapter = new ArrayAdapter( options.get().getActivity(), android.R.layout.simple_spinner_item, titles); diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/emu/GL2JNIView.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/emu/GL2JNIView.java index 723c8befe..f700a8cde 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/emu/GL2JNIView.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/emu/GL2JNIView.java @@ -32,8 +32,6 @@ import com.reicast.emulator.config.Config; import com.reicast.emulator.emu.OnScreenMenu.FpsPopup; import com.reicast.emulator.periph.VJoy; -import java.io.IOException; -import java.io.OutputStreamWriter; import java.io.UnsupportedEncodingException; import javax.microedition.khronos.egl.EGLConfig; @@ -678,18 +676,10 @@ public class GL2JNIView extends GLSurfaceView void reiosInfo(String reiosId, String reiosSoftware) { String gameId = reiosId.replaceAll("[^a-zA-Z0-9]+", "").toLowerCase(); - try { - OutputStreamWriter outputStreamWriter = new OutputStreamWriter( - context.openFileOutput(gameId + ".pgc", Context.MODE_PRIVATE)); - outputStreamWriter.write(reiosSoftware); - outputStreamWriter.close(); - } - catch (IOException e) { - Log.e("Exception", "File write failed: " + e.toString()); - } + SharedPreferences mPrefs = context.getSharedPreferences(gameId, Activity.MODE_PRIVATE); Emulator app = (Emulator) context.getApplicationContext(); - app.getGameConfiguration(gameId); - app.loadGameConfiguration(); + app.loadGameConfiguration(gameId); + mPrefs.edit().putString(Config.game_title, reiosSoftware.trim()).apply(); } } diff --git a/shell/android-studio/reicast/src/main/res/values/donottranslate.xml b/shell/android-studio/reicast/src/main/res/values/donottranslate.xml index 9feed5f46..a3a960853 100644 --- a/shell/android-studio/reicast/src/main/res/values/donottranslate.xml +++ b/shell/android-studio/reicast/src/main/res/values/donottranslate.xml @@ -9,7 +9,7 @@ 24 32 - + bin @@ -63,10 +63,6 @@ K - - pgc - - None VMU