mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2025-03-13 09:12:27 +01:00
apply settings only on finish
This commit is contained in:
parent
dbfefa615d
commit
c7f6d2d679
@ -35,6 +35,8 @@ class InputBindingSetting(
|
||||
.apply()
|
||||
}
|
||||
|
||||
private var key: String = ""
|
||||
|
||||
/**
|
||||
* Returns true if this key is for the 3DS Circle Pad
|
||||
*/
|
||||
@ -230,6 +232,29 @@ class InputBindingSetting(
|
||||
value = uiString
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the provided key input setting as an Android preference.
|
||||
* Only gets applied when apply(); is called.
|
||||
*
|
||||
* @param keyEvent KeyEvent of this key press.
|
||||
*/
|
||||
fun onKeyInputDeferred(keyEvent: KeyEvent) {
|
||||
if (!isButtonMappingSupported()) {
|
||||
Toast.makeText(context, R.string.input_message_analog_only, Toast.LENGTH_LONG).show()
|
||||
return
|
||||
}
|
||||
key = getInputButtonKey(keyEvent.keyCode)
|
||||
val uiString = "${keyEvent.device.name}: Button ${keyEvent.keyCode}"
|
||||
value = uiString
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the provided key input setting as an Android preference.
|
||||
*/
|
||||
fun applyMapping() {
|
||||
writeButtonMapping(key)
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the provided motion input setting as an Android preference.
|
||||
*
|
||||
|
@ -71,6 +71,7 @@ class ControllerQuickConfigDialog(
|
||||
|
||||
private fun prepareUIforIndex(i: Int) {
|
||||
if (allButtons.size-1 < i) {
|
||||
settingsList.forEach { it.applyMapping() }
|
||||
dialog?.dismiss()
|
||||
return
|
||||
}
|
||||
@ -145,6 +146,8 @@ class ControllerQuickConfigDialog(
|
||||
private var setting: InputBindingSetting? = null
|
||||
private var debounceTimestamp = System.currentTimeMillis()
|
||||
|
||||
private var settingsList = arrayListOf<InputBindingSetting>()
|
||||
|
||||
private fun onKeyEvent(event: KeyEvent): Boolean {
|
||||
return when (event.action) {
|
||||
KeyEvent.ACTION_UP -> {
|
||||
@ -154,7 +157,10 @@ class ControllerQuickConfigDialog(
|
||||
|
||||
debounceTimestamp = System.currentTimeMillis()
|
||||
index++
|
||||
setting?.onKeyInput(event)
|
||||
setting?.let {
|
||||
it.onKeyInputDeferred(event)
|
||||
settingsList.add(it)
|
||||
}
|
||||
prepareUIforIndex(index)
|
||||
// Even if we ignore the key, we still consume it. Thus return true regardless.
|
||||
true
|
||||
|
Loading…
x
Reference in New Issue
Block a user