mirror of
https://github.com/libretro/RetroArch
synced 2025-04-01 13:20:43 +00:00
Add refresh rate code.
This commit is contained in:
parent
32495632d8
commit
88a45c3c0f
@ -65,6 +65,11 @@
|
|||||||
android:key="video_sync_refreshrate_to_screen"
|
android:key="video_sync_refreshrate_to_screen"
|
||||||
android:summary="Synchronize RetroArch's refresh rate to the screen's refresh rate (recommended - some screens have refresh rates below 59.95Hz and need this enabled to get good audio/video sync)."
|
android:summary="Synchronize RetroArch's refresh rate to the screen's refresh rate (recommended - some screens have refresh rates below 59.95Hz and need this enabled to get good audio/video sync)."
|
||||||
android:title="Sync refreshrate to screen" />
|
android:title="Sync refreshrate to screen" />
|
||||||
|
<EditTextPreference
|
||||||
|
android:key="video_refresh_rate"
|
||||||
|
android:summary="Force a specific refresh rate to be detected. Only use if auto-detection of refresh rate reports wrong refresh rate."
|
||||||
|
android:title="Forced refresh rate (Hz)"
|
||||||
|
android:numeric="decimal" />
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
android:key="video_allow_rotate"
|
android:key="video_allow_rotate"
|
||||||
|
@ -51,11 +51,30 @@ public class RetroArch extends Activity implements
|
|||||||
static private String libretro_path;
|
static private String libretro_path;
|
||||||
static private final String TAG = "RetroArch-Phoenix";
|
static private final String TAG = "RetroArch-Phoenix";
|
||||||
private ConfigFile config;
|
private ConfigFile config;
|
||||||
|
|
||||||
private final double getRefreshRate() {
|
private final double getDisplayRefreshRate() {
|
||||||
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();
|
||||||
double rate = display.getRefreshRate();
|
return display.getRefreshRate();
|
||||||
|
}
|
||||||
|
|
||||||
|
private final double getRefreshRate() {
|
||||||
|
double rate = 0;
|
||||||
|
SharedPreferences prefs = PreferenceManager
|
||||||
|
.getDefaultSharedPreferences(getBaseContext());
|
||||||
|
String refresh_rate = prefs.getString("video_refresh_rate", "");
|
||||||
|
if (!refresh_rate.isEmpty()) {
|
||||||
|
try {
|
||||||
|
rate = Double.parseDouble(refresh_rate);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
Log.e(TAG, "Cannot parse: " + refresh_rate + " as a double!");
|
||||||
|
rate = getDisplayRefreshRate();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
rate = getDisplayRefreshRate();
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.i(TAG, "Using refresh rate: " + rate + " Hz.");
|
||||||
return rate;
|
return rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,15 +219,13 @@ public class RetroArch extends Activity implements
|
|||||||
config.setBoolean("input_autodetect_enable", prefs.getBoolean("input_autodetect_enable", true));
|
config.setBoolean("input_autodetect_enable", prefs.getBoolean("input_autodetect_enable", true));
|
||||||
config.setBoolean("input_debug_enable", prefs.getBoolean("input_debug_enable", false));
|
config.setBoolean("input_debug_enable", prefs.getBoolean("input_debug_enable", false));
|
||||||
|
|
||||||
if (prefs.getBoolean("video_sync_refreshrate_to_screen", true) &&
|
if (prefs.getBoolean("video_sync_refreshrate_to_screen", true)
|
||||||
(getRefreshRate() < 59.95))
|
&& (getRefreshRate() < 59.95)) {
|
||||||
{
|
Log.i(TAG,
|
||||||
Log.i(TAG, "Refresh rate of screen lower than 59.95Hz, adjusting to screen.");
|
"Refresh rate of screen lower than 59.95Hz, adjusting to screen.");
|
||||||
config.setDouble("video_refresh_rate", getRefreshRate());
|
config.setDouble("video_refresh_rate", getRefreshRate());
|
||||||
}
|
} else {
|
||||||
else
|
Log.i(TAG, "Refresh rate set to 59.95Hz (default).");
|
||||||
{
|
|
||||||
Log.i(TAG, "Refresh rate set to 59.95Hz (default).");
|
|
||||||
config.setDouble("video_refresh_rate", 59.95);
|
config.setDouble("video_refresh_rate", 59.95);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user