mobile/ebitenmobileview: Android: include keypress runes even for unmapped keys. (#2685)

Note that this is a theoretical bug - I do not have a keyboard I can
reproduce this. However, if I remove a key from genkeys.go, pressing
that key will, after this change, still emit its character to
AppendInputChars.

Thus, this better supports "odd" international keyboards.

Also, make the updateInput calls more consistent - always one call per
event. This should change no behavior, but should be more debuggable.

Closes #2684
This commit is contained in:
divVerent 2023-06-24 08:33:17 -04:00 committed by Hajime Hoshi
parent 1b9a7439f4
commit 0439167637

View File

@ -142,13 +142,13 @@ func OnKeyDownOnAndroid(keyCode int, unicodeChar int, source int, deviceID int)
case source&sourceKeyboard == sourceKeyboard: case source&sourceKeyboard == sourceKeyboard:
if key, ok := androidKeyToUIKey[keyCode]; ok { if key, ok := androidKeyToUIKey[keyCode]; ok {
keys[key] = struct{}{} keys[key] = struct{}{}
}
var runes []rune var runes []rune
if r := rune(unicodeChar); r != 0 && unicode.IsPrint(r) { if r := rune(unicodeChar); r != 0 && unicode.IsPrint(r) {
runes = []rune{r} runes = []rune{r}
} }
updateInput(runes) updateInput(runes)
} }
}
} }
func OnKeyUpOnAndroid(keyCode int, source int, deviceID int) { func OnKeyUpOnAndroid(keyCode int, source int, deviceID int) {
@ -163,8 +163,8 @@ func OnKeyUpOnAndroid(keyCode int, source int, deviceID int) {
case source&sourceKeyboard == sourceKeyboard: case source&sourceKeyboard == sourceKeyboard:
if key, ok := androidKeyToUIKey[keyCode]; ok { if key, ok := androidKeyToUIKey[keyCode]; ok {
delete(keys, key) delete(keys, key)
updateInput(nil)
} }
updateInput(nil)
} }
} }