Android: Add video backend choice to settings

This commit is contained in:
Stenzek 2016-08-13 22:57:58 +10:00
parent 77a128ab87
commit 4a4f6cc135
5 changed files with 82 additions and 2 deletions

View File

@ -14,6 +14,7 @@ import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.model.settings.BooleanSetting;
import org.dolphinemu.dolphinemu.model.settings.FloatSetting;
import org.dolphinemu.dolphinemu.model.settings.IntSetting;
import org.dolphinemu.dolphinemu.model.settings.StringSetting;
import org.dolphinemu.dolphinemu.model.settings.view.CheckBoxSetting;
import org.dolphinemu.dolphinemu.model.settings.view.SettingsItem;
import org.dolphinemu.dolphinemu.model.settings.view.SingleChoiceSetting;
@ -207,7 +208,11 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
}
else
{
if (scSetting.getKey().equals(SettingsFile.KEY_XFB_METHOD))
if (scSetting.getKey().equals(SettingsFile.KEY_VIDEO_BACKEND_INDEX))
{
putVideoBackendSetting(which);
}
else if (scSetting.getKey().equals(SettingsFile.KEY_XFB_METHOD))
{
putXfbSetting(which);
}
@ -318,6 +323,31 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
return -1;
}
public void putVideoBackendSetting(int which)
{
StringSetting gfxBackend = null;
switch (which)
{
case 0:
gfxBackend = new StringSetting(SettingsFile.KEY_VIDEO_BACKEND, SettingsFile.SECTION_CORE, "OGL");
break;
case 1:
gfxBackend = new StringSetting(SettingsFile.KEY_VIDEO_BACKEND, SettingsFile.SECTION_CORE, "Vulkan");
break;
case 2:
gfxBackend = new StringSetting(SettingsFile.KEY_VIDEO_BACKEND, SettingsFile.SECTION_CORE, "SW");
break;
case 3:
gfxBackend = new StringSetting(SettingsFile.KEY_VIDEO_BACKEND, SettingsFile.SECTION_CORE, "Null");
break;
}
mView.putSetting(gfxBackend);
}
public void putXfbSetting(int which)
{
BooleanSetting xfbEnable = null;

View File

@ -5,6 +5,7 @@ import org.dolphinemu.dolphinemu.model.settings.BooleanSetting;
import org.dolphinemu.dolphinemu.model.settings.IntSetting;
import org.dolphinemu.dolphinemu.model.settings.Setting;
import org.dolphinemu.dolphinemu.model.settings.SettingSection;
import org.dolphinemu.dolphinemu.model.settings.StringSetting;
import org.dolphinemu.dolphinemu.model.settings.view.CheckBoxSetting;
import org.dolphinemu.dolphinemu.model.settings.view.HeaderSetting;
import org.dolphinemu.dolphinemu.model.settings.view.SettingsItem;
@ -137,6 +138,7 @@ public final class SettingsFragmentPresenter
Setting dualCore = null;
Setting overclockEnable = null;
Setting overclock = null;
IntSetting videoBackend = new IntSetting(SettingsFile.KEY_VIDEO_BACKEND_INDEX, SettingsFile.SECTION_CORE, getVideoBackendValue());
Setting continuousScan = null;
Setting wiimoteSpeaker = null;
@ -162,6 +164,13 @@ public final class SettingsFragmentPresenter
sl.add(new CheckBoxSetting(SettingsFile.KEY_DUAL_CORE, SettingsFile.SECTION_CORE, R.string.dual_core, R.string.dual_core_descrip, true, dualCore));
sl.add(new CheckBoxSetting(SettingsFile.KEY_OVERCLOCK_ENABLE, SettingsFile.SECTION_CORE, R.string.overclock_enable, R.string.overclock_enable_description, false, overclockEnable));
sl.add(new SliderSetting(SettingsFile.KEY_OVERCLOCK_PERCENT, SettingsFile.SECTION_CORE, R.string.overclock_title, 0, 400, "%", 100, overclock));
// While it doesn't seem appropriate to store the video backend with the CPU settings, the video
// backend is stored in the main INI, which can't be changed by the graphics settings page, so
// we have to put it here.
sl.add(new SingleChoiceSetting(SettingsFile.KEY_VIDEO_BACKEND_INDEX, SettingsFile.SECTION_CORE, R.string.video_backend, R.string.video_backend_descrip,
R.array.videoBackendEntries, R.array.videoBackendValues, 0, videoBackend));
sl.add(new CheckBoxSetting(SettingsFile.KEY_WIIMOTE_SCAN, SettingsFile.SECTION_CORE, R.string.wiimote_scanning, R.string.wiimote_scanning_description, true, continuousScan));
sl.add(new CheckBoxSetting(SettingsFile.KEY_WIIMOTE_SPEAKER, SettingsFile.SECTION_CORE, R.string.wiimote_speaker, R.string.wiimote_speaker_description, true, wiimoteSpeaker));
}
@ -291,6 +300,32 @@ public final class SettingsFragmentPresenter
sl.add(new CheckBoxSetting(SettingsFile.KEY_GCADAPTER_BONGOS + gcPadNumber, SettingsFile.SECTION_CORE, R.string.gc_adapter_bongos, R.string.gc_adapter_bongos_description, false, bongos));
}
private int getVideoBackendValue()
{
int videoBackendValue;
try
{
String videoBackend = ((StringSetting)mSettings.get(SettingsFile.SECTION_CORE).getSetting(SettingsFile.KEY_VIDEO_BACKEND)).getValue();
if (videoBackend.equals("OGL"))
videoBackendValue = 0;
else if (videoBackend.equals("Vulkan"))
videoBackendValue = 1;
else if (videoBackend.equals("Software"))
videoBackendValue = 2;
else if (videoBackend.equals("Null"))
videoBackendValue = 3;
else
videoBackendValue = 0;
}
catch (NullPointerException ex)
{
videoBackendValue = 0;
}
return videoBackendValue;
}
private int getXfbValue()
{
int xfbValue;

View File

@ -86,6 +86,7 @@ public final class SettingsFile
public static final String KEY_WIIMOTE_SPEAKER = "WiimoteEnableSpeaker";
// Internal only, not actually found in settings file.
public static final String KEY_VIDEO_BACKEND_INDEX = "VideoBackendIndex";
public static final String KEY_XFB_METHOD = "XFBMethod";
private SettingsFile()

View File

@ -12,6 +12,20 @@
<item>5</item>
</integer-array>
<!-- Video backend selection -->
<string-array name="videoBackendEntries" translatable="false">
<item>OpenGL</item>
<item>Vulkan</item>
<item>Software</item>
<item>Null</item>
</string-array>
<integer-array name="videoBackendValues" translatable="false">
<item>0</item>
<item>1</item>
<item>2</item>
<item>3</item>
</integer-array>
<!-- Wiimote extensions -->
<string-array name="wiimoteExtEntries" translatable="false">
<item>"None"</item>

View File

@ -263,7 +263,7 @@
<string name="opengl_es3">OpenGL ES</string>
<string name="opengl">OpenGL</string>
<string name="video_backend">Video Backend</string>
<string name="video_backend_desc">%s</string>
<string name="video_backend_descrip">Select the API used for graphics rendering.</string>
<string name="show_fps">Show FPS</string>
<string name="show_fps_descrip">Show the number of frames rendered per second as a measure of emulation speed.</string>