Android: Add missing setStickValue function (#403)

This commit is contained in:
NullVector 2026-10-10 21:23:21 +10:30 committed by GitHub
parent 775b63bc77
commit 9ad3e3110d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 0 deletions

View File

@ -86,6 +86,11 @@ class NxEmuBridge(private val activity: MainActivity) {
fun getStickValue(playerIndex: Int, stickId: Int, key: String): Float =
ControllerSettings.stickValue(playerIndex, stickId, key)
@JavascriptInterface
fun setStickValue(playerIndex: Int, stickId: Int, key: String, value: Double) {
ControllerSettings.setStickValue(playerIndex, stickId, key, value.toFloat())
}
@JavascriptInterface
fun resetControllerMappings(playerIndex: Int) {
ControllerSettings.resetMappings(playerIndex)

View File

@ -52,6 +52,15 @@ object ControllerSettings {
return params.get(key, stickDefault(key))
}
fun setStickValue(playerIndex: Int, stickId: Int, key: String, value: Float) {
if (key != "range" && key != "deadzone" && key != "modifier_scale") {
return
}
val stick = NativeAnalog.from(stickId)
val next = NativeInput.getStickParam(player(playerIndex), stick)
next.set(key, value)
NativeInput.setStickParam(player(playerIndex), stick, next)
}
fun resetMappings(playerIndex: Int) {
NativeInput.resetControllerMappings(player(playerIndex))