Better lock key handling

This commit is contained in:
Lauri Kasanen 2013-12-13 14:27:06 +02:00
parent 021dd3d1a8
commit 2eba4e5832
1 changed files with 13 additions and 11 deletions

View File

@ -1195,6 +1195,7 @@ static void KdCheckLock(void)
void KdEnqueueKeyboardEvent(unsigned char scan_code, unsigned char is_up) void KdEnqueueKeyboardEvent(unsigned char scan_code, unsigned char is_up)
{ {
unsigned char key_code; unsigned char key_code;
static unsigned int locks = 0;
xEvent xE; xEvent xE;
@ -1218,18 +1219,19 @@ void KdEnqueueKeyboardEvent(unsigned char scan_code, unsigned char is_up)
xE.u.u.type = KeyPress; xE.u.u.type = KeyPress;
xE.u.u.detail = key_code; xE.u.u.detail = key_code;
// Handle toggling keys
if (xE.u.u.type == KeyPress) {
switch (KEYCOL1(key_code)) { switch (KEYCOL1(key_code)) {
case XK_Num_Lock: case XK_Num_Lock:
case XK_Scroll_Lock: locks ^= Mod2Mask;
break;
case XK_Shift_Lock: case XK_Shift_Lock:
case XK_Caps_Lock: case XK_Caps_Lock:
if (xE.u.u.type == KeyRelease) locks ^= LockMask;
return; break;
if (IsKeyDown(key_code))
xE.u.u.type = KeyRelease;
else
xE.u.u.type = KeyPress;
} }
}
keyc->state |= locks;
/* /*
* Check pressed keys which are already down * Check pressed keys which are already down