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

View File

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

View File

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

View File

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

View File

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

View File

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