Closed tomblenz closed 7 years ago
CC @marcelofg55 @bruvzg @BastiaanOlij in case one of you has relevant hardware :)
I do not have Magic Mouse, but AFAIK Magic Mouse's tracking surface is considered a trackpad and scroll events should be processed separately to handle kinetic scrolling.
Something like:
@interface GodotContentView : NSView <NSTextInputClient> {
...
NSPoint scrollDelta;
...
@end
@implementation GodotContentView
- (id)init {
...
scrollDelta = NSZeroPoint;
...
}
- (void)scrollWheel:(NSEvent *)event {
double deltaX = 0, deltaY = 0;
NSEventPhase momentumPhase = NSEventPhaseNone;
NSEventPhase phase = NSEventPhaseNone;
bool hasPreciseScrollingDeltas = false;
if ([event respondsToSelector:@selector(momentumPhase)])
momentumPhase = [event momentumPhase];
if ([event respondsToSelector:@selector(phase)])
phase = [event phase];
if ([event respondsToSelector:@selector(hasPreciseScrollingDeltas)])
hasPreciseScrollingDeltas = [event hasPreciseScrollingDeltas];
switch (phase) {
case NSEventPhaseBegan:
scrollDelta = NSZeroPoint;
break;
case NSEventPhaseChanged:
scrollDelta.x += [event scrollingDeltaX] / 100;
scrollDelta.y += [event scrollingDeltaY] / 100;
break;
case NSEventPhaseEnded:
deltaX = scrollDelta.x;
deltaY = scrollDelta.y;
scrollDelta = NSZeroPoint;
break;
case NSEventPhaseNone:
if (momentumPhase == NSEventPhaseNone) {
deltaX = [event scrollingDeltaX];
deltaY = [event scrollingDeltaY];
if (hasPreciseScrollingDeltas) {
deltaX *= 0.03;
deltaY *= 0.03;
}
}
break;
}
switch (momentumPhase) {
case NSEventPhaseBegan:
scrollDelta = NSZeroPoint;
break;
case NSEventPhaseChanged:
scrollDelta.x += [event scrollingDeltaX] / 100;
scrollDelta.y += [event scrollingDeltaY] / 100;
break;
case NSEventPhaseEnded:
deltaX = scrollDelta.x;
deltaY = scrollDelta.y;
scrollDelta = NSZeroPoint;
break;
}
if (fabs(deltaX)) {
sendScrollEvent(0 > deltaX ? BUTTON_WHEEL_RIGHT : BUTTON_WHEEL_LEFT, fabs(deltaX * 0.3), [event modifierFlags]);
}
if (fabs(deltaY)) {
sendScrollEvent(0 < deltaY ? BUTTON_WHEEL_UP : BUTTON_WHEEL_DOWN, fabs(deltaY * 0.3), [event modifierFlags]);
}
}
I'd be happy to ebay a magic mouse and send it somewhere, if you think it will improve adoption of Godot. Is there also a list of other hardware that the project needs?
I'm also happy to shout a core dev a mouse.
So I feel a bit dumb, but I've just picked up 2.1.4 and the three issues above appear to no longer be an issue. But I'm more relieved than embarrassed so there's that.
However, 3D scrolling is still a bit nuts.
Oh noce. I was wondering anyways since i fixed that some time ago ;) I fixed it for trackpad (osx) scrolling but apple would have made a really bad api if magic mpuse wouldnt send the same events. Scrolling got fixed fairly recently on 3.0 current master. I dont know if it is worthh to make the chnage for 2.1.5? I still would be thankful if you could test the magic mouse on 3.0 (there are daily builds)
Sure, I'll give it a hoon when I get home.
Your call on 2.1.5, I'm just happy it's usable under mac now, I was playing with it all night. However I did notice that the lack of a middle mouse button really hurts usability in the 2d/3d views as you can't pan around. I wonder if there's a solution for that, like a modifier key + drag.
@toger5 Everything looks good in the latest 3.0 build. :)
I don't see any way to easily pan around with a magic mouse (no scroll wheel, no Pan Mode hotke, no temporary-hold-down-to-pan-mode option) but that doesn't mean it doesn't exist... and is probably worth its own topic.
You should be able to turn on emulate 3 button mouse and use shift as pan modifier
Oh sweet! This issue is royally shut down then. Thanks for your time.
I know this is a closed issue. However, I have been having an issue with mac trackpad scrolling. only in the script editor in Godot. The v_Scrolling acts like there is a speed threshold on it. You have to scroll fast to get it to scroll up or down. There is an open issue for it. [ Script editor doesn't track scrolling via Touchpad smoothly (or at all when scrolling is slow) #28149 ]. It has been open since 2019.
I have been attempting to find the issue but this is my first time looking through Godot source code. @toger5 would you know where I could focus my look?
This is an issue in the 4.0 alpha build as well as in 3.x
Thanks for any info any of you could share.
Operating system or device, Godot version, GPU Model and driver (if graphics related): macOS Sierra 10.12.5 Godot 2.1.3-stable any magic mouse with a touch surface
Issue description: The apple magic mouse's touch/scroll event handling is poorly handled in the godot editor:
A magic mouse's touch scroll zooms excessively in the visual editor. Any minor scroll gestures cause the editor to zoom by several thousand percent. This makes using the mouse a hinderance on macOS as even accidentally smudging your finger can unexpectedly throw the editor (and you) way off.
The script editor is similarly too sensitive, and scrolls too readily (though it's manageable, possibly as a side effect of 3 below).
Script editor fling gestures behave strangely, with the editor scrolling at a consistent rate before abruptly stopping. I would expect the fling scrolling velocity to start fast and gradually tail off. See scrolling in other macOS apps for example expected behaviour.
Other apps, such as Unity, are able to support the mouse's touch events seamlessly (in fact I'd look to Unity for an example of expected zoom behaviour).
Steps to reproduce: Open godot's 2D editor. Interact with the surface of the mouse. The editor will zoom almost uncontrollably.
Open godot's script editor. Attempt to scroll a line or two at a time. Use a fling gesture to scroll down a large file.
Link to minimal example project: n/a