-
Notifications
You must be signed in to change notification settings - Fork 123
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
Update Unshaky/ShakyPressPreventer.m #19
Conversation
More targeted approach CMD+space issue after more investigation. Wrote up details of findings in comment.
Thanks for this PR, it feels like the only solution to go for. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a million for this PR. I started couple of conversations you can find below. What do you think of them?
|
||
// The incoming keycode. | ||
CGKeyCode keyCode = (CGKeyCode)CGEventGetIntegerValueField(event, kCGKeyboardEventKeycode); | ||
|
||
// ignore unconfigured keys | ||
if (keyDelays[keyCode] == 0) return event; | ||
|
||
// keyboard type, dismiss if it is not built-in keyboard | ||
if (ignoreExternalKeyboard) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not understand why we need to move ignoreExternalKeyboard
here. If the user types on an external keyboard, we do not have to extract the keyCode
at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. I figured that the minority of people would be using this with an external keyboard, since the butterfly keyboard's issues are the main reason to use it, so I figured that would be the earlier exit. Maybe not though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use MBP with external monitor and keyboard at office but Unshaky is always running. So this is useful option.
@@ -12,7 +12,7 @@ | |||
@implementation ShakyPressPreventer { | |||
NSTimeInterval lastPressedTimestamps[128]; | |||
CGEventType lastPressedEventTypes[128]; | |||
CGEventFlags lastEventFlagsAboutModifierKeys[128]; | |||
//CGEventFlags lastEventFlagsAboutModifierKeys[128]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just delete it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My mistake, forgot to do that before pushing.
int64_t type = CGEventGetIntegerValueField(event, kCGKeyboardEventKeyboardType); | ||
if (type != 58) return event; | ||
} | ||
/** Current version (for fork/pull request): */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we do not need this line either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, just forgot to delete again.
|
||
double stamp = [[NSDate date] timeIntervalSince1970]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you change this variable to currentTimestamp
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, go ahead.
|
||
double stamp = [[NSDate date] timeIntervalSince1970]; | ||
double lastStamp = lastPressedTimestamps[keyCode]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you change this variable to lastTimestamp
, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, go ahead.
interfere in such case. So I add this following checking */ | ||
&& lastEventFlagsAboutModifierKeys[keyCode] == eventFlagsAboutModifierKeys | ||
&& 1000 * ([[NSDate date] timeIntervalSince1970] - lastPressedTimestamps[keyCode]) < keyDelays[keyCode]) { | ||
if (eventType == kCGEventKeyDown && lastPressedEventTypes[keyCode] == kCGEventKeyUp ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a comment about the styling, I found there is an extra space
before the closing )
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool. I remembered to eliminate the first space since you mentioned not liking it earlier, but I missed that one.
|
||
if (lastPressedTimestamps[keyCode] != 0.0) { | ||
if (lastStamp != 0.0) { | ||
if (dismissNextEvent[keyCode]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move the double stamp = [[NSDate date] timeIntervalSince1970];
here? Since this value is not needed until here, and for more key press event, this variable is not required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure about that? Looks to me like it's determined at the last possible place before it's used.
@@ -57,58 +57,73 @@ - (void)loadIgnoreExternalKeyboard { | |||
ignoreExternalKeyboard = [defaults boolForKey:@"ignoreExternalKeyboard"]; // default No | |||
} | |||
|
|||
- (CGEventRef)filterShakyPressEvent:(CGEventRef)event { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I don't see why this line has been changed...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has it even been changed? I don't understand why it's been flagged.
Hi, definitely most thanks are due to you for creating this, so thanks again. I replied to all of your points, but I'm not familiar with the GitHub interface for this, so please feel free to just implement any of those changes as you see fit. Most of them were just copying errors on my part with the exception of the one about performing the timestamp calculation later, which I believe is already done at the latest possible point. |
It just came to my mind that there is another scenario, which I think makes remembering
|
Since you have not yet responded to change requests and I plan to implement an improved version directly. So I am gonna close this PR, thanks! |
More targeted approach for CMD+space issue after more investigation. Wrote up details of findings in comment.