Fixed incorrect numpad handling on Windows Areas.

This commit is contained in:
Pietro Gagliardi 2014-06-07 00:46:47 -04:00
parent 345e497611
commit dcefa88a04
4 changed files with 22 additions and 7 deletions

View File

@ -499,10 +499,10 @@ func areaKeyEvent(s *sysData, up bool, wparam _WPARAM, lparam _LPARAM) {
scancode := byte((lparam >> 16) & 0xFF)
ke.Modifiers = getModifiers()
if wparam == _VK_RETURN && (lparam & 0x01000000) != 0 {
// the above is special handling for numpad enter
// bit 24 of LPARAM (0x01000000) indicates right-hand keys
ke.ExtKey = NEnter
if extkey, ok := numpadextkeys[wparam]; (lparam & 0x01000000) == 0 && ok {
// the above is special handling for numpad keys to ignore the state of Num Lock and Shift; see http://blogs.msdn.com/b/oldnewthing/archive/2004/09/06/226045.aspx and https://github.com/glfw/glfw/blob/master/src/win32_window.c#L152
// bit 24 of LPARAM (0x01000000) indicates right-hand keys; in our case "right-hand keys" means the separate buttons, so 0 means numpad
ke.ExtKey = extkey
} else if extkey, ok := extkeys[wparam]; ok {
ke.ExtKey = extkey
} else if mod, ok := modonlykeys[wparam]; ok {
@ -524,6 +524,22 @@ func areaKeyEvent(s *sysData, up bool, wparam _WPARAM, lparam _LPARAM) {
}
}
// all mappings except the VK_RETURN one come from GLFW - https://github.com/glfw/glfw/blob/master/src/win32_window.c#L152
var numpadextkeys = map[_WPARAM]ExtKey{
_VK_HOME: N7,
_VK_UP: N8,
_VK_PRIOR: N9,
_VK_LEFT: N4,
_VK_CLEAR: N5,
_VK_RIGHT: N6,
_VK_END: N1,
_VK_DOWN: N2,
_VK_NEXT: N3,
_VK_INSERT: N0,
_VK_DELETE: NDot,
_VK_RETURN: NEnter,
}
var extkeys = map[_WPARAM]ExtKey{
_VK_ESCAPE: Escape,
_VK_INSERT: Insert,

View File

@ -36,6 +36,3 @@ ALL PLATFORMS:
- TODO remember what this means
- make all widths and heights parameters in constructors in the same place (or drop the ones in Window entirely?)
- Message boxes that belong to agiven parent are still application-modal on all platforms except Mac OS X because the whole system waits... we'll need to use a channel for this, I guess :S
- on Windows, Shift+(num pad key) triggers the shifted key code when num lock is off; will need to reorder key code tests on all platforms to fix this
- http://blogs.msdn.com/b/oldnewthing/archive/2004/09/06/226045.aspx

View File

@ -90,6 +90,7 @@ const _SW_SHOW = 5
const _SW_SHOWDEFAULT = 10
const _TRUE = 1
const _VK_ADD = 107
const _VK_CLEAR = 12
const _VK_CONTROL = 17
const _VK_DELETE = 46
const _VK_DIVIDE = 111

View File

@ -90,6 +90,7 @@ const _SW_SHOW = 5
const _SW_SHOWDEFAULT = 10
const _TRUE = 1
const _VK_ADD = 107
const _VK_CLEAR = 12
const _VK_CONTROL = 17
const _VK_DELETE = 46
const _VK_DIVIDE = 111