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 of SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN, SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION, or SDL_EVENT_GAMEPAD_TOUCHPAD_UP. finger down, finger sliding, finger gone. the whole arc. 😭
  • reserved β€” it's a Uint32 and it's just... there. sitting pretty. don't touch it, bestie, it's not for us. πŸ™ˆ
  • timestamp β€” a Uint64 measured in nanoseconds, populated using SDL_GetTicksNS(). so when you need to know when the touchpad moment happened, this is your girl. ⭐
  • which β€” the joystick instance id, typed as SDL_JoystickID. it's how you know which controller is out here catching feelings (and fingers). πŸ”₯
  • touchpad β€” a Sint32: the index of the touchpad. yes, there can be more than one. multitasking icon behaviour. πŸ’…
  • finger β€” a Sint32: the index of the finger on the touchpad. because apparently one finger wasn't enough drama. 🫢
  • x β€” a float, normalized in the range 0...1, with 0 being on the left. left edge, bestie. that's the origin story. 🌈
  • y β€” a float, normalized in the range 0...1, with 0 being at the top. so up is 0, and it goes down from there. coordinates said "y not". 😌
  • pressure β€” a float, normalized in the range 0...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