(Android) Add Report Refresh Rate (Java)

This commit is contained in:
twinaphex 2013-02-04 00:15:51 +01:00
parent bc28ccbaad
commit 00a8ceab7e
3 changed files with 16 additions and 10 deletions

View File

@ -2,7 +2,9 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/rarch_settings" android:title="@string/rarch_settings" android:showAsAction="ifRoom" />
<item android:id="@+id/input_method_select" android:title="@string/input_method" android:showAsAction="ifRoom" />
<item android:id="@+id/report_ime" android:title="@string/report_ime"></item><item android:id="@+id/retroarch_guide" android:title="@string/retroarch_guide"></item>
<item android:id="@+id/report_ime" android:title="@string/report_ime"></item>
<item android:id="@+id/report_refreshrate" android:title="@string/report_refreshrate"></item>
<item android:id="@+id/retroarch_guide" android:title="@string/retroarch_guide"></item>
<item android:id="@+id/cores_guide" android:title="@string/cores_guide"></item>
<item android:id="@+id/overlay_guide" android:title="@string/overlay_guide"></item>
<item android:id="@+id/shader_pack" android:title="@string/shader_pack"></item>

View File

@ -16,6 +16,7 @@
<string name="key_bind_title">Select the button to use</string>
<string name="key_bind_clear">Unbind</string>
<string name="report_ime">Report IME</string>
<string name="report_refreshrate">Report Refresh Rate</string>
<string name="key_bind_detect">Detect</string>
</resources>

View File

@ -60,6 +60,7 @@ public class RetroArch extends Activity implements
private IconAdapter<ModuleWrapper> adapter;
static private final int ACTIVITY_LOAD_ROM = 0;
static private String libretro_path;
static private Double report_refreshrate;
static private final String TAG = "RetroArch-Phoenix";
private ConfigFile config;
private ConfigFile core_config;
@ -147,9 +148,9 @@ public class RetroArch extends Activity implements
}
private void extractAssets() {
long version = 0;
int version = 0;
try {
version = getPackageManager().getPackageInfo(getPackageName(), 0).lastUpdateTime;
version = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
} catch(NameNotFoundException e) {
// weird exception, shouldn't happen
}
@ -162,13 +163,10 @@ public class RetroArch extends Activity implements
{
DataInputStream cacheStream = new DataInputStream(new FileInputStream(cacheVersion));
long currentCacheVersion = 0;
try {
currentCacheVersion = cacheStream.readLong();
} catch (IOException e) {}
int curretnCacheVersion = cacheStream.readInt();
cacheStream.close();
if (currentCacheVersion == version)
if (curretnCacheVersion == version)
{
Log.i(TAG, "assets already extracted, skipping");
return;
@ -178,8 +176,8 @@ public class RetroArch extends Activity implements
//extractAssets(assets, cacheDir, "Shaders", 1);
extractAssets(assets, cacheDir, "Overlays", 1);
DataOutputStream outputCacheVersion = new DataOutputStream(new FileOutputStream(cacheVersion, false));
outputCacheVersion.writeLong(version);
DataOutputStream outputCacheVersion = new DataOutputStream(new FileOutputStream(cacheVersion));
outputCacheVersion.writeInt(version);
outputCacheVersion.close();
} catch (IOException e) {
Log.e(TAG, "Failed to extract assets to cache.");
@ -206,6 +204,7 @@ public class RetroArch extends Activity implements
String cpuInfo = readCPUInfo();
boolean cpuIsNeon = cpuInfoIsNeon(cpuInfo);
report_refreshrate = getRefreshRate();
// Extracting assets appears to take considerable amount of time, so
// move extraction to a thread.
@ -492,6 +491,10 @@ public class RetroArch extends Activity implements
String current_ime = Settings.Secure.getString(getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
new AlertDialog.Builder(this).setMessage(current_ime).setNeutralButton("Close", null).show();
return true;
case R.id.report_refreshrate:
String current_rate = "Screen Refresh Rate: " + new Double(report_refreshrate).toString();
new AlertDialog.Builder(this).setMessage(current_rate).setNeutralButton("Close", null).show();
return true;
case R.id.retroarch_guide:
Intent rguide = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.libretro.org/documents/retroarch-manual.pdf"));