mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 11:18:54 +01:00
parent
8e46769284
commit
5ee3fdf628
19
genkeys.go
19
genkeys.go
@ -144,6 +144,8 @@ func init() {
|
||||
157: "KPAdd",
|
||||
160: "KPEnter",
|
||||
161: "KPEqual",
|
||||
117: "LeftSuper", // KEYCODE_META_LEFT
|
||||
118: "RightSuper", // KEYCODE_META_RIGHT
|
||||
}
|
||||
|
||||
gbuildKeyToDriverKeyName = map[key.Code]string{
|
||||
@ -189,6 +191,8 @@ func init() {
|
||||
key.CodeKeypadPlusSign: "KPAdd",
|
||||
key.CodeKeypadEnter: "KPEnter",
|
||||
key.CodeKeypadEqualSign: "KPEqual",
|
||||
key.CodeLeftGUI: "LeftSuper",
|
||||
key.CodeRightGUI: "RightSuper",
|
||||
|
||||
// Missing keys:
|
||||
// driver.KeyPrintScreen
|
||||
@ -242,6 +246,8 @@ func init() {
|
||||
"KPAdd": "NumpadAdd",
|
||||
"KPEnter": "NumpadEnter",
|
||||
"KPEqual": "NumpadEqual",
|
||||
"LeftSuper": "MetaLeft",
|
||||
"RightSuper": "MetaRight",
|
||||
}
|
||||
|
||||
// ASCII: 0 - 9
|
||||
@ -290,6 +296,7 @@ func init() {
|
||||
}
|
||||
|
||||
func init() {
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode
|
||||
// TODO: How should we treat modifier keys? Now 'left' modifier keys are available.
|
||||
edgeKeyCodeToName = map[int]string{
|
||||
0xbc: "Comma",
|
||||
@ -331,6 +338,8 @@ func init() {
|
||||
0x13: "Pause",
|
||||
0x91: "ScrollLock",
|
||||
0x5d: "Menu",
|
||||
0x5b: "LeftSuper", // "OSLeft" for macOS 10.10 or newer
|
||||
0xe0: "LeftSuper", // "DOM_VK_META" for macOS 10.9 or older
|
||||
|
||||
// On Edge, this key does not work. PrintScreen works only on keyup event.
|
||||
// 0x2C: "PrintScreen",
|
||||
@ -380,7 +389,8 @@ const (
|
||||
{{end}} KeyAlt Key = Key(driver.KeyReserved0)
|
||||
KeyControl Key = Key(driver.KeyReserved1)
|
||||
KeyShift Key = Key(driver.KeyReserved2)
|
||||
KeyMax Key = KeyShift
|
||||
KeySuper Key = Key(driver.KeyReserved3)
|
||||
KeyMax Key = KeySuper
|
||||
)
|
||||
|
||||
func (k Key) isValid() bool {
|
||||
@ -430,6 +440,7 @@ const (
|
||||
{{end}} KeyReserved0
|
||||
KeyReserved1
|
||||
KeyReserved2
|
||||
KeyReserved3
|
||||
)
|
||||
|
||||
func (k Key) String() string {
|
||||
@ -652,7 +663,7 @@ func main() {
|
||||
driverKeyNames := []string{}
|
||||
for name := range driverKeyNameToJSKey {
|
||||
driverKeyNames = append(driverKeyNames, name)
|
||||
if !strings.HasSuffix(name, "Alt") && !strings.HasSuffix(name, "Control") && !strings.HasSuffix(name, "Shift") {
|
||||
if !strings.HasSuffix(name, "Alt") && !strings.HasSuffix(name, "Control") && !strings.HasSuffix(name, "Shift") && !strings.HasSuffix(name, "Super") {
|
||||
ebitenKeyNames = append(ebitenKeyNames, name)
|
||||
ebitenKeyNamesWithoutMods = append(ebitenKeyNamesWithoutMods, name)
|
||||
continue
|
||||
@ -669,6 +680,10 @@ func main() {
|
||||
ebitenKeyNames = append(ebitenKeyNames, "Shift")
|
||||
continue
|
||||
}
|
||||
if name == "LeftSuper" {
|
||||
ebitenKeyNames = append(ebitenKeyNames, "Super")
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
sort.Slice(ebitenKeyNames, keyNamesLess(ebitenKeyNames))
|
||||
|
2
input.go
2
input.go
@ -66,6 +66,8 @@ func IsKeyPressed(key Key) bool {
|
||||
keys = []driver.Key{driver.KeyLeftControl, driver.KeyRightControl}
|
||||
case KeyShift:
|
||||
keys = []driver.Key{driver.KeyLeftShift, driver.KeyRightShift}
|
||||
case KeySuper:
|
||||
keys = []driver.Key{driver.KeyLeftSuper, driver.KeyRightSuper}
|
||||
default:
|
||||
keys = []driver.Key{driver.Key(key)}
|
||||
}
|
||||
|
@ -107,6 +107,7 @@ const (
|
||||
KeyLeftBracket
|
||||
KeyLeftControl
|
||||
KeyLeftShift
|
||||
KeyLeftSuper
|
||||
KeyMenu
|
||||
KeyMinus
|
||||
KeyNumLock
|
||||
@ -120,6 +121,7 @@ const (
|
||||
KeyRightBracket
|
||||
KeyRightControl
|
||||
KeyRightShift
|
||||
KeyRightSuper
|
||||
KeyScrollLock
|
||||
KeySemicolon
|
||||
KeySlash
|
||||
@ -129,6 +131,7 @@ const (
|
||||
KeyReserved0
|
||||
KeyReserved1
|
||||
KeyReserved2
|
||||
KeyReserved3
|
||||
)
|
||||
|
||||
func (k Key) String() string {
|
||||
@ -301,6 +304,8 @@ func (k Key) String() string {
|
||||
return "KeyLeftControl"
|
||||
case KeyLeftShift:
|
||||
return "KeyLeftShift"
|
||||
case KeyLeftSuper:
|
||||
return "KeyLeftSuper"
|
||||
case KeyMenu:
|
||||
return "KeyMenu"
|
||||
case KeyMinus:
|
||||
@ -327,6 +332,8 @@ func (k Key) String() string {
|
||||
return "KeyRightControl"
|
||||
case KeyRightShift:
|
||||
return "KeyRightShift"
|
||||
case KeyRightSuper:
|
||||
return "KeyRightSuper"
|
||||
case KeyScrollLock:
|
||||
return "KeyScrollLock"
|
||||
case KeySemicolon:
|
||||
|
@ -110,6 +110,7 @@ var glfwKeyToDriverKey = map[glfw.Key]driver.Key{
|
||||
glfw.KeyLeftBracket: driver.KeyLeftBracket,
|
||||
glfw.KeyLeftControl: driver.KeyLeftControl,
|
||||
glfw.KeyLeftShift: driver.KeyLeftShift,
|
||||
glfw.KeyLeftSuper: driver.KeyLeftSuper,
|
||||
glfw.KeyMenu: driver.KeyMenu,
|
||||
glfw.KeyMinus: driver.KeyMinus,
|
||||
glfw.KeyNumLock: driver.KeyNumLock,
|
||||
@ -123,6 +124,7 @@ var glfwKeyToDriverKey = map[glfw.Key]driver.Key{
|
||||
glfw.KeyRightBracket: driver.KeyRightBracket,
|
||||
glfw.KeyRightControl: driver.KeyRightControl,
|
||||
glfw.KeyRightShift: driver.KeyRightShift,
|
||||
glfw.KeyRightSuper: driver.KeyRightSuper,
|
||||
glfw.KeyScrollLock: driver.KeyScrollLock,
|
||||
glfw.KeySemicolon: driver.KeySemicolon,
|
||||
glfw.KeySlash: driver.KeySlash,
|
||||
@ -216,6 +218,7 @@ var driverKeyToGLFWKey = map[driver.Key]glfw.Key{
|
||||
driver.KeyLeftBracket: glfw.KeyLeftBracket,
|
||||
driver.KeyLeftControl: glfw.KeyLeftControl,
|
||||
driver.KeyLeftShift: glfw.KeyLeftShift,
|
||||
driver.KeyLeftSuper: glfw.KeyLeftSuper,
|
||||
driver.KeyMenu: glfw.KeyMenu,
|
||||
driver.KeyMinus: glfw.KeyMinus,
|
||||
driver.KeyNumLock: glfw.KeyNumLock,
|
||||
@ -229,6 +232,7 @@ var driverKeyToGLFWKey = map[driver.Key]glfw.Key{
|
||||
driver.KeyRightBracket: glfw.KeyRightBracket,
|
||||
driver.KeyRightControl: glfw.KeyRightControl,
|
||||
driver.KeyRightShift: glfw.KeyRightShift,
|
||||
driver.KeyRightSuper: glfw.KeyRightSuper,
|
||||
driver.KeyScrollLock: glfw.KeyScrollLock,
|
||||
driver.KeySemicolon: glfw.KeySemicolon,
|
||||
driver.KeySlash: glfw.KeySlash,
|
||||
|
@ -91,6 +91,7 @@ var driverKeyToJSKey = map[driver.Key]string{
|
||||
driver.KeyLeftBracket: "BracketLeft",
|
||||
driver.KeyLeftControl: "ControlLeft",
|
||||
driver.KeyLeftShift: "ShiftLeft",
|
||||
driver.KeyLeftSuper: "MetaLeft",
|
||||
driver.KeyM: "KeyM",
|
||||
driver.KeyMenu: "ContextMenu",
|
||||
driver.KeyMinus: "Minus",
|
||||
@ -110,6 +111,7 @@ var driverKeyToJSKey = map[driver.Key]string{
|
||||
driver.KeyRightBracket: "BracketRight",
|
||||
driver.KeyRightControl: "ControlRight",
|
||||
driver.KeyRightShift: "ShiftRight",
|
||||
driver.KeyRightSuper: "MetaRight",
|
||||
driver.KeyS: "KeyS",
|
||||
driver.KeyScrollLock: "ScrollLock",
|
||||
driver.KeySemicolon: "Semicolon",
|
||||
@ -183,6 +185,7 @@ var edgeKeyCodeToDriverKey = map[int]driver.Key{
|
||||
88: driver.KeyX,
|
||||
89: driver.KeyY,
|
||||
90: driver.KeyZ,
|
||||
91: driver.KeyLeftSuper,
|
||||
93: driver.KeyMenu,
|
||||
96: driver.KeyKP0,
|
||||
97: driver.KeyKP1,
|
||||
@ -224,4 +227,5 @@ var edgeKeyCodeToDriverKey = map[int]driver.Key{
|
||||
220: driver.KeyBackslash,
|
||||
221: driver.KeyRightBracket,
|
||||
222: driver.KeyApostrophe,
|
||||
224: driver.KeyLeftSuper,
|
||||
}
|
||||
|
@ -120,7 +120,9 @@ var gbuildKeyToDriverKey = map[key.Code]driver.Key{
|
||||
key.CodeLeftControl: driver.KeyLeftControl,
|
||||
key.CodeLeftShift: driver.KeyLeftShift,
|
||||
key.CodeLeftAlt: driver.KeyLeftAlt,
|
||||
key.CodeLeftGUI: driver.KeyLeftSuper,
|
||||
key.CodeRightControl: driver.KeyRightControl,
|
||||
key.CodeRightShift: driver.KeyRightShift,
|
||||
key.CodeRightAlt: driver.KeyRightAlt,
|
||||
key.CodeRightGUI: driver.KeyRightSuper,
|
||||
}
|
||||
|
9
keys.go
9
keys.go
@ -129,7 +129,8 @@ const (
|
||||
KeyAlt Key = Key(driver.KeyReserved0)
|
||||
KeyControl Key = Key(driver.KeyReserved1)
|
||||
KeyShift Key = Key(driver.KeyReserved2)
|
||||
KeyMax Key = KeyShift
|
||||
KeySuper Key = Key(driver.KeyReserved3)
|
||||
KeyMax Key = KeySuper
|
||||
)
|
||||
|
||||
func (k Key) isValid() bool {
|
||||
@ -330,6 +331,8 @@ func (k Key) isValid() bool {
|
||||
return true
|
||||
case KeySpace:
|
||||
return true
|
||||
case KeySuper:
|
||||
return true
|
||||
case KeyTab:
|
||||
return true
|
||||
case KeyUp:
|
||||
@ -541,6 +544,8 @@ func (k Key) String() string {
|
||||
return "Slash"
|
||||
case KeySpace:
|
||||
return "Space"
|
||||
case KeySuper:
|
||||
return "Super"
|
||||
case KeyTab:
|
||||
return "Tab"
|
||||
case KeyUp:
|
||||
@ -747,6 +752,8 @@ func keyNameToKeyCode(name string) (Key, bool) {
|
||||
return KeySlash, true
|
||||
case "space":
|
||||
return KeySpace, true
|
||||
case "super":
|
||||
return KeySuper, true
|
||||
case "tab":
|
||||
return KeyTab, true
|
||||
case "up":
|
||||
|
@ -89,6 +89,8 @@ var androidKeyToDriverKey = map[int]driver.Key{
|
||||
114: driver.KeyRightControl,
|
||||
115: driver.KeyCapsLock,
|
||||
116: driver.KeyScrollLock,
|
||||
117: driver.KeyLeftSuper,
|
||||
118: driver.KeyRightSuper,
|
||||
120: driver.KeyPrintScreen,
|
||||
121: driver.KeyPause,
|
||||
122: driver.KeyHome,
|
||||
|
Loading…
Reference in New Issue
Block a user