mirror of
https://github.com/libretro/RetroArch
synced 2025-03-31 10:20:41 +00:00
Add Load Game (History) to Android frontend.
Also cleanup core selection list a bit to be more readable.
This commit is contained in:
parent
8ebd81edbf
commit
758dc7e196
@ -16,6 +16,7 @@
|
|||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:hasCode="true">
|
android:hasCode="true">
|
||||||
<activity android:name=".browser.CoreSelection"></activity>
|
<activity android:name=".browser.CoreSelection"></activity>
|
||||||
|
<activity android:name=".browser.HistorySelection"></activity>
|
||||||
<activity android:name=".browser.DisplayRefreshRateTest"></activity>
|
<activity android:name=".browser.DisplayRefreshRateTest"></activity>
|
||||||
<activity android:name=".browser.RefreshRateSetOS"></activity>
|
<activity android:name=".browser.RefreshRateSetOS"></activity>
|
||||||
<activity android:name=".browser.MainMenuActivity">
|
<activity android:name=".browser.MainMenuActivity">
|
||||||
|
@ -1,27 +1,81 @@
|
|||||||
libretro_mednafen_pce_fast = "Mednafen PCE-fast (PC Engine/PC Engine CD)"
|
libretro_mednafen_pce_fast = "Mednafen PCE-fast"
|
||||||
libretro_mednafen_wswan = "Mednafen WSwan (Wonderswan)"
|
libretro_mednafen_pce_fast_system = "PC Engine/PC Engine CD"
|
||||||
libretro_fceumm = "FCEUmm (Nintendo NES)"
|
|
||||||
libretro_mednafen_vb = "Mednafen VB (Virtual Boy)"
|
libretro_mednafen_wswan = "Mednafen WSwan"
|
||||||
libretro_fba = "Final Burn Alpha (Arcade)"
|
libretro_mednafen_wswan_system = "Wonderswan"
|
||||||
libretro_mednafen_ngp = "Mednafen NGP (Neo-Geo Pocket)"
|
|
||||||
libretro_mednafen_psx = "Mednafen PSX (PlayStation1)"
|
libretro_fceumm = "FCEUmm"
|
||||||
libretro_gambatte = "Gambatte (GameBoy/GameBoy Color)"
|
libretro_fceumm_system = "Nintendo NES"
|
||||||
libretro_genesis_plus_gx = "Genesis Plus GX (Sega Genesis/Sega CD/Master System)"
|
|
||||||
libretro_picodrive = "Picodrive (Sega Genesis/Sega CD/Master System/32X)"
|
libretro_mednafen_vb = "Mednafen VB"
|
||||||
libretro_vba_next = "VBA Next (GameBoy Advance)"
|
libretro_mednafen_vb_system = "Virtual Boy"
|
||||||
libretro_prboom = "PrBoom (DOOM)"
|
|
||||||
libretro_snes9x = "SNES9x (Nintendo SNES)"
|
libretro_fba = "Final Burn Alpha"
|
||||||
libretro_snes9x_next = "SNES9x Next (Nintendo SNES)"
|
libretro_fba_system = "Arcade"
|
||||||
libretro_nestopia = "Nestopia (Nintendo NES)"
|
|
||||||
libretro_pcsx_rearmed-neon = "PCSX-reARMed (PlayStation1) [NEON]"
|
libretro_mednafen_ngp = "Mednafen NGP"
|
||||||
libretro_pcsx_rearmed = "PCSX-reARMed (PlayStation1)"
|
libretro_mednafen_ngp_system = "Neo-Geo Pocket"
|
||||||
libretro_nxengine = "NXEngine (Cave Story/Doukutsu Monogatari)"
|
|
||||||
libretro_quicknes = "QuickNES (Nintendo NES)"
|
libretro_mednafen_psx = "Mednafen PSX"
|
||||||
libretro_tyrquake = "TyrQuake (Quake 1)"
|
libretro_mednafen_psx_system = "PlayStation1"
|
||||||
libretro_instancingviewer = "InstancingViewer (Images)"
|
|
||||||
libretro_desmume = "Desmume (Nintendo DS)"
|
libretro_gambatte = "Gambatte"
|
||||||
libretro_stella = "Stella (Atari 2600)"
|
libretro_gambatte_system = "GameBoy/GameBoy Color"
|
||||||
libretro_scenewalker = "SceneWalker (Objects)"
|
|
||||||
libretro_modelviewer = "ModelViewer (Objects)"
|
libretro_genesis_plus_gx = "Genesis Plus GX"
|
||||||
libretro_mame078 = "MAME 2003 [0.78] (Arcade)"
|
libretro_genesis_plus_gx_system = "Sega Genesis/Sega CD/Master System"
|
||||||
libretro_bsnes_performance = "bsnes/higan Performance (Nintendo SNES)"
|
|
||||||
|
libretro_picodrive = "Picodrive"
|
||||||
|
libretro_picodrive_system = "Sega Genesis/Sega CD/Master System/32X"
|
||||||
|
|
||||||
|
libretro_vba_next = "VBA Next"
|
||||||
|
libretro_vba_next_system = "GameBoy Advance"
|
||||||
|
|
||||||
|
libretro_prboom = "PrBoom"
|
||||||
|
libretro_prboom_system = "DOOM"
|
||||||
|
|
||||||
|
libretro_snes9x = "SNES9x"
|
||||||
|
libretro_snes9x_system = "Nintendo SNES"
|
||||||
|
|
||||||
|
libretro_snes9x_next = "SNES9x Next"
|
||||||
|
libretro_snes9x_next_system = "Nintendo SNES"
|
||||||
|
|
||||||
|
libretro_nestopia = "Nestopia"
|
||||||
|
libretro_nestopia_system = "Nintendo NES"
|
||||||
|
|
||||||
|
libretro_pcsx_rearmed-neon = "PCSX-reARMed [NEON]"
|
||||||
|
libretro_pcsx_rearmed-neon_system = "PlayStation1"
|
||||||
|
|
||||||
|
libretro_pcsx_rearmed = "PCSX-reARMed"
|
||||||
|
libretro_pcsx_rearmed_system = "PlayStation1"
|
||||||
|
|
||||||
|
libretro_nxengine = "NXEngine"
|
||||||
|
libretro_nxengine_system = "Cave Story/Doukutsu Monogatari"
|
||||||
|
|
||||||
|
libretro_quicknes = "QuickNES"
|
||||||
|
libretro_quicknes_system = "Nintendo NES"
|
||||||
|
|
||||||
|
libretro_tyrquake = "TyrQuake"
|
||||||
|
libretro_tyrquake_system = "Quake 1"
|
||||||
|
|
||||||
|
libretro_instancingviewer = "InstancingViewer"
|
||||||
|
libretro_instancingviewer_system = "Images"
|
||||||
|
|
||||||
|
libretro_desmume = "Desmume"
|
||||||
|
libretro_desmume_system = "Nintendo DS"
|
||||||
|
|
||||||
|
libretro_stella = "Stella"
|
||||||
|
libretro_stella_system = "Atari 2600"
|
||||||
|
|
||||||
|
libretro_scenewalker = "SceneWalker"
|
||||||
|
libretro_scenewalker_system = "Objects"
|
||||||
|
|
||||||
|
libretro_modelviewer = "ModelViewer"
|
||||||
|
libretro_modelviewer_system = "Objects"
|
||||||
|
|
||||||
|
libretro_mame078 = "MAME 2003 [0.78]"
|
||||||
|
libretro_mame078_system = "Arcade"
|
||||||
|
|
||||||
|
libretro_bsnes_performance = "bsnes/higan Performance"
|
||||||
|
libretro_bsnes_performance_system = "Nintendo SNES"
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="48dp">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/icon"
|
android:id="@+id/icon"
|
||||||
@ -11,13 +11,27 @@
|
|||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
android:contentDescription="@string/file_type_icon"
|
android:contentDescription="@string/file_type_icon"
|
||||||
android:padding="8dp" />
|
android:padding="8dp" />
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:id="@+id/name"
|
android:layout_width="wrap_content"
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_weight="0.5"
|
android:orientation="vertical" >
|
||||||
android:textSize="18sp" />
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/name"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="left"
|
||||||
|
android:textSize="18sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/sub_name"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="left"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:textSize="12sp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -12,6 +12,11 @@
|
|||||||
android:targetClass="org.retroarch.browser.CoreSelection"
|
android:targetClass="org.retroarch.browser.CoreSelection"
|
||||||
android:targetPackage="org.retroarch" />
|
android:targetPackage="org.retroarch" />
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
<PreferenceScreen android:title="Load Game (History)">
|
||||||
|
<intent
|
||||||
|
android:targetClass="org.retroarch.browser.HistorySelection"
|
||||||
|
android:targetPackage="org.retroarch" />
|
||||||
|
</PreferenceScreen>
|
||||||
<PreferenceScreen android:title="Video Options" >
|
<PreferenceScreen android:title="Video Options" >
|
||||||
<PreferenceCategory android:title="General" >
|
<PreferenceCategory android:title="General" >
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
|
@ -28,17 +28,17 @@ public class CoreSelection extends Activity implements
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
ConfigFile core_config;
|
ConfigFile core_config;
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
core_config = new ConfigFile();
|
core_config = new ConfigFile();
|
||||||
try {
|
try {
|
||||||
core_config.append(getAssets().open("libretro_cores.cfg"));
|
core_config.append(getAssets().open("libretro_cores.cfg"));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(TAG, "Failed to load libretro_cores.cfg from assets.");
|
Log.e(TAG, "Failed to load libretro_cores.cfg from assets.");
|
||||||
}
|
}
|
||||||
|
|
||||||
String cpuInfo = MainMenuActivity.readCPUInfo();
|
String cpuInfo = MainMenuActivity.readCPUInfo();
|
||||||
boolean cpuIsNeon = cpuInfo.contains("neon");
|
boolean cpuIsNeon = cpuInfo.contains("neon");
|
||||||
|
|
||||||
setContentView(R.layout.line_list);
|
setContentView(R.layout.line_list);
|
||||||
|
|
||||||
// Setup the list
|
// Setup the list
|
||||||
@ -50,15 +50,16 @@ public class CoreSelection extends Activity implements
|
|||||||
setTitle("Select Libretro core");
|
setTitle("Select Libretro core");
|
||||||
|
|
||||||
// Populate the list
|
// Populate the list
|
||||||
final String modulePath = MainMenuActivity.getInstance().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();
|
||||||
|
|
||||||
// Never append a NEON lib if we don't have NEON.
|
// Never append a NEON lib if we don't have NEON.
|
||||||
if (libName.contains("neon") && !cpuIsNeon)
|
if (libName.contains("neon") && !cpuIsNeon)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// If we have a NEON version with NEON capable CPU,
|
// If we have a NEON version with NEON capable CPU,
|
||||||
// never append a non-NEON version.
|
// never append a non-NEON version.
|
||||||
if (cpuIsNeon && !libName.contains("neon")) {
|
if (cpuIsNeon && !libName.contains("neon")) {
|
||||||
@ -66,18 +67,20 @@ public class CoreSelection extends Activity implements
|
|||||||
for (final File lib_ : libs) {
|
for (final File lib_ : libs) {
|
||||||
String otherName = lib_.getName();
|
String otherName = lib_.getName();
|
||||||
String baseName = libName.replace(".so", "");
|
String baseName = libName.replace(".so", "");
|
||||||
if (otherName.contains("neon") && otherName.startsWith(baseName)) {
|
if (otherName.contains("neon")
|
||||||
|
&& otherName.startsWith(baseName)) {
|
||||||
hasNeonVersion = true;
|
hasNeonVersion = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasNeonVersion)
|
if (hasNeonVersion)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow both libretro-core.so and libretro_core.so.
|
// Allow both libretro-core.so and libretro_core.so.
|
||||||
if (libName.startsWith("libretro") && !libName.startsWith("libretroarch")) {
|
if (libName.startsWith("libretro")
|
||||||
|
&& !libName.startsWith("libretroarch")) {
|
||||||
try {
|
try {
|
||||||
adapter.add(new ModuleWrapper(this, lib, core_config));
|
adapter.add(new ModuleWrapper(this, lib, core_config));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -85,9 +88,9 @@ public class CoreSelection extends Activity implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
|
this.setVolumeControlStream(AudioManager.STREAM_MUSIC);
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
|
||||||
this.registerForContextMenu(findViewById(android.R.id.content));
|
this.registerForContextMenu(findViewById(android.R.id.content));
|
||||||
}
|
}
|
||||||
@ -106,10 +109,12 @@ public class CoreSelection extends Activity implements
|
|||||||
|
|
||||||
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);
|
||||||
|
|
||||||
MainMenuActivity.updateConfigFile();
|
MainMenuActivity.updateConfigFile();
|
||||||
|
MainMenuActivity.waitAssetThread();
|
||||||
|
|
||||||
switch (requestCode) {
|
switch (requestCode) {
|
||||||
case ACTIVITY_LOAD_ROM:
|
case ACTIVITY_LOAD_ROM:
|
||||||
if (data.getStringExtra("PATH") != null) {
|
if (data.getStringExtra("PATH") != null) {
|
||||||
@ -119,14 +124,14 @@ 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", MainMenuActivity.getDefaultConfigPath());
|
myIntent.putExtra("CONFIGFILE",
|
||||||
|
MainMenuActivity.getDefaultConfigPath());
|
||||||
myIntent.putExtra("IME", current_ime);
|
myIntent.putExtra("IME", current_ime);
|
||||||
startActivity(myIntent);
|
startActivity(myIntent);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -137,35 +142,31 @@ public class CoreSelection extends Activity implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void showPopup(View v) {
|
public void showPopup(View v) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||||
{
|
|
||||||
PopupMenuAbstract menu = new PopupMenuAbstract(this, v);
|
PopupMenuAbstract menu = new PopupMenuAbstract(this, v);
|
||||||
MenuInflater inflater = menu.getMenuInflater();
|
MenuInflater inflater = menu.getMenuInflater();
|
||||||
inflater.inflate(R.menu.context_menu, menu.getMenu());
|
inflater.inflate(R.menu.context_menu, menu.getMenu());
|
||||||
menu.setOnMenuItemClickListener(new PopupMenuAbstract.OnMenuItemClickListener()
|
menu.setOnMenuItemClickListener(new PopupMenuAbstract.OnMenuItemClickListener() {
|
||||||
{
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
return onContextItemSelected(item);
|
return onContextItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
menu.show();
|
menu.show();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
this.openContextMenu(findViewById(android.R.id.content));
|
this.openContextMenu(findViewById(android.R.id.content));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreateContextMenu(ContextMenu menu, View v,
|
public void onCreateContextMenu(ContextMenu menu, View v,
|
||||||
ContextMenuInfo menuInfo) {
|
ContextMenuInfo menuInfo) {
|
||||||
super.onCreateContextMenu(menu, v, menuInfo);
|
super.onCreateContextMenu(menu, v, menuInfo);
|
||||||
MenuInflater inflater = getMenuInflater();
|
MenuInflater inflater = getMenuInflater();
|
||||||
inflater.inflate(R.menu.context_menu, menu);
|
inflater.inflate(R.menu.context_menu, menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem aItem) {
|
public boolean onOptionsItemSelected(MenuItem aItem) {
|
||||||
switch (aItem.getItemId()) {
|
switch (aItem.getItemId()) {
|
||||||
@ -177,7 +178,7 @@ public class CoreSelection extends Activity implements
|
|||||||
return super.onOptionsItemSelected(aItem);
|
return super.onOptionsItemSelected(aItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextItemSelected(MenuItem item) {
|
public boolean onContextItemSelected(MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
|
@ -43,6 +43,11 @@ class FileWrapper implements IconAdapterItem {
|
|||||||
else
|
else
|
||||||
return file.getName();
|
return file.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSubText() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getIconResourceId() {
|
public int getIconResourceId() {
|
||||||
|
@ -0,0 +1,83 @@
|
|||||||
|
package org.retroarch.browser;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
|
||||||
|
import org.retroarch.R;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.provider.Settings;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.ListView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
public class HistorySelection extends Activity implements
|
||||||
|
AdapterView.OnItemClickListener {
|
||||||
|
|
||||||
|
private IconAdapter<HistoryWrapper> adapter;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
setContentView(R.layout.line_list);
|
||||||
|
|
||||||
|
// Setup the list
|
||||||
|
adapter = new IconAdapter<HistoryWrapper>(this, R.layout.line_list_item);
|
||||||
|
ListView list = (ListView) findViewById(R.id.list);
|
||||||
|
list.setAdapter(adapter);
|
||||||
|
list.setOnItemClickListener(this);
|
||||||
|
|
||||||
|
setTitle("Recently played games");
|
||||||
|
|
||||||
|
File history = new File(getApplicationInfo().dataDir, "retroarch-history.txt");
|
||||||
|
|
||||||
|
try {
|
||||||
|
BufferedReader br = new BufferedReader(new InputStreamReader(
|
||||||
|
new FileInputStream(history)));
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
String game = br.readLine();
|
||||||
|
String core = br.readLine();
|
||||||
|
String name = br.readLine();
|
||||||
|
if (game == null || core == null || name == null)
|
||||||
|
break;
|
||||||
|
|
||||||
|
adapter.add(new HistoryWrapper(game, core, name));
|
||||||
|
}
|
||||||
|
br.close();
|
||||||
|
} catch (IOException ex) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onItemClick(AdapterView<?> aListView, View aView,
|
||||||
|
int aPosition, long aID) {
|
||||||
|
final HistoryWrapper item = adapter.getItem(aPosition);
|
||||||
|
final String gamePath = item.getGamePath();
|
||||||
|
final String corePath = item.getCorePath();
|
||||||
|
|
||||||
|
Intent myIntent;
|
||||||
|
String current_ime = Settings.Secure.getString(getContentResolver(),
|
||||||
|
Settings.Secure.DEFAULT_INPUT_METHOD);
|
||||||
|
|
||||||
|
MainMenuActivity.updateConfigFile();
|
||||||
|
MainMenuActivity.waitAssetThread();
|
||||||
|
|
||||||
|
Toast.makeText(this, "Loading: [" + gamePath + "] ...",
|
||||||
|
Toast.LENGTH_SHORT).show();
|
||||||
|
myIntent = new Intent(this, RetroActivity.class);
|
||||||
|
myIntent.putExtra("ROM", gamePath);
|
||||||
|
myIntent.putExtra("LIBRETRO", corePath);
|
||||||
|
myIntent.putExtra("CONFIGFILE", MainMenuActivity.getDefaultConfigPath());
|
||||||
|
myIntent.putExtra("IME", current_ime);
|
||||||
|
startActivity(myIntent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,63 @@
|
|||||||
|
package org.retroarch.browser;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
|
||||||
|
public class HistoryWrapper implements IconAdapterItem {
|
||||||
|
|
||||||
|
private String gamePath;
|
||||||
|
private String gamePathShort;
|
||||||
|
private String corePath;
|
||||||
|
private String coreName;
|
||||||
|
|
||||||
|
public HistoryWrapper(String gamePath, String corePath, String coreName) {
|
||||||
|
this.gamePath = gamePath;
|
||||||
|
this.corePath = corePath;
|
||||||
|
this.coreName = coreName;
|
||||||
|
|
||||||
|
File file = new File(gamePath);
|
||||||
|
gamePathShort = file.getName();
|
||||||
|
try {
|
||||||
|
gamePathShort = gamePathShort.substring(0, gamePathShort.lastIndexOf('.'));
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGamePath() {
|
||||||
|
return gamePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCorePath() {
|
||||||
|
return corePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCoreName() {
|
||||||
|
return coreName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getText() {
|
||||||
|
return gamePathShort;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSubText() {
|
||||||
|
return coreName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getIconResourceId() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Drawable getIconDrawable() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -10,11 +10,9 @@ import android.widget.*;
|
|||||||
|
|
||||||
interface IconAdapterItem {
|
interface IconAdapterItem {
|
||||||
public abstract boolean isEnabled();
|
public abstract boolean isEnabled();
|
||||||
|
|
||||||
public abstract String getText();
|
public abstract String getText();
|
||||||
|
public abstract String getSubText();
|
||||||
public abstract int getIconResourceId();
|
public abstract int getIconResourceId();
|
||||||
|
|
||||||
public abstract Drawable getIconDrawable();
|
public abstract Drawable getIconDrawable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,7 +21,6 @@ class IconAdapter<T extends IconAdapterItem> extends ArrayAdapter<T> {
|
|||||||
|
|
||||||
public IconAdapter(Activity aContext, int aLayout) {
|
public IconAdapter(Activity aContext, int aLayout) {
|
||||||
super(aContext, aLayout);
|
super(aContext, aLayout);
|
||||||
|
|
||||||
layout = aLayout;
|
layout = aLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,6 +42,16 @@ class IconAdapter<T extends IconAdapterItem> extends ArrayAdapter<T> {
|
|||||||
textView.setText(item.getText());
|
textView.setText(item.getText());
|
||||||
textView.setEnabled(enabled);
|
textView.setEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
textView = (TextView) aConvertView.findViewById(R.id.sub_name);
|
||||||
|
if (null != textView) {
|
||||||
|
String subText = item.getSubText();
|
||||||
|
if (null != subText) {
|
||||||
|
textView.setVisibility(View.VISIBLE);
|
||||||
|
textView.setEnabled(item.isEnabled());
|
||||||
|
textView.setText(subText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ImageView imageView = (ImageView) aConvertView.findViewById(R.id.icon);
|
ImageView imageView = (ImageView) aConvertView.findViewById(R.id.icon);
|
||||||
if (null != imageView) {
|
if (null != imageView) {
|
||||||
|
@ -24,6 +24,19 @@ import android.widget.Toast;
|
|||||||
public class MainMenuActivity extends PreferenceActivity {
|
public class MainMenuActivity extends PreferenceActivity {
|
||||||
private static MainMenuActivity instance = null;
|
private static MainMenuActivity instance = null;
|
||||||
static private final String TAG = "MainMenu";
|
static private final String TAG = "MainMenu";
|
||||||
|
static private Thread assetThread = null;
|
||||||
|
|
||||||
|
public static void waitAssetThread() {
|
||||||
|
if (assetThread != null) {
|
||||||
|
try {
|
||||||
|
assetThread.join();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
assetThread = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
@ -32,56 +45,62 @@ public class MainMenuActivity extends PreferenceActivity {
|
|||||||
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);
|
||||||
|
|
||||||
// Extracting assets appears to take considerable amount of time, so
|
// Extracting assets appears to take considerable amount of time, so
|
||||||
// move extraction to a thread.
|
// move extraction to a thread.
|
||||||
Thread assetThread = new Thread(new Runnable() {
|
assetThread = new Thread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
extractAssets();
|
extractAssets();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
assetThread.start();
|
assetThread.start();
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
|
SharedPreferences prefs = PreferenceManager
|
||||||
|
.getDefaultSharedPreferences(getBaseContext());
|
||||||
|
|
||||||
if (!prefs.getBoolean("first_time_refreshrate_calculate", false)) {
|
if (!prefs.getBoolean("first_time_refreshrate_calculate", false)) {
|
||||||
prefs.edit().putBoolean("first_time_refreshrate_calculate", true).commit();
|
prefs.edit().putBoolean("first_time_refreshrate_calculate", true)
|
||||||
|
.commit();
|
||||||
if (!detectDevice(false))
|
|
||||||
{
|
if (!detectDevice(false)) {
|
||||||
AlertDialog.Builder alert = new AlertDialog.Builder(this)
|
AlertDialog.Builder alert = new AlertDialog.Builder(this)
|
||||||
.setTitle("Welcome to RetroArch")
|
.setTitle("Welcome to RetroArch")
|
||||||
.setMessage("This is your first time starting up RetroArch. RetroArch will now be preconfigured for the best possible gameplay experience. Please be aware that it might take some time until all shader and overlay assets are extracted...")
|
.setMessage(
|
||||||
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
"This is your first time starting up RetroArch. RetroArch will now be preconfigured for the best possible gameplay experience. Please be aware that it might take some time until all shader and overlay assets are extracted...")
|
||||||
@Override
|
.setPositiveButton("OK",
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
new DialogInterface.OnClickListener() {
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
|
@Override
|
||||||
SharedPreferences.Editor edit = prefs.edit();
|
public void onClick(DialogInterface dialog,
|
||||||
edit.putBoolean("video_threaded", true);
|
int which) {
|
||||||
edit.commit();
|
SharedPreferences prefs = PreferenceManager
|
||||||
}
|
.getDefaultSharedPreferences(getBaseContext());
|
||||||
});
|
SharedPreferences.Editor edit = prefs
|
||||||
alert.show();
|
.edit();
|
||||||
}
|
edit.putBoolean("video_threaded", true);
|
||||||
else
|
edit.commit();
|
||||||
{
|
}
|
||||||
|
});
|
||||||
|
alert.show();
|
||||||
|
} else {
|
||||||
AlertDialog.Builder alert = new AlertDialog.Builder(this)
|
AlertDialog.Builder alert = new AlertDialog.Builder(this)
|
||||||
.setTitle("Welcome to RetroArch")
|
.setTitle("Welcome to RetroArch")
|
||||||
.setMessage("This is your first time starting up RetroArch. Please be aware that it might take some time until all shader and overlay assets are extracted...")
|
.setMessage(
|
||||||
.setPositiveButton("OK", null);
|
"This is your first time starting up RetroArch. Please be aware that it might take some time until all shader and overlay assets are extracted...")
|
||||||
alert.show();
|
.setPositiveButton("OK", null);
|
||||||
|
alert.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MainMenuActivity getInstance() {
|
public static MainMenuActivity getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final double getDisplayRefreshRate() {
|
private final double getDisplayRefreshRate() {
|
||||||
// Android is *very* likely to screw this up.
|
// Android is *very* likely to screw this up.
|
||||||
// It is rarely a good value to use, so make sure it's not
|
// 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
|
// completely wrong. Some phones return refresh rates that are
|
||||||
|
// completely bogus
|
||||||
// (like 0.3 Hz, etc), so try to be very conservative here.
|
// (like 0.3 Hz, etc), so try to be very conservative here.
|
||||||
final WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
|
final WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
|
||||||
final Display display = wm.getDefaultDisplay();
|
final Display display = wm.getDefaultDisplay();
|
||||||
@ -94,7 +113,8 @@ public class MainMenuActivity extends PreferenceActivity {
|
|||||||
public static final double getRefreshRate() {
|
public static final double getRefreshRate() {
|
||||||
double rate = 0;
|
double rate = 0;
|
||||||
SharedPreferences prefs = PreferenceManager
|
SharedPreferences prefs = PreferenceManager
|
||||||
.getDefaultSharedPreferences(MainMenuActivity.getInstance().getBaseContext());
|
.getDefaultSharedPreferences(MainMenuActivity.getInstance()
|
||||||
|
.getBaseContext());
|
||||||
String refresh_rate = prefs.getString("video_refresh_rate", "");
|
String refresh_rate = prefs.getString("video_refresh_rate", "");
|
||||||
if (!refresh_rate.isEmpty()) {
|
if (!refresh_rate.isEmpty()) {
|
||||||
try {
|
try {
|
||||||
@ -106,11 +126,11 @@ public class MainMenuActivity extends PreferenceActivity {
|
|||||||
} else {
|
} else {
|
||||||
rate = MainMenuActivity.getInstance().getDisplayRefreshRate();
|
rate = MainMenuActivity.getInstance().getDisplayRefreshRate();
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.i(TAG, "Using refresh rate: " + rate + " Hz.");
|
Log.i(TAG, "Using refresh rate: " + rate + " Hz.");
|
||||||
return rate;
|
return rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String readCPUInfo() {
|
public static String readCPUInfo() {
|
||||||
String result = "";
|
String result = "";
|
||||||
|
|
||||||
@ -127,28 +147,32 @@ public class MainMenuActivity extends PreferenceActivity {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(17)
|
@TargetApi(17)
|
||||||
public static int getLowLatencyOptimalSamplingRate() {
|
public static int getLowLatencyOptimalSamplingRate() {
|
||||||
AudioManager manager = (AudioManager)MainMenuActivity.getInstance().getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
|
AudioManager manager = (AudioManager) MainMenuActivity.getInstance()
|
||||||
return Integer.parseInt(manager.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE));
|
.getApplicationContext()
|
||||||
|
.getSystemService(Context.AUDIO_SERVICE);
|
||||||
|
return Integer.parseInt(manager
|
||||||
|
.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getOptimalSamplingRate() {
|
public static int getOptimalSamplingRate() {
|
||||||
int ret;
|
int ret;
|
||||||
if (android.os.Build.VERSION.SDK_INT >= 17)
|
if (android.os.Build.VERSION.SDK_INT >= 17)
|
||||||
ret = getLowLatencyOptimalSamplingRate();
|
ret = getLowLatencyOptimalSamplingRate();
|
||||||
else
|
else
|
||||||
ret = AudioTrack.getNativeOutputSampleRate(AudioManager.STREAM_MUSIC);
|
ret = AudioTrack
|
||||||
|
.getNativeOutputSampleRate(AudioManager.STREAM_MUSIC);
|
||||||
|
|
||||||
Log.i(TAG, "Using sampling rate: " + ret + " Hz");
|
Log.i(TAG, "Using sampling rate: " + ret + " Hz");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getDefaultConfigPath() {
|
public static String getDefaultConfigPath() {
|
||||||
String internal = System.getenv("INTERNAL_STORAGE");
|
String internal = System.getenv("INTERNAL_STORAGE");
|
||||||
String external = System.getenv("EXTERNAL_STORAGE");
|
String external = System.getenv("EXTERNAL_STORAGE");
|
||||||
|
|
||||||
if (external != null) {
|
if (external != null) {
|
||||||
String confPath = external + File.separator + "retroarch.cfg";
|
String confPath = external + File.separator + "retroarch.cfg";
|
||||||
if (new File(confPath).exists())
|
if (new File(confPath).exists())
|
||||||
@ -162,17 +186,23 @@ public class MainMenuActivity extends PreferenceActivity {
|
|||||||
if (new File(confPath).exists())
|
if (new File(confPath).exists())
|
||||||
return confPath;
|
return confPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (internal != null && new File(internal + File.separator + "retroarch.cfg").canWrite())
|
if (internal != null
|
||||||
|
&& new File(internal + File.separator + "retroarch.cfg")
|
||||||
|
.canWrite())
|
||||||
return internal + File.separator + "retroarch.cfg";
|
return internal + File.separator + "retroarch.cfg";
|
||||||
else if (external != null && new File(internal + File.separator + "retroarch.cfg").canWrite())
|
else if (external != null
|
||||||
|
&& new File(internal + File.separator + "retroarch.cfg")
|
||||||
|
.canWrite())
|
||||||
return external + File.separator + "retroarch.cfg";
|
return external + File.separator + "retroarch.cfg";
|
||||||
else if ((MainMenuActivity.getInstance().getApplicationInfo().dataDir) != null)
|
else if ((MainMenuActivity.getInstance().getApplicationInfo().dataDir) != null)
|
||||||
return (MainMenuActivity.getInstance().getApplicationInfo().dataDir) + File.separator + "retroarch.cfg";
|
return (MainMenuActivity.getInstance().getApplicationInfo().dataDir)
|
||||||
else // emergency fallback, all else failed
|
+ File.separator + "retroarch.cfg";
|
||||||
|
else
|
||||||
|
// emergency fallback, all else failed
|
||||||
return "/mnt/sd/retroarch.cfg";
|
return "/mnt/sd/retroarch.cfg";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateConfigFile() {
|
public static void updateConfigFile() {
|
||||||
ConfigFile config;
|
ConfigFile config;
|
||||||
try {
|
try {
|
||||||
@ -180,30 +210,55 @@ public class MainMenuActivity extends PreferenceActivity {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
config = new ConfigFile();
|
config = new ConfigFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainMenuActivity.getInstance().getBaseContext());
|
SharedPreferences prefs = PreferenceManager
|
||||||
config.setString("libretro_path", MainMenuActivity.getInstance().getApplicationInfo().nativeLibraryDir);
|
.getDefaultSharedPreferences(MainMenuActivity.getInstance()
|
||||||
config.setBoolean("audio_rate_control", prefs.getBoolean("audio_rate_control", true));
|
.getBaseContext());
|
||||||
config.setInt("audio_out_rate", MainMenuActivity.getOptimalSamplingRate());
|
config.setString("libretro_path", MainMenuActivity.getInstance()
|
||||||
config.setInt("audio_latency", prefs.getBoolean("audio_high_latency", false) ? 160 : 64);
|
.getApplicationInfo().nativeLibraryDir);
|
||||||
config.setBoolean("audio_enable", prefs.getBoolean("audio_enable", true));
|
config.setBoolean("audio_rate_control",
|
||||||
config.setBoolean("video_smooth", prefs.getBoolean("video_smooth", true));
|
prefs.getBoolean("audio_rate_control", true));
|
||||||
config.setBoolean("video_allow_rotate", prefs.getBoolean("video_allow_rotate", true));
|
config.setInt("audio_out_rate",
|
||||||
config.setBoolean("savestate_auto_load", prefs.getBoolean("savestate_auto_load", true));
|
MainMenuActivity.getOptimalSamplingRate());
|
||||||
config.setBoolean("savestate_auto_save", prefs.getBoolean("savestate_auto_save", false));
|
config.setInt("audio_latency",
|
||||||
config.setBoolean("rewind_enable", prefs.getBoolean("rewind_enable", false));
|
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("video_vsync", prefs.getBoolean("video_vsync", true));
|
||||||
config.setBoolean("input_autodetect_enable", prefs.getBoolean("input_autodetect_enable", true));
|
config.setBoolean("input_autodetect_enable",
|
||||||
config.setBoolean("input_debug_enable", prefs.getBoolean("input_debug_enable", false));
|
prefs.getBoolean("input_autodetect_enable", true));
|
||||||
config.setInt("input_back_behavior", Integer.valueOf(prefs.getString("input_back_behavior", "0")));
|
config.setBoolean("input_debug_enable",
|
||||||
config.setInt("input_autodetect_icade_profile_pad1", Integer.valueOf(prefs.getString("input_autodetect_icade_profile_pad1", "0")));
|
prefs.getBoolean("input_debug_enable", false));
|
||||||
config.setInt("input_autodetect_icade_profile_pad2", Integer.valueOf(prefs.getString("input_autodetect_icade_profile_pad2", "0")));
|
config.setInt("input_back_behavior",
|
||||||
config.setInt("input_autodetect_icade_profile_pad3", Integer.valueOf(prefs.getString("input_autodetect_icade_profile_pad3", "0")));
|
Integer.valueOf(prefs.getString("input_back_behavior", "0")));
|
||||||
config.setInt("input_autodetect_icade_profile_pad4", Integer.valueOf(prefs.getString("input_autodetect_icade_profile_pad4", "0")));
|
config.setInt("input_autodetect_icade_profile_pad1", Integer
|
||||||
|
.valueOf(prefs.getString("input_autodetect_icade_profile_pad1",
|
||||||
config.setDouble("video_refresh_rate", MainMenuActivity.getRefreshRate());
|
"0")));
|
||||||
config.setBoolean("video_threaded", prefs.getBoolean("video_threaded", true));
|
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");
|
String aspect = prefs.getString("video_aspect_ratio", "auto");
|
||||||
if (aspect.equals("full")) {
|
if (aspect.equals("full")) {
|
||||||
config.setBoolean("video_force_aspect", false);
|
config.setBoolean("video_force_aspect", false);
|
||||||
@ -220,9 +275,10 @@ public class MainMenuActivity extends PreferenceActivity {
|
|||||||
config.setBoolean("video_force_aspect", true);
|
config.setBoolean("video_force_aspect", true);
|
||||||
config.setDouble("video_aspect_ratio", aspect_ratio);
|
config.setDouble("video_aspect_ratio", aspect_ratio);
|
||||||
}
|
}
|
||||||
|
|
||||||
config.setBoolean("video_scale_integer", prefs.getBoolean("video_scale_integer", false));
|
config.setBoolean("video_scale_integer",
|
||||||
|
prefs.getBoolean("video_scale_integer", false));
|
||||||
|
|
||||||
String shaderPath = prefs.getString("video_shader", "");
|
String shaderPath = prefs.getString("video_shader", "");
|
||||||
config.setString("video_shader", shaderPath);
|
config.setString("video_shader", shaderPath);
|
||||||
config.setBoolean("video_shader_enable",
|
config.setBoolean("video_shader_enable",
|
||||||
@ -231,28 +287,42 @@ public class MainMenuActivity extends PreferenceActivity {
|
|||||||
|
|
||||||
boolean useOverlay = prefs.getBoolean("input_overlay_enable", true);
|
boolean useOverlay = prefs.getBoolean("input_overlay_enable", true);
|
||||||
if (useOverlay) {
|
if (useOverlay) {
|
||||||
String overlayPath = prefs.getString("input_overlay", (MainMenuActivity.getInstance().getApplicationInfo().dataDir) + "/overlays/snes-landscape.cfg");
|
String overlayPath = prefs
|
||||||
|
.getString("input_overlay", (MainMenuActivity.getInstance()
|
||||||
|
.getApplicationInfo().dataDir)
|
||||||
|
+ "/overlays/snes-landscape.cfg");
|
||||||
config.setString("input_overlay", overlayPath);
|
config.setString("input_overlay", overlayPath);
|
||||||
config.setDouble("input_overlay_opacity", prefs.getFloat("input_overlay_opacity", 1.0f));
|
config.setDouble("input_overlay_opacity",
|
||||||
|
prefs.getFloat("input_overlay_opacity", 1.0f));
|
||||||
} else {
|
} else {
|
||||||
config.setString("input_overlay", "");
|
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));
|
||||||
|
|
||||||
config.setString("savefile_directory", prefs.getBoolean("savefile_directory_enable", false) ?
|
config.setString("game_history_path", MainMenuActivity.getInstance().getApplicationInfo().dataDir + "/retroarch-history.txt");
|
||||||
prefs.getString("savefile_directory", "") : "");
|
|
||||||
config.setString("savestate_directory", prefs.getBoolean("savestate_directory_enable", false) ?
|
for (int i = 1; i <= 4; i++) {
|
||||||
prefs.getString("savestate_directory", "") : "");
|
final String btns[] = { "up", "down", "left", "right", "a", "b",
|
||||||
config.setString("system_directory", prefs.getBoolean("system_directory_enable", false) ?
|
"x", "y", "start", "select", "l", "r", "l2", "r2", "l3",
|
||||||
prefs.getString("system_directory", "") : "");
|
"r3" };
|
||||||
|
for (String b : btns) {
|
||||||
config.setBoolean("video_font_enable", prefs.getBoolean("video_font_enable", true));
|
String p = "input_player" + String.valueOf(i) + "_" + b
|
||||||
|
+ "_btn";
|
||||||
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));
|
config.setInt(p, prefs.getInt(p, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -264,7 +334,7 @@ public class MainMenuActivity extends PreferenceActivity {
|
|||||||
Log.e(TAG, "Failed to save config file to: " + confPath);
|
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);
|
||||||
@ -273,22 +343,24 @@ public class MainMenuActivity extends PreferenceActivity {
|
|||||||
stream.read(buf, 0, len);
|
stream.read(buf, 0, len);
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void extractAssets(AssetManager manager, String dataDir, String relativePath, int level) throws IOException {
|
private void extractAssets(AssetManager manager, String dataDir,
|
||||||
|
String relativePath, int level) throws IOException {
|
||||||
final String[] paths = manager.list(relativePath);
|
final String[] paths = manager.list(relativePath);
|
||||||
if (paths != null && paths.length > 0) { // Directory
|
if (paths != null && paths.length > 0) { // Directory
|
||||||
//Log.d(TAG, "Extracting assets directory: " + relativePath);
|
// Log.d(TAG, "Extracting assets directory: " + relativePath);
|
||||||
for (final String path : paths)
|
for (final String path : paths)
|
||||||
extractAssets(manager, dataDir, relativePath + (level > 0 ? File.separator : "") + path, level + 1);
|
extractAssets(manager, dataDir, relativePath
|
||||||
|
+ (level > 0 ? File.separator : "") + path, level + 1);
|
||||||
} else { // File, extract.
|
} else { // File, extract.
|
||||||
//Log.d(TAG, "Extracting assets file: " + relativePath);
|
// Log.d(TAG, "Extracting assets file: " + relativePath);
|
||||||
|
|
||||||
String parentPath = new File(relativePath).getParent();
|
String parentPath = new File(relativePath).getParent();
|
||||||
if (parentPath != null) {
|
if (parentPath != null) {
|
||||||
File parentFile = new File(dataDir, parentPath);
|
File parentFile = new File(dataDir, parentPath);
|
||||||
parentFile.mkdirs(); // Doesn't throw.
|
parentFile.mkdirs(); // Doesn't throw.
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] asset = loadAsset(relativePath);
|
byte[] asset = loadAsset(relativePath);
|
||||||
BufferedOutputStream writer = new BufferedOutputStream(
|
BufferedOutputStream writer = new BufferedOutputStream(
|
||||||
new FileOutputStream(new File(dataDir, relativePath)));
|
new FileOutputStream(new File(dataDir, relativePath)));
|
||||||
@ -298,128 +370,146 @@ public class MainMenuActivity extends PreferenceActivity {
|
|||||||
writer.close();
|
writer.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void extractAssets() {
|
private void extractAssets() {
|
||||||
int version = 0;
|
int version = 0;
|
||||||
try {
|
try {
|
||||||
version = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
|
version = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
|
||||||
} catch(NameNotFoundException e) {
|
} catch (NameNotFoundException e) {
|
||||||
// weird exception, shouldn't happen
|
// weird exception, shouldn't happen
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
AssetManager assets = getAssets();
|
AssetManager assets = getAssets();
|
||||||
String dataDir = getApplicationInfo().dataDir;
|
String dataDir = getApplicationInfo().dataDir;
|
||||||
File cacheVersion = new File(dataDir, ".cacheversion");
|
File cacheVersion = new File(dataDir, ".cacheversion");
|
||||||
if (cacheVersion != null && cacheVersion.isFile() && cacheVersion.canRead() && cacheVersion.canWrite())
|
if (cacheVersion != null && cacheVersion.isFile()
|
||||||
{
|
&& cacheVersion.canRead() && cacheVersion.canWrite()) {
|
||||||
DataInputStream cacheStream = new DataInputStream(new FileInputStream(cacheVersion));
|
DataInputStream cacheStream = new DataInputStream(
|
||||||
|
new FileInputStream(cacheVersion));
|
||||||
|
|
||||||
int currentCacheVersion = 0;
|
int currentCacheVersion = 0;
|
||||||
try {
|
try {
|
||||||
currentCacheVersion = cacheStream.readInt();
|
currentCacheVersion = cacheStream.readInt();
|
||||||
} catch (IOException e) {}
|
} catch (IOException e) {
|
||||||
cacheStream.close();
|
}
|
||||||
|
cacheStream.close();
|
||||||
if (currentCacheVersion == version)
|
|
||||||
{
|
if (currentCacheVersion == version) {
|
||||||
Log.i("ASSETS", "Assets already extracted, skipping...");
|
Log.i("ASSETS", "Assets already extracted, skipping...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//extractAssets(assets, cacheDir, "", 0);
|
// extractAssets(assets, cacheDir, "", 0);
|
||||||
Log.i("ASSETS", "Extracting shader assets now ...");
|
Log.i("ASSETS", "Extracting shader assets now ...");
|
||||||
try {
|
try {
|
||||||
extractAssets(assets, dataDir, "shaders_glsl", 1);
|
extractAssets(assets, dataDir, "shaders_glsl", 1);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.i("ASSETS", "Failed to extract shaders ...");
|
Log.i("ASSETS", "Failed to extract shaders ...");
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.i("ASSETS", "Extracting overlay assets now ...");
|
Log.i("ASSETS", "Extracting overlay assets now ...");
|
||||||
try {
|
try {
|
||||||
extractAssets(assets, dataDir, "overlays", 1);
|
extractAssets(assets, dataDir, "overlays", 1);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.i("ASSETS", "Failed to extract overlays ...");
|
Log.i("ASSETS", "Failed to extract overlays ...");
|
||||||
}
|
}
|
||||||
|
|
||||||
DataOutputStream outputCacheVersion = new DataOutputStream(new FileOutputStream(cacheVersion, false));
|
DataOutputStream outputCacheVersion = new DataOutputStream(
|
||||||
|
new FileOutputStream(cacheVersion, false));
|
||||||
outputCacheVersion.writeInt(version);
|
outputCacheVersion.writeInt(version);
|
||||||
outputCacheVersion.close();
|
outputCacheVersion.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(TAG, "Failed to extract assets to cache.");
|
Log.e(TAG, "Failed to extract assets to cache.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean detectDevice(boolean show_dialog)
|
boolean detectDevice(boolean show_dialog) {
|
||||||
{
|
|
||||||
boolean retval = false;
|
boolean retval = false;
|
||||||
|
|
||||||
Log.i("Device MODEL", android.os.Build.MODEL);
|
Log.i("Device MODEL", android.os.Build.MODEL);
|
||||||
if (android.os.Build.MODEL.equals("SHIELD"))
|
if (android.os.Build.MODEL.equals("SHIELD")) {
|
||||||
{
|
|
||||||
AlertDialog.Builder alert = new AlertDialog.Builder(this)
|
AlertDialog.Builder alert = new AlertDialog.Builder(this)
|
||||||
.setTitle("NVidia Shield detected")
|
.setTitle("NVidia Shield detected")
|
||||||
.setMessage("The ideal configuration options for your device will now be preconfigured.\nNOTE: For optimal performance, turn off Google Account sync, Google Play Store auto-updates, GPS and Wifi in your Android settings menu.")
|
.setMessage(
|
||||||
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
"The ideal configuration options for your device will now be preconfigured.\nNOTE: For optimal performance, turn off Google Account sync, Google Play Store auto-updates, GPS and Wifi in your Android settings menu.")
|
||||||
@Override
|
.setPositiveButton("OK",
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
new DialogInterface.OnClickListener() {
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
|
@Override
|
||||||
SharedPreferences.Editor edit = prefs.edit();
|
public void onClick(DialogInterface dialog,
|
||||||
edit.putString("video_refresh_rate", Double.valueOf(60.00d).toString());
|
int which) {
|
||||||
edit.putBoolean("input_overlay_enable", false);
|
SharedPreferences prefs = PreferenceManager
|
||||||
edit.putBoolean("input_autodetect_enable", true);
|
.getDefaultSharedPreferences(getBaseContext());
|
||||||
edit.commit();
|
SharedPreferences.Editor edit = prefs
|
||||||
}
|
.edit();
|
||||||
});
|
edit.putString("video_refresh_rate", Double
|
||||||
|
.valueOf(60.00d).toString());
|
||||||
|
edit.putBoolean("input_overlay_enable",
|
||||||
|
false);
|
||||||
|
edit.putBoolean("input_autodetect_enable",
|
||||||
|
true);
|
||||||
|
edit.commit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
alert.show();
|
||||||
|
retval = true;
|
||||||
|
} else if (android.os.Build.MODEL.equals("OUYA Console")) {
|
||||||
|
AlertDialog.Builder alert = new AlertDialog.Builder(this)
|
||||||
|
.setTitle("OUYA detected")
|
||||||
|
.setMessage(
|
||||||
|
"The ideal configuration options for your device will now be preconfigured.\nNOTE: For optimal performance, turn off Google Account sync, GPS and Wifi in your Android settings menu.")
|
||||||
|
.setPositiveButton("OK",
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog,
|
||||||
|
int which) {
|
||||||
|
SharedPreferences prefs = PreferenceManager
|
||||||
|
.getDefaultSharedPreferences(getBaseContext());
|
||||||
|
SharedPreferences.Editor edit = prefs
|
||||||
|
.edit();
|
||||||
|
edit.putBoolean("input_overlay_enable",
|
||||||
|
false);
|
||||||
|
edit.putBoolean("input_autodetect_enable",
|
||||||
|
true);
|
||||||
|
edit.commit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
alert.show();
|
||||||
|
retval = true;
|
||||||
|
} else if (android.os.Build.ID.equals("JSS15J")) {
|
||||||
|
AlertDialog.Builder alert = new AlertDialog.Builder(this)
|
||||||
|
.setTitle("Nexus 7 2013 detected")
|
||||||
|
.setMessage(
|
||||||
|
"The ideal configuration options for your device will now be preconfigured.\nNOTE: For optimal performance, turn off Google Account sync, Google Play Store auto-updates, GPS and Wifi in your Android settings menu.")
|
||||||
|
.setPositiveButton("OK",
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog,
|
||||||
|
int which) {
|
||||||
|
SharedPreferences prefs = PreferenceManager
|
||||||
|
.getDefaultSharedPreferences(getBaseContext());
|
||||||
|
SharedPreferences.Editor edit = prefs
|
||||||
|
.edit();
|
||||||
|
edit.putString("video_refresh_rate", Double
|
||||||
|
.valueOf(59.65).toString());
|
||||||
|
edit.commit();
|
||||||
|
}
|
||||||
|
});
|
||||||
alert.show();
|
alert.show();
|
||||||
retval = true;
|
retval = true;
|
||||||
}
|
}
|
||||||
else if (android.os.Build.MODEL.equals( "OUYA Console"))
|
|
||||||
{
|
|
||||||
AlertDialog.Builder alert = new AlertDialog.Builder(this)
|
|
||||||
.setTitle("OUYA detected")
|
|
||||||
.setMessage("The ideal configuration options for your device will now be preconfigured.\nNOTE: For optimal performance, turn off Google Account sync, GPS and Wifi in your Android settings menu.")
|
|
||||||
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
|
|
||||||
SharedPreferences.Editor edit = prefs.edit();
|
|
||||||
edit.putBoolean("input_overlay_enable", false);
|
|
||||||
edit.putBoolean("input_autodetect_enable", true);
|
|
||||||
edit.commit();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
alert.show();
|
|
||||||
retval = true;
|
|
||||||
}
|
|
||||||
else if (android.os.Build.ID.equals("JSS15J"))
|
|
||||||
{
|
|
||||||
AlertDialog.Builder alert = new AlertDialog.Builder(this)
|
|
||||||
.setTitle("Nexus 7 2013 detected")
|
|
||||||
.setMessage("The ideal configuration options for your device will now be preconfigured.\nNOTE: For optimal performance, turn off Google Account sync, Google Play Store auto-updates, GPS and Wifi in your Android settings menu.")
|
|
||||||
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
|
|
||||||
SharedPreferences.Editor edit = prefs.edit();
|
|
||||||
edit.putString("video_refresh_rate", Double.valueOf(59.65).toString());
|
|
||||||
edit.commit();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
alert.show();
|
|
||||||
retval = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (show_dialog) {
|
if (show_dialog) {
|
||||||
Toast.makeText(this,
|
Toast.makeText(
|
||||||
"Device either not detected in list or doesn't have any optimal settings in our database.",
|
this,
|
||||||
Toast.LENGTH_SHORT).show();
|
"Device either not detected in list or doesn't have any optimal settings in our database.",
|
||||||
|
Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
|
@ -28,6 +28,15 @@ class ModuleWrapper implements IconAdapterItem {
|
|||||||
} else
|
} else
|
||||||
return stripped;
|
return stripped;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSubText() {
|
||||||
|
String stripped = file.getName().replace(".so", "") + "_system";
|
||||||
|
if (config.keyExists(stripped)) {
|
||||||
|
return config.getString(stripped);
|
||||||
|
} else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getIconResourceId() {
|
public int getIconResourceId() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user