SDL_GamepadTouchpadEvent(3type)
π SDL_GamepadTouchpadEvent π
okay bestie, welcome to the SDL3 DATATYPES corner of the manual, and today's main character is SDL_GamepadTouchpadEvent β literally the struct for gamepad touchpad events (you'll see it filed under event.gtouchpad.* in the wild, iykyk). π
β¨ NAME β¨
SDL_GamepadTouchpadEvent β the Gamepad touchpad event structure, aka the event.gtouchpad.* family. it's giving finger-on-glass energy. π
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_events.h>
typedef struct SDL_GamepadTouchpadEvent
{
SDL_EventType type; /**< SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN or SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION or SDL_EVENT_GAMEPAD_TOUCHPAD_UP */
Uint32 reserved;
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
SDL_JoystickID which; /**< The joystick instance id */
Sint32 touchpad; /**< The index of the touchpad */
Sint32 finger; /**< The index of the finger on the touchpad */
float x; /**< Normalized in the range 0...1 with 0 being on the left */
float y; /**< Normalized in the range 0...1 with 0 being at the top */
float pressure; /**< Normalized in the range 0...1 */
} SDL_GamepadTouchpadEvent;
π DESCRIPTION π
so here's the tea, field by field, no skips, no shortcuts, fr fr:
typeβ this one's the vibe check on what actually happened. it holds one ofSDL_EVENT_GAMEPAD_TOUCHPAD_DOWN,SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION, orSDL_EVENT_GAMEPAD_TOUCHPAD_UP. finger down, finger sliding, finger gone. the whole arc. πreservedβ it's aUint32and it's just... there. sitting pretty. don't touch it, bestie, it's not for us. πtimestampβ aUint64measured in nanoseconds, populated usingSDL_GetTicksNS(). so when you need to know when the touchpad moment happened, this is your girl. βwhichβ the joystick instance id, typed asSDL_JoystickID. it's how you know which controller is out here catching feelings (and fingers). π₯touchpadβ aSint32: the index of the touchpad. yes, there can be more than one. multitasking icon behaviour. πfingerβ aSint32: the index of the finger on the touchpad. because apparently one finger wasn't enough drama. π«Άxβ afloat, normalized in the range0...1, with0being on the left. left edge, bestie. that's the origin story. πyβ afloat, normalized in the range0...1, with0being at the top. so up is0, and it goes down from there. coordinates said "y not". πpressureβ afloat, normalized in the range0...1. how hard you're pressing. gentle lil tap or full-on emotional damage, your call. β¨
ngl, everything normalized in 0...1 means you never have to care what the physical touchpad resolution is. iconic of SDL, honestly.
π¦ AVAILABILITY π¦
this struct is available since SDL 3.2.0. she's not an OG, she's a newer addition, and we respect the glow-up. π
and that's the whole page, bestie, you ate it. π
signing off from the Simple Directmedia Layer, running SDL 3.4.18 β stay normalized, stay in the 0...1 range, and go handle those event.gtouchpad.* moments like the main character you are. πβ¨
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms