2015-06-21 18:33:46 +03:00
|
|
|
/*
|
|
|
|
Simple DirectMedia Layer
|
2024-01-02 00:15:26 +03:00
|
|
|
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
2015-06-21 18:33:46 +03:00
|
|
|
|
|
|
|
This software is provided 'as-is', without any express or implied
|
|
|
|
warranty. In no event will the authors be held liable for any damages
|
|
|
|
arising from the use of this software.
|
|
|
|
|
|
|
|
Permission is granted to anyone to use this software for any purpose,
|
|
|
|
including commercial applications, and to alter it and redistribute it
|
|
|
|
freely, subject to the following restrictions:
|
|
|
|
|
|
|
|
1. The origin of this software must not be misrepresented; you must not
|
|
|
|
claim that you wrote the original software. If you use this software
|
|
|
|
in a product, an acknowledgment in the product documentation would be
|
|
|
|
appreciated but is not required.
|
|
|
|
2. Altered source versions must be plainly marked as such, and must not be
|
|
|
|
misrepresented as being the original software.
|
|
|
|
3. This notice may not be removed or altered from any source distribution.
|
|
|
|
*/
|
|
|
|
|
2016-11-21 08:34:54 +03:00
|
|
|
#ifndef SDL_power_h_
|
|
|
|
#define SDL_power_h_
|
2015-06-21 18:33:46 +03:00
|
|
|
|
|
|
|
/**
|
2024-05-16 17:44:37 +03:00
|
|
|
* # CategoryPower
|
2015-06-21 18:33:46 +03:00
|
|
|
*
|
2024-05-16 17:44:37 +03:00
|
|
|
* SDL power management routines.
|
2015-06-21 18:33:46 +03:00
|
|
|
*/
|
|
|
|
|
2022-11-27 07:43:38 +03:00
|
|
|
#include <SDL3/SDL_stdinc.h>
|
2024-04-04 19:38:21 +03:00
|
|
|
#include <SDL3/SDL_error.h>
|
2015-06-21 18:33:46 +03:00
|
|
|
|
2022-12-22 19:38:59 +03:00
|
|
|
#include <SDL3/SDL_begin_code.h>
|
2015-06-21 18:33:46 +03:00
|
|
|
/* Set up for C function definitions, even when using C++ */
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
2024-04-09 05:36:57 +03:00
|
|
|
* The basic state for the system's power supply.
|
|
|
|
*
|
|
|
|
* These are results returned by SDL_GetPowerInfo().
|
|
|
|
*
|
2024-10-23 19:19:38 +03:00
|
|
|
* \since This enum is available since SDL 3.1.3
|
2015-06-21 18:33:46 +03:00
|
|
|
*/
|
2024-04-09 05:36:57 +03:00
|
|
|
typedef enum SDL_PowerState
|
2015-06-21 18:33:46 +03:00
|
|
|
{
|
2024-03-30 20:55:13 +03:00
|
|
|
SDL_POWERSTATE_ERROR = -1, /**< error determining power status */
|
2015-06-21 18:33:46 +03:00
|
|
|
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;
|
|
|
|
|
|
|
|
/**
|
2021-03-21 21:18:39 +03:00
|
|
|
* Get the current power supply details.
|
2015-06-21 18:33:46 +03:00
|
|
|
*
|
2021-03-21 21:18:39 +03:00
|
|
|
* You should never take a battery status as absolute truth. Batteries
|
|
|
|
* (especially failing batteries) are delicate hardware, and the values
|
|
|
|
* reported here are best estimates based on what that hardware reports. It's
|
|
|
|
* not uncommon for older batteries to lose stored power much faster than it
|
|
|
|
* reports, or completely drain when reporting it has 20 percent left, etc.
|
2015-06-21 18:33:46 +03:00
|
|
|
*
|
2021-03-21 21:18:39 +03:00
|
|
|
* Battery status can change at any time; if you are concerned with power
|
|
|
|
* state, you should call this function frequently, and perhaps ignore changes
|
|
|
|
* until they seem to be stable for a few seconds.
|
2015-06-21 18:33:46 +03:00
|
|
|
*
|
2021-03-21 21:18:39 +03:00
|
|
|
* It's possible a platform can only report battery percentage or time left
|
|
|
|
* but not both.
|
|
|
|
*
|
2024-04-02 00:00:26 +03:00
|
|
|
* \param seconds a pointer filled in with the seconds of battery life left,
|
|
|
|
* or NULL to ignore. This will be filled in with -1 if we
|
|
|
|
* can't determine a value or there is no battery.
|
|
|
|
* \param percent a pointer filled in with the percentage of battery life
|
|
|
|
* left, between 0 and 100, or NULL to ignore. This will be
|
|
|
|
* filled in with -1 we can't determine a value or there is no
|
|
|
|
* battery.
|
|
|
|
* \returns the current battery state or `SDL_POWERSTATE_ERROR` on failure;
|
|
|
|
* call SDL_GetError() for more information.
|
2021-10-27 04:36:05 +03:00
|
|
|
*
|
2024-10-23 19:19:38 +03:00
|
|
|
* \since This function is available since SDL 3.1.3.
|
2015-06-21 18:33:46 +03:00
|
|
|
*/
|
2024-05-18 02:52:36 +03:00
|
|
|
extern SDL_DECLSPEC SDL_PowerState SDLCALL SDL_GetPowerInfo(int *seconds, int *percent);
|
2015-06-21 18:33:46 +03:00
|
|
|
|
|
|
|
/* Ends C function definitions when using C++ */
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2022-12-22 19:38:59 +03:00
|
|
|
#include <SDL3/SDL_close_code.h>
|
2015-06-21 18:33:46 +03:00
|
|
|
|
2016-11-21 08:34:54 +03:00
|
|
|
#endif /* SDL_power_h_ */
|