Rename mod key names

This commit is contained in:
Hajime Hoshi 2015-01-07 23:18:40 +09:00
parent 90ab31a872
commit 4eaa16b8d1
6 changed files with 172 additions and 156 deletions

View File

@ -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 {

View File

@ -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{
@ -247,6 +258,7 @@ func main() {
"KeyCodeToName": keyCodeToName,
"Codes": codes,
"KeyNames": names,
"KeyNamesWithoutMods": namesWithoutMods,
})
}
}

View File

@ -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

View File

@ -80,9 +80,6 @@ var glfwKeyCodeToKey = map[glfw.Key]Key{
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,
@ -90,4 +87,11 @@ var glfwKeyCodeToKey = map[glfw.Key]Key{
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,
}

View File

@ -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,

View File

@ -59,9 +59,11 @@ const (
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)
@ -82,13 +84,11 @@ const (
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)
KeyShift = Key(ui.KeyShift)
KeySpace = Key(ui.KeySpace)
KeyTab = Key(ui.KeyTab)
KeyUp = Key(ui.KeyUp)