- fixed keycode generation for the right alt/ctrl/shift keys. Windows generates

multiple keypresses when holding down these keys.
This commit is contained in:
Volker Ruppert 2005-10-02 17:37:56 +00:00
parent 6a290014f6
commit 85afaff11d

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: win32.cc,v 1.95 2005-06-06 20:14:50 vruppert Exp $
// $Id: win32.cc,v 1.96 2005-10-02 17:37:56 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -1130,42 +1130,66 @@ LRESULT CALLBACK simWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
void enq_key_event(Bit32u key, Bit32u press_release)
{
static BOOL alt_pressed = FALSE;
static BOOL ctrl_pressed = FALSE;
static BOOL shift_pressed = FALSE;
static BOOL alt_pressed_l = FALSE;
static BOOL alt_pressed_r = FALSE;
static BOOL ctrl_pressed_l = FALSE;
static BOOL ctrl_pressed_r = FALSE;
static BOOL shift_pressed_l = FALSE;
static BOOL shift_pressed_r = FALSE;
// Windows generates multiple keypresses when holding down these keys
if (press_release == BX_KEY_PRESSED) {
switch (key) {
case 0x1d:
if (ctrl_pressed)
if (ctrl_pressed_l)
return;
else
ctrl_pressed = TRUE;
ctrl_pressed_l = TRUE;
break;
case 0x2a:
if (shift_pressed)
if (shift_pressed_l)
return;
else
shift_pressed = TRUE;
shift_pressed_l = TRUE;
break;
case 0x36:
if (shift_pressed_r)
return;
shift_pressed_r = TRUE;
break;
case 0x38:
if (alt_pressed)
if (alt_pressed_l)
return;
else
alt_pressed = TRUE;
alt_pressed_l = TRUE;
break;
case 0x011d:
if (ctrl_pressed_r)
return;
ctrl_pressed_r = TRUE;
break;
case 0x0138:
if (alt_pressed_r)
return;
alt_pressed_r = TRUE;
break;
}
}
if (press_release == BX_KEY_RELEASED) {
} else {
switch (key) {
case 0x1d:
ctrl_pressed = FALSE;
ctrl_pressed_l = FALSE;
break;
case 0x2a:
shift_pressed = FALSE;
shift_pressed_l = FALSE;
break;
case 0x36:
shift_pressed_r = FALSE;
break;
case 0x38:
alt_pressed = FALSE;
alt_pressed_l = FALSE;
break;
case 0x011d:
ctrl_pressed_r = FALSE;
break;
case 0x0138:
alt_pressed_r = FALSE;
break;
}
}