Added the new Modifiers handling to the Windows backend.

This commit is contained in:
Pietro Gagliardi 2014-05-29 12:17:02 -04:00
parent 20a7e4fb62
commit 055cd36b20
3 changed files with 32 additions and 0 deletions

View File

@ -513,6 +513,10 @@ func areaKeyEvent(s *sysData, up bool, wparam _WPARAM, lparam _LPARAM) bool {
ke.ExtKey = NEnter
} else if extkey, ok := extkeys[wparam]; ok {
ke.ExtKey = extkey
} else if mod, ok := modonlykeys[wparam]; ok {
ke.Modifier = mod
// don't include the modifier in ke.Modifiers
ke.Modifiers &^= mod
} else if xke, ok := fromScancode(uintptr(scancode)); ok {
// one of these will be nonzero
ke.Key = xke.Key
@ -580,6 +584,22 @@ func init() {
}
}
var modonlykeys = map[_WPARAM]Modifiers{
// TODO except for Super, are the separate left/right necessary?
_VK_CONTROL: Ctrl,
_VK_LCONTROL: Ctrl,
_VK_RCONTROL: Ctrl,
_VK_MENU: Alt,
_VK_LMENU: Alt,
_VK_RMENU: Alt,
_VK_SHIFT: Shift,
_VK_LSHIFT: Shift,
_VK_RSHIFT: Shift,
// there's no combined Windows key virtual-key code as there is with the others
_VK_LWIN: Super,
_VK_RWIN: Super,
}
var (
_setFocus = user32.NewProc("SetFocus")
)

View File

@ -105,14 +105,20 @@ const _VK_F8 = 119
const _VK_F9 = 120
const _VK_HOME = 36
const _VK_INSERT = 45
const _VK_LCONTROL = 162
const _VK_LEFT = 37
const _VK_LMENU = 164
const _VK_LSHIFT = 160
const _VK_LWIN = 91
const _VK_MENU = 18
const _VK_MULTIPLY = 106
const _VK_NEXT = 34
const _VK_PRIOR = 33
const _VK_RCONTROL = 163
const _VK_RETURN = 13
const _VK_RIGHT = 39
const _VK_RMENU = 165
const _VK_RSHIFT = 161
const _VK_RWIN = 92
const _VK_SHIFT = 16
const _VK_SUBTRACT = 109

View File

@ -105,14 +105,20 @@ const _VK_F8 = 119
const _VK_F9 = 120
const _VK_HOME = 36
const _VK_INSERT = 45
const _VK_LCONTROL = 162
const _VK_LEFT = 37
const _VK_LMENU = 164
const _VK_LSHIFT = 160
const _VK_LWIN = 91
const _VK_MENU = 18
const _VK_MULTIPLY = 106
const _VK_NEXT = 34
const _VK_PRIOR = 33
const _VK_RCONTROL = 163
const _VK_RETURN = 13
const _VK_RIGHT = 39
const _VK_RMENU = 165
const _VK_RSHIFT = 161
const _VK_RWIN = 92
const _VK_SHIFT = 16
const _VK_SUBTRACT = 109