fermium/
power.rs

1//! Lets you get power info about the system.
2
3use crate::c_int;
4
5/// The basic state for the system's power supply.
6///
7/// See the `SDL_POWERSTATE_*` constants.
8#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
9#[repr(transparent)]
10pub struct SDL_PowerState(pub u32);
11
12/// Cannot determine power status.
13pub const SDL_POWERSTATE_UNKNOWN: SDL_PowerState = SDL_PowerState(0);
14/// Not plugged in, running on the battery.
15pub const SDL_POWERSTATE_ON_BATTERY: SDL_PowerState = SDL_PowerState(1);
16/// Plugged in, no battery available.
17pub const SDL_POWERSTATE_NO_BATTERY: SDL_PowerState = SDL_PowerState(2);
18/// Plugged in, charging battery.
19pub const SDL_POWERSTATE_CHARGING: SDL_PowerState = SDL_PowerState(3);
20/// Plugged in, battery charged.
21pub const SDL_POWERSTATE_CHARGED: SDL_PowerState = SDL_PowerState(4);
22
23extern "C" {
24  /// Get the current power supply details.
25  ///
26  /// * `secs` Seconds of battery life left. You can pass a NULL here if you
27  ///   don't care. Will return -1 if we can't determine a value, or if we're
28  ///   not running on a battery.
29  ///
30  /// * `pct` Percentage of battery life left, between 0 and 100. You can pass a
31  ///   NULL here if you don't care. Will return -1 if we can't determine a
32  ///   value, or if we're not running on a battery.
33  ///
34  /// **Returns:** The state of the battery (if any).
35  pub fn SDL_GetPowerInfo(secs: *mut c_int, pct: *mut c_int) -> SDL_PowerState;
36}