SDL_GetGamepadPowerInfo(3)

✨ NAME ✨

SDL_GetGamepadPowerInfo β€” bestie, this is the one that tells you how much juice your gamepad has left πŸ”‹

(it lives in the SDL3 FUNCTIONS manual, iykyk)


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_gamepad.h>

SDL_PowerState SDL_GetGamepadPowerInfo(SDL_Gamepad *gamepad, int *percent);

πŸ’– DESCRIPTION πŸ’–

Okay so real talk, bestie: never treat a battery status like it's the gospel truth. Periodt. Batteries β€” especially dying ones β€” are delicate little hardware divas, and the numbers you get back here are best estimates based on whatever that hardware decides to tell you. πŸ™ˆ

And like, it's genuinely not uncommon for older batteries to lose their stored power way faster than they report, or to just fully drain themselves while still swearing up and down they've got 20 percent left, etc. So take it with a grain of salt, mwah πŸ’…


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • gamepad β€” the gamepad object you wanna query, babe.
  • percent β€” a pointer that gets filled in with the percentage of battery life left, somewhere between 0 and 100. Pass NULL if you literally don't care. Oh and heads up: it gets filled in with -1 when we can't determine a value or there's no battery at all. πŸ’€

πŸ‘‘ RETURN VALUE πŸ‘‘

Returns the current battery state. That's it, that's the tea. ✨


πŸ¦‹ THREAD SAFETY πŸ¦‹

It is safe to call this function from any thread. Go off, queen, call it from wherever 🫢


🌈 AVAILABILITY 🌈

This function is available since SDL 3.2.0. No cap.


and that's the whole page, bestie πŸ’œ stay charged, stay iconic ⭐

signing off β€” brought to you by the Simple Directmedia Layer girlies, version SDL 3.4.18, and yes this page is giving SDL_GetGamepadPowerInfo(3) energy πŸŽ€

πŸ“¦ where this page comes from