File: timer.py

package info (click to toggle)
pysdl2 0.9.9%2Bdfsg1-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,276 kB
  • sloc: python: 18,592; makefile: 148; sh: 40
file content (35 lines) | stat: -rw-r--r-- 953 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
from ctypes import CFUNCTYPE, c_void_p, c_int
from .dll import _bind
from .stdinc import Uint32, Uint64, SDL_bool

__all__ = [
    # Defines
    "SDL_TimerID",

    # Macro Functions
    "SDL_TICKS_PASSED",

    # Functions
    "SDL_GetTicks", "SDL_GetPerformanceCounter",
    "SDL_GetPerformanceFrequency", "SDL_Delay",
    "SDL_AddTimer", "SDL_RemoveTimer",

    # Callback Functions
    "SDL_TimerCallback"
]


SDL_GetTicks = _bind("SDL_GetTicks", None, Uint32)
SDL_GetPerformanceCounter = _bind("SDL_GetPerformanceCounter", None, Uint64)
SDL_GetPerformanceFrequency = _bind("SDL_GetPerformanceFrequency", None, Uint64)
SDL_Delay = _bind("SDL_Delay", [Uint32])

SDL_TimerCallback = CFUNCTYPE(Uint32, Uint32, c_void_p)
SDL_TimerID = c_int

SDL_AddTimer = _bind("SDL_AddTimer", [Uint32, SDL_TimerCallback, c_void_p], SDL_TimerID)
SDL_RemoveTimer = _bind("SDL_RemoveTimer", [SDL_TimerID], SDL_bool)

def SDL_TICKS_PASSED(A, B):
    return (B - A) <= 0