Android: Remove hacks for Wii Remote extension and video backend settings
This commit is contained in:
parent
ae2348023b
commit
e9cc89af83
|
@ -1,7 +1,9 @@
|
|||
package org.dolphinemu.dolphinemu.features.settings.model.view;
|
||||
|
||||
import org.dolphinemu.dolphinemu.DolphinApplication;
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.Setting;
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.StringSetting;
|
||||
import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag;
|
||||
|
||||
public class StringSingleChoiceSetting extends SettingsItem
|
||||
{
|
||||
|
@ -9,14 +11,39 @@ public class StringSingleChoiceSetting extends SettingsItem
|
|||
|
||||
private String[] mChoicesId;
|
||||
private String[] mValuesId;
|
||||
private MenuTag mMenuTag;
|
||||
|
||||
public StringSingleChoiceSetting(String key, String section, int titleId, int descriptionId,
|
||||
String[] choicesId, String[] valuesId, String defaultValue, Setting setting,
|
||||
MenuTag menuTag)
|
||||
{
|
||||
super(key, section, setting, titleId, descriptionId);
|
||||
mChoicesId = choicesId;
|
||||
mValuesId = valuesId;
|
||||
mDefaultValue = defaultValue;
|
||||
mMenuTag = menuTag;
|
||||
}
|
||||
|
||||
public StringSingleChoiceSetting(String key, String section, int titleId, int descriptionId,
|
||||
String[] choicesId, String[] valuesId, String defaultValue, Setting setting)
|
||||
{
|
||||
this(key, section, titleId, descriptionId, choicesId, valuesId, defaultValue, setting, null);
|
||||
}
|
||||
|
||||
public StringSingleChoiceSetting(String key, String section, int titleId, int descriptionId,
|
||||
int choicesId, int valuesId, String defaultValue, Setting setting, MenuTag menuTag)
|
||||
{
|
||||
super(key, section, setting, titleId, descriptionId);
|
||||
mValuesId = valuesId;
|
||||
mChoicesId = choicesId;
|
||||
mChoicesId = DolphinApplication.getAppContext().getResources().getStringArray(choicesId);
|
||||
mValuesId = DolphinApplication.getAppContext().getResources().getStringArray(valuesId);
|
||||
mDefaultValue = defaultValue;
|
||||
mMenuTag = menuTag;
|
||||
}
|
||||
|
||||
public StringSingleChoiceSetting(String key, String section, int titleId, int descriptionId,
|
||||
int choicesId, int valuesId, String defaultValue, Setting setting)
|
||||
{
|
||||
this(key, section, titleId, descriptionId, choicesId, valuesId, defaultValue, setting, null);
|
||||
}
|
||||
|
||||
public String[] getChoicesId()
|
||||
|
@ -69,6 +96,11 @@ public class StringSingleChoiceSetting extends SettingsItem
|
|||
return -1;
|
||||
}
|
||||
|
||||
public MenuTag getMenuTag()
|
||||
{
|
||||
return mMenuTag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a value to the backing int. If that int was previously null,
|
||||
* initializes a new one and returns it, so it can be added to the Hashmap.
|
||||
|
|
|
@ -369,6 +369,27 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
|
|||
sView.onSettingChanged(null);
|
||||
}
|
||||
|
||||
private void handleMenuTag(MenuTag menuTag, int value)
|
||||
{
|
||||
if (menuTag != null)
|
||||
{
|
||||
if (menuTag.isGCPadMenu())
|
||||
{
|
||||
mView.onGcPadSettingChanged(menuTag, value);
|
||||
}
|
||||
|
||||
if (menuTag.isWiimoteMenu())
|
||||
{
|
||||
mView.onWiimoteSettingChanged(menuTag, value);
|
||||
}
|
||||
|
||||
if (menuTag.isWiimoteExtensionMenu())
|
||||
{
|
||||
mView.onExtensionSettingChanged(menuTag, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
|
@ -380,24 +401,7 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
|
|||
if (scSetting.getSelectedValue() != value)
|
||||
mView.onSettingChanged(mClickedItem.getKey());
|
||||
|
||||
MenuTag menuTag = scSetting.getMenuTag();
|
||||
if (menuTag != null)
|
||||
{
|
||||
if (menuTag.isGCPadMenu())
|
||||
{
|
||||
mView.onGcPadSettingChanged(menuTag, value);
|
||||
}
|
||||
|
||||
if (menuTag.isWiimoteMenu())
|
||||
{
|
||||
mView.onWiimoteSettingChanged(menuTag, value);
|
||||
}
|
||||
|
||||
if (menuTag.isWiimoteExtensionMenu())
|
||||
{
|
||||
mView.onExtensionSettingChanged(menuTag, value);
|
||||
}
|
||||
}
|
||||
handleMenuTag(scSetting.getMenuTag(), value);
|
||||
|
||||
// Get the backing Setting, which may be null (if for example it was missing from the file)
|
||||
IntSetting setting = scSetting.setSelectedValue(value);
|
||||
|
@ -405,25 +409,6 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
|
|||
{
|
||||
mView.putSetting(setting);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (scSetting.getKey().equals(SettingsFile.KEY_VIDEO_BACKEND_INDEX))
|
||||
{
|
||||
putVideoBackendSetting(which);
|
||||
}
|
||||
else if (scSetting.getKey().equals(SettingsFile.KEY_WIIMOTE_EXTENSION))
|
||||
{
|
||||
putExtensionSetting(which, Character.getNumericValue(
|
||||
scSetting.getSection().charAt(scSetting.getSection().length() - 1)), false);
|
||||
}
|
||||
else if (scSetting.getKey().contains(SettingsFile.KEY_WIIMOTE_EXTENSION) &&
|
||||
scSetting.getSection().equals(Settings.SECTION_CONTROLS))
|
||||
{
|
||||
putExtensionSetting(which, Character
|
||||
.getNumericValue(scSetting.getKey().charAt(scSetting.getKey().length() - 1)),
|
||||
true);
|
||||
}
|
||||
}
|
||||
|
||||
closeDialog();
|
||||
}
|
||||
|
@ -452,6 +437,8 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
|
|||
if (!scSetting.getSelectedValue().equals(value))
|
||||
mView.onSettingChanged(mClickedItem.getKey());
|
||||
|
||||
handleMenuTag(scSetting.getMenuTag(), which);
|
||||
|
||||
StringSetting setting = scSetting.setSelectedValue(value);
|
||||
if (setting != null)
|
||||
{
|
||||
|
@ -613,52 +600,4 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
|
|||
|
||||
return -1;
|
||||
}
|
||||
|
||||
private void putVideoBackendSetting(int which)
|
||||
{
|
||||
StringSetting gfxBackend = null;
|
||||
switch (which)
|
||||
{
|
||||
case 0:
|
||||
gfxBackend =
|
||||
new StringSetting(SettingsFile.KEY_VIDEO_BACKEND, Settings.SECTION_INI_CORE, "OGL");
|
||||
break;
|
||||
|
||||
case 1:
|
||||
gfxBackend = new StringSetting(SettingsFile.KEY_VIDEO_BACKEND, Settings.SECTION_INI_CORE,
|
||||
"Vulkan");
|
||||
break;
|
||||
|
||||
case 2:
|
||||
gfxBackend = new StringSetting(SettingsFile.KEY_VIDEO_BACKEND, Settings.SECTION_INI_CORE,
|
||||
"Software Renderer");
|
||||
break;
|
||||
|
||||
case 3:
|
||||
gfxBackend = new StringSetting(SettingsFile.KEY_VIDEO_BACKEND, Settings.SECTION_INI_CORE,
|
||||
"Null");
|
||||
break;
|
||||
}
|
||||
|
||||
mView.putSetting(gfxBackend);
|
||||
}
|
||||
|
||||
private void putExtensionSetting(int which, int wiimoteNumber, boolean isGame)
|
||||
{
|
||||
if (!isGame)
|
||||
{
|
||||
StringSetting extension = new StringSetting(SettingsFile.KEY_WIIMOTE_EXTENSION,
|
||||
Settings.SECTION_WIIMOTE + wiimoteNumber,
|
||||
mContext.getResources().getStringArray(R.array.wiimoteExtensionsEntries)[which]);
|
||||
mView.putSetting(extension);
|
||||
}
|
||||
else
|
||||
{
|
||||
StringSetting extension =
|
||||
new StringSetting(SettingsFile.KEY_WIIMOTE_EXTENSION + wiimoteNumber,
|
||||
Settings.SECTION_CONTROLS, mContext.getResources()
|
||||
.getStringArray(R.array.wiimoteExtensionsEntries)[which]);
|
||||
mView.putSetting(extension);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -500,14 +500,15 @@ public final class SettingsFragmentPresenter
|
|||
|
||||
private void addGraphicsSettings(ArrayList<SettingsItem> sl)
|
||||
{
|
||||
IntSetting videoBackend =
|
||||
new IntSetting(SettingsFile.KEY_VIDEO_BACKEND_INDEX, Settings.SECTION_INI_CORE,
|
||||
getVideoBackendValue());
|
||||
Setting videoBackend = null;
|
||||
Setting showFps = null;
|
||||
Setting shaderCompilationMode = null;
|
||||
Setting waitForShaders = null;
|
||||
Setting aspectRatio = null;
|
||||
|
||||
SettingSection coreSection = mSettings.getSection(Settings.SECTION_INI_CORE);
|
||||
videoBackend = coreSection.getSetting(SettingsFile.KEY_VIDEO_BACKEND);
|
||||
|
||||
SettingSection gfxSection = mSettings.getSection(Settings.SECTION_GFX_SETTINGS);
|
||||
showFps = gfxSection.getSetting(SettingsFile.KEY_SHOW_FPS);
|
||||
shaderCompilationMode = gfxSection.getSetting(SettingsFile.KEY_SHADER_COMPILATION_MODE);
|
||||
|
@ -515,9 +516,9 @@ public final class SettingsFragmentPresenter
|
|||
aspectRatio = gfxSection.getSetting(SettingsFile.KEY_ASPECT_RATIO);
|
||||
|
||||
sl.add(new HeaderSetting(null, null, R.string.graphics_general, 0));
|
||||
sl.add(new SingleChoiceSetting(SettingsFile.KEY_VIDEO_BACKEND_INDEX, Settings.SECTION_INI_CORE,
|
||||
sl.add(new StringSingleChoiceSetting(SettingsFile.KEY_VIDEO_BACKEND, Settings.SECTION_INI_CORE,
|
||||
R.string.video_backend, 0, R.array.videoBackendEntries,
|
||||
R.array.videoBackendValues, 0, videoBackend));
|
||||
R.array.videoBackendValues, "OGL", videoBackend));
|
||||
sl.add(new CheckBoxSetting(SettingsFile.KEY_SHOW_FPS, Settings.SECTION_GFX_SETTINGS,
|
||||
R.string.show_fps, R.string.show_fps_description, false, showFps));
|
||||
sl.add(new SingleChoiceSettingDynamicDescriptions(SettingsFile.KEY_SHADER_COMPILATION_MODE,
|
||||
|
@ -985,28 +986,26 @@ public final class SettingsFragmentPresenter
|
|||
// But game game specific extension settings are saved in their own profile. These profiles
|
||||
// do not have any way to specify the controller that is loaded outside of knowing the filename
|
||||
// of the profile that was loaded.
|
||||
IntSetting extension;
|
||||
Setting extension;
|
||||
if (mGameID.equals(""))
|
||||
{
|
||||
extension = new IntSetting(SettingsFile.KEY_WIIMOTE_EXTENSION,
|
||||
Settings.SECTION_WIIMOTE + wiimoteNumber, getExtensionValue(wiimoteNumber - 3),
|
||||
MenuTag.getWiimoteExtensionMenuTag(wiimoteNumber));
|
||||
sl.add(new SingleChoiceSetting(SettingsFile.KEY_WIIMOTE_EXTENSION,
|
||||
extension = mSettings.getSection(Settings.SECTION_WIIMOTE + (wiimoteNumber - 3)).
|
||||
getSetting(SettingsFile.KEY_WIIMOTE_EXTENSION);
|
||||
sl.add(new StringSingleChoiceSetting(SettingsFile.KEY_WIIMOTE_EXTENSION,
|
||||
Settings.SECTION_WIIMOTE + (wiimoteNumber - 3), R.string.wiimote_extensions,
|
||||
0, R.array.wiimoteExtensionsEntries,
|
||||
R.array.wiimoteExtensionsValues, 0, extension,
|
||||
R.array.wiimoteExtensionsValues, getExtensionValue(wiimoteNumber - 3), extension,
|
||||
MenuTag.getWiimoteExtensionMenuTag(wiimoteNumber)));
|
||||
}
|
||||
else
|
||||
{
|
||||
mSettings.loadWiimoteProfile(mGameID, String.valueOf(wiimoteNumber - 4));
|
||||
extension = new IntSetting(SettingsFile.KEY_WIIMOTE_EXTENSION + (wiimoteNumber - 4),
|
||||
Settings.SECTION_CONTROLS, getExtensionValue(wiimoteNumber - 4),
|
||||
MenuTag.getWiimoteExtensionMenuTag(wiimoteNumber));
|
||||
sl.add(new SingleChoiceSetting(SettingsFile.KEY_WIIMOTE_EXTENSION + (wiimoteNumber - 4),
|
||||
extension = mSettings.getSection(Settings.SECTION_CONTROLS).
|
||||
getSetting(SettingsFile.KEY_WIIMOTE_EXTENSION + (wiimoteNumber - 4));
|
||||
sl.add(new StringSingleChoiceSetting(SettingsFile.KEY_WIIMOTE_EXTENSION + (wiimoteNumber - 4),
|
||||
Settings.SECTION_CONTROLS, R.string.wiimote_extensions,
|
||||
0, R.array.wiimoteExtensionsEntries,
|
||||
R.array.wiimoteExtensionsValues, 0, extension,
|
||||
R.array.wiimoteExtensionsValues, getExtensionValue(wiimoteNumber - 4), extension,
|
||||
MenuTag.getWiimoteExtensionMenuTag(wiimoteNumber)));
|
||||
}
|
||||
|
||||
|
@ -1555,99 +1554,25 @@ public final class SettingsFragmentPresenter
|
|||
}
|
||||
}
|
||||
|
||||
private int getVideoBackendValue()
|
||||
private String getExtensionValue(int wiimoteNumber)
|
||||
{
|
||||
SettingSection coreSection = mSettings.getSection(Settings.SECTION_INI_CORE);
|
||||
|
||||
int videoBackendValue;
|
||||
|
||||
try
|
||||
{
|
||||
String videoBackend =
|
||||
((StringSetting) coreSection.getSetting(SettingsFile.KEY_VIDEO_BACKEND)).getValue();
|
||||
if (videoBackend.equals("OGL"))
|
||||
{
|
||||
videoBackendValue = 0;
|
||||
}
|
||||
else if (videoBackend.equals("Vulkan"))
|
||||
{
|
||||
videoBackendValue = 1;
|
||||
}
|
||||
else if (videoBackend.equals("Software Renderer"))
|
||||
{
|
||||
videoBackendValue = 2;
|
||||
}
|
||||
else if (videoBackend.equals("Null"))
|
||||
{
|
||||
videoBackendValue = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
videoBackendValue = 0;
|
||||
}
|
||||
}
|
||||
catch (NullPointerException ex)
|
||||
{
|
||||
videoBackendValue = 0;
|
||||
}
|
||||
|
||||
return videoBackendValue;
|
||||
}
|
||||
|
||||
private int getExtensionValue(int wiimoteNumber)
|
||||
{
|
||||
int extensionValue;
|
||||
|
||||
try
|
||||
{
|
||||
String extension;
|
||||
if (mGameID.equals("")) // Main settings
|
||||
{
|
||||
extension =
|
||||
((StringSetting) mSettings.getSection(Settings.SECTION_WIIMOTE + wiimoteNumber)
|
||||
.getSetting(SettingsFile.KEY_WIIMOTE_EXTENSION)).getValue();
|
||||
return ((StringSetting) mSettings.getSection(Settings.SECTION_WIIMOTE + wiimoteNumber)
|
||||
.getSetting(SettingsFile.KEY_WIIMOTE_EXTENSION)).getValue();
|
||||
}
|
||||
else // Game settings
|
||||
{
|
||||
extension = ((StringSetting) mSettings.getSection(Settings.SECTION_PROFILE)
|
||||
return ((StringSetting) mSettings.getSection(Settings.SECTION_PROFILE)
|
||||
.getSetting(SettingsFile.KEY_WIIMOTE_EXTENSION)).getValue();
|
||||
}
|
||||
|
||||
if (extension.equals("None"))
|
||||
{
|
||||
extensionValue = 0;
|
||||
}
|
||||
else if (extension.equals("Nunchuk"))
|
||||
{
|
||||
extensionValue = 1;
|
||||
}
|
||||
else if (extension.equals("Classic"))
|
||||
{
|
||||
extensionValue = 2;
|
||||
}
|
||||
else if (extension.equals("Guitar"))
|
||||
{
|
||||
extensionValue = 3;
|
||||
}
|
||||
else if (extension.equals("Drums"))
|
||||
{
|
||||
extensionValue = 4;
|
||||
}
|
||||
else if (extension.equals("Turntable"))
|
||||
{
|
||||
extensionValue = 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
extensionValue = 0;
|
||||
}
|
||||
}
|
||||
catch (NullPointerException ex)
|
||||
{
|
||||
extensionValue = 0;
|
||||
return "None";
|
||||
}
|
||||
|
||||
return extensionValue;
|
||||
}
|
||||
|
||||
public static String getDefaultNANDRootPath()
|
||||
|
|
|
@ -286,9 +286,6 @@ public final class SettingsFile
|
|||
public static final String KEY_WIIMOTE_SCAN = "WiimoteContinuousScanning";
|
||||
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";
|
||||
|
||||
private static BiMap<String, String> sectionsMap = new BiMap<>();
|
||||
|
||||
static
|
||||
|
|
|
@ -86,21 +86,29 @@
|
|||
</integer-array>
|
||||
|
||||
<!-- Video backend selection -->
|
||||
<string-array name="videoBackendEntries" translatable="false">
|
||||
<string-array name="videoBackendEntries">
|
||||
<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>
|
||||
<string-array name="videoBackendValues" translatable="false">
|
||||
<item>OGL</item>
|
||||
<item>Vulkan</item>
|
||||
<item>Software Renderer</item>
|
||||
<item>Null</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Wii Remote extensions -->
|
||||
<string-array name="wiimoteExtensionsEntries" translatable="false">
|
||||
<string-array name="wiimoteExtensionsEntries">
|
||||
<item>None</item>
|
||||
<item>Nunchuk</item>
|
||||
<item>Classic</item>
|
||||
<item>Guitar</item>
|
||||
<item>Drums</item>
|
||||
<item>Turntable</item>
|
||||
</string-array>
|
||||
<string-array name="wiimoteExtensionsValues" translatable="false">
|
||||
<item>None</item>
|
||||
<item>Nunchuk</item>
|
||||
<item>Classic</item>
|
||||
|
@ -108,14 +116,6 @@
|
|||
<item>Drums</item>
|
||||
<item>Turntable</item>
|
||||
</string-array>
|
||||
<integer-array name="wiimoteExtensionsValues" translatable="false">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
<item>3</item>
|
||||
<item>4</item>
|
||||
<item>5</item>
|
||||
</integer-array>
|
||||
|
||||
<!-- Texture Cache Accuracy Preference -->
|
||||
<string-array name="textureCacheAccuracyEntries" translatable="false">
|
||||
|
|
Loading…
Reference in New Issue