mirror of
https://github.com/AppleWin/AppleWin.git
synced 2024-12-31 21:29:39 +00:00
SysKey hook filter:
. Fix for GetKeyState() not detecting the special keys as being up (so AKD was erroneously reporting the key still down). . eg. Whilst pressing TAB, press LEFT ALT, then release TAB.
This commit is contained in:
parent
6b53adde55
commit
0d4be07e7e
@ -1260,7 +1260,7 @@ LRESULT CALLBACK FrameWndProc (
|
|||||||
|
|
||||||
case WM_KEYDOWN:
|
case WM_KEYDOWN:
|
||||||
KeybUpdateCtrlShiftStatus();
|
KeybUpdateCtrlShiftStatus();
|
||||||
KeybSpecialKeydown(wparam);
|
KeybSpecialKeyTransition(WM_KEYDOWN, wparam);
|
||||||
|
|
||||||
// Process is done in WM_KEYUP: VK_F1 VK_F2 VK_F3 VK_F4 VK_F5 VK_F6 VK_F7 VK_F8
|
// Process is done in WM_KEYUP: VK_F1 VK_F2 VK_F3 VK_F4 VK_F5 VK_F6 VK_F7 VK_F8
|
||||||
if ((wparam >= VK_F1) && (wparam <= VK_F8) && (buttondown == -1))
|
if ((wparam >= VK_F1) && (wparam <= VK_F8) && (buttondown == -1))
|
||||||
@ -1400,7 +1400,14 @@ LRESULT CALLBACK FrameWndProc (
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_KEYUP:
|
case WM_KEYUP:
|
||||||
KeybSpecialKeyup(wparam);
|
KeybSpecialKeyTransition(WM_KEYUP, wparam);
|
||||||
|
|
||||||
|
if (wparam == VK_ESCAPE || wparam == VK_SPACE || wparam == VK_TAB)
|
||||||
|
{
|
||||||
|
char str[40];
|
||||||
|
sprintf(str, "WM_KEYUP: %d\n", wparam);
|
||||||
|
OutputDebugString(str);
|
||||||
|
}
|
||||||
|
|
||||||
// Process is done in WM_KEYUP: VK_F1 VK_F2 VK_F3 VK_F4 VK_F5 VK_F6 VK_F7 VK_F8
|
// Process is done in WM_KEYUP: VK_F1 VK_F2 VK_F3 VK_F4 VK_F5 VK_F6 VK_F7 VK_F8
|
||||||
if ((wparam >= VK_F1) && (wparam <= VK_F8) && (buttondown == (int)wparam-VK_F1))
|
if ((wparam >= VK_F1) && (wparam <= VK_F8) && (buttondown == (int)wparam-VK_F1))
|
||||||
|
@ -390,53 +390,39 @@ static char ClipboardCurrChar(bool bIncPtr)
|
|||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
// For AKD (Any Key Down), need special handling for the hooked key combos(*), as GetKeyState() doesn't detect the keys as being down.
|
// For AKD (Any Key Down), need special handling for the hooked key combos(*), as GetKeyState() doesn't detect the keys as being down.
|
||||||
|
// . And equally GetKeyState() doesn't detect the keys as being up: eg. Whilst pressing TAB, press LEFT ALT, then release TAB.
|
||||||
// (*) ALT+TAB, ALT+ESCAPE, ALT+SPACE
|
// (*) ALT+TAB, ALT+ESCAPE, ALT+SPACE
|
||||||
|
|
||||||
static enum {AKD_TAB=0, AKD_ESCAPE, AKD_SPACE};
|
static enum {AKD_TAB=0, AKD_ESCAPE, AKD_SPACE};
|
||||||
static bool g_specialAKD[3] = {false,false,false};
|
static bool g_specialAKD[3] = {false,false,false};
|
||||||
|
|
||||||
void KeybSpecialKeydown(DWORD wparam)
|
void KeybSpecialKeyTransition(UINT message, WPARAM wparam)
|
||||||
{
|
{
|
||||||
|
_ASSERT(message == WM_KEYUP || message == WM_KEYDOWN);
|
||||||
|
bool bState = message == WM_KEYDOWN;
|
||||||
|
|
||||||
switch (wparam)
|
switch (wparam)
|
||||||
{
|
{
|
||||||
case VK_TAB:
|
case VK_TAB:
|
||||||
g_specialAKD[AKD_TAB] = true;
|
g_specialAKD[AKD_TAB] = bState;
|
||||||
break;
|
break;
|
||||||
case VK_ESCAPE:
|
case VK_ESCAPE:
|
||||||
g_specialAKD[AKD_ESCAPE] = true;
|
g_specialAKD[AKD_ESCAPE] = bState;
|
||||||
break;
|
break;
|
||||||
case VK_SPACE:
|
case VK_SPACE:
|
||||||
g_specialAKD[AKD_SPACE] = true;
|
g_specialAKD[AKD_SPACE] = bState;
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeybSpecialKeyup(DWORD wparam)
|
static void GetKeyStateOfSpecialAKD(int lastvirtkey, bool& bState)
|
||||||
{
|
|
||||||
switch (wparam)
|
|
||||||
{
|
|
||||||
case VK_TAB:
|
|
||||||
g_specialAKD[AKD_TAB] = false;
|
|
||||||
break;
|
|
||||||
case VK_ESCAPE:
|
|
||||||
g_specialAKD[AKD_ESCAPE] = false;
|
|
||||||
break;
|
|
||||||
case VK_SPACE:
|
|
||||||
g_specialAKD[AKD_SPACE] = false;
|
|
||||||
break;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool IsSpecialAKD(int lastvirtkey)
|
|
||||||
{
|
{
|
||||||
if (VK_TAB == lastvirtkey)
|
if (VK_TAB == lastvirtkey)
|
||||||
return g_specialAKD[AKD_TAB];
|
bState = g_specialAKD[AKD_TAB];
|
||||||
else if (VK_ESCAPE == lastvirtkey)
|
else if (VK_ESCAPE == lastvirtkey)
|
||||||
return g_specialAKD[AKD_ESCAPE];
|
bState = g_specialAKD[AKD_ESCAPE];
|
||||||
else if (VK_SPACE == lastvirtkey)
|
else if (VK_SPACE == lastvirtkey)
|
||||||
return g_specialAKD[AKD_SPACE];
|
bState = g_specialAKD[AKD_SPACE];
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
@ -480,10 +466,10 @@ BYTE __stdcall KeybReadFlag (WORD, WORD, BYTE, BYTE, ULONG)
|
|||||||
|
|
||||||
keywaiting = 0;
|
keywaiting = 0;
|
||||||
|
|
||||||
if (IsSpecialAKD(lastvirtkey))
|
bool bState = GetKeyState(lastvirtkey) < 0;
|
||||||
return keycode | 0x80;
|
GetKeyStateOfSpecialAKD(lastvirtkey, bState);
|
||||||
|
|
||||||
return keycode | ((GetKeyState(lastvirtkey) < 0) ? 0x80 : 0);
|
return keycode | (bState ? 0x80 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
@ -14,8 +14,7 @@ BYTE KeybGetKeycode ();
|
|||||||
void KeybQueueKeypress (int,BOOL);
|
void KeybQueueKeypress (int,BOOL);
|
||||||
void KeybToggleCapsLock ();
|
void KeybToggleCapsLock ();
|
||||||
void KeybToggleP8ACapsLock ();
|
void KeybToggleP8ACapsLock ();
|
||||||
void KeybSpecialKeydown(DWORD wparam);
|
void KeybSpecialKeyTransition(UINT message, WPARAM wparam);
|
||||||
void KeybSpecialKeyup(DWORD wparam);
|
|
||||||
void KeybSetSnapshot_v1(const BYTE LastKey);
|
void KeybSetSnapshot_v1(const BYTE LastKey);
|
||||||
void KeybSaveSnapshot(class YamlSaveHelper& yamlSaveHelper);
|
void KeybSaveSnapshot(class YamlSaveHelper& yamlSaveHelper);
|
||||||
void KeybLoadSnapshot(class YamlLoadHelper& yamlLoadHelper);
|
void KeybLoadSnapshot(class YamlLoadHelper& yamlLoadHelper);
|
||||||
|
Loading…
Reference in New Issue
Block a user