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

Single-modifier only activation not working in MacOS Big Sur #2533

Closed
jonathanalevi opened this issue Oct 2, 2020 · 14 comments · Fixed by #2706
Closed

Single-modifier only activation not working in MacOS Big Sur #2533

jonathanalevi opened this issue Oct 2, 2020 · 14 comments · Fixed by #2706

Comments

@jonathanalevi
Copy link

jonathanalevi commented Oct 2, 2020

Greetings
Since updating to the Big Sur beta, my "Single Fn" modifier doesn't work consistently.
It was not working at all... Disabling and re-enabling seems to have improved it significantly. However, invoking it the first time is still spotty and requires multiple presses. Getting it to "go away" is also still spotty.

QS 1.6.0 (4025)
OS X 11.0 Beta (20A5364e)

Updating:
Issue is still present in QS 1.6.1 (4026) / OS X 11.0 Beta (20A5395g)

@jonathanalevi
Copy link
Author

Updating that this issue remains and has now morphed into single-modifier activation not working at all anymore.

@jonathanalevi jonathanalevi changed the title Single-modifier only activation spotty in MacOS Big Sur Single-modifier only activation not working in MacOS Big Sur Oct 23, 2020
@dhoepfl
Copy link
Contributor

dhoepfl commented Nov 14, 2020

Seeing this here, too.
Both modifier-only activation (single and double) do not work for Fn.
The other modifiers do work for me. But Caps Lock is disabled.

@dhoepfl
Copy link
Contributor

dhoepfl commented Nov 16, 2020

I traced the issue (setting the SDK to macosx instead of macos10.13) down to QSModifierKeyEvents:166:

fabs(timeDiff - keyPressDif) is bigger than the 0.001s barrier.

@arvidtp
Copy link

arvidtp commented Dec 1, 2021

Just chiming in that I've been having this problem too. Fix would be awesome. I've tried other triggers, but single Fn just works so well and feels so natural on macbook pro keyboards.

For now, if any of you also use BetterTouchTool, here's a workaround that allows me to use single Fn trigger again on macOS 11 Big Sur. Seems to be reliable so far:

  • in BetterTouchTool, Go to configure > keyboard shortcuts
  • Make a new shortcut triggered by the Fn key (triggered on key down)
  • Add a :"send keyboard shortcut" action to this item and set it to your standard QS shortcut (eg for me, Opt-Esc).
  • Configure that action to send the Key Up only.

This method is better than just triggering the QS app, because then if you cancel or don't launch another app, then your previous app is still in the foreground rather than QS. And it allows you to cancel the QS dialog with the same shortcut (single Fn) as normal rather than re-trigger it.

This approach might work in other keyboard shortcut apps as well if they are configurable enough.

@pjrobertson
Copy link
Member

May be fixed by #2594

Devs on Big Sur and later please also check this out when testing #2594 (@skurfer @n8henrie )

@skurfer
Copy link
Member

skurfer commented Feb 9, 2022

If I change fn to “Do Nothing” in System Prefs, then configure QS to activate using it, I still don’t get anything.

@pjrobertson
Copy link
Member

Does this work with v2.0.1 of Quicksilver @skurfer @jonathanalevi ?

What if you go into System Preferences > Security > Privacy and allow Quicksilver for 'Input Monitoring'?

@dhoepfl
Copy link
Contributor

dhoepfl commented Apr 4, 2022

Does not work for me.

QS: 2.0.1:(HEAD detached at v2.0.1) (4029)
macOS: 12.3.1 (21E258)
MacBook Pro 16" (Intel).

Touch Bar configuration:

• Touch bar shows [App Controls] [X] Show Control Strip
• Press fn key to [Do Nothing]
• Press and hold fn key to [Expand Control Strip]
• [ ] Use F1, F2, etc. …

@dhoepfl
Copy link
Contributor

dhoepfl commented Apr 4, 2022

OK, in Xcode, I see where it bails out:
A breakpoint in QSModifierKeyEvents.m:166 is triggered.

  • timeDiff is -0.13304793834686279
  • timeSinceLastKeyDown is 7.6635877079999997
  • newTimeSinceLastKeyDown is 0.0023386980000000002
    → keyPressDif is 7.6612490099999996
    → timeDiff - keyPressDif is -7.7942969483468624
    → fabs(timeDiff - keyPressDif) is 7.7942969483468624
    → > 0.001 → sendAction is not called.

Why is this time test necessary? There is already a timed reset window in lines 175/177.

@pjrobertson
Copy link
Member

I think that was answered by Rob here: #2538 (comment)

If you remove it, does it still work if you say set the activation to 'shift' but then press 'shift-p' for a capital "P"?

@dhoepfl
Copy link
Contributor

dhoepfl commented Apr 4, 2022

I see. (Been there ... a while ago)

It seems like releasing Fn is considered as key down event in BigSur (for CGEventSourceSecondsSinceLastEventType but not for CGEventSourceCounterForEventType!).

That matches what I saw this morning: timeSinceLastKeyDown was about 8s when I pressed Fn (Cmd-R, wait for start, press Fn → ~8s) but newTimeSinceLastKeyDown was close to 0 when I released Fn.

Storing the return value of CGEventSourceCounterForEventType and triggering the action if it is the same when releasing the modifier works for me in a quick test (for both Fn and Shift, but blocks Shift-P):

    if (!modsAdded || (self.modifierActivationMask == NSAlphaShiftKeyMask && self.timesKeysPressed == 1)) {
        if (self.modifierActivationMask == NSAlphaShiftKeyMask) {
            // keyUp events aren't sent for the caps lock key, so we have to check it here and manually increase the key pressed count
            self.timesKeysPressed += 1;
        }
        uint32_t newPressedKeyDownCount = CGEventSourceCounterForEventType (
                                                                 kCGEventSourceStateHIDSystemState,
                                                                 kCGEventKeyDown
                                                                 );
        if (newPressedKeyDownCount == pressedKeyDownCount && self.timesKeysPressed == self.modifierActivationCount) {
            [self sendAction];
        }
    } else {
        pressedKeyDownCount = CGEventSourceCounterForEventType(
                                                               kCGEventSourceStateHIDSystemState,
                                                               kCGEventKeyDown
                                                               );
        double window = 0.3;
        self.timesKeysPressed += 1;
        [self performSelector:@selector(resetTimesKeysPressed:) withObject:nil afterDelay:window extend:YES];
        
    }

@pjrobertson
Copy link
Member

Nice! Can you issue a PR and then I can test locally on my 10.14 machine.

And I guess your other PR can be closed?

Thanks

dhoepfl added a commit to dhoepfl/Quicksilver that referenced this issue Apr 4, 2022
…erForEventType since

the first seems to consider Fn up shortly after Fn down as key down event on BigSur.

Fixes quicksilver#2533.
@dhoepfl dhoepfl mentioned this issue Apr 4, 2022
@dhoepfl
Copy link
Contributor

dhoepfl commented Apr 4, 2022

Here’s the pull request, closed the other one.

@dhoepfl
Copy link
Contributor

dhoepfl commented Apr 5, 2022

I just noticed that I wrote "BigSur" when I actually run "Monterey".

I’m sorry! :-(

I lost track when they stopped using cat’s names.

skurfer pushed a commit that referenced this issue Apr 7, 2022
…erForEventType since (#2706)

the first seems to consider Fn up shortly after Fn down as key down event on BigSur.

Fixes #2533.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants