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?
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 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 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?
How do I distinguish whether the event -(void)scrollWheel:(NSEvent *)event was triggered by a Magic Mouse or a trackpad?
The reason I'm asking this question is because I want to assign a different action to the scrolling event when a trackpad is used because the user can pinch to zoom on the trackpad. On the magic mouse, however, the user can't pinch easily, so I want to use the scrolling function as a substitute for pinching.
I can distinguish between a normal mouse and a Magic Mouse using this line:
if (([event momentumPhase] != NSEventPhaseNone) || [event phase] != NSEventPhaseNone)
However this test is passed for both, trackpad and Magic Mouse.
I was able to distinguish between a scroll wheel on a mouse (not a Magic Mouse, but I suspect it will still work) and a trackpad using NSEvent's subtype:
enum {
NSMouseEventSubtype = NX_SUBTYPE_DEFAULT,
NSTabletPointEventSubtype = NX_SUBTYPE_TABLET_POINT,
NSTabletProximityEventSubtype = NX_SUBTYPE_TABLET_PROXIMITY
NSTouchEventSubtype = NX_SUBTYPE_MOUSE_TOUCH
};
You should handle scrollWheel for the Magic Mouse and add a NSMagnificationGestureRecognizer for the pinch gesture on the trackpad. The two do not conflict with each-other but the swipe-scroll on the trackpad will trigger scrollWheel.