From f0cd0c67e797c9cc845ca0f1dbcbb0e9287aa5b9 Mon Sep 17 00:00:00 2001 From: sgschantz Date: Fri, 13 Dec 2024 13:56:02 +0700 Subject: [PATCH 1/3] fix(mac): osk and physical keyboard modifiers kept in sync additional logic applied to keep two modifier types consistent with each other also lots of refactoring to keep naming clear Fixes: #12582 --- .../OnScreenKeyboard/OSKWindowController.m | 106 +++++++-- .../KME/OnScreenKeyboard/OSKView.h | 10 +- .../KME/OnScreenKeyboard/OSKView.m | 223 ++++++++++-------- 3 files changed, 214 insertions(+), 125 deletions(-) diff --git a/mac/Keyman4MacIM/Keyman4MacIM/OnScreenKeyboard/OSKWindowController.m b/mac/Keyman4MacIM/Keyman4MacIM/OnScreenKeyboard/OSKWindowController.m index 33d7eda4062..4a20a537daf 100644 --- a/mac/Keyman4MacIM/Keyman4MacIM/OnScreenKeyboard/OSKWindowController.m +++ b/mac/Keyman4MacIM/Keyman4MacIM/OnScreenKeyboard/OSKWindowController.m @@ -15,9 +15,9 @@ @interface OSKWindowController () @property (nonatomic, strong) NSButton *helpButton; @property (nonatomic, strong) NSTimer *modFlagsTimer; -@property (nonatomic, assign) BOOL xShiftState; -@property (nonatomic, assign) BOOL xAltState; -@property (nonatomic, assign) BOOL xCtrlState; +@property (nonatomic, assign) BOOL previousShiftState; +@property (nonatomic, assign) BOOL previousOptionState; +@property (nonatomic, assign) BOOL previousControlState; @end @implementation OSKWindowController @@ -58,7 +58,7 @@ - (void)windowDidLoad { [super windowDidLoad]; [self.oskView setKvk:[self.AppDelegate kvk]]; [self startTimerWithTimeInterval:0.1]; - // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file. + // [self startTimerToTrackPhysicalModifierState:0.1]; } - (void)windowDidResize:(NSNotification *)notification { @@ -116,52 +116,110 @@ - (void)stopTimer { } } +/** + * Called repeatedly by timer to track the state of the physical modifier keys. + * Changes in state are reported to the OSKView, so it can make corresponding updates to the OSK's appearance + * and apply the state as necessary when keys on the OSK are clicked. + */ - (void)timerAction:(NSTimer *)timer { UInt32 modifiers = GetCurrentKeyModifiers(); if ((modifiers & shiftKey) == shiftKey) { - [self.oskView setShiftState:YES]; - self.xShiftState = YES; + [self.oskView setPhysicalShiftState:YES]; + self.previousShiftState = YES; } else { - [self.oskView setShiftState:NO]; - if (self.xShiftState) + [self.oskView setPhysicalShiftState:NO]; + if (self.previousShiftState) [self.oskView setOskShiftState:NO]; - self.xShiftState = NO; + self.previousShiftState = NO; } - if ((modifiers & optionKey) == optionKey) { - [self.oskView setAltState:YES]; - self.xAltState = YES; + [self.oskView setPhysicalOptionState:YES]; + self.previousOptionState = YES; } else { - [self.oskView setAltState:NO]; - if (self.xAltState) - [self.oskView setOskAltState:NO]; - self.xAltState = NO; + [self.oskView setPhysicalOptionState:NO]; + if (self.previousOptionState) + [self.oskView setOskOptionState:NO]; + self.previousOptionState = NO; } if ((modifiers & controlKey) == controlKey) { - [self.oskView setCtrlState:YES]; - self.xCtrlState = YES; + [self.oskView setPhysicalControlState:YES]; + self.previousControlState = YES; + } + else { + [self.oskView setPhysicalControlState:NO]; + if (self.previousControlState) + [self.oskView setOskControlState:NO]; + self.previousControlState = NO; + } +} + +/* +- (void)trackPhysicalModifierKeyState:(NSTimer *)timer { + UInt32 modifiers = GetCurrentKeyModifiers(); + + [self trackPhysicalShiftKeyState: modifiers]; + [self trackPhysicalOptionKeyState: modifiers]; + [self trackPhysicalControlKeyState: modifiers]; +} + +- (void)trackPhysicalShiftKeyState:(UInt32) modifiers { + if ((modifiers & shiftKey) == shiftKey) { + [self.oskView setPhysicalShiftState:YES]; + self.previousShiftState = YES; + } + else { + [self.oskView setPhysicalShiftState:NO]; + if (self.previousShiftState) { + [self.oskView setOskShiftState:NO]; + } + self.previousShiftState = NO; + } +} + +- (void)trackPhysicalOptionKeyState:(UInt32) modifiers { + if ((modifiers & optionKey) == optionKey) { + [self.oskView setPhysicalOptionState:YES]; + self.previousOptionState = YES; + } + else { + [self.oskView setPhysicalOptionState:NO]; + if (self.previousOptionState) { + [self.oskView setOskOptionState:NO]; + } + self.previousOptionState = NO; + } +} + +- (void)trackPhysicalControlKeyState:(UInt32) modifiers { + if ((modifiers & controlKey) == controlKey) { + [self.oskView setPhysicalControlState:YES]; + self.previousControlState = YES; } else { - [self.oskView setCtrlState:NO]; - if (self.xCtrlState) - [self.oskView setOskCtrlState:NO]; - self.xCtrlState = NO; + [self.oskView setPhysicalControlState:NO]; + if (self.previousControlState) { + [self.oskView setOskControlState:NO]; + } + self.previousControlState = NO; } } +*/ - (BOOL)hasHelpDocumentation { NSString *kvkPath = [self AppDelegate].kvk.filePath; - if (!kvkPath) + if (!kvkPath) { return NO; + } NSString *packagePath = [kvkPath stringByDeletingLastPathComponent]; if (packagePath != nil) { NSString *welcomeFile = [packagePath stringByAppendingPathComponent:@"welcome.htm"]; - if ([[NSFileManager defaultManager] fileExistsAtPath:welcomeFile]) + if ([[NSFileManager defaultManager] fileExistsAtPath:welcomeFile]) { return YES; + } } return NO; diff --git a/mac/KeymanEngine4Mac/KeymanEngine4Mac/KME/OnScreenKeyboard/OSKView.h b/mac/KeymanEngine4Mac/KeymanEngine4Mac/KME/OnScreenKeyboard/OSKView.h index 26914858f98..082604871e8 100644 --- a/mac/KeymanEngine4Mac/KeymanEngine4Mac/KME/OnScreenKeyboard/OSKView.h +++ b/mac/KeymanEngine4Mac/KeymanEngine4Mac/KME/OnScreenKeyboard/OSKView.h @@ -19,12 +19,12 @@ + (BOOL)isOskKeyDownEvent:(CGEventRef)event; + (NSEventModifierFlags)extractModifierFlagsFromOskEvent:(CGEventRef)event; - (void)handleKeyEvent:(NSEvent *)event; -- (void)setShiftState:(BOOL)shiftState; +- (void)setPhysicalShiftState:(BOOL)shiftState; - (void)setOskShiftState:(BOOL)oskShiftState; -- (void)setAltState:(BOOL)altState; -- (void)setOskAltState:(BOOL)oskAltState; -- (void)setCtrlState:(BOOL)ctrlState; -- (void)setOskCtrlState:(BOOL)oskCtrlState; +- (void)setPhysicalOptionState:(BOOL)altState; +- (void)setOskOptionState:(BOOL)oskAltState; +- (void)setPhysicalControlState:(BOOL)ctrlState; +- (void)setOskControlState:(BOOL)oskCtrlState; - (void)resetOSK; - (void)resizeOSKLayout; - (int64_t)createOskEventUserData; diff --git a/mac/KeymanEngine4Mac/KeymanEngine4Mac/KME/OnScreenKeyboard/OSKView.m b/mac/KeymanEngine4Mac/KeymanEngine4Mac/KME/OnScreenKeyboard/OSKView.m index 4a4cb98c776..0483cfeb3e5 100644 --- a/mac/KeymanEngine4Mac/KeymanEngine4Mac/KME/OnScreenKeyboard/OSKView.m +++ b/mac/KeymanEngine4Mac/KeymanEngine4Mac/KME/OnScreenKeyboard/OSKView.m @@ -23,12 +23,12 @@ @interface OSKView() @property (nonatomic, strong) NSArray *oskLayout; @property (nonatomic, strong) NSArray *oskDefaultNKeys; -@property (nonatomic, assign) BOOL shiftState; +@property (nonatomic, assign) BOOL physicalShiftState; @property (nonatomic, assign) BOOL oskShiftState; -@property (nonatomic, assign) BOOL altState; -@property (nonatomic, assign) BOOL oskAltState; -@property (nonatomic, assign) BOOL ctrlState; -@property (nonatomic, assign) BOOL oskCtrlState; +@property (nonatomic, assign) BOOL physicalOptionState; +@property (nonatomic, assign) BOOL oskOptionState; +@property (nonatomic, assign) BOOL physicalControlState; +@property (nonatomic, assign) BOOL oskControlState; @end @implementation OSKView @@ -69,8 +69,8 @@ - (id)initWithFrame:(NSRect)frame { } - (NSString *)description { - NSString *format = @""; - NSString *str = [NSString stringWithFormat:format, _shiftState, _oskShiftState, _altState, _oskAltState, _ctrlState, _oskCtrlState]; + NSString *format = @""; + NSString *str = [NSString stringWithFormat:format, _physicalShiftState, _oskShiftState, _physicalOptionState, _oskOptionState, _physicalControlState, _oskControlState]; return str; } @@ -140,7 +140,7 @@ - (void)setKvk:(KVKFile *)kvk { _oskLayout = nil; _oskDefaultNKeys = nil; - [self setKeyLabels:self.oskShiftState alt:self.oskAltState ctrl:self.oskCtrlState]; + [self displayKeyLabelsForLayer]; } - (void)initOSKKeys { @@ -166,7 +166,7 @@ - (void)initOSKKeys { [keyView setTarget:self]; if (self.oskShiftState && (keyView.key.keyCode == MVK_LEFT_SHIFT || keyView.key.keyCode == MVK_RIGHT_SHIFT)) [keyView setKeyPressed:YES]; - else if (self.oskAltState && (keyView.key.keyCode == MVK_LEFT_ALT || keyView.key.keyCode == MVK_RIGHT_ALT)) + else if (self.oskOptionState && (keyView.key.keyCode == MVK_LEFT_ALT || keyView.key.keyCode == MVK_RIGHT_ALT)) [keyView setKeyPressed:YES]; [self addSubview:keyView]; px += width; @@ -174,7 +174,7 @@ - (void)initOSKKeys { py += keyHeight; } - [self setKeyLabels:self.oskShiftState alt:self.oskAltState ctrl:self.oskCtrlState]; + [self displayKeyLabelsForLayer]; } - (NSArray *)oskLayout { @@ -429,7 +429,7 @@ - (NSArray *)oskDefaultNKeys { - (void)resetOSK { [self setOskShiftState:NO]; - [self setOskAltState:NO]; + [self setOskOptionState:NO]; [self.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)]; [self initOSKKeys]; } @@ -467,10 +467,10 @@ - (void)keyAction:(id)sender { [self setOskShiftState:!self.oskShiftState]; } else if (keyCode == MVK_LEFT_ALT || keyCode == MVK_RIGHT_ALT) { - [self setOskAltState:!self.oskAltState]; + [self setOskOptionState:!self.oskOptionState]; } else if (keyCode == MVK_LEFT_CTRL || keyCode == MVK_RIGHT_CTRL) { - [self setOskCtrlState:!self.oskCtrlState]; + [self setOskControlState:!self.oskControlState]; } } } @@ -489,17 +489,17 @@ - (int64_t) createOskEventUserData { // set bit to identify this user data as originating from the OSK int64_t oskEventData = OSK_EVENT_FLAG; - if (self.oskShiftState || self.shiftState) { + if (self.oskShiftState || self.physicalShiftState) { oskEventData = oskEventData | kCGEventFlagMaskShift; } /** - * Both left and right alt keys on the OSK cause oskAltState to be true without distinction of left or right. + * Both left and right option keys on the OSK cause oskOptionState to be true without distinction of left or right. * However, the generated event is a right alt so that it will trigger the right alt rules in the Keyman keyboard. */ - if (self.oskAltState || self.altState) { + if (self.oskOptionState || self.physicalOptionState) { oskEventData = oskEventData | MK_RIGHT_ALT_MASK; } - if (self.oskCtrlState || self.oskCtrlState) { + if (self.oskControlState || self.oskControlState) { oskEventData = oskEventData | kCGEventFlagMaskControl; } @@ -523,8 +523,17 @@ - (void)setKeyPressedOff:(KeyView *)keyView { [keyView setKeyPressed:NO]; } -- (void)setKeyLabels:(BOOL)shift alt:(BOOL)alt ctrl:(BOOL)ctrl { - os_log_debug([KMELogs oskLog], "OSKView setKeyLabels, shift: %d, alt: %d, ctrl: %d", shift, alt, ctrl); +/** + * Display the key labels that correspond to the current state of the modifier keys. + * The layer shown depends on both the physical modifier state and the osk modifier state. + */ +- (void)displayKeyLabelsForLayer { + os_log_debug([KMELogs oskLog], "OSKView setKeyLabels, phsyical modifiers [shift: %d, option: %d, control: %d]\nosk modifiers [shift: %d, option: %d, control: %d]", self.physicalShiftState, self.physicalOptionState, self.physicalControlState, self.oskShiftState, self.oskOptionState, self.oskControlState); + + BOOL shift = self.physicalShiftState | self.oskShiftState; + BOOL option = self.physicalOptionState | self.oskOptionState; + BOOL control = self.physicalControlState | self.oskControlState; + [self resetKeyLabels]; NSMutableArray *mKeys = [[self keyTags] mutableCopy]; NSArray *nkeys = [self.kvk keys]; @@ -535,14 +544,14 @@ - (void)setKeyLabels:(BOOL)shift alt:(BOOL)alt ctrl:(BOOL)ctrl { if (shift) { flags |= KVKS_SHIFT; } - if (alt) { + if (option) { if (self.kvk.containsRightAltKeys) { flags |= KVKS_RALT; } else if (self.kvk.containsAltKeys) { flags |= KVKS_ALT; } } - if (ctrl) { + if (control) { flags |= KVKS_RCTRL; } @@ -613,114 +622,136 @@ - (void)resetKeyLabels { } } -- (void)setShiftState:(BOOL)shiftState { - if (_shiftState != shiftState) { - _shiftState = shiftState; - KeyView *shiftKeyL = (KeyView *)[self viewWithTag:MVK_LEFT_SHIFT|0x1000]; - KeyView *shiftKeyR = (KeyView *)[self viewWithTag:MVK_RIGHT_SHIFT|0x1000]; - if (shiftState) { - [self setKeyLabels:YES alt:self.oskAltState ctrl:self.oskCtrlState]; - [shiftKeyL setKeyPressed:YES]; - [shiftKeyR setKeyPressed:YES]; +- (void)setPhysicalShiftState:(BOOL)state { + if (_physicalShiftState != state) { + _physicalShiftState = state; + + /** + * When setting the physical shift state, clear the OSK shift state + * The state of the physical key overrides the modifier key clicked in the OSK. + */ + _oskShiftState = NO; + + if (state) { + os_log_debug([KMELogs oskLog], "hardware shift key pressed"); + [self displayKeyLabelsForLayer]; + [self displaysShiftKeysAsPressed:YES]; } else { - [self setKeyLabels:NO alt:self.oskAltState ctrl:self.oskCtrlState]; - [shiftKeyL setKeyPressed:NO]; - [shiftKeyR setKeyPressed:NO]; + os_log_debug([KMELogs oskLog], "hardware shift key released"); + [self displayKeyLabelsForLayer]; + [self displaysShiftKeysAsPressed:NO]; } } } -- (void)setOskShiftState:(BOOL)oskShiftState { - if (_oskShiftState != oskShiftState && !self.shiftState) { - _oskShiftState = oskShiftState; - KeyView *shiftKeyL = (KeyView *)[self viewWithTag:MVK_LEFT_SHIFT|0x1000]; - KeyView *shiftKeyR = (KeyView *)[self viewWithTag:MVK_RIGHT_SHIFT|0x1000]; - if (oskShiftState) { - [self setKeyLabels:YES alt:self.oskAltState ctrl:self.oskCtrlState]; - [shiftKeyL setKeyPressed:YES]; - [shiftKeyR setKeyPressed:YES]; +- (void)setOskShiftState:(BOOL)state { + if (_oskShiftState != state && !self.physicalShiftState) { + _oskShiftState = state; + if (state) { + os_log_debug([KMELogs oskLog], "OSK shift key selected"); + [self displayKeyLabelsForLayer]; + [self displaysShiftKeysAsPressed:YES]; } - else if (!self.shiftState) { - [self setKeyLabels:NO alt:self.oskAltState ctrl:self.oskCtrlState]; - [shiftKeyL setKeyPressed:NO]; - [shiftKeyR setKeyPressed:NO]; + else if (!self.physicalShiftState) { + os_log_debug([KMELogs oskLog], "OSK shift key de-selected"); + [self displayKeyLabelsForLayer]; + [self displaysShiftKeysAsPressed:NO]; } } } -- (void)setAltState:(BOOL)altState { - if (_altState != altState) { - _altState = altState; - KeyView *altKeyL = (KeyView *)[self viewWithTag:MVK_LEFT_ALT|0x1000]; - KeyView *altKeyR = (KeyView *)[self viewWithTag:MVK_RIGHT_ALT|0x1000]; - if (altState) { - [self setKeyLabels:self.oskShiftState alt:YES ctrl:self.oskCtrlState]; - [altKeyL setKeyPressed:YES]; - [altKeyR setKeyPressed:YES]; +- (void)setPhysicalOptionState:(BOOL)state { + if (_physicalOptionState != state) { + _physicalOptionState = state; + + /** + * When setting the physical option state, clear the OSK option state + * The state of the physical key overrides the modifier key clicked in the OSK. + */ + _oskOptionState = NO; + + if (state) { + [self displayKeyLabelsForLayer]; + [self displaysOptionKeysAsPressed:YES]; } else { - [self setKeyLabels:self.oskShiftState alt:NO ctrl:self.oskCtrlState]; - [altKeyL setKeyPressed:NO]; - [altKeyR setKeyPressed:NO]; + [self displayKeyLabelsForLayer]; + [self displaysOptionKeysAsPressed:NO]; } } } -- (void)setOskAltState:(BOOL)oskAltState { - if (_oskAltState != oskAltState && !self.altState) { - _oskAltState = oskAltState; - KeyView *altKeyL = (KeyView *)[self viewWithTag:MVK_LEFT_ALT|0x1000]; - KeyView *altKeyR = (KeyView *)[self viewWithTag:MVK_RIGHT_ALT|0x1000]; - if (oskAltState) { - [self setKeyLabels:self.oskShiftState alt:YES ctrl:self.oskCtrlState]; - [altKeyL setKeyPressed:YES]; - [altKeyR setKeyPressed:YES]; +- (void)setOskOptionState:(BOOL)state { + if (_oskOptionState != state && !self.physicalOptionState) { + _oskOptionState = state; + if (state) { + [self displayKeyLabelsForLayer]; + [self displaysOptionKeysAsPressed:YES]; } - else if (!self.altState) { - [self setKeyLabels:self.oskShiftState alt:NO ctrl:self.oskCtrlState]; - [altKeyL setKeyPressed:NO]; - [altKeyR setKeyPressed:NO]; + else if (!self.physicalOptionState) { + [self displayKeyLabelsForLayer]; + [self displaysOptionKeysAsPressed:NO]; } } } -- (void)setCtrlState:(BOOL)ctrlState { - if (_ctrlState != ctrlState) { - _ctrlState = ctrlState; - KeyView *ctrlKeyL = (KeyView *)[self viewWithTag:MVK_LEFT_CTRL|0x1000]; - KeyView *ctrlKeyR = (KeyView *)[self viewWithTag:MVK_RIGHT_CTRL|0x1000]; - if (ctrlState) { - [self setKeyLabels:self.oskShiftState alt:self.oskAltState ctrl:YES]; - [ctrlKeyL setKeyPressed:YES]; - [ctrlKeyR setKeyPressed:YES]; +- (void)setPhysicalControlState:(BOOL)state { + if (_physicalControlState != state) { + _physicalControlState = state; + + /** + * When setting the physical control state, clear the OSK control state + * The state of the physical key overrides the modifier key clicked in the OSK. + */ + _oskControlState = NO; + + if (state) { + [self displayKeyLabelsForLayer]; + [self displaysControlKeysAsPressed:YES]; } else { - [self setKeyLabels:self.oskShiftState alt:self.oskAltState ctrl:NO]; - [ctrlKeyL setKeyPressed:NO]; - [ctrlKeyR setKeyPressed:NO]; + [self displayKeyLabelsForLayer]; + [self displaysControlKeysAsPressed:NO]; } } } -- (void)setOskCtrlState:(BOOL)oskCtrlState { - if (_oskCtrlState != oskCtrlState && !self.ctrlState) { - _oskCtrlState = oskCtrlState; - KeyView *ctrlKeyL = (KeyView *)[self viewWithTag:MVK_LEFT_CTRL|0x1000]; - KeyView *ctrlKeyR = (KeyView *)[self viewWithTag:MVK_RIGHT_CTRL|0x1000]; - if (oskCtrlState) { - [self setKeyLabels:self.oskShiftState alt:self.oskAltState ctrl:YES]; - [ctrlKeyL setKeyPressed:YES]; - [ctrlKeyR setKeyPressed:YES]; +- (void)setOskControlState:(BOOL)state { + if (_oskControlState != state && !self.physicalControlState) { + _oskControlState = state; + if (state) { + [self displayKeyLabelsForLayer]; + [self displaysControlKeysAsPressed:YES]; } - else if (!self.ctrlState) { - [self setKeyLabels:self.oskShiftState alt:self.oskAltState ctrl:NO]; - [ctrlKeyL setKeyPressed:NO]; - [ctrlKeyR setKeyPressed:NO]; + else if (!self.physicalControlState) { + [self displayKeyLabelsForLayer]; + [self displaysControlKeysAsPressed:NO]; } } } +- (void)displaysShiftKeysAsPressed:(BOOL)pressed { + KeyView *leftShiftKey = (KeyView *)[self viewWithTag:MVK_LEFT_SHIFT|0x1000]; + KeyView *rightShiftKey = (KeyView *)[self viewWithTag:MVK_RIGHT_SHIFT|0x1000]; + [leftShiftKey setKeyPressed:pressed]; + [rightShiftKey setKeyPressed:pressed]; +} + +- (void)displaysOptionKeysAsPressed:(BOOL)pressed { + KeyView *leftOptionKey = (KeyView *)[self viewWithTag:MVK_LEFT_ALT|0x1000]; + KeyView *rightOptionKey = (KeyView *)[self viewWithTag:MVK_RIGHT_ALT|0x1000]; + [leftOptionKey setKeyPressed:pressed]; + [rightOptionKey setKeyPressed:pressed]; +} + +- (void)displaysControlKeysAsPressed:(BOOL)pressed { + KeyView *leftControlKey = (KeyView *)[self viewWithTag:MVK_LEFT_CTRL|0x1000]; + KeyView *rightControlKey = (KeyView *)[self viewWithTag:MVK_RIGHT_CTRL|0x1000]; + [leftControlKey setKeyPressed:pressed]; + [rightControlKey setKeyPressed:pressed]; +} + - (NSString *)ansiFont { return [self.kvk ansiFont].name; } From 03b925a209465c3d8871e3f619302e24f8f88ffa Mon Sep 17 00:00:00 2001 From: sgschantz Date: Fri, 13 Dec 2024 15:53:42 +0700 Subject: [PATCH 2/3] fix(mac): break up timerAction function --- .../OnScreenKeyboard/OSKWindowController.m | 37 ------------------- 1 file changed, 37 deletions(-) diff --git a/mac/Keyman4MacIM/Keyman4MacIM/OnScreenKeyboard/OSKWindowController.m b/mac/Keyman4MacIM/Keyman4MacIM/OnScreenKeyboard/OSKWindowController.m index 4a20a537daf..ca4181d11c6 100644 --- a/mac/Keyman4MacIM/Keyman4MacIM/OnScreenKeyboard/OSKWindowController.m +++ b/mac/Keyman4MacIM/Keyman4MacIM/OnScreenKeyboard/OSKWindowController.m @@ -123,42 +123,6 @@ - (void)stopTimer { */ - (void)timerAction:(NSTimer *)timer { UInt32 modifiers = GetCurrentKeyModifiers(); - if ((modifiers & shiftKey) == shiftKey) { - [self.oskView setPhysicalShiftState:YES]; - self.previousShiftState = YES; - } - else { - [self.oskView setPhysicalShiftState:NO]; - if (self.previousShiftState) - [self.oskView setOskShiftState:NO]; - self.previousShiftState = NO; - } - if ((modifiers & optionKey) == optionKey) { - [self.oskView setPhysicalOptionState:YES]; - self.previousOptionState = YES; - } - else { - [self.oskView setPhysicalOptionState:NO]; - if (self.previousOptionState) - [self.oskView setOskOptionState:NO]; - self.previousOptionState = NO; - } - - if ((modifiers & controlKey) == controlKey) { - [self.oskView setPhysicalControlState:YES]; - self.previousControlState = YES; - } - else { - [self.oskView setPhysicalControlState:NO]; - if (self.previousControlState) - [self.oskView setOskControlState:NO]; - self.previousControlState = NO; - } -} - -/* -- (void)trackPhysicalModifierKeyState:(NSTimer *)timer { - UInt32 modifiers = GetCurrentKeyModifiers(); [self trackPhysicalShiftKeyState: modifiers]; [self trackPhysicalOptionKeyState: modifiers]; @@ -206,7 +170,6 @@ - (void)trackPhysicalControlKeyState:(UInt32) modifiers { self.previousControlState = NO; } } -*/ - (BOOL)hasHelpDocumentation { NSString *kvkPath = [self AppDelegate].kvk.filePath; From fcb3d4cc4035055d5d374c5dfe07818433af497c Mon Sep 17 00:00:00 2001 From: sgschantz Date: Mon, 16 Dec 2024 13:02:41 +0700 Subject: [PATCH 3/3] fix(mac): rename method in log statement --- .../KeymanEngine4Mac/KME/OnScreenKeyboard/OSKView.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mac/KeymanEngine4Mac/KeymanEngine4Mac/KME/OnScreenKeyboard/OSKView.m b/mac/KeymanEngine4Mac/KeymanEngine4Mac/KME/OnScreenKeyboard/OSKView.m index 0483cfeb3e5..4bf0f6a0e81 100644 --- a/mac/KeymanEngine4Mac/KeymanEngine4Mac/KME/OnScreenKeyboard/OSKView.m +++ b/mac/KeymanEngine4Mac/KeymanEngine4Mac/KME/OnScreenKeyboard/OSKView.m @@ -528,7 +528,7 @@ - (void)setKeyPressedOff:(KeyView *)keyView { * The layer shown depends on both the physical modifier state and the osk modifier state. */ - (void)displayKeyLabelsForLayer { - os_log_debug([KMELogs oskLog], "OSKView setKeyLabels, phsyical modifiers [shift: %d, option: %d, control: %d]\nosk modifiers [shift: %d, option: %d, control: %d]", self.physicalShiftState, self.physicalOptionState, self.physicalControlState, self.oskShiftState, self.oskOptionState, self.oskControlState); + os_log_debug([KMELogs oskLog], "OSKView displayKeyLabelsForLayer, phsyical modifiers [shift: %d, option: %d, control: %d]\nosk modifiers [shift: %d, option: %d, control: %d]", self.physicalShiftState, self.physicalOptionState, self.physicalControlState, self.oskShiftState, self.oskOptionState, self.oskControlState); BOOL shift = self.physicalShiftState | self.oskShiftState; BOOL option = self.physicalOptionState | self.oskOptionState;