2011-03-15 04:40:26 +00:00
|
|
|
import ctypes
|
2011-03-27 05:46:06 +00:00
|
|
|
from .internal import _SDL, errcheck, Version
|
2011-03-27 17:30:13 +00:00
|
|
|
from enum import CEnum
|
2011-03-15 04:40:26 +00:00
|
|
|
|
|
|
|
# Constants
|
2011-03-28 02:09:39 +00:00
|
|
|
class InitFlags(CEnum):
|
2011-03-16 18:41:54 +00:00
|
|
|
TIMER = 0x00000001
|
|
|
|
AUDIO = 0x00000010
|
|
|
|
VIDEO = 0x00000020
|
|
|
|
JOYSTICK = 0x00000200
|
|
|
|
HAPTIC = 0x00001000
|
|
|
|
NOPARACHUTE = 0x00100000
|
|
|
|
EVERYTHING = 0x0000FFFF
|
|
|
|
|
2011-03-15 04:40:26 +00:00
|
|
|
##### Error Handling
|
|
|
|
|
|
|
|
_SDL.SDL_GetError.restype = ctypes.c_char_p
|
|
|
|
def get_error():
|
|
|
|
return _SDL.SDL_GetError()
|
|
|
|
|
|
|
|
def set_error(msg):
|
|
|
|
_SDL.SDL_SetError(msg)
|
|
|
|
|
|
|
|
def clear_error():
|
|
|
|
_SDL.SDL_ClearError()
|
|
|
|
|
|
|
|
##### Initialization
|
|
|
|
|
|
|
|
def init(flags):
|
|
|
|
errcheck(_SDL.SDL_Init(flags))
|
|
|
|
|
|
|
|
def init_sub_system(flags):
|
|
|
|
errcheck(_SDL.SDL_InitSubSystem(flags))
|
|
|
|
|
|
|
|
def quit_sub_system(flags):
|
|
|
|
errcheck(_SDL.SDL_QuitSubSystem(flags))
|
|
|
|
|
|
|
|
def was_init(flags=0):
|
|
|
|
errcheck(_SDL.SDL_WasInit(flags))
|
|
|
|
|
|
|
|
def quit():
|
|
|
|
_SDL.SDL_Quit()
|
|
|
|
|
|
|
|
##### Version Info
|
|
|
|
|
|
|
|
|
|
|
|
def get_version():
|
|
|
|
v = Version()
|
|
|
|
_SDL.SDL_GetVersion(ctypes.byref(v))
|
|
|
|
return v
|
|
|
|
|
|
|
|
_SDL.SDL_GetRevision.restype = ctypes.c_char_p
|
|
|
|
def get_revision():
|
|
|
|
return _SDL.SDL_GetRevision()
|
|
|
|
|