input: Move Key to driver package

This commit is contained in:
Hajime Hoshi 2019-03-30 23:28:07 +09:00
parent e5b1aa8742
commit 7dca1889a1
7 changed files with 422 additions and 420 deletions

View File

@ -239,7 +239,7 @@ package ebiten
import ( import (
"strings" "strings"
"github.com/hajimehoshi/ebiten/internal/input" "github.com/hajimehoshi/ebiten/internal/driver"
) )
// A Key represents a keyboard key. // A Key represents a keyboard key.
@ -249,7 +249,7 @@ type Key int
// Keys. // Keys.
const ( const (
{{range $index, $name := .KeyNames}}Key{{$name}} Key = Key(input.Key{{$name}}) {{range $index, $name := .KeyNames}}Key{{$name}} Key = Key(driver.Key{{$name}})
{{end}} KeyMax Key = Key{{.LastKeyName}} {{end}} KeyMax Key = Key{{.LastKeyName}}
) )
@ -273,11 +273,11 @@ func keyNameToKey(name string) (Key, bool) {
} }
` `
const inputKeysTmpl = `{{.License}} const driverKeysTmpl = `{{.License}}
{{.DoNotEdit}} {{.DoNotEdit}}
package input package driver
type Key int type Key int
@ -296,18 +296,19 @@ const inputKeysGlfwTmpl = `{{.License}}
package input package input
import ( import (
"github.com/hajimehoshi/ebiten/internal/driver"
"github.com/hajimehoshi/ebiten/internal/glfw" "github.com/hajimehoshi/ebiten/internal/glfw"
) )
var glfwKeyCodeToKey = map[glfw.Key]Key{ var glfwKeyCodeToKey = map[glfw.Key]driver.Key{
{{range $index, $name := .KeyNamesWithoutMods}}glfw.Key{{$name}}: Key{{$name}}, {{range $index, $name := .KeyNamesWithoutMods}}glfw.Key{{$name}}: driver.Key{{$name}},
{{end}} {{end}}
glfw.KeyLeftAlt: KeyAlt, glfw.KeyLeftAlt: driver.KeyAlt,
glfw.KeyRightAlt: KeyAlt, glfw.KeyRightAlt: driver.KeyAlt,
glfw.KeyLeftControl: KeyControl, glfw.KeyLeftControl: driver.KeyControl,
glfw.KeyRightControl: KeyControl, glfw.KeyRightControl: driver.KeyControl,
glfw.KeyLeftShift: KeyShift, glfw.KeyLeftShift: driver.KeyShift,
glfw.KeyRightShift: KeyShift, glfw.KeyRightShift: driver.KeyShift,
} }
` `
@ -320,14 +321,14 @@ const inputKeysJSTmpl = `{{.License}}
package input package input
var keyToCodes = map[Key][]string{ var keyToCodes = map[Key][]string{
{{range $name, $codes := .NameToJSKeyCodes}}Key{{$name}}: []string{ {{range $name, $codes := .NameToJSKeyCodes}}driver.Key{{$name}}: []string{
{{range $code := $codes}}"{{$code}}",{{end}} {{range $code := $codes}}"{{$code}}",{{end}}
}, },
{{end}} {{end}}
} }
var keyCodeToKeyEdge = map[int]Key{ var keyCodeToKeyEdge = map[int]Key{
{{range $code, $name := .KeyCodeToNameEdge}}{{$code}}: Key{{$name}}, {{range $code, $name := .KeyCodeToNameEdge}}{{$code}}: driver.Key{{$name}},
{{end}} {{end}}
} }
` `
@ -468,7 +469,7 @@ func main() {
for path, tmpl := range map[string]string{ for path, tmpl := range map[string]string{
"keys.go": ebitenKeysTmpl, "keys.go": ebitenKeysTmpl,
"internal/input/keys.go": inputKeysTmpl, "internal/driver/keys.go": driverKeysTmpl,
"internal/input/keys_glfw.go": inputKeysGlfwTmpl, "internal/input/keys_glfw.go": inputKeysGlfwTmpl,
"internal/input/keys_js.go": inputKeysJSTmpl, "internal/input/keys_js.go": inputKeysJSTmpl,
"internal/glfw/keys.go": glfwKeysTmpl, "internal/glfw/keys.go": glfwKeysTmpl,

View File

@ -43,7 +43,7 @@ func InputChars() []rune {
// //
// IsKeyPressed is concurrent-safe. // IsKeyPressed is concurrent-safe.
func IsKeyPressed(key Key) bool { func IsKeyPressed(key Key) bool {
return input.Get().IsKeyPressed(input.Key(key)) return input.Get().IsKeyPressed(driver.Key(key))
} }
// CursorPosition returns a position of a mouse cursor. // CursorPosition returns a position of a mouse cursor.

View File

@ -14,7 +14,7 @@
// Code generated by genkeys.go using 'go generate'. DO NOT EDIT. // Code generated by genkeys.go using 'go generate'. DO NOT EDIT.
package input package driver
type Key int type Key int

View File

@ -59,7 +59,7 @@ func (i *Input) ResetScrollValues() {
i.scrollX, i.scrollY = 0, 0 i.scrollX, i.scrollY = 0, 0
} }
func (i *Input) IsKeyPressed(key Key) bool { func (i *Input) IsKeyPressed(key driver.Key) bool {
i.m.RLock() i.m.RLock()
defer i.m.RUnlock() defer i.m.RUnlock()
if i.keyPressed == nil { if i.keyPressed == nil {

View File

@ -22,112 +22,113 @@
package input package input
import ( import (
"github.com/hajimehoshi/ebiten/internal/driver"
"github.com/hajimehoshi/ebiten/internal/glfw" "github.com/hajimehoshi/ebiten/internal/glfw"
) )
var glfwKeyCodeToKey = map[glfw.Key]Key{ var glfwKeyCodeToKey = map[glfw.Key]driver.Key{
glfw.Key0: Key0, glfw.Key0: driver.Key0,
glfw.Key1: Key1, glfw.Key1: driver.Key1,
glfw.Key2: Key2, glfw.Key2: driver.Key2,
glfw.Key3: Key3, glfw.Key3: driver.Key3,
glfw.Key4: Key4, glfw.Key4: driver.Key4,
glfw.Key5: Key5, glfw.Key5: driver.Key5,
glfw.Key6: Key6, glfw.Key6: driver.Key6,
glfw.Key7: Key7, glfw.Key7: driver.Key7,
glfw.Key8: Key8, glfw.Key8: driver.Key8,
glfw.Key9: Key9, glfw.Key9: driver.Key9,
glfw.KeyA: KeyA, glfw.KeyA: driver.KeyA,
glfw.KeyB: KeyB, glfw.KeyB: driver.KeyB,
glfw.KeyC: KeyC, glfw.KeyC: driver.KeyC,
glfw.KeyD: KeyD, glfw.KeyD: driver.KeyD,
glfw.KeyE: KeyE, glfw.KeyE: driver.KeyE,
glfw.KeyF: KeyF, glfw.KeyF: driver.KeyF,
glfw.KeyG: KeyG, glfw.KeyG: driver.KeyG,
glfw.KeyH: KeyH, glfw.KeyH: driver.KeyH,
glfw.KeyI: KeyI, glfw.KeyI: driver.KeyI,
glfw.KeyJ: KeyJ, glfw.KeyJ: driver.KeyJ,
glfw.KeyK: KeyK, glfw.KeyK: driver.KeyK,
glfw.KeyL: KeyL, glfw.KeyL: driver.KeyL,
glfw.KeyM: KeyM, glfw.KeyM: driver.KeyM,
glfw.KeyN: KeyN, glfw.KeyN: driver.KeyN,
glfw.KeyO: KeyO, glfw.KeyO: driver.KeyO,
glfw.KeyP: KeyP, glfw.KeyP: driver.KeyP,
glfw.KeyQ: KeyQ, glfw.KeyQ: driver.KeyQ,
glfw.KeyR: KeyR, glfw.KeyR: driver.KeyR,
glfw.KeyS: KeyS, glfw.KeyS: driver.KeyS,
glfw.KeyT: KeyT, glfw.KeyT: driver.KeyT,
glfw.KeyU: KeyU, glfw.KeyU: driver.KeyU,
glfw.KeyV: KeyV, glfw.KeyV: driver.KeyV,
glfw.KeyW: KeyW, glfw.KeyW: driver.KeyW,
glfw.KeyX: KeyX, glfw.KeyX: driver.KeyX,
glfw.KeyY: KeyY, glfw.KeyY: driver.KeyY,
glfw.KeyZ: KeyZ, glfw.KeyZ: driver.KeyZ,
glfw.KeyApostrophe: KeyApostrophe, glfw.KeyApostrophe: driver.KeyApostrophe,
glfw.KeyBackslash: KeyBackslash, glfw.KeyBackslash: driver.KeyBackslash,
glfw.KeyBackspace: KeyBackspace, glfw.KeyBackspace: driver.KeyBackspace,
glfw.KeyCapsLock: KeyCapsLock, glfw.KeyCapsLock: driver.KeyCapsLock,
glfw.KeyComma: KeyComma, glfw.KeyComma: driver.KeyComma,
glfw.KeyDelete: KeyDelete, glfw.KeyDelete: driver.KeyDelete,
glfw.KeyDown: KeyDown, glfw.KeyDown: driver.KeyDown,
glfw.KeyEnd: KeyEnd, glfw.KeyEnd: driver.KeyEnd,
glfw.KeyEnter: KeyEnter, glfw.KeyEnter: driver.KeyEnter,
glfw.KeyEqual: KeyEqual, glfw.KeyEqual: driver.KeyEqual,
glfw.KeyEscape: KeyEscape, glfw.KeyEscape: driver.KeyEscape,
glfw.KeyF1: KeyF1, glfw.KeyF1: driver.KeyF1,
glfw.KeyF2: KeyF2, glfw.KeyF2: driver.KeyF2,
glfw.KeyF3: KeyF3, glfw.KeyF3: driver.KeyF3,
glfw.KeyF4: KeyF4, glfw.KeyF4: driver.KeyF4,
glfw.KeyF5: KeyF5, glfw.KeyF5: driver.KeyF5,
glfw.KeyF6: KeyF6, glfw.KeyF6: driver.KeyF6,
glfw.KeyF7: KeyF7, glfw.KeyF7: driver.KeyF7,
glfw.KeyF8: KeyF8, glfw.KeyF8: driver.KeyF8,
glfw.KeyF9: KeyF9, glfw.KeyF9: driver.KeyF9,
glfw.KeyF10: KeyF10, glfw.KeyF10: driver.KeyF10,
glfw.KeyF11: KeyF11, glfw.KeyF11: driver.KeyF11,
glfw.KeyF12: KeyF12, glfw.KeyF12: driver.KeyF12,
glfw.KeyGraveAccent: KeyGraveAccent, glfw.KeyGraveAccent: driver.KeyGraveAccent,
glfw.KeyHome: KeyHome, glfw.KeyHome: driver.KeyHome,
glfw.KeyInsert: KeyInsert, glfw.KeyInsert: driver.KeyInsert,
glfw.KeyKP0: KeyKP0, glfw.KeyKP0: driver.KeyKP0,
glfw.KeyKP1: KeyKP1, glfw.KeyKP1: driver.KeyKP1,
glfw.KeyKP2: KeyKP2, glfw.KeyKP2: driver.KeyKP2,
glfw.KeyKP3: KeyKP3, glfw.KeyKP3: driver.KeyKP3,
glfw.KeyKP4: KeyKP4, glfw.KeyKP4: driver.KeyKP4,
glfw.KeyKP5: KeyKP5, glfw.KeyKP5: driver.KeyKP5,
glfw.KeyKP6: KeyKP6, glfw.KeyKP6: driver.KeyKP6,
glfw.KeyKP7: KeyKP7, glfw.KeyKP7: driver.KeyKP7,
glfw.KeyKP8: KeyKP8, glfw.KeyKP8: driver.KeyKP8,
glfw.KeyKP9: KeyKP9, glfw.KeyKP9: driver.KeyKP9,
glfw.KeyKPAdd: KeyKPAdd, glfw.KeyKPAdd: driver.KeyKPAdd,
glfw.KeyKPDecimal: KeyKPDecimal, glfw.KeyKPDecimal: driver.KeyKPDecimal,
glfw.KeyKPDivide: KeyKPDivide, glfw.KeyKPDivide: driver.KeyKPDivide,
glfw.KeyKPEnter: KeyKPEnter, glfw.KeyKPEnter: driver.KeyKPEnter,
glfw.KeyKPEqual: KeyKPEqual, glfw.KeyKPEqual: driver.KeyKPEqual,
glfw.KeyKPMultiply: KeyKPMultiply, glfw.KeyKPMultiply: driver.KeyKPMultiply,
glfw.KeyKPSubtract: KeyKPSubtract, glfw.KeyKPSubtract: driver.KeyKPSubtract,
glfw.KeyLeft: KeyLeft, glfw.KeyLeft: driver.KeyLeft,
glfw.KeyLeftBracket: KeyLeftBracket, glfw.KeyLeftBracket: driver.KeyLeftBracket,
glfw.KeyMenu: KeyMenu, glfw.KeyMenu: driver.KeyMenu,
glfw.KeyMinus: KeyMinus, glfw.KeyMinus: driver.KeyMinus,
glfw.KeyNumLock: KeyNumLock, glfw.KeyNumLock: driver.KeyNumLock,
glfw.KeyPageDown: KeyPageDown, glfw.KeyPageDown: driver.KeyPageDown,
glfw.KeyPageUp: KeyPageUp, glfw.KeyPageUp: driver.KeyPageUp,
glfw.KeyPause: KeyPause, glfw.KeyPause: driver.KeyPause,
glfw.KeyPeriod: KeyPeriod, glfw.KeyPeriod: driver.KeyPeriod,
glfw.KeyPrintScreen: KeyPrintScreen, glfw.KeyPrintScreen: driver.KeyPrintScreen,
glfw.KeyRight: KeyRight, glfw.KeyRight: driver.KeyRight,
glfw.KeyRightBracket: KeyRightBracket, glfw.KeyRightBracket: driver.KeyRightBracket,
glfw.KeyScrollLock: KeyScrollLock, glfw.KeyScrollLock: driver.KeyScrollLock,
glfw.KeySemicolon: KeySemicolon, glfw.KeySemicolon: driver.KeySemicolon,
glfw.KeySlash: KeySlash, glfw.KeySlash: driver.KeySlash,
glfw.KeySpace: KeySpace, glfw.KeySpace: driver.KeySpace,
glfw.KeyTab: KeyTab, glfw.KeyTab: driver.KeyTab,
glfw.KeyUp: KeyUp, glfw.KeyUp: driver.KeyUp,
glfw.KeyLeftAlt: KeyAlt, glfw.KeyLeftAlt: driver.KeyAlt,
glfw.KeyRightAlt: KeyAlt, glfw.KeyRightAlt: driver.KeyAlt,
glfw.KeyLeftControl: KeyControl, glfw.KeyLeftControl: driver.KeyControl,
glfw.KeyRightControl: KeyControl, glfw.KeyRightControl: driver.KeyControl,
glfw.KeyLeftShift: KeyShift, glfw.KeyLeftShift: driver.KeyShift,
glfw.KeyRightShift: KeyShift, glfw.KeyRightShift: driver.KeyShift,
} }

View File

@ -19,404 +19,404 @@
package input package input
var keyToCodes = map[Key][]string{ var keyToCodes = map[Key][]string{
Key0: { driver.Key0: {
"Digit0", "Digit0",
}, },
Key1: { driver.Key1: {
"Digit1", "Digit1",
}, },
Key2: { driver.Key2: {
"Digit2", "Digit2",
}, },
Key3: { driver.Key3: {
"Digit3", "Digit3",
}, },
Key4: { driver.Key4: {
"Digit4", "Digit4",
}, },
Key5: { driver.Key5: {
"Digit5", "Digit5",
}, },
Key6: { driver.Key6: {
"Digit6", "Digit6",
}, },
Key7: { driver.Key7: {
"Digit7", "Digit7",
}, },
Key8: { driver.Key8: {
"Digit8", "Digit8",
}, },
Key9: { driver.Key9: {
"Digit9", "Digit9",
}, },
KeyA: { driver.KeyA: {
"KeyA", "KeyA",
}, },
KeyAlt: { driver.KeyAlt: {
"AltLeft", "AltRight", "AltLeft", "AltRight",
}, },
KeyApostrophe: { driver.KeyApostrophe: {
"Quote", "Quote",
}, },
KeyB: { driver.KeyB: {
"KeyB", "KeyB",
}, },
KeyBackslash: { driver.KeyBackslash: {
"Backslash", "Backslash",
}, },
KeyBackspace: { driver.KeyBackspace: {
"Backspace", "Backspace",
}, },
KeyC: { driver.KeyC: {
"KeyC", "KeyC",
}, },
KeyCapsLock: { driver.KeyCapsLock: {
"CapsLock", "CapsLock",
}, },
KeyComma: { driver.KeyComma: {
"Comma", "Comma",
}, },
KeyControl: { driver.KeyControl: {
"ControlLeft", "ControlRight", "ControlLeft", "ControlRight",
}, },
KeyD: { driver.KeyD: {
"KeyD", "KeyD",
}, },
KeyDelete: { driver.KeyDelete: {
"Delete", "Delete",
}, },
KeyDown: { driver.KeyDown: {
"ArrowDown", "ArrowDown",
}, },
KeyE: { driver.KeyE: {
"KeyE", "KeyE",
}, },
KeyEnd: { driver.KeyEnd: {
"End", "End",
}, },
KeyEnter: { driver.KeyEnter: {
"Enter", "Enter",
}, },
KeyEqual: { driver.KeyEqual: {
"Equal", "Equal",
}, },
KeyEscape: { driver.KeyEscape: {
"Escape", "Escape",
}, },
KeyF: { driver.KeyF: {
"KeyF", "KeyF",
}, },
KeyF1: { driver.KeyF1: {
"F1", "F1",
}, },
KeyF10: { driver.KeyF10: {
"F10", "F10",
}, },
KeyF11: { driver.KeyF11: {
"F11", "F11",
}, },
KeyF12: { driver.KeyF12: {
"F12", "F12",
}, },
KeyF2: { driver.KeyF2: {
"F2", "F2",
}, },
KeyF3: { driver.KeyF3: {
"F3", "F3",
}, },
KeyF4: { driver.KeyF4: {
"F4", "F4",
}, },
KeyF5: { driver.KeyF5: {
"F5", "F5",
}, },
KeyF6: { driver.KeyF6: {
"F6", "F6",
}, },
KeyF7: { driver.KeyF7: {
"F7", "F7",
}, },
KeyF8: { driver.KeyF8: {
"F8", "F8",
}, },
KeyF9: { driver.KeyF9: {
"F9", "F9",
}, },
KeyG: { driver.KeyG: {
"KeyG", "KeyG",
}, },
KeyGraveAccent: { driver.KeyGraveAccent: {
"Backquote", "Backquote",
}, },
KeyH: { driver.KeyH: {
"KeyH", "KeyH",
}, },
KeyHome: { driver.KeyHome: {
"Home", "Home",
}, },
KeyI: { driver.KeyI: {
"KeyI", "KeyI",
}, },
KeyInsert: { driver.KeyInsert: {
"Insert", "Insert",
}, },
KeyJ: { driver.KeyJ: {
"KeyJ", "KeyJ",
}, },
KeyK: { driver.KeyK: {
"KeyK", "KeyK",
}, },
KeyKP0: { driver.KeyKP0: {
"Numpad0", "Numpad0",
}, },
KeyKP1: { driver.KeyKP1: {
"Numpad1", "Numpad1",
}, },
KeyKP2: { driver.KeyKP2: {
"Numpad2", "Numpad2",
}, },
KeyKP3: { driver.KeyKP3: {
"Numpad3", "Numpad3",
}, },
KeyKP4: { driver.KeyKP4: {
"Numpad4", "Numpad4",
}, },
KeyKP5: { driver.KeyKP5: {
"Numpad5", "Numpad5",
}, },
KeyKP6: { driver.KeyKP6: {
"Numpad6", "Numpad6",
}, },
KeyKP7: { driver.KeyKP7: {
"Numpad7", "Numpad7",
}, },
KeyKP8: { driver.KeyKP8: {
"Numpad8", "Numpad8",
}, },
KeyKP9: { driver.KeyKP9: {
"Numpad9", "Numpad9",
}, },
KeyKPAdd: { driver.KeyKPAdd: {
"NumpadAdd", "NumpadAdd",
}, },
KeyKPDecimal: { driver.KeyKPDecimal: {
"NumpadDecimal", "NumpadDecimal",
}, },
KeyKPDivide: { driver.KeyKPDivide: {
"NumpadDivide", "NumpadDivide",
}, },
KeyKPEnter: { driver.KeyKPEnter: {
"NumpadEnter", "NumpadEnter",
}, },
KeyKPEqual: { driver.KeyKPEqual: {
"NumpadEqual", "NumpadEqual",
}, },
KeyKPMultiply: { driver.KeyKPMultiply: {
"NumpadMultiply", "NumpadMultiply",
}, },
KeyKPSubtract: { driver.KeyKPSubtract: {
"NumpadSubtract", "NumpadSubtract",
}, },
KeyL: { driver.KeyL: {
"KeyL", "KeyL",
}, },
KeyLeft: { driver.KeyLeft: {
"ArrowLeft", "ArrowLeft",
}, },
KeyLeftBracket: { driver.KeyLeftBracket: {
"BracketLeft", "BracketLeft",
}, },
KeyM: { driver.KeyM: {
"KeyM", "KeyM",
}, },
KeyMenu: { driver.KeyMenu: {
"ContextMenu", "ContextMenu",
}, },
KeyMinus: { driver.KeyMinus: {
"Minus", "Minus",
}, },
KeyN: { driver.KeyN: {
"KeyN", "KeyN",
}, },
KeyNumLock: { driver.KeyNumLock: {
"NumLock", "NumLock",
}, },
KeyO: { driver.KeyO: {
"KeyO", "KeyO",
}, },
KeyP: { driver.KeyP: {
"KeyP", "KeyP",
}, },
KeyPageDown: { driver.KeyPageDown: {
"PageDown", "PageDown",
}, },
KeyPageUp: { driver.KeyPageUp: {
"PageUp", "PageUp",
}, },
KeyPause: { driver.KeyPause: {
"Pause", "Pause",
}, },
KeyPeriod: { driver.KeyPeriod: {
"Period", "Period",
}, },
KeyPrintScreen: { driver.KeyPrintScreen: {
"PrintScreen", "PrintScreen",
}, },
KeyQ: { driver.KeyQ: {
"KeyQ", "KeyQ",
}, },
KeyR: { driver.KeyR: {
"KeyR", "KeyR",
}, },
KeyRight: { driver.KeyRight: {
"ArrowRight", "ArrowRight",
}, },
KeyRightBracket: { driver.KeyRightBracket: {
"BracketRight", "BracketRight",
}, },
KeyS: { driver.KeyS: {
"KeyS", "KeyS",
}, },
KeyScrollLock: { driver.KeyScrollLock: {
"ScrollLock", "ScrollLock",
}, },
KeySemicolon: { driver.KeySemicolon: {
"Semicolon", "Semicolon",
}, },
KeyShift: { driver.KeyShift: {
"ShiftLeft", "ShiftRight", "ShiftLeft", "ShiftRight",
}, },
KeySlash: { driver.KeySlash: {
"Slash", "Slash",
}, },
KeySpace: { driver.KeySpace: {
"Space", "Space",
}, },
KeyT: { driver.KeyT: {
"KeyT", "KeyT",
}, },
KeyTab: { driver.KeyTab: {
"Tab", "Tab",
}, },
KeyU: { driver.KeyU: {
"KeyU", "KeyU",
}, },
KeyUp: { driver.KeyUp: {
"ArrowUp", "ArrowUp",
}, },
KeyV: { driver.KeyV: {
"KeyV", "KeyV",
}, },
KeyW: { driver.KeyW: {
"KeyW", "KeyW",
}, },
KeyX: { driver.KeyX: {
"KeyX", "KeyX",
}, },
KeyY: { driver.KeyY: {
"KeyY", "KeyY",
}, },
KeyZ: { driver.KeyZ: {
"KeyZ", "KeyZ",
}, },
} }
var keyCodeToKeyEdge = map[int]Key{ var keyCodeToKeyEdge = map[int]Key{
8: KeyBackspace, 8: driver.KeyBackspace,
9: KeyTab, 9: driver.KeyTab,
13: KeyEnter, 13: driver.KeyEnter,
16: KeyShift, 16: driver.KeyShift,
17: KeyControl, 17: driver.KeyControl,
18: KeyAlt, 18: driver.KeyAlt,
19: KeyPause, 19: driver.KeyPause,
20: KeyCapsLock, 20: driver.KeyCapsLock,
27: KeyEscape, 27: driver.KeyEscape,
32: KeySpace, 32: driver.KeySpace,
33: KeyPageUp, 33: driver.KeyPageUp,
34: KeyPageDown, 34: driver.KeyPageDown,
35: KeyEnd, 35: driver.KeyEnd,
36: KeyHome, 36: driver.KeyHome,
37: KeyLeft, 37: driver.KeyLeft,
38: KeyUp, 38: driver.KeyUp,
39: KeyRight, 39: driver.KeyRight,
40: KeyDown, 40: driver.KeyDown,
45: KeyInsert, 45: driver.KeyInsert,
46: KeyDelete, 46: driver.KeyDelete,
48: Key0, 48: driver.Key0,
49: Key1, 49: driver.Key1,
50: Key2, 50: driver.Key2,
51: Key3, 51: driver.Key3,
52: Key4, 52: driver.Key4,
53: Key5, 53: driver.Key5,
54: Key6, 54: driver.Key6,
55: Key7, 55: driver.Key7,
56: Key8, 56: driver.Key8,
57: Key9, 57: driver.Key9,
65: KeyA, 65: driver.KeyA,
66: KeyB, 66: driver.KeyB,
67: KeyC, 67: driver.KeyC,
68: KeyD, 68: driver.KeyD,
69: KeyE, 69: driver.KeyE,
70: KeyF, 70: driver.KeyF,
71: KeyG, 71: driver.KeyG,
72: KeyH, 72: driver.KeyH,
73: KeyI, 73: driver.KeyI,
74: KeyJ, 74: driver.KeyJ,
75: KeyK, 75: driver.KeyK,
76: KeyL, 76: driver.KeyL,
77: KeyM, 77: driver.KeyM,
78: KeyN, 78: driver.KeyN,
79: KeyO, 79: driver.KeyO,
80: KeyP, 80: driver.KeyP,
81: KeyQ, 81: driver.KeyQ,
82: KeyR, 82: driver.KeyR,
83: KeyS, 83: driver.KeyS,
84: KeyT, 84: driver.KeyT,
85: KeyU, 85: driver.KeyU,
86: KeyV, 86: driver.KeyV,
87: KeyW, 87: driver.KeyW,
88: KeyX, 88: driver.KeyX,
89: KeyY, 89: driver.KeyY,
90: KeyZ, 90: driver.KeyZ,
93: KeyMenu, 93: driver.KeyMenu,
96: KeyKP0, 96: driver.KeyKP0,
97: KeyKP1, 97: driver.KeyKP1,
98: KeyKP2, 98: driver.KeyKP2,
99: KeyKP3, 99: driver.KeyKP3,
100: KeyKP4, 100: driver.KeyKP4,
101: KeyKP5, 101: driver.KeyKP5,
102: KeyKP6, 102: driver.KeyKP6,
103: KeyKP7, 103: driver.KeyKP7,
104: KeyKP8, 104: driver.KeyKP8,
105: KeyKP9, 105: driver.KeyKP9,
106: KeyKPMultiply, 106: driver.KeyKPMultiply,
107: KeyKPAdd, 107: driver.KeyKPAdd,
109: KeyKPSubtract, 109: driver.KeyKPSubtract,
110: KeyKPDecimal, 110: driver.KeyKPDecimal,
111: KeyKPDivide, 111: driver.KeyKPDivide,
112: KeyF1, 112: driver.KeyF1,
113: KeyF2, 113: driver.KeyF2,
114: KeyF3, 114: driver.KeyF3,
115: KeyF4, 115: driver.KeyF4,
116: KeyF5, 116: driver.KeyF5,
117: KeyF6, 117: driver.KeyF6,
118: KeyF7, 118: driver.KeyF7,
119: KeyF8, 119: driver.KeyF8,
120: KeyF9, 120: driver.KeyF9,
121: KeyF10, 121: driver.KeyF10,
122: KeyF11, 122: driver.KeyF11,
123: KeyF12, 123: driver.KeyF12,
144: KeyNumLock, 144: driver.KeyNumLock,
145: KeyScrollLock, 145: driver.KeyScrollLock,
186: KeySemicolon, 186: driver.KeySemicolon,
187: KeyEqual, 187: driver.KeyEqual,
188: KeyComma, 188: driver.KeyComma,
189: KeyMinus, 189: driver.KeyMinus,
190: KeyPeriod, 190: driver.KeyPeriod,
191: KeySlash, 191: driver.KeySlash,
192: KeyGraveAccent, 192: driver.KeyGraveAccent,
219: KeyLeftBracket, 219: driver.KeyLeftBracket,
220: KeyBackslash, 220: driver.KeyBackslash,
221: KeyRightBracket, 221: driver.KeyRightBracket,
222: KeyApostrophe, 222: driver.KeyApostrophe,
} }

202
keys.go
View File

@ -19,7 +19,7 @@ package ebiten
import ( import (
"strings" "strings"
"github.com/hajimehoshi/ebiten/internal/input" "github.com/hajimehoshi/ebiten/internal/driver"
) )
// A Key represents a keyboard key. // A Key represents a keyboard key.
@ -29,106 +29,106 @@ type Key int
// Keys. // Keys.
const ( const (
Key0 Key = Key(input.Key0) Key0 Key = Key(driver.Key0)
Key1 Key = Key(input.Key1) Key1 Key = Key(driver.Key1)
Key2 Key = Key(input.Key2) Key2 Key = Key(driver.Key2)
Key3 Key = Key(input.Key3) Key3 Key = Key(driver.Key3)
Key4 Key = Key(input.Key4) Key4 Key = Key(driver.Key4)
Key5 Key = Key(input.Key5) Key5 Key = Key(driver.Key5)
Key6 Key = Key(input.Key6) Key6 Key = Key(driver.Key6)
Key7 Key = Key(input.Key7) Key7 Key = Key(driver.Key7)
Key8 Key = Key(input.Key8) Key8 Key = Key(driver.Key8)
Key9 Key = Key(input.Key9) Key9 Key = Key(driver.Key9)
KeyA Key = Key(input.KeyA) KeyA Key = Key(driver.KeyA)
KeyB Key = Key(input.KeyB) KeyB Key = Key(driver.KeyB)
KeyC Key = Key(input.KeyC) KeyC Key = Key(driver.KeyC)
KeyD Key = Key(input.KeyD) KeyD Key = Key(driver.KeyD)
KeyE Key = Key(input.KeyE) KeyE Key = Key(driver.KeyE)
KeyF Key = Key(input.KeyF) KeyF Key = Key(driver.KeyF)
KeyG Key = Key(input.KeyG) KeyG Key = Key(driver.KeyG)
KeyH Key = Key(input.KeyH) KeyH Key = Key(driver.KeyH)
KeyI Key = Key(input.KeyI) KeyI Key = Key(driver.KeyI)
KeyJ Key = Key(input.KeyJ) KeyJ Key = Key(driver.KeyJ)
KeyK Key = Key(input.KeyK) KeyK Key = Key(driver.KeyK)
KeyL Key = Key(input.KeyL) KeyL Key = Key(driver.KeyL)
KeyM Key = Key(input.KeyM) KeyM Key = Key(driver.KeyM)
KeyN Key = Key(input.KeyN) KeyN Key = Key(driver.KeyN)
KeyO Key = Key(input.KeyO) KeyO Key = Key(driver.KeyO)
KeyP Key = Key(input.KeyP) KeyP Key = Key(driver.KeyP)
KeyQ Key = Key(input.KeyQ) KeyQ Key = Key(driver.KeyQ)
KeyR Key = Key(input.KeyR) KeyR Key = Key(driver.KeyR)
KeyS Key = Key(input.KeyS) KeyS Key = Key(driver.KeyS)
KeyT Key = Key(input.KeyT) KeyT Key = Key(driver.KeyT)
KeyU Key = Key(input.KeyU) KeyU Key = Key(driver.KeyU)
KeyV Key = Key(input.KeyV) KeyV Key = Key(driver.KeyV)
KeyW Key = Key(input.KeyW) KeyW Key = Key(driver.KeyW)
KeyX Key = Key(input.KeyX) KeyX Key = Key(driver.KeyX)
KeyY Key = Key(input.KeyY) KeyY Key = Key(driver.KeyY)
KeyZ Key = Key(input.KeyZ) KeyZ Key = Key(driver.KeyZ)
KeyAlt Key = Key(input.KeyAlt) KeyAlt Key = Key(driver.KeyAlt)
KeyApostrophe Key = Key(input.KeyApostrophe) KeyApostrophe Key = Key(driver.KeyApostrophe)
KeyBackslash Key = Key(input.KeyBackslash) KeyBackslash Key = Key(driver.KeyBackslash)
KeyBackspace Key = Key(input.KeyBackspace) KeyBackspace Key = Key(driver.KeyBackspace)
KeyCapsLock Key = Key(input.KeyCapsLock) KeyCapsLock Key = Key(driver.KeyCapsLock)
KeyComma Key = Key(input.KeyComma) KeyComma Key = Key(driver.KeyComma)
KeyControl Key = Key(input.KeyControl) KeyControl Key = Key(driver.KeyControl)
KeyDelete Key = Key(input.KeyDelete) KeyDelete Key = Key(driver.KeyDelete)
KeyDown Key = Key(input.KeyDown) KeyDown Key = Key(driver.KeyDown)
KeyEnd Key = Key(input.KeyEnd) KeyEnd Key = Key(driver.KeyEnd)
KeyEnter Key = Key(input.KeyEnter) KeyEnter Key = Key(driver.KeyEnter)
KeyEqual Key = Key(input.KeyEqual) KeyEqual Key = Key(driver.KeyEqual)
KeyEscape Key = Key(input.KeyEscape) KeyEscape Key = Key(driver.KeyEscape)
KeyF1 Key = Key(input.KeyF1) KeyF1 Key = Key(driver.KeyF1)
KeyF2 Key = Key(input.KeyF2) KeyF2 Key = Key(driver.KeyF2)
KeyF3 Key = Key(input.KeyF3) KeyF3 Key = Key(driver.KeyF3)
KeyF4 Key = Key(input.KeyF4) KeyF4 Key = Key(driver.KeyF4)
KeyF5 Key = Key(input.KeyF5) KeyF5 Key = Key(driver.KeyF5)
KeyF6 Key = Key(input.KeyF6) KeyF6 Key = Key(driver.KeyF6)
KeyF7 Key = Key(input.KeyF7) KeyF7 Key = Key(driver.KeyF7)
KeyF8 Key = Key(input.KeyF8) KeyF8 Key = Key(driver.KeyF8)
KeyF9 Key = Key(input.KeyF9) KeyF9 Key = Key(driver.KeyF9)
KeyF10 Key = Key(input.KeyF10) KeyF10 Key = Key(driver.KeyF10)
KeyF11 Key = Key(input.KeyF11) KeyF11 Key = Key(driver.KeyF11)
KeyF12 Key = Key(input.KeyF12) KeyF12 Key = Key(driver.KeyF12)
KeyGraveAccent Key = Key(input.KeyGraveAccent) KeyGraveAccent Key = Key(driver.KeyGraveAccent)
KeyHome Key = Key(input.KeyHome) KeyHome Key = Key(driver.KeyHome)
KeyInsert Key = Key(input.KeyInsert) KeyInsert Key = Key(driver.KeyInsert)
KeyKP0 Key = Key(input.KeyKP0) KeyKP0 Key = Key(driver.KeyKP0)
KeyKP1 Key = Key(input.KeyKP1) KeyKP1 Key = Key(driver.KeyKP1)
KeyKP2 Key = Key(input.KeyKP2) KeyKP2 Key = Key(driver.KeyKP2)
KeyKP3 Key = Key(input.KeyKP3) KeyKP3 Key = Key(driver.KeyKP3)
KeyKP4 Key = Key(input.KeyKP4) KeyKP4 Key = Key(driver.KeyKP4)
KeyKP5 Key = Key(input.KeyKP5) KeyKP5 Key = Key(driver.KeyKP5)
KeyKP6 Key = Key(input.KeyKP6) KeyKP6 Key = Key(driver.KeyKP6)
KeyKP7 Key = Key(input.KeyKP7) KeyKP7 Key = Key(driver.KeyKP7)
KeyKP8 Key = Key(input.KeyKP8) KeyKP8 Key = Key(driver.KeyKP8)
KeyKP9 Key = Key(input.KeyKP9) KeyKP9 Key = Key(driver.KeyKP9)
KeyKPAdd Key = Key(input.KeyKPAdd) KeyKPAdd Key = Key(driver.KeyKPAdd)
KeyKPDecimal Key = Key(input.KeyKPDecimal) KeyKPDecimal Key = Key(driver.KeyKPDecimal)
KeyKPDivide Key = Key(input.KeyKPDivide) KeyKPDivide Key = Key(driver.KeyKPDivide)
KeyKPEnter Key = Key(input.KeyKPEnter) KeyKPEnter Key = Key(driver.KeyKPEnter)
KeyKPEqual Key = Key(input.KeyKPEqual) KeyKPEqual Key = Key(driver.KeyKPEqual)
KeyKPMultiply Key = Key(input.KeyKPMultiply) KeyKPMultiply Key = Key(driver.KeyKPMultiply)
KeyKPSubtract Key = Key(input.KeyKPSubtract) KeyKPSubtract Key = Key(driver.KeyKPSubtract)
KeyLeft Key = Key(input.KeyLeft) KeyLeft Key = Key(driver.KeyLeft)
KeyLeftBracket Key = Key(input.KeyLeftBracket) KeyLeftBracket Key = Key(driver.KeyLeftBracket)
KeyMenu Key = Key(input.KeyMenu) KeyMenu Key = Key(driver.KeyMenu)
KeyMinus Key = Key(input.KeyMinus) KeyMinus Key = Key(driver.KeyMinus)
KeyNumLock Key = Key(input.KeyNumLock) KeyNumLock Key = Key(driver.KeyNumLock)
KeyPageDown Key = Key(input.KeyPageDown) KeyPageDown Key = Key(driver.KeyPageDown)
KeyPageUp Key = Key(input.KeyPageUp) KeyPageUp Key = Key(driver.KeyPageUp)
KeyPause Key = Key(input.KeyPause) KeyPause Key = Key(driver.KeyPause)
KeyPeriod Key = Key(input.KeyPeriod) KeyPeriod Key = Key(driver.KeyPeriod)
KeyPrintScreen Key = Key(input.KeyPrintScreen) KeyPrintScreen Key = Key(driver.KeyPrintScreen)
KeyRight Key = Key(input.KeyRight) KeyRight Key = Key(driver.KeyRight)
KeyRightBracket Key = Key(input.KeyRightBracket) KeyRightBracket Key = Key(driver.KeyRightBracket)
KeyScrollLock Key = Key(input.KeyScrollLock) KeyScrollLock Key = Key(driver.KeyScrollLock)
KeySemicolon Key = Key(input.KeySemicolon) KeySemicolon Key = Key(driver.KeySemicolon)
KeyShift Key = Key(input.KeyShift) KeyShift Key = Key(driver.KeyShift)
KeySlash Key = Key(input.KeySlash) KeySlash Key = Key(driver.KeySlash)
KeySpace Key = Key(input.KeySpace) KeySpace Key = Key(driver.KeySpace)
KeyTab Key = Key(input.KeyTab) KeyTab Key = Key(driver.KeyTab)
KeyUp Key = Key(input.KeyUp) KeyUp Key = Key(driver.KeyUp)
KeyMax Key = KeyUp KeyMax Key = KeyUp
) )