Comments (11)
After further investigation I think this is unavoidable because I don't think it's possible to distinguish between mouse gesture events and touchbar events without first creating the NSEvent
.
from haptickey.
@chrisballinger Thank you for your investigation, I didn't realize that eventWithCGEvent:
costs that much. Actually, after disassemble NSEvent
implementation, it does more than I expected. Technically, scan all possible event types and create touches synchronously upfront, which is not deferring at all. I think we can use CGEvent
directly with some private values to mitigate this call.
from haptickey.
Created #15 for testing.
The change removes all eventWithCGEvent:
call from non Touch Bar related gesture events.
However, as I tested, probably because of amount of events we anyways need to observe, it still costs some CPU usage.
Wondering if this patch is worth enough or not...
from haptickey.
I made a very similar patch on a branch that I threw away :) The hard part will be figuring out how to filter mouse gestures vs touchpad gestures from some private CGEvent API without first converting to NSEvent, because that would eliminate most of the noise. Even if you still have to eventually convert the touchpad gestures to NSEvent, being able to efficiently ignore the extraneous trackpad input would eliminate the vast majority of CPU usage since most of the time I'm not using the touchbar.
from haptickey.
@chrisballinger Yeah, that part, differentiating events from Touch Bar or normal multi touch device, requires some undocumented API usages. If you can test this branch and see some benefits, I’m going to merge this.
from haptickey.
I found another potential solution; watch IOHID
for Touch Bar events, and only enable CGEventTap
for a brief period after. As long as the CGEventTap
was created before the event, it does seem to catch the keydown event.
Proof of concept: https://gist.github.com/ghazel/e2e0f2644f816cb4167021a2e0566357
from haptickey.
@ghazel Awesome. This is good hack. For sure, using IOKit
would be a possible solution, not only for this but also other issues such as #4. Let me test your proof of concept and see the results!
from haptickey.
Hi! Have you tried the proposed IOKit solution?
from haptickey.
@gch1p Yeah, I tested once and tried to use it, however recently I was a little bit busy and couldn’t have time to work on it. I will give another work soon.
from haptickey.
@niw Just found this app and it's extremely useful! However, I just can't use it while this bug is active, I prefer more battery life than constant loading on CPU. Would it be possible to fix this issue?
from haptickey.
I can second that. If @niw is currently busy, @ghazel would you be up to trying to add this to HapticKey?
from haptickey.
Related Issues (20)
- Why no feedback on volume, brightness up / down HOT 5
- Build issue HOT 8
- No sound when enable sound effect HOT 6
- Any plans to make it a paid app on the app store? HOT 1
- HapticKey blocks Notification Centre Gesture (two fingers) on the Trackpad MB2019 16" HOT 9
- Missing dependencies? HOT 6
- Special configuration for Terminal? HOT 5
- Can it cause damage to Haptic Engine? HOT 2
- 'ESC and F1, F2, etc. Keys' haptic setting doesn't do anything HOT 3
- HapticKey not working on MacBook Pro with M1 Chip HOT 7
- Haptics still not working with M1 MacBook Pro HOT 1
- Haptic Key macOS 11.1 compatibility HOT 3
- Release a new version? HOT 4
- Possible to limit area where haptics activate? HOT 1
- Does this work on a M1 Mac? HOT 4
- Does this work on M1 and Monterey? HOT 4
- Doesn't work with Magic Trackpad 2?
- Not Installing M1 Macbook Pro HOT 3
- Haptics don't work with MacOS Monterey HOT 8
- Please make Weak option truly weak (1 instead of 3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from haptickey.