Android: Convert InputMappingDoubleSetting to Kotlin

This commit is contained in:
Charles Lombardo 2023-06-10 05:15:11 -04:00
parent b2e2c3b8d4
commit 60b3b1231b
2 changed files with 25 additions and 51 deletions

View File

@ -1,51 +0,0 @@
// SPDX-License-Identifier: GPL-2.0-or-later
package org.dolphinemu.dolphinemu.features.input.model;
import androidx.annotation.NonNull;
import org.dolphinemu.dolphinemu.features.input.model.controlleremu.NumericSetting;
import org.dolphinemu.dolphinemu.features.settings.model.AbstractFloatSetting;
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
// Yes, floats are not the same thing as doubles... They're close enough, though
public class InputMappingDoubleSetting implements AbstractFloatSetting
{
private final NumericSetting mNumericSetting;
public InputMappingDoubleSetting(NumericSetting numericSetting)
{
mNumericSetting = numericSetting;
}
@Override
public float getFloat()
{
return (float) mNumericSetting.getDoubleValue();
}
@Override
public void setFloat(@NonNull Settings settings, float newValue)
{
mNumericSetting.setDoubleValue(newValue);
}
@Override
public boolean isOverridden()
{
return false;
}
@Override
public boolean isRuntimeEditable()
{
return true;
}
@Override
public boolean delete(@NonNull Settings settings)
{
mNumericSetting.setDoubleValue(mNumericSetting.getDoubleDefaultValue());
return true;
}
}

View File

@ -0,0 +1,25 @@
// SPDX-License-Identifier: GPL-2.0-or-later
package org.dolphinemu.dolphinemu.features.input.model
import org.dolphinemu.dolphinemu.features.input.model.controlleremu.NumericSetting
import org.dolphinemu.dolphinemu.features.settings.model.AbstractFloatSetting
import org.dolphinemu.dolphinemu.features.settings.model.Settings
// Yes, floats are not the same thing as doubles... They're close enough, though
class InputMappingDoubleSetting(private val numericSetting: NumericSetting) : AbstractFloatSetting {
override val float: Float
get() = numericSetting.getDoubleValue().toFloat()
override fun setFloat(settings: Settings, newValue: Float) =
numericSetting.setDoubleValue(newValue.toDouble())
override val isOverridden: Boolean = false
override val isRuntimeEditable: Boolean = true
override fun delete(settings: Settings): Boolean {
numericSetting.setDoubleValue(numericSetting.getDoubleDefaultValue())
return true
}
}