input: Add Pause and Print Screen buttons (#555)

Fixes #579
This commit is contained in:
Jake Bentvelzen 2018-04-22 02:36:28 +10:00 committed by Hajime Hoshi
parent 3fa2beb502
commit 2f4ca72dbd
5 changed files with 53 additions and 0 deletions

View File

@ -70,6 +70,10 @@ func init() {
"RightBracket": {"BracketRight"}, "RightBracket": {"BracketRight"},
"GraveAccent": {"Backquote"}, "GraveAccent": {"Backquote"},
"NumLock": {"NumLock"}, "NumLock": {"NumLock"},
"Pause": {"Pause"},
"PrintScreen": {"PrintScreen"},
"ScrollLock": {"ScrollLock"},
"Menu": {"ContextMenu"},
} }
// ASCII: 0 - 9 // ASCII: 0 - 9
for c := '0'; c <= '9'; c++ { for c := '0'; c <= '9'; c++ {
@ -135,6 +139,12 @@ func init() {
0x6a: "KPMultiply", 0x6a: "KPMultiply",
0x6d: "KPSubtract", 0x6d: "KPSubtract",
0x6b: "KPAdd", 0x6b: "KPAdd",
0x13: "Pause",
0x91: "ScrollLock",
0x5d: "Menu",
// NOTE: On Edge, this key does not work. PrintScreen works only on keyup event, and PrintScreen doesn't work on Edge well.
//0x2C: "PrintScreen",
// TODO: On Edge, it is impossible to tell KPEnter and Enter / KPEqual and Equal. // TODO: On Edge, it is impossible to tell KPEnter and Enter / KPEqual and Equal.
// 0x0d: "KPEnter", // 0x0d: "KPEnter",

View File

@ -102,13 +102,17 @@ const (
KeyKPSubtract KeyKPSubtract
KeyLeft KeyLeft
KeyLeftBracket KeyLeftBracket
KeyMenu
KeyMinus KeyMinus
KeyNumLock KeyNumLock
KeyPageDown KeyPageDown
KeyPageUp KeyPageUp
KeyPause
KeyPeriod KeyPeriod
KeyPrintScreen
KeyRight KeyRight
KeyRightBracket KeyRightBracket
KeyScrollLock
KeySemicolon KeySemicolon
KeyShift KeyShift
KeySlash KeySlash

View File

@ -107,13 +107,17 @@ var glfwKeyCodeToKey = map[glfw.Key]Key{
glfw.KeyKPSubtract: KeyKPSubtract, glfw.KeyKPSubtract: KeyKPSubtract,
glfw.KeyLeft: KeyLeft, glfw.KeyLeft: KeyLeft,
glfw.KeyLeftBracket: KeyLeftBracket, glfw.KeyLeftBracket: KeyLeftBracket,
glfw.KeyMenu: KeyMenu,
glfw.KeyMinus: KeyMinus, glfw.KeyMinus: KeyMinus,
glfw.KeyNumLock: KeyNumLock, glfw.KeyNumLock: KeyNumLock,
glfw.KeyPageDown: KeyPageDown, glfw.KeyPageDown: KeyPageDown,
glfw.KeyPageUp: KeyPageUp, glfw.KeyPageUp: KeyPageUp,
glfw.KeyPause: KeyPause,
glfw.KeyPeriod: KeyPeriod, glfw.KeyPeriod: KeyPeriod,
glfw.KeyPrintScreen: KeyPrintScreen,
glfw.KeyRight: KeyRight, glfw.KeyRight: KeyRight,
glfw.KeyRightBracket: KeyRightBracket, glfw.KeyRightBracket: KeyRightBracket,
glfw.KeyScrollLock: KeyScrollLock,
glfw.KeySemicolon: KeySemicolon, glfw.KeySemicolon: KeySemicolon,
glfw.KeySlash: KeySlash, glfw.KeySlash: KeySlash,
glfw.KeySpace: KeySpace, glfw.KeySpace: KeySpace,

View File

@ -229,6 +229,9 @@ var keyToCodes = map[Key][]string{
KeyM: { KeyM: {
"KeyM", "KeyM",
}, },
KeyMenu: {
"ContextMenu",
},
KeyMinus: { KeyMinus: {
"Minus", "Minus",
}, },
@ -250,9 +253,15 @@ var keyToCodes = map[Key][]string{
KeyPageUp: { KeyPageUp: {
"PageUp", "PageUp",
}, },
KeyPause: {
"Pause",
},
KeyPeriod: { KeyPeriod: {
"Period", "Period",
}, },
KeyPrintScreen: {
"PrintScreen",
},
KeyQ: { KeyQ: {
"KeyQ", "KeyQ",
}, },
@ -268,6 +277,9 @@ var keyToCodes = map[Key][]string{
KeyS: { KeyS: {
"KeyS", "KeyS",
}, },
KeyScrollLock: {
"ScrollLock",
},
KeySemicolon: { KeySemicolon: {
"Semicolon", "Semicolon",
}, },
@ -316,6 +328,7 @@ var keyCodeToKeyEdge = map[int]Key{
16: KeyShift, 16: KeyShift,
17: KeyControl, 17: KeyControl,
18: KeyAlt, 18: KeyAlt,
19: KeyPause,
20: KeyCapsLock, 20: KeyCapsLock,
27: KeyEscape, 27: KeyEscape,
32: KeySpace, 32: KeySpace,
@ -365,6 +378,7 @@ var keyCodeToKeyEdge = map[int]Key{
88: KeyX, 88: KeyX,
89: KeyY, 89: KeyY,
90: KeyZ, 90: KeyZ,
93: KeyMenu,
96: KeyKP0, 96: KeyKP0,
97: KeyKP1, 97: KeyKP1,
98: KeyKP2, 98: KeyKP2,
@ -393,6 +407,7 @@ var keyCodeToKeyEdge = map[int]Key{
122: KeyF11, 122: KeyF11,
123: KeyF12, 123: KeyF12,
144: KeyNumLock, 144: KeyNumLock,
145: KeyScrollLock,
186: KeySemicolon, 186: KeySemicolon,
187: KeyEqual, 187: KeyEqual,
188: KeyComma, 188: KeyComma,

20
keys.go
View File

@ -114,13 +114,17 @@ const (
KeyKPSubtract Key = Key(input.KeyKPSubtract) KeyKPSubtract Key = Key(input.KeyKPSubtract)
KeyLeft Key = Key(input.KeyLeft) KeyLeft Key = Key(input.KeyLeft)
KeyLeftBracket Key = Key(input.KeyLeftBracket) KeyLeftBracket Key = Key(input.KeyLeftBracket)
KeyMenu Key = Key(input.KeyMenu)
KeyMinus Key = Key(input.KeyMinus) KeyMinus Key = Key(input.KeyMinus)
KeyNumLock Key = Key(input.KeyNumLock) KeyNumLock Key = Key(input.KeyNumLock)
KeyPageDown Key = Key(input.KeyPageDown) KeyPageDown Key = Key(input.KeyPageDown)
KeyPageUp Key = Key(input.KeyPageUp) KeyPageUp Key = Key(input.KeyPageUp)
KeyPause Key = Key(input.KeyPause)
KeyPeriod Key = Key(input.KeyPeriod) KeyPeriod Key = Key(input.KeyPeriod)
KeyPrintScreen Key = Key(input.KeyPrintScreen)
KeyRight Key = Key(input.KeyRight) KeyRight Key = Key(input.KeyRight)
KeyRightBracket Key = Key(input.KeyRightBracket) KeyRightBracket Key = Key(input.KeyRightBracket)
KeyScrollLock Key = Key(input.KeyScrollLock)
KeySemicolon Key = Key(input.KeySemicolon) KeySemicolon Key = Key(input.KeySemicolon)
KeyShift Key = Key(input.KeyShift) KeyShift Key = Key(input.KeyShift)
KeySlash Key = Key(input.KeySlash) KeySlash Key = Key(input.KeySlash)
@ -301,6 +305,8 @@ func (k Key) String() string {
return "Left" return "Left"
case KeyLeftBracket: case KeyLeftBracket:
return "LeftBracket" return "LeftBracket"
case KeyMenu:
return "Menu"
case KeyMinus: case KeyMinus:
return "Minus" return "Minus"
case KeyNumLock: case KeyNumLock:
@ -309,12 +315,18 @@ func (k Key) String() string {
return "PageDown" return "PageDown"
case KeyPageUp: case KeyPageUp:
return "PageUp" return "PageUp"
case KeyPause:
return "Pause"
case KeyPeriod: case KeyPeriod:
return "Period" return "Period"
case KeyPrintScreen:
return "PrintScreen"
case KeyRight: case KeyRight:
return "Right" return "Right"
case KeyRightBracket: case KeyRightBracket:
return "RightBracket" return "RightBracket"
case KeyScrollLock:
return "ScrollLock"
case KeySemicolon: case KeySemicolon:
return "Semicolon" return "Semicolon"
case KeyShift: case KeyShift:
@ -499,6 +511,8 @@ func keyNameToKey(name string) (Key, bool) {
return KeyLeft, true return KeyLeft, true
case "leftbracket": case "leftbracket":
return KeyLeftBracket, true return KeyLeftBracket, true
case "menu":
return KeyMenu, true
case "minus": case "minus":
return KeyMinus, true return KeyMinus, true
case "numlock": case "numlock":
@ -507,12 +521,18 @@ func keyNameToKey(name string) (Key, bool) {
return KeyPageDown, true return KeyPageDown, true
case "pageup": case "pageup":
return KeyPageUp, true return KeyPageUp, true
case "pause":
return KeyPause, true
case "period": case "period":
return KeyPeriod, true return KeyPeriod, true
case "printscreen":
return KeyPrintScreen, true
case "right": case "right":
return KeyRight, true return KeyRight, true
case "rightbracket": case "rightbracket":
return KeyRightBracket, true return KeyRightBracket, true
case "scrolllock":
return KeyScrollLock, true
case "semicolon": case "semicolon":
return KeySemicolon, true return KeySemicolon, true
case "shift": case "shift":