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"},
"GraveAccent": {"Backquote"},
"NumLock": {"NumLock"},
"Pause": {"Pause"},
"PrintScreen": {"PrintScreen"},
"ScrollLock": {"ScrollLock"},
"Menu": {"ContextMenu"},
}
// ASCII: 0 - 9
for c := '0'; c <= '9'; c++ {
@ -135,6 +139,12 @@ func init() {
0x6a: "KPMultiply",
0x6d: "KPSubtract",
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.
// 0x0d: "KPEnter",

View File

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

View File

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

View File

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

20
keys.go
View File

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