input: Refactoring

This commit is contained in:
Hajime Hoshi 2020-02-20 00:18:40 +09:00
parent 682f454fc2
commit 6faad68931

View File

@ -84,6 +84,13 @@ func init() {
"RightAlt": glfw.KeyRightAlt, "RightAlt": glfw.KeyRightAlt,
"RightSuper": glfw.KeyRightSuper, "RightSuper": glfw.KeyRightSuper,
"Menu": glfw.KeyMenu, "Menu": glfw.KeyMenu,
"KPDecimal": glfw.KeyKPDecimal,
"KPDivide": glfw.KeyKPDivide,
"KPMultiply": glfw.KeyKPMultiply,
"KPSubtract": glfw.KeyKPSubtract,
"KPAdd": glfw.KeyKPAdd,
"KPEnter": glfw.KeyKPEnter,
"KPEqual": glfw.KeyKPEqual,
"Last": glfw.KeyLast, "Last": glfw.KeyLast,
} }
nameToJSKey = map[string]string{ nameToJSKey = map[string]string{
@ -125,6 +132,13 @@ func init() {
"PrintScreen": "PrintScreen", "PrintScreen": "PrintScreen",
"ScrollLock": "ScrollLock", "ScrollLock": "ScrollLock",
"Menu": "ContextMenu", "Menu": "ContextMenu",
"KPDecimal": "NumpadDecimal",
"KPDivide": "NumpadDivide",
"KPMultiply": "NumpadMultiply",
"KPSubtract": "NumpadSubtract",
"KPAdd": "NumpadAdd",
"KPEnter": "NumpadEnter",
"KPEqual": "NumpadEqual",
} }
// ASCII: 0 - 9 // ASCII: 0 - 9
for c := '0'; c <= '9'; c++ { for c := '0'; c <= '9'; c++ {
@ -149,22 +163,6 @@ func init() {
nameToGLFWKey[name] = glfw.KeyKP0 + glfw.Key(c) - '0' nameToGLFWKey[name] = glfw.KeyKP0 + glfw.Key(c) - '0'
nameToJSKey[name] = "Numpad" + string(c) nameToJSKey[name] = "Numpad" + string(c)
} }
nameToGLFWKey["KPDecimal"] = glfw.KeyKPDecimal
nameToGLFWKey["KPDivide"] = glfw.KeyKPDivide
nameToGLFWKey["KPMultiply"] = glfw.KeyKPMultiply
nameToGLFWKey["KPSubtract"] = glfw.KeyKPSubtract
nameToGLFWKey["KPAdd"] = glfw.KeyKPAdd
nameToGLFWKey["KPEnter"] = glfw.KeyKPEnter
nameToGLFWKey["KPEqual"] = glfw.KeyKPEqual
nameToJSKey["KPDecimal"] = "NumpadDecimal"
nameToJSKey["KPDivide"] = "NumpadDivide"
nameToJSKey["KPMultiply"] = "NumpadMultiply"
nameToJSKey["KPSubtract"] = "NumpadSubtract"
nameToJSKey["KPAdd"] = "NumpadAdd"
nameToJSKey["KPEnter"] = "NumpadEnter"
nameToJSKey["KPEqual"] = "NumpadEqual"
} }
func init() { func init() {