Trackpad events

In order to implement modern scrolling behavior with a laptop trackpad (i.e., as long as your finger is on the trackpad, the screen only moves when you move your finger; if you move your finger and release the trackpad, the scroll motion has ‘inertia’) I need to know whether or not a finger is currently on the trackpad.

This is ostensibly a use case for SDL_FINGERDOWN and SDL_FINGERUP events, but I haven’t been able to receive those events in my program.

I tried setting both of these hints based on old posts:


I don’t really know if I set the hints successfully because SDL_SetHint returns true even if I pass it garbage. In any case, I’m still not receiving finger events.

[EDIT: SDL_GetHint confirms both hints have value “1” after being set]

I don’t think there’s a good way to implement this with mouse wheel events alone.

I’m on MacOS right now and will test on Ubuntu when I get the chance.

Any help would be much appreciated!

I think the correct way to set those hints are either like this:


or like this:


Ah, you’re right – thanks. The first parameter of SDL_SetHint is a const char* called “name”, even though what you pass to it is not a name and is being mutated by the function… confusing.

SDL_SetHint(SDL_HINT_MOUSE_TOUCH_EVENTS, "1"); unlocks the events I’m looking for.

It’s the name of the hint. The string that you pass is not modified by the function.

You’re right, thanks again. I was misreading the names and didn’t realize that they were distinct from the macro names.