mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
Rename mod key names
This commit is contained in:
parent
90ab31a872
commit
4eaa16b8d1
@ -35,7 +35,7 @@ var keyNames = map[ebiten.Key]string{
|
||||
ebiten.KeyComma: "','",
|
||||
ebiten.KeyDelete: "Delete",
|
||||
ebiten.KeyEnter: "Enter",
|
||||
ebiten.KeyEscape: "Escape",
|
||||
ebiten.KeyEscape: "Esc",
|
||||
ebiten.KeyPeriod: "'.'",
|
||||
ebiten.KeySpace: "Space",
|
||||
ebiten.KeyTab: "Tab",
|
||||
@ -47,9 +47,9 @@ var keyNames = map[ebiten.Key]string{
|
||||
ebiten.KeyUp: "Up",
|
||||
|
||||
// Mods
|
||||
ebiten.KeyLeftShift: "Shift",
|
||||
ebiten.KeyLeftControl: "Ctrl",
|
||||
ebiten.KeyLeftAlt: "Alt",
|
||||
ebiten.KeyShift: "Shift",
|
||||
ebiten.KeyControl: "Ctrl",
|
||||
ebiten.KeyAlt: "Alt",
|
||||
}
|
||||
|
||||
func update(screen *ebiten.Image) error {
|
||||
|
28
genkeys.go
28
genkeys.go
@ -37,10 +37,10 @@ func init() {
|
||||
keyCodeToName = map[int]string{
|
||||
0xBC: "Comma",
|
||||
0xBE: "Period",
|
||||
0x12: "LeftAlt",
|
||||
0x12: "Alt",
|
||||
0x14: "CapsLock",
|
||||
0x11: "LeftControl",
|
||||
0x10: "LeftShift",
|
||||
0x11: "Control",
|
||||
0x10: "Shift",
|
||||
0x0D: "Enter",
|
||||
0x20: "Space",
|
||||
0x09: "Tab",
|
||||
@ -114,8 +114,14 @@ import (
|
||||
)
|
||||
|
||||
var glfwKeyCodeToKey = map[glfw.Key]Key{
|
||||
{{range $index, $name := .KeyNames}}glfw.Key{{$name}}: Key{{$name}},
|
||||
{{range $index, $name := .KeyNamesWithoutMods}}glfw.Key{{$name}}: Key{{$name}},
|
||||
{{end}}
|
||||
glfw.KeyLeftAlt: KeyAlt,
|
||||
glfw.KeyRightAlt: KeyAlt,
|
||||
glfw.KeyLeftControl: KeyControl,
|
||||
glfw.KeyRightControl: KeyControl,
|
||||
glfw.KeyLeftShift: KeyShift,
|
||||
glfw.KeyRightShift: KeyShift,
|
||||
}
|
||||
`
|
||||
|
||||
@ -218,12 +224,17 @@ func main() {
|
||||
license := "// " + strings.Join(lines[:len(lines)-1], "\n// ")
|
||||
|
||||
names := []string{}
|
||||
namesWithoutMods := []string{}
|
||||
codes := []int{}
|
||||
for code, name := range keyCodeToName {
|
||||
names = append(names, name)
|
||||
codes = append(codes, code)
|
||||
if name != "Alt" && name != "Control" && name != "Shift" {
|
||||
namesWithoutMods = append(namesWithoutMods, name)
|
||||
}
|
||||
}
|
||||
sort.Sort(KeyNames(names))
|
||||
sort.Sort(KeyNames(namesWithoutMods))
|
||||
sort.Ints(codes)
|
||||
|
||||
for path, tmpl := range map[string]string{
|
||||
@ -243,10 +254,11 @@ func main() {
|
||||
}
|
||||
// NOTE: According to godoc, maps are automatically sorted by key.
|
||||
tmpl.Execute(f, map[string]interface{}{
|
||||
"License": license,
|
||||
"KeyCodeToName": keyCodeToName,
|
||||
"Codes": codes,
|
||||
"KeyNames": names,
|
||||
"License": license,
|
||||
"KeyCodeToName": keyCodeToName,
|
||||
"Codes": codes,
|
||||
"KeyNames": names,
|
||||
"KeyNamesWithoutMods": namesWithoutMods,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -53,9 +53,11 @@ const (
|
||||
KeyX
|
||||
KeyY
|
||||
KeyZ
|
||||
KeyAlt
|
||||
KeyBackspace
|
||||
KeyCapsLock
|
||||
KeyComma
|
||||
KeyControl
|
||||
KeyDelete
|
||||
KeyDown
|
||||
KeyEnd
|
||||
@ -76,13 +78,11 @@ const (
|
||||
KeyHome
|
||||
KeyInsert
|
||||
KeyLeft
|
||||
KeyLeftAlt
|
||||
KeyLeftControl
|
||||
KeyLeftShift
|
||||
KeyPageDown
|
||||
KeyPageUp
|
||||
KeyPeriod
|
||||
KeyRight
|
||||
KeyShift
|
||||
KeySpace
|
||||
KeyTab
|
||||
KeyUp
|
||||
|
@ -21,73 +21,77 @@ import (
|
||||
)
|
||||
|
||||
var glfwKeyCodeToKey = map[glfw.Key]Key{
|
||||
glfw.Key0: Key0,
|
||||
glfw.Key1: Key1,
|
||||
glfw.Key2: Key2,
|
||||
glfw.Key3: Key3,
|
||||
glfw.Key4: Key4,
|
||||
glfw.Key5: Key5,
|
||||
glfw.Key6: Key6,
|
||||
glfw.Key7: Key7,
|
||||
glfw.Key8: Key8,
|
||||
glfw.Key9: Key9,
|
||||
glfw.KeyA: KeyA,
|
||||
glfw.KeyB: KeyB,
|
||||
glfw.KeyC: KeyC,
|
||||
glfw.KeyD: KeyD,
|
||||
glfw.KeyE: KeyE,
|
||||
glfw.KeyF: KeyF,
|
||||
glfw.KeyG: KeyG,
|
||||
glfw.KeyH: KeyH,
|
||||
glfw.KeyI: KeyI,
|
||||
glfw.KeyJ: KeyJ,
|
||||
glfw.KeyK: KeyK,
|
||||
glfw.KeyL: KeyL,
|
||||
glfw.KeyM: KeyM,
|
||||
glfw.KeyN: KeyN,
|
||||
glfw.KeyO: KeyO,
|
||||
glfw.KeyP: KeyP,
|
||||
glfw.KeyQ: KeyQ,
|
||||
glfw.KeyR: KeyR,
|
||||
glfw.KeyS: KeyS,
|
||||
glfw.KeyT: KeyT,
|
||||
glfw.KeyU: KeyU,
|
||||
glfw.KeyV: KeyV,
|
||||
glfw.KeyW: KeyW,
|
||||
glfw.KeyX: KeyX,
|
||||
glfw.KeyY: KeyY,
|
||||
glfw.KeyZ: KeyZ,
|
||||
glfw.KeyBackspace: KeyBackspace,
|
||||
glfw.KeyCapsLock: KeyCapsLock,
|
||||
glfw.KeyComma: KeyComma,
|
||||
glfw.KeyDelete: KeyDelete,
|
||||
glfw.KeyDown: KeyDown,
|
||||
glfw.KeyEnd: KeyEnd,
|
||||
glfw.KeyEnter: KeyEnter,
|
||||
glfw.KeyEscape: KeyEscape,
|
||||
glfw.KeyF1: KeyF1,
|
||||
glfw.KeyF2: KeyF2,
|
||||
glfw.KeyF3: KeyF3,
|
||||
glfw.KeyF4: KeyF4,
|
||||
glfw.KeyF5: KeyF5,
|
||||
glfw.KeyF6: KeyF6,
|
||||
glfw.KeyF7: KeyF7,
|
||||
glfw.KeyF8: KeyF8,
|
||||
glfw.KeyF9: KeyF9,
|
||||
glfw.KeyF10: KeyF10,
|
||||
glfw.KeyF11: KeyF11,
|
||||
glfw.KeyF12: KeyF12,
|
||||
glfw.KeyHome: KeyHome,
|
||||
glfw.KeyInsert: KeyInsert,
|
||||
glfw.KeyLeft: KeyLeft,
|
||||
glfw.KeyLeftAlt: KeyLeftAlt,
|
||||
glfw.KeyLeftControl: KeyLeftControl,
|
||||
glfw.KeyLeftShift: KeyLeftShift,
|
||||
glfw.KeyPageDown: KeyPageDown,
|
||||
glfw.KeyPageUp: KeyPageUp,
|
||||
glfw.KeyPeriod: KeyPeriod,
|
||||
glfw.KeyRight: KeyRight,
|
||||
glfw.KeySpace: KeySpace,
|
||||
glfw.KeyTab: KeyTab,
|
||||
glfw.KeyUp: KeyUp,
|
||||
glfw.Key0: Key0,
|
||||
glfw.Key1: Key1,
|
||||
glfw.Key2: Key2,
|
||||
glfw.Key3: Key3,
|
||||
glfw.Key4: Key4,
|
||||
glfw.Key5: Key5,
|
||||
glfw.Key6: Key6,
|
||||
glfw.Key7: Key7,
|
||||
glfw.Key8: Key8,
|
||||
glfw.Key9: Key9,
|
||||
glfw.KeyA: KeyA,
|
||||
glfw.KeyB: KeyB,
|
||||
glfw.KeyC: KeyC,
|
||||
glfw.KeyD: KeyD,
|
||||
glfw.KeyE: KeyE,
|
||||
glfw.KeyF: KeyF,
|
||||
glfw.KeyG: KeyG,
|
||||
glfw.KeyH: KeyH,
|
||||
glfw.KeyI: KeyI,
|
||||
glfw.KeyJ: KeyJ,
|
||||
glfw.KeyK: KeyK,
|
||||
glfw.KeyL: KeyL,
|
||||
glfw.KeyM: KeyM,
|
||||
glfw.KeyN: KeyN,
|
||||
glfw.KeyO: KeyO,
|
||||
glfw.KeyP: KeyP,
|
||||
glfw.KeyQ: KeyQ,
|
||||
glfw.KeyR: KeyR,
|
||||
glfw.KeyS: KeyS,
|
||||
glfw.KeyT: KeyT,
|
||||
glfw.KeyU: KeyU,
|
||||
glfw.KeyV: KeyV,
|
||||
glfw.KeyW: KeyW,
|
||||
glfw.KeyX: KeyX,
|
||||
glfw.KeyY: KeyY,
|
||||
glfw.KeyZ: KeyZ,
|
||||
glfw.KeyBackspace: KeyBackspace,
|
||||
glfw.KeyCapsLock: KeyCapsLock,
|
||||
glfw.KeyComma: KeyComma,
|
||||
glfw.KeyDelete: KeyDelete,
|
||||
glfw.KeyDown: KeyDown,
|
||||
glfw.KeyEnd: KeyEnd,
|
||||
glfw.KeyEnter: KeyEnter,
|
||||
glfw.KeyEscape: KeyEscape,
|
||||
glfw.KeyF1: KeyF1,
|
||||
glfw.KeyF2: KeyF2,
|
||||
glfw.KeyF3: KeyF3,
|
||||
glfw.KeyF4: KeyF4,
|
||||
glfw.KeyF5: KeyF5,
|
||||
glfw.KeyF6: KeyF6,
|
||||
glfw.KeyF7: KeyF7,
|
||||
glfw.KeyF8: KeyF8,
|
||||
glfw.KeyF9: KeyF9,
|
||||
glfw.KeyF10: KeyF10,
|
||||
glfw.KeyF11: KeyF11,
|
||||
glfw.KeyF12: KeyF12,
|
||||
glfw.KeyHome: KeyHome,
|
||||
glfw.KeyInsert: KeyInsert,
|
||||
glfw.KeyLeft: KeyLeft,
|
||||
glfw.KeyPageDown: KeyPageDown,
|
||||
glfw.KeyPageUp: KeyPageUp,
|
||||
glfw.KeyPeriod: KeyPeriod,
|
||||
glfw.KeyRight: KeyRight,
|
||||
glfw.KeySpace: KeySpace,
|
||||
glfw.KeyTab: KeyTab,
|
||||
glfw.KeyUp: KeyUp,
|
||||
|
||||
glfw.KeyLeftAlt: KeyAlt,
|
||||
glfw.KeyRightAlt: KeyAlt,
|
||||
glfw.KeyLeftControl: KeyControl,
|
||||
glfw.KeyRightControl: KeyControl,
|
||||
glfw.KeyLeftShift: KeyShift,
|
||||
glfw.KeyRightShift: KeyShift,
|
||||
}
|
||||
|
@ -20,9 +20,9 @@ var keyCodeToKey = map[int]Key{
|
||||
8: KeyBackspace,
|
||||
9: KeyTab,
|
||||
13: KeyEnter,
|
||||
16: KeyLeftShift,
|
||||
17: KeyLeftControl,
|
||||
18: KeyLeftAlt,
|
||||
16: KeyShift,
|
||||
17: KeyControl,
|
||||
18: KeyAlt,
|
||||
20: KeyCapsLock,
|
||||
27: KeyEscape,
|
||||
32: KeySpace,
|
||||
|
138
keys.go
138
keys.go
@ -23,73 +23,73 @@ type Key int
|
||||
|
||||
// Keys
|
||||
const (
|
||||
Key0 = Key(ui.Key0)
|
||||
Key1 = Key(ui.Key1)
|
||||
Key2 = Key(ui.Key2)
|
||||
Key3 = Key(ui.Key3)
|
||||
Key4 = Key(ui.Key4)
|
||||
Key5 = Key(ui.Key5)
|
||||
Key6 = Key(ui.Key6)
|
||||
Key7 = Key(ui.Key7)
|
||||
Key8 = Key(ui.Key8)
|
||||
Key9 = Key(ui.Key9)
|
||||
KeyA = Key(ui.KeyA)
|
||||
KeyB = Key(ui.KeyB)
|
||||
KeyC = Key(ui.KeyC)
|
||||
KeyD = Key(ui.KeyD)
|
||||
KeyE = Key(ui.KeyE)
|
||||
KeyF = Key(ui.KeyF)
|
||||
KeyG = Key(ui.KeyG)
|
||||
KeyH = Key(ui.KeyH)
|
||||
KeyI = Key(ui.KeyI)
|
||||
KeyJ = Key(ui.KeyJ)
|
||||
KeyK = Key(ui.KeyK)
|
||||
KeyL = Key(ui.KeyL)
|
||||
KeyM = Key(ui.KeyM)
|
||||
KeyN = Key(ui.KeyN)
|
||||
KeyO = Key(ui.KeyO)
|
||||
KeyP = Key(ui.KeyP)
|
||||
KeyQ = Key(ui.KeyQ)
|
||||
KeyR = Key(ui.KeyR)
|
||||
KeyS = Key(ui.KeyS)
|
||||
KeyT = Key(ui.KeyT)
|
||||
KeyU = Key(ui.KeyU)
|
||||
KeyV = Key(ui.KeyV)
|
||||
KeyW = Key(ui.KeyW)
|
||||
KeyX = Key(ui.KeyX)
|
||||
KeyY = Key(ui.KeyY)
|
||||
KeyZ = Key(ui.KeyZ)
|
||||
KeyBackspace = Key(ui.KeyBackspace)
|
||||
KeyCapsLock = Key(ui.KeyCapsLock)
|
||||
KeyComma = Key(ui.KeyComma)
|
||||
KeyDelete = Key(ui.KeyDelete)
|
||||
KeyDown = Key(ui.KeyDown)
|
||||
KeyEnd = Key(ui.KeyEnd)
|
||||
KeyEnter = Key(ui.KeyEnter)
|
||||
KeyEscape = Key(ui.KeyEscape)
|
||||
KeyF1 = Key(ui.KeyF1)
|
||||
KeyF2 = Key(ui.KeyF2)
|
||||
KeyF3 = Key(ui.KeyF3)
|
||||
KeyF4 = Key(ui.KeyF4)
|
||||
KeyF5 = Key(ui.KeyF5)
|
||||
KeyF6 = Key(ui.KeyF6)
|
||||
KeyF7 = Key(ui.KeyF7)
|
||||
KeyF8 = Key(ui.KeyF8)
|
||||
KeyF9 = Key(ui.KeyF9)
|
||||
KeyF10 = Key(ui.KeyF10)
|
||||
KeyF11 = Key(ui.KeyF11)
|
||||
KeyF12 = Key(ui.KeyF12)
|
||||
KeyHome = Key(ui.KeyHome)
|
||||
KeyInsert = Key(ui.KeyInsert)
|
||||
KeyLeft = Key(ui.KeyLeft)
|
||||
KeyLeftAlt = Key(ui.KeyLeftAlt)
|
||||
KeyLeftControl = Key(ui.KeyLeftControl)
|
||||
KeyLeftShift = Key(ui.KeyLeftShift)
|
||||
KeyPageDown = Key(ui.KeyPageDown)
|
||||
KeyPageUp = Key(ui.KeyPageUp)
|
||||
KeyPeriod = Key(ui.KeyPeriod)
|
||||
KeyRight = Key(ui.KeyRight)
|
||||
KeySpace = Key(ui.KeySpace)
|
||||
KeyTab = Key(ui.KeyTab)
|
||||
KeyUp = Key(ui.KeyUp)
|
||||
Key0 = Key(ui.Key0)
|
||||
Key1 = Key(ui.Key1)
|
||||
Key2 = Key(ui.Key2)
|
||||
Key3 = Key(ui.Key3)
|
||||
Key4 = Key(ui.Key4)
|
||||
Key5 = Key(ui.Key5)
|
||||
Key6 = Key(ui.Key6)
|
||||
Key7 = Key(ui.Key7)
|
||||
Key8 = Key(ui.Key8)
|
||||
Key9 = Key(ui.Key9)
|
||||
KeyA = Key(ui.KeyA)
|
||||
KeyB = Key(ui.KeyB)
|
||||
KeyC = Key(ui.KeyC)
|
||||
KeyD = Key(ui.KeyD)
|
||||
KeyE = Key(ui.KeyE)
|
||||
KeyF = Key(ui.KeyF)
|
||||
KeyG = Key(ui.KeyG)
|
||||
KeyH = Key(ui.KeyH)
|
||||
KeyI = Key(ui.KeyI)
|
||||
KeyJ = Key(ui.KeyJ)
|
||||
KeyK = Key(ui.KeyK)
|
||||
KeyL = Key(ui.KeyL)
|
||||
KeyM = Key(ui.KeyM)
|
||||
KeyN = Key(ui.KeyN)
|
||||
KeyO = Key(ui.KeyO)
|
||||
KeyP = Key(ui.KeyP)
|
||||
KeyQ = Key(ui.KeyQ)
|
||||
KeyR = Key(ui.KeyR)
|
||||
KeyS = Key(ui.KeyS)
|
||||
KeyT = Key(ui.KeyT)
|
||||
KeyU = Key(ui.KeyU)
|
||||
KeyV = Key(ui.KeyV)
|
||||
KeyW = Key(ui.KeyW)
|
||||
KeyX = Key(ui.KeyX)
|
||||
KeyY = Key(ui.KeyY)
|
||||
KeyZ = Key(ui.KeyZ)
|
||||
KeyAlt = Key(ui.KeyAlt)
|
||||
KeyBackspace = Key(ui.KeyBackspace)
|
||||
KeyCapsLock = Key(ui.KeyCapsLock)
|
||||
KeyComma = Key(ui.KeyComma)
|
||||
KeyControl = Key(ui.KeyControl)
|
||||
KeyDelete = Key(ui.KeyDelete)
|
||||
KeyDown = Key(ui.KeyDown)
|
||||
KeyEnd = Key(ui.KeyEnd)
|
||||
KeyEnter = Key(ui.KeyEnter)
|
||||
KeyEscape = Key(ui.KeyEscape)
|
||||
KeyF1 = Key(ui.KeyF1)
|
||||
KeyF2 = Key(ui.KeyF2)
|
||||
KeyF3 = Key(ui.KeyF3)
|
||||
KeyF4 = Key(ui.KeyF4)
|
||||
KeyF5 = Key(ui.KeyF5)
|
||||
KeyF6 = Key(ui.KeyF6)
|
||||
KeyF7 = Key(ui.KeyF7)
|
||||
KeyF8 = Key(ui.KeyF8)
|
||||
KeyF9 = Key(ui.KeyF9)
|
||||
KeyF10 = Key(ui.KeyF10)
|
||||
KeyF11 = Key(ui.KeyF11)
|
||||
KeyF12 = Key(ui.KeyF12)
|
||||
KeyHome = Key(ui.KeyHome)
|
||||
KeyInsert = Key(ui.KeyInsert)
|
||||
KeyLeft = Key(ui.KeyLeft)
|
||||
KeyPageDown = Key(ui.KeyPageDown)
|
||||
KeyPageUp = Key(ui.KeyPageUp)
|
||||
KeyPeriod = Key(ui.KeyPeriod)
|
||||
KeyRight = Key(ui.KeyRight)
|
||||
KeyShift = Key(ui.KeyShift)
|
||||
KeySpace = Key(ui.KeySpace)
|
||||
KeyTab = Key(ui.KeyTab)
|
||||
KeyUp = Key(ui.KeyUp)
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user