Android: Add missing setStickValue function (#403)
This commit is contained in:
parent
775b63bc77
commit
9ad3e3110d
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Reference in New Issue