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

Gestures stop working after reconnecting the magic mouse #40

Closed
katzelad opened this issue Oct 19, 2022 · 13 comments · Fixed by #49
Closed

Gestures stop working after reconnecting the magic mouse #40

katzelad opened this issue Oct 19, 2022 · 13 comments · Fixed by #49
Labels
bug Something isn't working

Comments

@katzelad
Copy link

katzelad commented Oct 19, 2022

After disconnecting and reconnecting the magic mouse its gestures stop working for me, and I have to restart the app to get them to work again.
I use MacOS Monterey on a 2019 16" MBP.
Thanks for maintaining this great app!

@aaronkollasch
Copy link
Collaborator

Related to #28

I will get to this eventually – Jitouch has code to detect newly connected devices already so it needs some investigation.
For the moment I use Shortcuts.app to create a "Reload Jitouch" shortcut that just runs killall -HUP Jitouch, which tells Jitouch to reload the device list.

@aaronkollasch
Copy link
Collaborator

aaronkollasch commented Nov 12, 2022

Hey, I've made a pull request that should fix this issue. I don't have a Magic Mouse to test, but it should work for the Magic Mouse as well as the Trackpad. Try out the debug build below and let me know how it goes.

Install-Jitouch.zip (updated 2022-11-13)

@katzelad
Copy link
Author

Works great, thanks!

@katzelad
Copy link
Author

katzelad commented Nov 21, 2022

@aaronkollasch The middle click gesture (with 2 fingers) still doesn't work after reconnection (other gestures work).

@aaronkollasch
Copy link
Collaborator

aaronkollasch commented Nov 21, 2022

Thanks for reporting.

The function turnOffMagicMouse() gets called when the mouse is disconnected, which sets middleClickFlag to 0:
https://github.com/aaronkollasch/jitouch/blob/833c26f72e07141ac8de407dfbd91f096766b2f3/jitouch/Jitouch/Gesture.m#L226-L233

but middleClickFlag should be quickly overwritten the next time the magicMouseCallback is run, by gestureMagicMouseMiddleClick():
https://github.com/aaronkollasch/jitouch/blob/833c26f72e07141ac8de407dfbd91f096766b2f3/jitouch/Jitouch/Gesture.m#L2615-L2619

Since all the other gestures are working, I'm not sure why this one isn't. Can you set the logging mode to debug (in the "About" section of the preferences), try a few different gestures, and check the logs at ~/Library/Logs/com.jitouch.Jitouch.log? Perhaps the middle click gesture is being replaced by another gesture?

Also, if you see messages like Suppressed MouseDown in the debug logs when you try to perform the 2-finger middle-click, that could show that the trackpadCallback is unexpectedly being run for the magic mouse and is suppressing left clicks with two fingers down.

@aaronkollasch aaronkollasch reopened this Nov 21, 2022
@katzelad
Copy link
Author

@aaronkollasch Not really sure this has to do with reconnection.
The problem is with all click gestures (middle click and 3 finger click). Nothing is printed to the log. Other gestures work and are written to the log in DEBUG mode.
I do get the following message on reconnection despite Jitouch being enabled in the accessibility settings:

Received kCGEventTapDisabledByTimeout; attempting to recreate CGEventTap. Allow Jitouch in System Preferences -> Privacy -> Accessibility.

@aaronkollasch
Copy link
Collaborator

Ok, can you try removing Jitouch from the accessibility settings, then run killall Jitouch, then re-add Jitouch when prompted?
The accessibility settings can sometimes show Jitouch as enabled when it really points to a different location, so it's easiest to just remove the permission and re-enable.

Other than that, I'm not sure why Jitouch would receive a kCGEventTapDisabledByTimeout on reconnection. Can you try disabling magic mouse character recognition? Just a thought from looking at the code.

@katzelad
Copy link
Author

Readding Jitouch in the accessibility settings doesn't solve the problem - the click gestures work again but stop working some time after reconnection.
It is definitely because of CGEventTap, I get "Could not create CGEventTap" in the log right before the click gestures stop working. This always happens a few minutes after reconnection (immediately after the gestures still work).
Character recognition is disabled.

@aaronkollasch
Copy link
Collaborator

Which version of Jitouch are you running? Can you send the logs from where you start Jitouch to reconnection to observing the issue?

@katzelad
Copy link
Author

katzelad commented Dec 5, 2022

v2.82.1-beta.1, the problem also affects the trackpad (no clicks-based gestures).
The log from initialization to the problem starting (18:28:40) to the gesture attempt in the end (doesn't show up in the logs).
com.jitouch.Jitouch.log

@aaronkollasch
Copy link
Collaborator

That's strange, I'm not sure why the EventTap is timing out, but Jitouch should be attempting to recreate it.

I wonder if perhaps something in this block is hanging, perhaps a call to mouseRecognizer(): https://github.com/aaronkollasch/jitouch/blob/299af2b382e103ba3abd673883ffe6c056cf55b8/jitouch/Jitouch/Gesture.m#L3074-L3141

@katzelad
Copy link
Author

@aaronkollasch It looks like 2.82.1 fixed it, thanks!
Another small problem I encounter occasionally - sometimes the magic mouse left click stops working until I perform a left click on the trackpad.

2023-01-11 10:59:42.853 Jitouch[13225:4794400] Suppressed MouseDown with 2 fingers d=0.285989 t=0.020944

After clicking the trackpad, MouseDown is no longer suppressed.

@aaronkollasch
Copy link
Collaborator

Great, I'm glad to hear it! That means the fix was probably this commit: d571556

Could you open a separate issue for that problem, and I'll close this issue. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants