🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
3.1 KiB

  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. #ifndef SDL_power_h_
  19. #define SDL_power_h_
  20. /**
  21. * \file SDL_power.h
  22. *
  23. * Header for the SDL power management routines.
  24. */
  25. #include "SDL_stdinc.h"
  26. #include "begin_code.h"
  27. /* Set up for C function definitions, even when using C++ */
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. /**
  32. * The basic state for the system's power supply.
  33. */
  34. typedef enum
  35. {
  36. SDL_POWERSTATE_UNKNOWN, /**< cannot determine power status */
  37. SDL_POWERSTATE_ON_BATTERY, /**< Not plugged in, running on the battery */
  38. SDL_POWERSTATE_NO_BATTERY, /**< Plugged in, no battery available */
  39. SDL_POWERSTATE_CHARGING, /**< Plugged in, charging battery */
  40. SDL_POWERSTATE_CHARGED /**< Plugged in, battery charged */
  41. } SDL_PowerState;
  42. /**
  43. * Get the current power supply details.
  44. *
  45. * You should never take a battery status as absolute truth. Batteries
  46. * (especially failing batteries) are delicate hardware, and the values
  47. * reported here are best estimates based on what that hardware reports. It's
  48. * not uncommon for older batteries to lose stored power much faster than it
  49. * reports, or completely drain when reporting it has 20 percent left, etc.
  50. *
  51. * Battery status can change at any time; if you are concerned with power
  52. * state, you should call this function frequently, and perhaps ignore changes
  53. * until they seem to be stable for a few seconds.
  54. *
  55. * It's possible a platform can only report battery percentage or time left
  56. * but not both.
  57. *
  58. * \param secs seconds of battery life left, you can pass a NULL here if you
  59. * don't care, will return -1 if we can't determine a value, or
  60. * we're not running on a battery
  61. * \param pct percentage of battery life left, between 0 and 100, you can pass
  62. * a NULL here if you don't care, will return -1 if we can't
  63. * determine a value, or we're not running on a battery
  64. * \returns an SDL_PowerState enum representing the current battery state.
  65. *
  66. * \since This function is available since SDL 2.0.0.
  67. */
  68. extern DECLSPEC SDL_PowerState SDLCALL SDL_GetPowerInfo(int *secs, int *pct);
  69. /* Ends C function definitions when using C++ */
  70. #ifdef __cplusplus
  71. }
  72. #endif
  73. #include "close_code.h"
  74. #endif /* SDL_power_h_ */
  75. /* vi: set ts=4 sw=4 expandtab: */