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;
switch (KEYCOL1(key_code)) { // Handle toggling keys
case XK_Num_Lock: if (xE.u.u.type == KeyPress) {
case XK_Scroll_Lock: switch (KEYCOL1(key_code)) {
case XK_Shift_Lock: case XK_Num_Lock:
case XK_Caps_Lock: locks ^= Mod2Mask;
if (xE.u.u.type == KeyRelease) break;
return; case XK_Shift_Lock:
if (IsKeyDown(key_code)) case XK_Caps_Lock:
xE.u.u.type = KeyRelease; locks ^= LockMask;
else break;
xE.u.u.type = KeyPress; }
} }
keyc->state |= locks;
/* /*
* Check pressed keys which are already down * Check pressed keys which are already down