SDL_JoyBatteryEvent(3type)

๐ŸŒธ SDL_JoyBatteryEvent โ€” from the SDL3 DATATYPES manual, bestie ๐ŸŽ€

okay so quick vibe check: this page is literally all about SDL_JoyBatteryEvent, and the manual name it lives under is SDL3 DATATYPES. iykyk.


โœจ NAME โœจ

SDL_JoyBatteryEvent โ€” the joystick battery level change event structure, aka event.jbattery.* ๐Ÿ’…

it's giving "your controller's battery just changed and SDL wants you to know" energy. ๐Ÿ”‹


๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

#include <SDL3/SDL_events.h>

typedef struct SDL_JoyBatteryEvent
{
    SDL_EventType type; /**< SDL_EVENT_JOYSTICK_BATTERY_UPDATED */
    Uint32 reserved;
    Uint64 timestamp;   /**< In nanoseconds, populated using SDL_GetTicksNS() */
    SDL_JoystickID which; /**< The joystick instance id */
    SDL_PowerState state; /**< The joystick battery state */
    int percent;          /**< The joystick battery percent charge remaining */
} SDL_JoyBatteryEvent;

okay let's break down the members because the way that each one has a job is so iconic ๐Ÿ‘‘

  • type โ€” an SDL_EventType, and for this struct it's SDL_EVENT_JOYSTICK_BATTERY_UPDATED. it's the little label that says "hey bestie, a battery thing happened."
  • reserved โ€” a Uint32. it's just sitting there. do not touch it, fr fr. ๐Ÿ™ˆ
  • timestamp โ€” a Uint64, measured in nanoseconds, populated using SDL_GetTicksNS(). so like, exactly when the battery update happened, to the nanosecond. main character precision. โฑ๏ธ
  • which โ€” an SDL_JoystickID, and it's the joystick instance id. this is how you know which controller is the one having a battery moment. ๐ŸŽฎ
  • state โ€” an SDL_PowerState, the joystick battery state. the vibe of the battery, if you will.
  • percent โ€” an int, the joystick battery percent charge remaining. yes bestie, it's the number you're stressed about. ๐Ÿ”‹

๐Ÿ’œ AVAILABILITY ๐Ÿ’œ

this struct is available since SDL 3.2.0. so if you're on anything older, no battery gossip for you, sorry. ๐Ÿ˜ญ


๐ŸŒŸ lowkey reminder: keep every field spelled exactly like the struct says, because SDL_JoyBatteryEvent does not play about typos. periodt.

that's the whole page, bestie!! you understood it, you ate, no crumbs left. ๐Ÿ“โœจ

made with love by Simple Directmedia Layer, version SDL 3.4.18 โ€” mwah, go forth and check those batteries ๐Ÿซถ๐Ÿ’–

๐Ÿ“ฆ where this page comes from