I am trying to find CPU idle time using GetLastInputInfo(). This works for all keyboard buttons and mouse/touchpad movement and clicks. While this also detects external mouse's scrolling, it fails to detect two finger scrolling on laptop touchpad!!
Any solutions?
Related
I would like to create an app that intercepts the mouse coordinates and modify them.
I want to build an app that runs in the background and intercepts the mouse movement, filtering it, for all apps running on macOS.
Suppose the mouse is scrolling freely but if the user presses a global shortcut, like CMD ALT X, the vertical scrolling is filtered and just the horizontal scrolling passes to macOS.
First question: what should I use to do that? Just point me in the right direction if the topic is too extensive.
Second question: is that possible to do for a sandbox app?
I am using a macbook, and have noticed that when adding an input to my project's input map to detect the scroll wheel, then calling it with "Input.is_action_just_released(scroll_up)", it works with a regular mouse with a normal scroll wheel, but not with my magic mouse or the trackpad on my mac. The input is set to be for all devices, not just device 0.
What am I doing wrong? I cannot seem to find an answer to this anywhere.
I'm trying to get zooming working so that the normal pan/pinch-zoom touchpad features work as expected, and scrolling a real mouse wheel zooms in/out (without any modifiers held).
Unfortunately it seems like touchpad pan gestures get converted into wheel events (there is Qt::PanGesture but it doesn't seem to be used). Therefore I need some way to distinguish real QWheelEvent events from touchpad ones.
The obvious thing is QWheelEvent::device()->type():
if (event->device()->type() == QInputDevice::DeviceType::Mouse)
// zoom
else
// pan
Unfortunately the QWheelEvents from my actual real physical mouse have a device()->type() of DeviceType::TouchPad.
I also tried
event->source() != Qt::MouseEventNotSynthesized
But again both real and touchpad events have that set to Qt::MouseEventSynthesizedBySystem.
Is there any way to do this?
I see that the SingleChildScrollView allows scrolling via the MacBook trackpad with two-finger-panning.
However, I cannot find any gesture recogniser that is triggered by two-finger-panning.
How is two-finger-panning implemented for SingleChildScrollView?
I found the answer. Scrollable listens to PointerScrollEvent.
https://github.com/flutter/flutter/blob/b007a81ad498eb9b7cd687fda0aa9d8d2bb77dc3/packages/flutter/lib/src/widgets/scrollable.dart#L642
However, there is no reliable way to detect when scrolling actually ended and is not just idle (the user lifted the fingers).
I'm trying to implement system-wide drag operation with middle mouse button. It should override middle mouse drag behavior in other programs. Currently, I am handling global mouse events with system-wide hooks.
Problem is - many programs still receive and handle same events like I did not intercept them.
Here's what I tried:
not call the next hook for mouse down event: I never receive mouse up, so I don't know where and when to stop dragging
not call the next hook for mouse move: cursor slows down tremendously
not call the next hook for mouse up: most windows in the system stop reacting to mouse events completely after my drag is finished
always call the next hook in the chain: if the control under mouse has scroll in it, most of the time it will be scrolling while my drag is in progress. Also UWP apps continue receiving mouse events during my drag, so if a link in MS Edge happens to be under cursor when it started, and mouse does not leave Edge boundary, Edge receives click event, and new tab is opened
What I need is: when user holds middle mouse and starts dragging, my drag handler should be called, and no other handlers, like file drag, scroll, etc should happen.
I ended up with somewhat hacky solution:
do not call the next hook for mouse down for middle button
record where it was pressed
when handling mouse up, if user did not drag - replay the whole mouse up + mouse down using SendInput from a separate thread (to avoid deadlock due to reentrancy)