mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-05 00:15:32 +00:00
fix(windows): address review comments
Some checks failed
Keyman Build Summary / Summarize build status checks (push) Has been cancelled
Some checks failed
Keyman Build Summary / Summarize build status checks (push) Has been cancelled
This commit is contained in:
parent
c23284ea51
commit
02db51c9b6
5 changed files with 26 additions and 19 deletions
|
|
@ -114,14 +114,6 @@ void ProcessToggleChange(UINT key) { // I4793
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the cache of the last key event received, this is set here - TIP processing, and by
|
||||
* the GetMessage hook.
|
||||
* @param _td Theread data to update
|
||||
* @param wParam WPARAM of the key event
|
||||
* @param scan Scan code of the key event
|
||||
* @param keyTransition Transition state of the key event (0 = key down, 1 = repeat, 3 = key up)
|
||||
*/
|
||||
void UpdateLastKeyCache(PKEYMAN64THREADDATA _td, WPARAM wParam, BYTE scan, BYTE keyTransition) {
|
||||
_td->LastKey = wParam;
|
||||
_td->LastScanCode = scan;
|
||||
|
|
@ -142,7 +134,7 @@ BOOL TIPProcessKeyInternal(
|
|||
BOOL isUp = keyFlags & KF_UP ? TRUE : FALSE;
|
||||
BOOL extended = keyFlags & KF_EXTENDED ? TRUE : FALSE;
|
||||
BYTE scan = keyFlags & 0xFF;
|
||||
BYTE keyTransition = (BYTE)((HIWORD(lParam) & (KF_UP | KF_REPEAT)) >> 14);
|
||||
BYTE keyTransition = KEYMSG_FLAG_TRANSITION(lParam);
|
||||
WPARAM prevKey = _td->LastKey;
|
||||
BYTE prevScanCode = _td->LastScanCode;
|
||||
BYTE prevKeyTransition = _td->LastTransition;
|
||||
|
|
@ -152,7 +144,7 @@ BOOL TIPProcessKeyInternal(
|
|||
SendDebugMessageFormat("VirtualKey=%s lParam=%x IsUp=%d Extended=%d Updateable=%d Preserved=%d",
|
||||
Debug_VirtualKey((WORD) wParam), lParam, isUp, extended, Updateable, Preserved);
|
||||
|
||||
if (_td->LastKey == wParam && scan == 0) { // I4642 - handle issue with Logos application.
|
||||
if (_td->LastKey == wParam && scan == 0) { // I4642 - handle issue with Logos application.
|
||||
scan = _td->LastScanCode;
|
||||
SendDebugMessageFormat("Scan code was zero so using cached scan code %x", scan);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,4 +88,19 @@ public:
|
|||
* @param key
|
||||
*/
|
||||
void ProcessToggleChange(UINT key);
|
||||
|
||||
// Forward declaration - final in globals.h
|
||||
struct tagKEYMAN64THREADDATA;
|
||||
typedef struct tagKEYMAN64THREADDATA *PKEYMAN64THREADDATA;
|
||||
|
||||
/**
|
||||
* Update the cache of the last key event received, this is set here - TIP processing, and by
|
||||
* the GetMessage hook.
|
||||
* @param _td Thread data to update
|
||||
* @param wParam WPARAM of the key event
|
||||
* @param scan Scan code of the key event
|
||||
* @param keyTransition Transition state of the key event (00b = key down, 01b = repeat, 11b = keyup)
|
||||
*/
|
||||
void UpdateLastKeyCache(PKEYMAN64THREADDATA _td, WPARAM wParam, BYTE scan, BYTE keyTransition);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -118,11 +118,14 @@
|
|||
#define KEYMSG_FLAG_DLGMODE(lParam) (HIWORD(lParam) & KF_DLGMODE ? 1 : 0)
|
||||
#define KEYMSG_FLAG_MENUMODE(lParam) (HIWORD(lParam) & KF_MENUMODE ? 1 : 0)
|
||||
#define KEYMSG_FLAG_ALTDOWN(lParam) (HIWORD(lParam) & KF_ALTDOWN ? 1 : 0)
|
||||
// Repeat is actually previous "up" value of the key
|
||||
// Repeat is actually previous KF_UP value of the key.
|
||||
// It is always set to 1 for WM_KEYUP and WM_SYSKEYUP messages.
|
||||
// It is set to 1 for WM_KEYDOWN and WM_SYSKEYDOWN keystroke messages generated by the automatic repeat feature.
|
||||
// see https://learn.microsoft.com/en-us/windows/win32/inputdev/about-keyboard-input#previous-key-state-flag
|
||||
#define KEYMSG_FLAG_REPEAT(lParam) (HIWORD(lParam) & KF_REPEAT ? 1 : 0)
|
||||
#define KEYMSG_FLAG_UP(lParam) (HIWORD(lParam) & KF_UP ? 1 : 0)
|
||||
// Combine the transition flags into a single value for higher chance of identification
|
||||
// 0 = key down, 1 = repeat, 2 = keyup
|
||||
// 00b = key down, 01b = repeat, 11b = keyup
|
||||
#define KEYMSG_FLAG_TRANSITION(lParam) ((BYTE)((HIWORD(lParam) & (KF_UP | KF_REPEAT)) >> 14))
|
||||
|
||||
// TODO: Deprecate overloading of scancodes and use dwExtraInfo instead
|
||||
|
|
|
|||
|
|
@ -158,9 +158,7 @@ LRESULT _kmnGetMessageProc(int nCode, WPARAM wParam, LPARAM lParam)
|
|||
BYTE scan = KEYMSG_LPARAM_SCAN(mp->lParam);
|
||||
BYTE keyTransitionEvent = KEYMSG_FLAG_TRANSITION(mp->lParam);
|
||||
CheckScheduledRefresh();
|
||||
_td->LastScanCode = scan;
|
||||
_td->LastKey = mp->wParam;
|
||||
_td->LastTransition = keyTransitionEvent;
|
||||
UpdateLastKeyCache(_td, mp->wParam, scan, keyTransitionEvent);
|
||||
|
||||
switch (mp->wParam) {
|
||||
case VK_MENU:
|
||||
|
|
|
|||
|
|
@ -79,16 +79,15 @@ processPersistOpt(km_core_actions const* actions, LPINTKEYBOARDINFO activeKeyboa
|
|||
|
||||
static void processCapsLock(const km_core_caps_state caps_state_change, BOOL isUp, BOOL Updateable, BOOL externalEvent) {
|
||||
BOOL isCapsOn = IsCapsLockOn();
|
||||
|
||||
|
||||
// This debug message is useful for understanding the sequence of events around caps lock changes
|
||||
//SendDebugMessageFormat("ACTION CAPS STATE:%d FIsUp=%d Updateable=%d ExternalEvent=%d CapsState=%d", caps_state_change, isUp, Updateable,
|
||||
// externalEvent, isCapsOn);
|
||||
|
||||
|
||||
// We only want to process the Caps Lock key event once;
|
||||
// it has to be when updateble=1 as TSF does not consistently
|
||||
// have updateable=0 events.
|
||||
if (!Updateable || caps_state_change == KM_CORE_CAPS_UNCHANGED)
|
||||
{
|
||||
if (!Updateable || caps_state_change == KM_CORE_CAPS_UNCHANGED) {
|
||||
return;
|
||||
}
|
||||
// Turn three state value into a boolean for whether capslock should be on or off,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue