mirror of
https://github.com/azahar-emu/azahar
synced 2025-11-07 07:29: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
dee9e93e9a
commit
6c63a1c8b6
@ -238,20 +238,26 @@ class EmulationActivity : AppCompatActivity() {
|
|||||||
preferences.getInt(InputBindingSetting.getInputButtonKey(event.keyCode), event.keyCode)
|
preferences.getInt(InputBindingSetting.getInputButtonKey(event.keyCode), event.keyCode)
|
||||||
val action: Int = when (event.action) {
|
val action: Int = when (event.action) {
|
||||||
KeyEvent.ACTION_DOWN -> {
|
KeyEvent.ACTION_DOWN -> {
|
||||||
|
hotkeyUtility.handleHotkey(button)
|
||||||
|
|
||||||
// On some devices, the back gesture / button press is not intercepted by androidx
|
// 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
|
// 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)
|
// cover for either a fault on androidx's side or in OEM skins (MIUI at least)
|
||||||
if (event.keyCode == KeyEvent.KEYCODE_BACK) {
|
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.
|
// Normal key events.
|
||||||
NativeLibrary.ButtonState.PRESSED
|
NativeLibrary.ButtonState.PRESSED
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyEvent.ACTION_UP -> NativeLibrary.ButtonState.RELEASED
|
KeyEvent.ACTION_UP -> {
|
||||||
|
hotkeyUtility.HotkeyIsPressed = false
|
||||||
|
NativeLibrary.ButtonState.RELEASED
|
||||||
|
}
|
||||||
else -> return false
|
else -> return false
|
||||||
}
|
}
|
||||||
val input = event.device
|
val input = event.device
|
||||||
|
|||||||
@ -17,6 +17,7 @@ class HotkeyUtility(
|
|||||||
private val context: Context) {
|
private val context: Context) {
|
||||||
|
|
||||||
private val hotkeyButtons = Hotkey.entries.map { it.button }
|
private val hotkeyButtons = Hotkey.entries.map { it.button }
|
||||||
|
var HotkeyIsPressed = false
|
||||||
|
|
||||||
fun handleHotkey(bindedButton: Int): Boolean {
|
fun handleHotkey(bindedButton: Int): Boolean {
|
||||||
if(hotkeyButtons.contains(bindedButton)) {
|
if(hotkeyButtons.contains(bindedButton)) {
|
||||||
@ -45,6 +46,7 @@ class HotkeyUtility(
|
|||||||
}
|
}
|
||||||
else -> {}
|
else -> {}
|
||||||
}
|
}
|
||||||
|
HotkeyIsPressed = true
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user