ebiten: add KeyIntlBackslash

Updates #2921
This commit is contained in:
Hajime Hoshi 2024-03-12 12:10:19 +09:00
parent 4c7ed56077
commit 7389f9ddb2
6 changed files with 25 additions and 4 deletions

View File

@ -140,9 +140,17 @@ func init() {
"NumpadSubtract": "KPSubtract",
"NumpadEnter": "KPEnter",
"NumpadEqual": "KPEqual",
"IntlBackslash": "World1",
}
// https://developer.android.com/reference/android/view/KeyEvent
//
// Android doesn't distinguish these keys:
// - a US backslash key (HID: 0x31),
// - an international pound/tilde key (HID: 0x32), and
// - an international backslash key (HID: 0x64).
// These are mapped to the same key code KEYCODE_BACKSLASH (73).
// See https://source.android.com/docs/core/interaction/input/keyboard-devices
androidKeyToUIKeyName = map[int]string{
55: "Comma",
56: "Period",
@ -204,16 +212,16 @@ func init() {
0x35: "Backquote",
// These three keys are:
// - US backslash-pipe key (above return),
// - non-US backslash key (next to left shift; on German layout this is the <>| key), and
// - US backslash-pipe key, and
// - non-US hashmark key (bottom left of return; on German layout, this is the #' key).
// On US layout configurations, they all map to the same characters - the backslash.
//
// See also: https://www.w3.org/TR/uievents-code/#keyboard-102
0x31: "Backslash", // UIKeyboardHIDUsageKeyboardBackslash
0x64: "Backslash", // UIKeyboardHIDUsageKeyboardNonUSBackslash
0x32: "Backslash", // UIKeyboardHIDUsageKeyboardNonUSPound
0x64: "IntlBackslash", // UIKeyboardHIDUsageKeyboardNonUSBackslash
0x2A: "Backspace",
0x2F: "BracketLeft",
0x30: "BracketRight",
@ -326,6 +334,7 @@ func init() {
"NumpadEqual": "NumpadEqual",
"MetaLeft": "MetaLeft",
"MetaRight": "MetaRight",
"IntlBackslash": "IntlBackslash",
}
const (

View File

@ -106,6 +106,7 @@ const (
KeyF24
KeyHome
KeyInsert
KeyIntlBackslash
KeyMetaLeft
KeyMetaRight
KeyMinus
@ -315,6 +316,8 @@ func (k Key) String() string {
return "KeyHome"
case KeyInsert:
return "KeyInsert"
case KeyIntlBackslash:
return "KeyIntlBackslash"
case KeyMetaLeft:
return "KeyMetaLeft"
case KeyMetaRight:

View File

@ -89,6 +89,7 @@ var uiKeyToGLFWKey = map[Key]glfw.Key{
KeyHome: glfw.KeyHome,
KeyI: glfw.KeyI,
KeyInsert: glfw.KeyInsert,
KeyIntlBackslash: glfw.KeyWorld1,
KeyJ: glfw.KeyJ,
KeyK: glfw.KeyK,
KeyL: glfw.KeyL,

View File

@ -87,6 +87,7 @@ var uiKeyToJSCode = map[Key]js.Value{
KeyHome: js.ValueOf("Home"),
KeyI: js.ValueOf("KeyI"),
KeyInsert: js.ValueOf("Insert"),
KeyIntlBackslash: js.ValueOf("IntlBackslash"),
KeyJ: js.ValueOf("KeyJ"),
KeyK: js.ValueOf("KeyK"),
KeyL: js.ValueOf("KeyL"),

View File

@ -113,6 +113,7 @@ const (
KeyF24 Key = Key(ui.KeyF24)
KeyHome Key = Key(ui.KeyHome)
KeyInsert Key = Key(ui.KeyInsert)
KeyIntlBackslash Key = Key(ui.KeyIntlBackslash)
KeyMetaLeft Key = Key(ui.KeyMetaLeft)
KeyMetaRight Key = Key(ui.KeyMetaRight)
KeyMinus Key = Key(ui.KeyMinus)
@ -365,6 +366,8 @@ func (k Key) isValid() bool {
return true
case KeyInsert:
return true
case KeyIntlBackslash:
return true
case KeyMeta:
return true
case KeyMetaLeft:
@ -618,6 +621,8 @@ func (k Key) String() string {
return "Home"
case KeyInsert:
return "Insert"
case KeyIntlBackslash:
return "IntlBackslash"
case KeyMeta:
return "Meta"
case KeyMetaLeft:
@ -892,6 +897,8 @@ func keyNameToKeyCode(name string) (Key, bool) {
return KeyHome, true
case "insert":
return KeyInsert, true
case "intlbackslash":
return KeyIntlBackslash, true
case "kp0":
return KeyKP0, true
case "kp1":

View File

@ -117,7 +117,7 @@ var iosKeyToUIKey = map[int]ui.Key{
97: ui.KeyNumpad9,
98: ui.KeyNumpad0,
99: ui.KeyNumpadDecimal,
100: ui.KeyBackslash,
100: ui.KeyIntlBackslash,
103: ui.KeyNumpadEqual,
104: ui.KeyF13,
105: ui.KeyF14,