Comments (6)
I do not have a Windows machine with a trackpad I am going to be able to test this on, but I suspect there is a different way of getting trackpad info. I suspect this sort of thing is also a problem on OS X.
from libuiohook.
I've decided to look more closely into this issue, and the problem is that the rotation value is divided by 120. A mouse generates rotation values which are multiples of 120, but a trackpad generates other values which are usually much smaller, and when these values are divided by 120, we get 0. I've replaced this: (int16_t) HIWORD(mshook->mouseData) / WHEEL_DELTA
with this: (int16_t) HIWORD(mshook->mouseData)
and now here's what I'm getting:
id=11,when=1659258447626,mask=0x0,type=1,amount=5,rotation=120
id=11,when=1659258450538,mask=0x0,type=1,amount=5,rotation=1
The first event was generated by a mouse, and the second one - by a trackpad. Problem is, a trackpad can generate much higher values if I scroll with it more intensely (I was able to generate values between 1 and 134), and as far as I understand, we can't determine whether it was a mouse scroll, or a trackpad scroll in the hook callback.
The question is, what should we do about it? Do we really need to divide the scroll rotation by 120?
from libuiohook.
https://github.com/kwhat/libuiohook/pull/160/files Solves half the problem here by carrying over WHEEL_DELTA but this should probably change after I figure out what is going on with other platforms like OSX. I will probably end up back porting this fix back to 1.2 for windows.
from libuiohook.
#160 solves this issue in a more intuitive way. I've redone how wheel events work on all platforms which should be more accurate and consistent across platforms.
from libuiohook.
So, on Windows when a mouse wheel event is generated by, well, a mouse wheel, then the rotation value helps distinguish the direction of the scroll. But on a trackpad rotation is always 0 so the direction is not known.
Use uiohook_event.data.wheel.direction value on the struct should be used to detect which direction the wheel is moving in.
Problem is, a trackpad can generate much higher values if I scroll with it more intensely ... we can't determine whether it was a mouse scroll, or a trackpad scroll in the hook callback.
This is the more interesting problem. You are correct, Windows does not provide a distinction between mouse and touchpad "wheel" events.
I was able to generate values between 1 and 134
You may have stumbled on the answer here without realizing it.
I think what maybe happening here is that the wheel is in WHEEL_BLOCK_SCROLL
and the touchpad is in WHEEL_UNIT_SCROLL
where only one of these type's should be divided by WHEEL_DELTA
.
from libuiohook.
I've just run a sample app and tried scrolling with a mouse and a touchpad - both of them emit WHEEL_UNIT_SCROLL
, so I don't think that's the case.
from libuiohook.
Related Issues (20)
- Can't type special characters with right alt HOT 3
- replace key ouput with other value HOT 11
- Caps lock can't be suppressed on Mac OS Monterey HOT 1
- Posting Keys Does Not Work in Games on Windows
- KeyTyped event wasn't emitted for @ on German keyboard layout HOT 10
- hook_create_screen_info doesn't work correctly on Windows when there are multiple screens HOT 1
- Darwin Segfualt on CGEventTapCreate failure
- [Feature Request] Add support for Mac Catalyst HOT 8
- Address issues with Windows hook restarts HOT 2
- coordinates multiplied by two for the mouse on windows HOT 9
- error in the readme HOT 1
- Add keychar support to press and release HOT 2
- Remap a keyboard key as a left mouse button unable to register a double click HOT 1
- Getting mouse position without listening to an event. HOT 4
- add libuiohook as a package on xmake-repo HOT 2
- `keycode` does not match (all?) definitions from `uiohook.h` on Windows HOT 7
- Help for Compiling on Windows HOT 3
- The KEYEVENTF_EXTENDEDKEY flag is not added to every key that needs it when simulating keyboard events on Windows HOT 4
- Deadlock when used with NodeJS NAPI module HOT 2
- Remove USE_XRECORD_ASYNC build flag.
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 libuiohook.