We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3344 - OS X Scroll Momentum
Summary: OS X Scroll Momentum
Status: RESOLVED WONTFIX
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: 2.0.4
Hardware: All Mac OS X 10.11
: P2 minor
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-26 10:33 UTC by Martijn Courteaux
Modified: 2019-08-23 13:24 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martijn Courteaux 2016-05-26 10:33:00 UTC
It turns out I don't receive the usual inertia scroll events in OS X. I get regular scroll events, but not the ones caused by momentum, which should be managed by the OS, I believe.

I'm not 100% sure, but I think this is an OS X feature, and not really a feature of a GUI library of Apple. So I suspect that SDL is retrieving these scroll events in a special alternative way?

If someone fixes this (maybe me within a couple of months), is it a good idea to add flag that indicates that these events are caused by momentum? Something like:

    int SDL_Event.wheel.momentum
Comment 1 Alex Szpakowski 2016-05-27 17:04:29 UTC
it's explicitly disabled in SDL's code ( https://hg.libsdl.org/SDL/file/7cbfd97f1430/src/video/cocoa/SDL_cocoaevents.m#l327 ).

I'm not positive about the reason why, but I suspect it's because scroll momentum is unwanted in a lot of games.
Comment 2 Martijn Courteaux 2016-05-27 18:00:32 UTC
Aha, nice. I am most likely about to change this for my application. (I'm building an application, with a GUI where scrolling through lists etc feels more natural with momentum, using SDL instead of a game.) So, do you want me to contribute these changes to the SDL repository?

If so, how would you prefer seeing this implemented? I see three options:

 - Enable it by default, and indicate wether scroll events are caused by momentum or are regular scroll events. (This breaks compatibility with existing games, because these games will all start receiving unwanted scroll momentum events as regular SDL_MOUSEWHEELEVENTS.)

 - Second option is to make this some sort of configuration option when initialising SDL. I'm not sure wether OS X allows to change this settings more than once, but if that is possible, it would also be possible to provide a function to change behaviour. Something like: SDL_AllowScrollMomentumEvents(SDL_Bool); Of course, this in combination with the flag that a scroll event is caused by momentum or not. This is also backwards compatible.

 - Third option: create a new type of SDL_Event that will represent scroll momentum events. I don't like this approach, but is backwards compatible.

Personally, I like the second option the most. But if this won't be contributed to the SDL repository, I can go with the first option, since I want momentum events, whatsoever.

Thanks!
Comment 3 Martijn Courteaux 2016-05-31 21:17:56 UTC
I fixed it using another way. Super easy hack: create a OS X specific file ending in the .mm extension and make a function in it like this:

void OSX_HACK_enable_scroll_momentum()
{
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSDictionary *appDefaults = [NSDictionary dictionaryWithObject:@"YES" forKey:@"AppleMomentumScrollSupported"];
    [defaults registerDefaults:appDefaults];
}

And of course call it.
Comment 4 Sam Lantinga 2017-08-12 02:20:36 UTC
Great hack!

I'm closing the bug since in general game developers don't want this for game control.
Comment 5 Martijn Courteaux 2019-08-23 13:24:20 UTC
The new hack is:

[[NSUserDefaults standardUserDefaults]
    setBool: YES forKey: @"AppleMomentumScrollSupported"];