Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distinguish Left/Right Modifiers #688

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions SquirrelInputController.m
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ - (BOOL)handleEvent:(NSEvent*)event client:(id)sender
break;
}
//NSLog(@"FLAGSCHANGED client: %@, modifiers: 0x%lx", sender, modifiers);
int keyCode = event.keyCode;
int rime_modifiers = osx_modifiers_to_rime_modifiers(modifiers);
int release_mask = 0;
NSUInteger changes = _lastModifier ^ modifiers;
Expand All @@ -91,22 +92,35 @@ - (BOOL)handleEvent:(NSEvent*)event client:(id)sender
}
if (changes & OSX_SHIFT_MASK) {
release_mask = modifiers & OSX_SHIFT_MASK ? 0 : kReleaseMask;
[self processKey:XK_Shift_L
modifiers:(rime_modifiers | release_mask)];
if (keyCode == 0x38) {
[self processKey:XK_Shift_L modifiers:(rime_modifiers | release_mask)];
} else if (keyCode == 0x3c) {
[self processKey:XK_Shift_R modifiers:(rime_modifiers | release_mask)];
}
}
if (changes & OSX_CTRL_MASK) {
release_mask = modifiers & OSX_CTRL_MASK ? 0 : kReleaseMask;
[self processKey:XK_Control_L
modifiers:(rime_modifiers | release_mask)];
if (keyCode == 0x3b) {
[self processKey:XK_Control_L modifiers:(rime_modifiers | release_mask)];
} else if (keyCode == 0x3e) {
[self processKey:XK_Control_R modifiers:(rime_modifiers | release_mask)];
}
}
if (changes & OSX_ALT_MASK) {
release_mask = modifiers & OSX_ALT_MASK ? 0 : kReleaseMask;
[self processKey:XK_Alt_L modifiers:(rime_modifiers | release_mask)];
if (keyCode == 0x3a) {
[self processKey:XK_Alt_L modifiers:(rime_modifiers | release_mask)];
} else if (keyCode == 0x3d) {
[self processKey:XK_Alt_R modifiers:(rime_modifiers | release_mask)];
}
}
if (changes & OSX_COMMAND_MASK) {
release_mask = modifiers & OSX_COMMAND_MASK ? 0 : kReleaseMask;
[self processKey:XK_Super_L
modifiers:(rime_modifiers | release_mask)];
if (keyCode == 0x37) {
[self processKey:XK_Super_L modifiers:(rime_modifiers | release_mask)];
} else if (keyCode == 0x36) {
[self processKey:XK_Super_R modifiers:(rime_modifiers | release_mask)];
}
// do not update UI when using Command key
break;
}
Expand Down