Android: Convert InputDeviceSetting to Kotlin
This commit is contained in:
parent
2590382871
commit
9d7bd6e6bd
|
@ -1,70 +0,0 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
package org.dolphinemu.dolphinemu.features.input.model.view;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import org.dolphinemu.dolphinemu.features.input.model.ControllerInterface;
|
|
||||||
import org.dolphinemu.dolphinemu.features.input.model.controlleremu.EmulatedController;
|
|
||||||
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
|
|
||||||
import org.dolphinemu.dolphinemu.features.settings.model.view.StringSingleChoiceSetting;
|
|
||||||
|
|
||||||
public class InputDeviceSetting extends StringSingleChoiceSetting
|
|
||||||
{
|
|
||||||
private final EmulatedController mController;
|
|
||||||
|
|
||||||
public InputDeviceSetting(Context context, int titleId, int descriptionId,
|
|
||||||
EmulatedController controller)
|
|
||||||
{
|
|
||||||
super(context, null, titleId, descriptionId, null, null, null);
|
|
||||||
|
|
||||||
mController = controller;
|
|
||||||
|
|
||||||
refreshChoicesAndValues();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getSelectedChoice()
|
|
||||||
{
|
|
||||||
return mController.getDefaultDevice();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getSelectedValue()
|
|
||||||
{
|
|
||||||
return mController.getDefaultDevice();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setSelectedValue(Settings settings, String newValue)
|
|
||||||
{
|
|
||||||
mController.setDefaultDevice(newValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void refreshChoicesAndValues()
|
|
||||||
{
|
|
||||||
String[] devices = ControllerInterface.getAllDeviceStrings();
|
|
||||||
|
|
||||||
setChoices(devices);
|
|
||||||
setValues(devices);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isEditable()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canClear()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear(Settings settings)
|
|
||||||
{
|
|
||||||
setSelectedValue(settings, "");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
package org.dolphinemu.dolphinemu.features.input.model.view
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import org.dolphinemu.dolphinemu.features.input.model.ControllerInterface
|
||||||
|
import org.dolphinemu.dolphinemu.features.input.model.controlleremu.EmulatedController
|
||||||
|
import org.dolphinemu.dolphinemu.features.settings.model.Settings
|
||||||
|
import org.dolphinemu.dolphinemu.features.settings.model.view.StringSingleChoiceSetting
|
||||||
|
|
||||||
|
class InputDeviceSetting(
|
||||||
|
context: Context,
|
||||||
|
titleId: Int,
|
||||||
|
descriptionId: Int,
|
||||||
|
private val controller: EmulatedController
|
||||||
|
) : StringSingleChoiceSetting(context, null, titleId, descriptionId, null, null, null) {
|
||||||
|
init {
|
||||||
|
refreshChoicesAndValues()
|
||||||
|
}
|
||||||
|
|
||||||
|
override val selectedChoice: String
|
||||||
|
get() = controller.getDefaultDevice()
|
||||||
|
|
||||||
|
override val selectedValue: String
|
||||||
|
get() = controller.getDefaultDevice()
|
||||||
|
|
||||||
|
override fun setSelectedValue(settings: Settings, selection: String) =
|
||||||
|
controller.setDefaultDevice(selection)
|
||||||
|
|
||||||
|
override fun refreshChoicesAndValues() {
|
||||||
|
val devices = ControllerInterface.getAllDeviceStrings()
|
||||||
|
|
||||||
|
choices = devices
|
||||||
|
values = devices
|
||||||
|
}
|
||||||
|
|
||||||
|
override val isEditable: Boolean = true
|
||||||
|
|
||||||
|
override fun canClear(): Boolean = true
|
||||||
|
|
||||||
|
override fun clear(settings: Settings) = setSelectedValue(settings, "")
|
||||||
|
}
|
|
@ -4,14 +4,14 @@ package org.dolphinemu.dolphinemu.features.settings.model
|
||||||
|
|
||||||
object PostProcessing {
|
object PostProcessing {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
val shaderList: Array<String?>
|
val shaderList: Array<String>
|
||||||
external get
|
external get
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
val anaglyphShaderList: Array<String?>
|
val anaglyphShaderList: Array<String>
|
||||||
external get
|
external get
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
val passiveShaderList: Array<String?>
|
val passiveShaderList: Array<String>
|
||||||
external get
|
external get
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,9 @@ open class StringSingleChoiceSetting : SettingsItem {
|
||||||
override val setting: AbstractSetting?
|
override val setting: AbstractSetting?
|
||||||
get() = stringSetting
|
get() = stringSetting
|
||||||
|
|
||||||
var choices: Array<String?>?
|
var choices: Array<String>?
|
||||||
protected set
|
protected set
|
||||||
var values: Array<String?>?
|
var values: Array<String>?
|
||||||
protected set
|
protected set
|
||||||
val menuTag: MenuTag?
|
val menuTag: MenuTag?
|
||||||
var noChoicesAvailableString = 0
|
var noChoicesAvailableString = 0
|
||||||
|
@ -37,8 +37,8 @@ open class StringSingleChoiceSetting : SettingsItem {
|
||||||
setting: AbstractStringSetting?,
|
setting: AbstractStringSetting?,
|
||||||
titleId: Int,
|
titleId: Int,
|
||||||
descriptionId: Int,
|
descriptionId: Int,
|
||||||
choices: Array<String?>?,
|
choices: Array<String>?,
|
||||||
values: Array<String?>?,
|
values: Array<String>?,
|
||||||
menuTag: MenuTag? = null
|
menuTag: MenuTag? = null
|
||||||
) : super(context, titleId, descriptionId) {
|
) : super(context, titleId, descriptionId) {
|
||||||
stringSetting = setting
|
stringSetting = setting
|
||||||
|
@ -52,8 +52,8 @@ open class StringSingleChoiceSetting : SettingsItem {
|
||||||
setting: AbstractStringSetting,
|
setting: AbstractStringSetting,
|
||||||
titleId: Int,
|
titleId: Int,
|
||||||
descriptionId: Int,
|
descriptionId: Int,
|
||||||
choices: Array<String?>,
|
choices: Array<String>,
|
||||||
values: Array<String?>,
|
values: Array<String>,
|
||||||
noChoicesAvailableString: Int
|
noChoicesAvailableString: Int
|
||||||
) : this(context, setting, titleId, descriptionId, choices, values) {
|
) : this(context, setting, titleId, descriptionId, choices, values) {
|
||||||
this.noChoicesAvailableString = noChoicesAvailableString
|
this.noChoicesAvailableString = noChoicesAvailableString
|
||||||
|
@ -102,8 +102,8 @@ open class StringSingleChoiceSetting : SettingsItem {
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun setSelectedValue(settings: Settings?, selection: String?) {
|
open fun setSelectedValue(settings: Settings, selection: String) {
|
||||||
stringSetting!!.setString(settings!!, selection!!)
|
stringSetting!!.setString(settings, selection)
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun refreshChoicesAndValues() {}
|
open fun refreshChoicesAndValues() {}
|
||||||
|
|
|
@ -474,7 +474,7 @@ class SettingsAdapter(
|
||||||
val value = scSetting.getValueAt(which)
|
val value = scSetting.getValueAt(which)
|
||||||
if (scSetting.selectedValue != value) fragmentView.onSettingChanged()
|
if (scSetting.selectedValue != value) fragmentView.onSettingChanged()
|
||||||
|
|
||||||
scSetting.setSelectedValue(settings, value)
|
scSetting.setSelectedValue(settings!!, value!!)
|
||||||
|
|
||||||
closeDialog()
|
closeDialog()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1339,13 +1339,8 @@ class SettingsFragmentPresenter(
|
||||||
val shaderList =
|
val shaderList =
|
||||||
if (stereoModeValue == anaglyphMode) PostProcessing.anaglyphShaderList else PostProcessing.shaderList
|
if (stereoModeValue == anaglyphMode) PostProcessing.anaglyphShaderList else PostProcessing.shaderList
|
||||||
|
|
||||||
val shaderListEntries = arrayOfNulls<String>(shaderList.size + 1)
|
val shaderListEntries = arrayOf(context.getString(R.string.off), *shaderList)
|
||||||
shaderListEntries[0] = context.getString(R.string.off)
|
val shaderListValues = arrayOf("", *shaderList)
|
||||||
System.arraycopy(shaderList, 0, shaderListEntries, 1, shaderList.size)
|
|
||||||
|
|
||||||
val shaderListValues = arrayOfNulls<String>(shaderList.size + 1)
|
|
||||||
shaderListValues[0] = ""
|
|
||||||
System.arraycopy(shaderList, 0, shaderListValues, 1, shaderList.size)
|
|
||||||
|
|
||||||
sl.add(
|
sl.add(
|
||||||
StringSingleChoiceSetting(
|
StringSingleChoiceSetting(
|
||||||
|
|
Loading…
Reference in New Issue