SDL_PowerState(3type)

πŸ’– SDL_PowerState πŸ’–

ok so bestie, welcome to SDL_PowerState β€” she's a lil enum from the SDL3 datatypes crew and she's literally the whole vibe check on your system's power supply. πŸ”‹βœ¨


✨ NAME ✨

SDL_PowerState β€” the basic state for the system's power supply. that's it, that's the girl. πŸ‘‘


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_power.h>

typedef enum SDL_PowerState
{
    SDL_POWERSTATE_ERROR = -1,   /**< error determining power status */
    SDL_POWERSTATE_UNKNOWN,      /**< cannot determine power status */
    SDL_POWERSTATE_ON_BATTERY,   /**< Not plugged in, running on the battery */
    SDL_POWERSTATE_NO_BATTERY,   /**< Plugged in, no battery available */
    SDL_POWERSTATE_CHARGING,     /**< Plugged in, charging battery */
    SDL_POWERSTATE_CHARGED       /**< Plugged in, battery charged */
} SDL_PowerState;

no cap, that's the whole thing. six little states, one very important enum. 🫢


πŸ’… DESCRIPTION πŸ’…

okay so listen β€” these are the results that get handed back to you by SDL_GetPowerInfo(). that's the function that does the actual snooping on your power supply, and this enum is how it tells you what it found. it's giving "messenger, not the message." πŸ“¬

let's meet the girls one by one, fr fr:

  • SDL_POWERSTATE_ERROR = -1 β€” something went wrong determining power status. the error one. she's negative (literally, she's -1) and she's not happy about it. 😭
  • SDL_POWERSTATE_UNKNOWN β€” cannot determine power status. like, nobody knows. it's a mystery. the info just isn't giving. πŸ™ˆ
  • SDL_POWERSTATE_ON_BATTERY β€” not plugged in, running on the battery. you are free, you are unplugged, you are living on borrowed electrons. πŸ¦‹
  • SDL_POWERSTATE_NO_BATTERY β€” plugged in, no battery available. she's on the wall and there's no battery in the building. iconic, honestly. πŸ”Œ
  • SDL_POWERSTATE_CHARGING β€” plugged in, charging battery. the glow-up is in progress. give her a minute. ⚑
  • SDL_POWERSTATE_CHARGED β€” plugged in, battery charged. full bars, full main character energy. she ate. πŸ‘‘

πŸŽ€ AVAILABILITY πŸŽ€

this enum is available since SDL 3.2.0. so if you're on anything older, sorry bestie, she doesn't exist yet. πŸ’€


heads up, bestie: SDL_POWERSTATE_ERROR is -1, so don't go treating these like unsigned values unless you wanna have a bad time. πŸ’…

and that's the page!! tysm for reading, go forth and check your power state responsibly. 🌈⭐

mwah πŸ’‹ β€” this one's brought to you by Simple Directmedia Layer, sitting pretty at version SDL 3.4.18, and yes she is still SDL_PowerState(3type). periodt. πŸŽ€βœ¨

πŸ“¦ where this page comes from