File: power.py

package info (click to toggle)
pysdl2 0.9.17%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,328 kB
  • sloc: python: 24,685; makefile: 36; sh: 8
file content (37 lines) | stat: -rw-r--r-- 880 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from ctypes import c_int
from ctypes import POINTER as _P
from .dll import _bind, SDLFunc, AttributeDict

__all__ = [
    # Enums
    "SDL_PowerState",
    "SDL_POWERSTATE_UNKNOWN", "SDL_POWERSTATE_ON_BATTERY",
    "SDL_POWERSTATE_NO_BATTERY", "SDL_POWERSTATE_CHARGING",
    "SDL_POWERSTATE_CHARGED",
]


# Constants & enums

SDL_PowerState = c_int
SDL_POWERSTATE_UNKNOWN = 0
SDL_POWERSTATE_ON_BATTERY = 1
SDL_POWERSTATE_NO_BATTERY = 2
SDL_POWERSTATE_CHARGING = 3
SDL_POWERSTATE_CHARGED = 4


# Raw ctypes function definitions

_funcdefs = [
    SDLFunc("SDL_GetPowerInfo", [_P(c_int), _P(c_int)], SDL_PowerState),
]
_ctypes = AttributeDict()
for f in _funcdefs:
    _ctypes[f.name] = _bind(f.name, f.args, f.returns, f.added)
    __all__.append(f.name) # Add all bound functions to module namespace


# Aliases for ctypes bindings

SDL_GetPowerInfo = _ctypes["SDL_GetPowerInfo"]