From 60b3b1231ba4a706801d8b300575383e6b13089b Mon Sep 17 00:00:00 2001 From: Charles Lombardo Date: Sat, 10 Jun 2023 05:15:11 -0400 Subject: [PATCH] Android: Convert InputMappingDoubleSetting to Kotlin --- .../model/InputMappingDoubleSetting.java | 51 ------------------- .../input/model/InputMappingDoubleSetting.kt | 25 +++++++++ 2 files changed, 25 insertions(+), 51 deletions(-) delete mode 100644 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/InputMappingDoubleSetting.java create mode 100644 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/InputMappingDoubleSetting.kt diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/InputMappingDoubleSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/InputMappingDoubleSetting.java deleted file mode 100644 index 0311e6d2b3..0000000000 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/InputMappingDoubleSetting.java +++ /dev/null @@ -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; - } -} diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/InputMappingDoubleSetting.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/InputMappingDoubleSetting.kt new file mode 100644 index 0000000000..e2da062250 --- /dev/null +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/InputMappingDoubleSetting.kt @@ -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 + } +}