mirror of
https://github.com/azahar-emu/azahar
synced 2025-11-06 15:09:58 +01:00
android: Fix hotkey presses opening nav drawer even after being bound (#1122)
* android: Fix hotkey presses opening nav drawer even after being bound * Removed unnecessary return --------- Co-authored-by: Kleidis <167202775+kleidis@users.noreply.github.com> Co-authored-by: OpenSauce04 <opensauce04@gmail.com>
This commit is contained in:
parent
11687fe32b
commit
2b51691d57
@ -238,20 +238,26 @@ class EmulationActivity : AppCompatActivity() {
|
||||
preferences.getInt(InputBindingSetting.getInputButtonKey(event.keyCode), event.keyCode)
|
||||
val action: Int = when (event.action) {
|
||||
KeyEvent.ACTION_DOWN -> {
|
||||
hotkeyUtility.handleHotkey(button)
|
||||
|
||||
// On some devices, the back gesture / button press is not intercepted by androidx
|
||||
// and fails to open the emulation menu. So we're stuck running deprecated code to
|
||||
// cover for either a fault on androidx's side or in OEM skins (MIUI at least)
|
||||
if (event.keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
onBackPressed()
|
||||
// If the hotkey is pressed, we don't want to open the drawer
|
||||
if (!hotkeyUtility.HotkeyIsPressed) {
|
||||
onBackPressed()
|
||||
}
|
||||
}
|
||||
|
||||
hotkeyUtility.handleHotkey(button)
|
||||
|
||||
// Normal key events.
|
||||
NativeLibrary.ButtonState.PRESSED
|
||||
}
|
||||
|
||||
KeyEvent.ACTION_UP -> NativeLibrary.ButtonState.RELEASED
|
||||
KeyEvent.ACTION_UP -> {
|
||||
hotkeyUtility.HotkeyIsPressed = false
|
||||
NativeLibrary.ButtonState.RELEASED
|
||||
}
|
||||
else -> return false
|
||||
}
|
||||
val input = event.device
|
||||
|
||||
@ -17,6 +17,7 @@ class HotkeyUtility(
|
||||
private val context: Context) {
|
||||
|
||||
private val hotkeyButtons = Hotkey.entries.map { it.button }
|
||||
var HotkeyIsPressed = false
|
||||
|
||||
fun handleHotkey(bindedButton: Int): Boolean {
|
||||
if(hotkeyButtons.contains(bindedButton)) {
|
||||
@ -45,6 +46,7 @@ class HotkeyUtility(
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
HotkeyIsPressed = true
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user