Commits

Marcus von Appen committed 778517b

- changed some line endings to be consistent.

Comments (0)

Files changed (27)

-"""SDL2 wrapper package"""
-from .dll import get_dll_file, _bind
-from ctypes import c_int as _cint
-
-
-#__all__ = ["SDL_INIT_TIMER", "SDL_INIT_AUDIO", "SDL_INIT_VIDEO",
-#           "SDL_INIT_JOYSTICK", "SDL_INIT_HAPTIC", "SDL_INIT_GAMECONTROLLER",
-#           "SDL_INIT_NOPARACHUTE", "SDL_INIT_EVERYTHING", "SDL_Init",
-#           "SDL_InitSubSystem", "SDL_QuitSubSystem", "SDL_WasInit", "SDL_Quit",
-#           "version_info"
-#           ]
-
-
-from .audio import *
-from .blendmode import *
-from .clipboard import *
-from .cpuinfo import *
-from .endian import *
-from .error import *
-from .events import *
-from .gamecontroller import *
-from .gesture import *
-from .haptic import *
-from .hints import *
-from .joystick import *
-from .keyboard import *
-from .loadso import *
-from .log import *
-from .messagebox import *
-from .mouse import *
-from .pixels import *
-from .platform import *
-from .power import *
-from .rect import *
-from .render import *
-from .rwops import *
-from .shape import *
-from .stdinc import *
-from .surface import *
-from .syswm import *
-from .timer import *
-from .touch import *
-from .version import *
-from .video import *
-
-from .keycode import *
-from .scancode import *
-
-SDL_INIT_TIMER = 0x00000001
-SDL_INIT_AUDIO = 0x00000010
-SDL_INIT_VIDEO = 0x00000020
-SDL_INIT_JOYSTICK = 0x00000200
-SDL_INIT_HAPTIC = 0x00001000
-SDL_INIT_GAMECONTROLLER = 0x00002000
-SDL_INIT_NOPARACHUTE = 0x00100000
-SDL_INIT_EVERYTHING = 0x0000FFFF
-
-SDL_Init = _bind("SDL_Init", [Uint32], _cint)
-SDL_InitSubSystem = _bind("SDL_InitSubSystem", [Uint32], _cint)
-SDL_QuitSubSystem = _bind("SDL_QuitSubSystem", [Uint32])
-SDL_WasInit = _bind("SDL_WasInit", [Uint32], Uint32)
-SDL_Quit = _bind("SDL_Quit")
-
-__version__ = "0.2.0"
-version_info = (0, 2, 0, "")
+"""SDL2 wrapper package"""
+from .dll import get_dll_file, _bind
+from ctypes import c_int as _cint
+
+
+#__all__ = ["SDL_INIT_TIMER", "SDL_INIT_AUDIO", "SDL_INIT_VIDEO",
+#           "SDL_INIT_JOYSTICK", "SDL_INIT_HAPTIC", "SDL_INIT_GAMECONTROLLER",
+#           "SDL_INIT_NOPARACHUTE", "SDL_INIT_EVERYTHING", "SDL_Init",
+#           "SDL_InitSubSystem", "SDL_QuitSubSystem", "SDL_WasInit", "SDL_Quit",
+#           "version_info"
+#           ]
+
+
+from .audio import *
+from .blendmode import *
+from .clipboard import *
+from .cpuinfo import *
+from .endian import *
+from .error import *
+from .events import *
+from .gamecontroller import *
+from .gesture import *
+from .haptic import *
+from .hints import *
+from .joystick import *
+from .keyboard import *
+from .loadso import *
+from .log import *
+from .messagebox import *
+from .mouse import *
+from .pixels import *
+from .platform import *
+from .power import *
+from .rect import *
+from .render import *
+from .rwops import *
+from .shape import *
+from .stdinc import *
+from .surface import *
+from .syswm import *
+from .timer import *
+from .touch import *
+from .version import *
+from .video import *
+
+from .keycode import *
+from .scancode import *
+
+SDL_INIT_TIMER = 0x00000001
+SDL_INIT_AUDIO = 0x00000010
+SDL_INIT_VIDEO = 0x00000020
+SDL_INIT_JOYSTICK = 0x00000200
+SDL_INIT_HAPTIC = 0x00001000
+SDL_INIT_GAMECONTROLLER = 0x00002000
+SDL_INIT_NOPARACHUTE = 0x00100000
+SDL_INIT_EVERYTHING = 0x0000FFFF
+
+SDL_Init = _bind("SDL_Init", [Uint32], _cint)
+SDL_InitSubSystem = _bind("SDL_InitSubSystem", [Uint32], _cint)
+SDL_QuitSubSystem = _bind("SDL_QuitSubSystem", [Uint32])
+SDL_WasInit = _bind("SDL_WasInit", [Uint32], Uint32)
+SDL_Quit = _bind("SDL_Quit")
+
+__version__ = "0.2.0"
+version_info = (0, 2, 0, "")
-import sys
-from ctypes import Structure, c_int, c_char_p, c_double, c_void_p, CFUNCTYPE, \
-    POINTER
-from .dll import _bind
-from .endian import SDL_BYTEORDER, SDL_LIL_ENDIAN
-from .stdinc import Uint8, Uint16, Uint32
-from .rwops import SDL_RWops, SDL_RWFromFile
-
-__all__ = ["SDL_AudioFormat", "SDL_AUDIO_MASK_BITSIZE",
-           "SDL_AUDIO_MASK_DATATYPE", "SDL_AUDIO_MASK_ENDIAN",
-           "SDL_AUDIO_MASK_SIGNED", "SDL_AUDIO_BITSIZE", "SDL_AUDIO_ISFLOAT",
-           "SDL_AUDIO_ISBIGENDIAN", "SDL_AUDIO_ISSIGNED", "SDL_AUDIO_ISINT",
-           "SDL_AUDIO_ISLITTLEENDIAN", "SDL_AUDIO_ISUNSIGNED", "AUDIO_U8",
-           "AUDIO_S8", "AUDIO_U16LSB", "AUDIO_S16LSB", "AUDIO_U16MSB",
-           "AUDIO_S16MSB", "AUDIO_U16", "AUDIO_S16", "AUDIO_S32LSB",
-           "AUDIO_S32MSB", "AUDIO_S32", "AUDIO_F32LSB", "AUDIO_S32MSB",
-           "AUDIO_F32", "AUDIO_U16SYS", "AUDIO_S16SYS", "AUDIO_S32SYS",
-           "AUDIO_F32SYS", "SDL_AUDIO_ALLOW_FREQUENCY_CHANGE",
-           "SDL_AUDIO_ALLOW_FORMAT_CHANGE", "SDL_AUDIO_ALLOW_CHANNELS_CHANGE",
-           "SDL_AUDIO_ALLOW_ANY_CHANGE", "SDL_AudioCallback", "SDL_AudioSpec",
-           "SDL_AudioCVT", "SDL_AudioFilter", "SDL_GetNumAudioDrivers",
-           "SDL_GetAudioDriver", "SDL_AudioInit", "SDL_AudioQuit",
-           "SDL_GetCurrentAudioDriver", "SDL_OpenAudio", "SDL_AudioDeviceID",
-           "SDL_GetNumAudioDevices", "SDL_GetAudioDeviceName",
-           "SDL_OpenAudioDevice", "SDL_AUDIO_STOPPED", "SDL_AUDIO_PLAYING",
-           "SDL_AUDIO_PAUSED", "SDL_AudioStatus", "SDL_GetAudioStatus",
-           "SDL_GetAudioDeviceStatus", "SDL_PauseAudio", "SDL_PauseAudioDevice",
-           "SDL_LoadWAV_RW", "SDL_LoadWAV", "SDL_FreeWAV", "SDL_BuildAudioCVT",
-           "SDL_ConvertAudio", "SDL_MIX_MAXVOLUME", "SDL_MixAudio",
-           "SDL_MixAudioFormat", "SDL_LockAudio", "SDL_LockAudioDevice",
-           "SDL_UnlockAudio", "SDL_UnlockAudioDevice", "SDL_CloseAudio",
-           "SDL_CloseAudioDevice"
-         ]
-
-SDL_AudioFormat = Uint16
-
-SDL_AUDIO_MASK_BITSIZE = 0xFF
-SDL_AUDIO_MASK_DATATYPE = 1 << 8
-SDL_AUDIO_MASK_ENDIAN = 1 << 12
-SDL_AUDIO_MASK_SIGNED = 1 << 15
-SDL_AUDIO_BITSIZE = lambda x: (x & SDL_AUDIO_MASK_BITSIZE)
-SDL_AUDIO_ISFLOAT = lambda x: (x & SDL_AUDIO_MASK_DATATYPE)
-SDL_AUDIO_ISBIGENDIAN = lambda x: (x & SDL_AUDIO_MASK_ENDIAN)
-SDL_AUDIO_ISSIGNED = lambda x: (x & SDL_AUDIO_MASK_SIGNED)
-SDL_AUDIO_ISINT = lambda x: (not SDL_AUDIO_ISFLOAT(x))
-SDL_AUDIO_ISLITTLEENDIAN = lambda x: (not SDL_AUDIO_ISBIGENDIAN(x))
-SDL_AUDIO_ISUNSIGNED = lambda x: (not SDL_AUDIO_ISSIGNED(x))
-
-AUDIO_U8 = 0x0008
-AUDIO_S8 = 0x8008
-AUDIO_U16LSB = 0x0010
-AUDIO_S16LSB = 0x8010
-AUDIO_U16MSB = 0x1010
-AUDIO_S16MSB = 0x9010
-AUDIO_U16 = AUDIO_U16LSB
-AUDIO_S16 = AUDIO_S16LSB
-AUDIO_S32LSB = 0x8020
-AUDIO_S32MSB = 0x9020
-AUDIO_S32 = AUDIO_S32LSB
-AUDIO_F32LSB = 0x8120
-AUDIO_F32MSB = 0x9120
-AUDIO_F32 = AUDIO_F32LSB
-
-if SDL_BYTEORDER == SDL_LIL_ENDIAN:
-    AUDIO_U16SYS = AUDIO_U16LSB
-    AUDIO_S16SYS = AUDIO_S16LSB
-    AUDIO_S32SYS = AUDIO_S32LSB
-    AUDIO_F32SYS = AUDIO_F32LSB
-else:
-    AUDIO_U16SYS = AUDIO_U16MSB
-    AUDIO_S16SYS = AUDIO_S16MSB
-    AUDIO_S32SYS = AUDIO_S32MSB
-    AUDIO_F32SYS = AUDIO_F32MSB
-
-SDL_AUDIO_ALLOW_FREQUENCY_CHANGE = 0x00000001
-SDL_AUDIO_ALLOW_FORMAT_CHANGE = 0x00000002
-SDL_AUDIO_ALLOW_CHANNELS_CHANGE = 0x00000004
-SDL_AUDIO_ALLOW_ANY_CHANGE = (SDL_AUDIO_ALLOW_FREQUENCY_CHANGE |
-                              SDL_AUDIO_ALLOW_FORMAT_CHANGE |
-                              SDL_AUDIO_ALLOW_CHANNELS_CHANGE)
-
-SDL_AudioCallback = CFUNCTYPE(None, c_void_p, POINTER(Uint8), c_int)
-
-class SDL_AudioSpec(Structure):
-    _fields_ = [("freq", c_int),
-                ("format", SDL_AudioFormat),
-                ("channels", Uint8),
-                ("silence", Uint8),
-                ("samples", Uint16),
-                ("padding", Uint16),
-                ("size", Uint32),
-                ("callback", c_void_p),
-                ("userdata", c_void_p)
-                ]
-    def __init__(self, freq, aformat, channels, samples,
-                 callback=SDL_AudioCallback(), userdata=c_void_p(0)):
-        super(SDL_AudioSpec, self).__init__()
-        self.freq = freq
-        self.format = aformat
-        self.channels = channels
-        self.samples = samples
-        self.callback = callback
-        self.userdata = userdata
-
-class SDL_AudioCVT(Structure):
-    pass
-
-SDL_AudioFilter = CFUNCTYPE(POINTER(SDL_AudioCVT), SDL_AudioFormat)
-# HACK: hack for an IronPython 2.7.2.1+ issue:
-#    ptrarray = (CFUNCTYPE() * int)
-# is not supported properly
-if sys.platform == "cli":
-    _X_SDL_AudioFilter = POINTER(SDL_AudioFilter)
-else:
-    _X_SDL_AudioFilter = SDL_AudioFilter
-
-SDL_AudioCVT._fields_ = [("needed", c_int),
-                         ("src_format", SDL_AudioFormat),
-                         ("dst_format", SDL_AudioFormat),
-                         ("rate_incr", c_double),
-                         ("buf", POINTER(Uint8)),
-                         ("len", c_int),
-                         ("len_cvt", c_int),
-                         ("len_mult", c_int),
-                         ("len_ratio", c_double),
-                         ("filters", (_X_SDL_AudioFilter * 10)),
-                         ("filter_index", c_int)
-                         ]
-
-SDL_GetNumAudioDrivers = _bind("SDL_GetNumAudioDrivers", None, c_int)
-SDL_GetAudioDriver = _bind("SDL_GetAudioDriver", [c_int], c_char_p)
-SDL_AudioInit = _bind("SDL_AudioInit", [c_char_p], c_int)
-SDL_AudioQuit = _bind("SDL_AudioQuit")
-SDL_GetCurrentAudioDriver = _bind("SDL_GetCurrentAudioDriver", None, c_char_p)
-SDL_OpenAudio = _bind("SDL_OpenAudio", [POINTER(SDL_AudioSpec), POINTER(SDL_AudioSpec)], c_int)
-SDL_AudioDeviceID = Uint32
-SDL_GetNumAudioDevices = _bind("SDL_GetNumAudioDevices", [c_int], c_int)
-SDL_GetAudioDeviceName = _bind("SDL_GetAudioDeviceName", [c_int, c_int], c_char_p)
-SDL_OpenAudioDevice = _bind("SDL_OpenAudioDevice", [c_char_p, c_int, POINTER(SDL_AudioSpec), POINTER(SDL_AudioSpec), c_int], SDL_AudioDeviceID)
-SDL_AUDIO_STOPPED = 0
-SDL_AUDIO_PLAYING = 1
-SDL_AUDIO_PAUSED = 2
-SDL_AudioStatus = c_int
-SDL_GetAudioStatus = _bind("SDL_GetAudioStatus", None, SDL_AudioStatus)
-SDL_GetAudioDeviceStatus = _bind("SDL_GetAudioDeviceStatus", [SDL_AudioDeviceID], SDL_AudioStatus)
-SDL_PauseAudio = _bind("SDL_PauseAudio", [c_int])
-SDL_PauseAudioDevice = _bind("SDL_PauseAudioDevice", [SDL_AudioDeviceID, c_int])
-SDL_LoadWAV_RW = _bind("SDL_LoadWAV_RW", [POINTER(SDL_RWops), c_int, POINTER(SDL_AudioSpec), POINTER(POINTER(Uint8)), POINTER(Uint32)], POINTER(SDL_AudioSpec))
-SDL_LoadWAV = lambda f, s, ab, al: SDL_LoadWAV_RW(SDL_RWFromFile(f, "rb"), 1, s, ab , al)
-SDL_FreeWAV = _bind("SDL_FreeWAV", [POINTER(Uint8)])
-SDL_BuildAudioCVT = _bind("SDL_BuildAudioCVT", [POINTER(SDL_AudioCVT), SDL_AudioFormat, Uint8, c_int, SDL_AudioFormat, Uint8, c_int], c_int)
-SDL_ConvertAudio = _bind("SDL_ConvertAudio", [POINTER(SDL_AudioCVT)], c_int)
-SDL_MIX_MAXVOLUME = 128
-SDL_MixAudio = _bind("SDL_MixAudio", [POINTER(Uint8), POINTER(Uint8), Uint32, c_int])
-SDL_MixAudioFormat = _bind("SDL_MixAudioFormat", [POINTER(Uint8), POINTER(Uint8), SDL_AudioFormat, Uint32, c_int])
-SDL_LockAudio = _bind("SDL_LockAudio")
-SDL_LockAudioDevice = _bind("SDL_LockAudioDevice", [SDL_AudioDeviceID])
-SDL_UnlockAudio = _bind("SDL_UnlockAudio")
-SDL_UnlockAudioDevice = _bind("SDL_UnlockAudioDevice", [SDL_AudioDeviceID])
-SDL_CloseAudio = _bind("SDL_CloseAudio")
-SDL_CloseAudioDevice = _bind("SDL_CloseAudioDevice", [SDL_AudioDeviceID])
-# SDL_AudioDeviceConnected = _bind("SDL_AudioDeviceConnected", [SDL_AudioDeviceID])
+import sys
+from ctypes import Structure, c_int, c_char_p, c_double, c_void_p, CFUNCTYPE, \
+    POINTER
+from .dll import _bind
+from .endian import SDL_BYTEORDER, SDL_LIL_ENDIAN
+from .stdinc import Uint8, Uint16, Uint32
+from .rwops import SDL_RWops, SDL_RWFromFile
+
+__all__ = ["SDL_AudioFormat", "SDL_AUDIO_MASK_BITSIZE",
+           "SDL_AUDIO_MASK_DATATYPE", "SDL_AUDIO_MASK_ENDIAN",
+           "SDL_AUDIO_MASK_SIGNED", "SDL_AUDIO_BITSIZE", "SDL_AUDIO_ISFLOAT",
+           "SDL_AUDIO_ISBIGENDIAN", "SDL_AUDIO_ISSIGNED", "SDL_AUDIO_ISINT",
+           "SDL_AUDIO_ISLITTLEENDIAN", "SDL_AUDIO_ISUNSIGNED", "AUDIO_U8",
+           "AUDIO_S8", "AUDIO_U16LSB", "AUDIO_S16LSB", "AUDIO_U16MSB",
+           "AUDIO_S16MSB", "AUDIO_U16", "AUDIO_S16", "AUDIO_S32LSB",
+           "AUDIO_S32MSB", "AUDIO_S32", "AUDIO_F32LSB", "AUDIO_S32MSB",
+           "AUDIO_F32", "AUDIO_U16SYS", "AUDIO_S16SYS", "AUDIO_S32SYS",
+           "AUDIO_F32SYS", "SDL_AUDIO_ALLOW_FREQUENCY_CHANGE",
+           "SDL_AUDIO_ALLOW_FORMAT_CHANGE", "SDL_AUDIO_ALLOW_CHANNELS_CHANGE",
+           "SDL_AUDIO_ALLOW_ANY_CHANGE", "SDL_AudioCallback", "SDL_AudioSpec",
+           "SDL_AudioCVT", "SDL_AudioFilter", "SDL_GetNumAudioDrivers",
+           "SDL_GetAudioDriver", "SDL_AudioInit", "SDL_AudioQuit",
+           "SDL_GetCurrentAudioDriver", "SDL_OpenAudio", "SDL_AudioDeviceID",
+           "SDL_GetNumAudioDevices", "SDL_GetAudioDeviceName",
+           "SDL_OpenAudioDevice", "SDL_AUDIO_STOPPED", "SDL_AUDIO_PLAYING",
+           "SDL_AUDIO_PAUSED", "SDL_AudioStatus", "SDL_GetAudioStatus",
+           "SDL_GetAudioDeviceStatus", "SDL_PauseAudio", "SDL_PauseAudioDevice",
+           "SDL_LoadWAV_RW", "SDL_LoadWAV", "SDL_FreeWAV", "SDL_BuildAudioCVT",
+           "SDL_ConvertAudio", "SDL_MIX_MAXVOLUME", "SDL_MixAudio",
+           "SDL_MixAudioFormat", "SDL_LockAudio", "SDL_LockAudioDevice",
+           "SDL_UnlockAudio", "SDL_UnlockAudioDevice", "SDL_CloseAudio",
+           "SDL_CloseAudioDevice"
+         ]
+
+SDL_AudioFormat = Uint16
+
+SDL_AUDIO_MASK_BITSIZE = 0xFF
+SDL_AUDIO_MASK_DATATYPE = 1 << 8
+SDL_AUDIO_MASK_ENDIAN = 1 << 12
+SDL_AUDIO_MASK_SIGNED = 1 << 15
+SDL_AUDIO_BITSIZE = lambda x: (x & SDL_AUDIO_MASK_BITSIZE)
+SDL_AUDIO_ISFLOAT = lambda x: (x & SDL_AUDIO_MASK_DATATYPE)
+SDL_AUDIO_ISBIGENDIAN = lambda x: (x & SDL_AUDIO_MASK_ENDIAN)
+SDL_AUDIO_ISSIGNED = lambda x: (x & SDL_AUDIO_MASK_SIGNED)
+SDL_AUDIO_ISINT = lambda x: (not SDL_AUDIO_ISFLOAT(x))
+SDL_AUDIO_ISLITTLEENDIAN = lambda x: (not SDL_AUDIO_ISBIGENDIAN(x))
+SDL_AUDIO_ISUNSIGNED = lambda x: (not SDL_AUDIO_ISSIGNED(x))
+
+AUDIO_U8 = 0x0008
+AUDIO_S8 = 0x8008
+AUDIO_U16LSB = 0x0010
+AUDIO_S16LSB = 0x8010
+AUDIO_U16MSB = 0x1010
+AUDIO_S16MSB = 0x9010
+AUDIO_U16 = AUDIO_U16LSB
+AUDIO_S16 = AUDIO_S16LSB
+AUDIO_S32LSB = 0x8020
+AUDIO_S32MSB = 0x9020
+AUDIO_S32 = AUDIO_S32LSB
+AUDIO_F32LSB = 0x8120
+AUDIO_F32MSB = 0x9120
+AUDIO_F32 = AUDIO_F32LSB
+
+if SDL_BYTEORDER == SDL_LIL_ENDIAN:
+    AUDIO_U16SYS = AUDIO_U16LSB
+    AUDIO_S16SYS = AUDIO_S16LSB
+    AUDIO_S32SYS = AUDIO_S32LSB
+    AUDIO_F32SYS = AUDIO_F32LSB
+else:
+    AUDIO_U16SYS = AUDIO_U16MSB
+    AUDIO_S16SYS = AUDIO_S16MSB
+    AUDIO_S32SYS = AUDIO_S32MSB
+    AUDIO_F32SYS = AUDIO_F32MSB
+
+SDL_AUDIO_ALLOW_FREQUENCY_CHANGE = 0x00000001
+SDL_AUDIO_ALLOW_FORMAT_CHANGE = 0x00000002
+SDL_AUDIO_ALLOW_CHANNELS_CHANGE = 0x00000004
+SDL_AUDIO_ALLOW_ANY_CHANGE = (SDL_AUDIO_ALLOW_FREQUENCY_CHANGE |
+                              SDL_AUDIO_ALLOW_FORMAT_CHANGE |
+                              SDL_AUDIO_ALLOW_CHANNELS_CHANGE)
+
+SDL_AudioCallback = CFUNCTYPE(None, c_void_p, POINTER(Uint8), c_int)
+
+class SDL_AudioSpec(Structure):
+    _fields_ = [("freq", c_int),
+                ("format", SDL_AudioFormat),
+                ("channels", Uint8),
+                ("silence", Uint8),
+                ("samples", Uint16),
+                ("padding", Uint16),
+                ("size", Uint32),
+                ("callback", c_void_p),
+                ("userdata", c_void_p)
+                ]
+    def __init__(self, freq, aformat, channels, samples,
+                 callback=SDL_AudioCallback(), userdata=c_void_p(0)):
+        super(SDL_AudioSpec, self).__init__()
+        self.freq = freq
+        self.format = aformat
+        self.channels = channels
+        self.samples = samples
+        self.callback = callback
+        self.userdata = userdata
+
+class SDL_AudioCVT(Structure):
+    pass
+
+SDL_AudioFilter = CFUNCTYPE(POINTER(SDL_AudioCVT), SDL_AudioFormat)
+# HACK: hack for an IronPython 2.7.2.1+ issue:
+#    ptrarray = (CFUNCTYPE() * int)
+# is not supported properly
+if sys.platform == "cli":
+    _X_SDL_AudioFilter = POINTER(SDL_AudioFilter)
+else:
+    _X_SDL_AudioFilter = SDL_AudioFilter
+
+SDL_AudioCVT._fields_ = [("needed", c_int),
+                         ("src_format", SDL_AudioFormat),
+                         ("dst_format", SDL_AudioFormat),
+                         ("rate_incr", c_double),
+                         ("buf", POINTER(Uint8)),
+                         ("len", c_int),
+                         ("len_cvt", c_int),
+                         ("len_mult", c_int),
+                         ("len_ratio", c_double),
+                         ("filters", (_X_SDL_AudioFilter * 10)),
+                         ("filter_index", c_int)
+                         ]
+
+SDL_GetNumAudioDrivers = _bind("SDL_GetNumAudioDrivers", None, c_int)
+SDL_GetAudioDriver = _bind("SDL_GetAudioDriver", [c_int], c_char_p)
+SDL_AudioInit = _bind("SDL_AudioInit", [c_char_p], c_int)
+SDL_AudioQuit = _bind("SDL_AudioQuit")
+SDL_GetCurrentAudioDriver = _bind("SDL_GetCurrentAudioDriver", None, c_char_p)
+SDL_OpenAudio = _bind("SDL_OpenAudio", [POINTER(SDL_AudioSpec), POINTER(SDL_AudioSpec)], c_int)
+SDL_AudioDeviceID = Uint32
+SDL_GetNumAudioDevices = _bind("SDL_GetNumAudioDevices", [c_int], c_int)
+SDL_GetAudioDeviceName = _bind("SDL_GetAudioDeviceName", [c_int, c_int], c_char_p)
+SDL_OpenAudioDevice = _bind("SDL_OpenAudioDevice", [c_char_p, c_int, POINTER(SDL_AudioSpec), POINTER(SDL_AudioSpec), c_int], SDL_AudioDeviceID)
+SDL_AUDIO_STOPPED = 0
+SDL_AUDIO_PLAYING = 1
+SDL_AUDIO_PAUSED = 2
+SDL_AudioStatus = c_int
+SDL_GetAudioStatus = _bind("SDL_GetAudioStatus", None, SDL_AudioStatus)
+SDL_GetAudioDeviceStatus = _bind("SDL_GetAudioDeviceStatus", [SDL_AudioDeviceID], SDL_AudioStatus)
+SDL_PauseAudio = _bind("SDL_PauseAudio", [c_int])
+SDL_PauseAudioDevice = _bind("SDL_PauseAudioDevice", [SDL_AudioDeviceID, c_int])
+SDL_LoadWAV_RW = _bind("SDL_LoadWAV_RW", [POINTER(SDL_RWops), c_int, POINTER(SDL_AudioSpec), POINTER(POINTER(Uint8)), POINTER(Uint32)], POINTER(SDL_AudioSpec))
+SDL_LoadWAV = lambda f, s, ab, al: SDL_LoadWAV_RW(SDL_RWFromFile(f, "rb"), 1, s, ab , al)
+SDL_FreeWAV = _bind("SDL_FreeWAV", [POINTER(Uint8)])
+SDL_BuildAudioCVT = _bind("SDL_BuildAudioCVT", [POINTER(SDL_AudioCVT), SDL_AudioFormat, Uint8, c_int, SDL_AudioFormat, Uint8, c_int], c_int)
+SDL_ConvertAudio = _bind("SDL_ConvertAudio", [POINTER(SDL_AudioCVT)], c_int)
+SDL_MIX_MAXVOLUME = 128
+SDL_MixAudio = _bind("SDL_MixAudio", [POINTER(Uint8), POINTER(Uint8), Uint32, c_int])
+SDL_MixAudioFormat = _bind("SDL_MixAudioFormat", [POINTER(Uint8), POINTER(Uint8), SDL_AudioFormat, Uint32, c_int])
+SDL_LockAudio = _bind("SDL_LockAudio")
+SDL_LockAudioDevice = _bind("SDL_LockAudioDevice", [SDL_AudioDeviceID])
+SDL_UnlockAudio = _bind("SDL_UnlockAudio")
+SDL_UnlockAudioDevice = _bind("SDL_UnlockAudioDevice", [SDL_AudioDeviceID])
+SDL_CloseAudio = _bind("SDL_CloseAudio")
+SDL_CloseAudioDevice = _bind("SDL_CloseAudioDevice", [SDL_AudioDeviceID])
+# SDL_AudioDeviceConnected = _bind("SDL_AudioDeviceConnected", [SDL_AudioDeviceID])

sdl2/blendmode.py

-from ctypes import c_int
-
-__all__ = ["SDL_BLENDMODE_NONE", "SDL_BLENDMODE_BLEND", "SDL_BLENDMODE_ADD",
-           "SDL_BLENDMODE_MOD", "SDL_BlendMode"
-           ]
-
-SDL_BLENDMODE_NONE = 0x00000000
-SDL_BLENDMODE_BLEND = 0x00000001
-SDL_BLENDMODE_ADD = 0x00000002
-SDL_BLENDMODE_MOD = 0x00000004
-SDL_BlendMode = c_int
+from ctypes import c_int
+
+__all__ = ["SDL_BLENDMODE_NONE", "SDL_BLENDMODE_BLEND", "SDL_BLENDMODE_ADD",
+           "SDL_BLENDMODE_MOD", "SDL_BlendMode"
+           ]
+
+SDL_BLENDMODE_NONE = 0x00000000
+SDL_BLENDMODE_BLEND = 0x00000001
+SDL_BLENDMODE_ADD = 0x00000002
+SDL_BLENDMODE_MOD = 0x00000004
+SDL_BlendMode = c_int

sdl2/clipboard.py

-from ctypes import c_char_p, c_int
-from .dll import _bind
-from .stdinc import SDL_bool
-
-__all__ = ["SDL_SetClipboardText", "SDL_GetClipboardText",
-           "SDL_HasClipboardText"]
-
-SDL_SetClipboardText = _bind("SDL_SetClipboardText", [c_char_p], c_int)
-SDL_GetClipboardText = _bind("SDL_GetClipboardText", None, c_char_p)
-SDL_HasClipboardText = _bind("SDL_HasClipboardText", None, SDL_bool)
+from ctypes import c_char_p, c_int
+from .dll import _bind
+from .stdinc import SDL_bool
+
+__all__ = ["SDL_SetClipboardText", "SDL_GetClipboardText",
+           "SDL_HasClipboardText"]
+
+SDL_SetClipboardText = _bind("SDL_SetClipboardText", [c_char_p], c_int)
+SDL_GetClipboardText = _bind("SDL_GetClipboardText", None, c_char_p)
+SDL_HasClipboardText = _bind("SDL_HasClipboardText", None, SDL_bool)
-from ctypes import c_int
-from .dll import _bind
-from .stdinc import SDL_bool
-
-__all__ = ["SDL_CACHELINE_SIZE", "SDL_GetCPUCount", "SDL_GetCPUCacheLineSize",
-           "SDL_HasRDTSC", "SDL_HasAltiVec", "SDL_HasMMX", "SDL_Has3DNow",
-           "SDL_HasSSE", "SDL_HasSSE2", "SDL_HasSSE3", "SDL_HasSSE41",
-           "SDL_HasSSE42"
-           ]
-
-SDL_CACHELINE_SIZE = 128
-SDL_GetCPUCount = _bind("SDL_GetCPUCount", None, c_int)
-SDL_GetCPUCacheLineSize = _bind("SDL_GetCPUCacheLineSize", None, c_int)
-SDL_HasRDTSC = _bind("SDL_HasRDTSC", None, SDL_bool)
-SDL_HasAltiVec = _bind("SDL_HasAltiVec", None, SDL_bool)
-SDL_HasMMX = _bind("SDL_HasMMX", None, SDL_bool)
-SDL_Has3DNow = _bind("SDL_Has3DNow", None, SDL_bool)
-SDL_HasSSE = _bind("SDL_HasSSE", None, SDL_bool)
-SDL_HasSSE2 = _bind("SDL_HasSSE2", None, SDL_bool)
-SDL_HasSSE3 = _bind("SDL_HasSSE3", None, SDL_bool)
-SDL_HasSSE41 = _bind("SDL_HasSSE41", None, SDL_bool)
-SDL_HasSSE42 = _bind("SDL_HasSSE42", None, SDL_bool)
+from ctypes import c_int
+from .dll import _bind
+from .stdinc import SDL_bool
+
+__all__ = ["SDL_CACHELINE_SIZE", "SDL_GetCPUCount", "SDL_GetCPUCacheLineSize",
+           "SDL_HasRDTSC", "SDL_HasAltiVec", "SDL_HasMMX", "SDL_Has3DNow",
+           "SDL_HasSSE", "SDL_HasSSE2", "SDL_HasSSE3", "SDL_HasSSE41",
+           "SDL_HasSSE42"
+           ]
+
+SDL_CACHELINE_SIZE = 128
+SDL_GetCPUCount = _bind("SDL_GetCPUCount", None, c_int)
+SDL_GetCPUCacheLineSize = _bind("SDL_GetCPUCacheLineSize", None, c_int)
+SDL_HasRDTSC = _bind("SDL_HasRDTSC", None, SDL_bool)
+SDL_HasAltiVec = _bind("SDL_HasAltiVec", None, SDL_bool)
+SDL_HasMMX = _bind("SDL_HasMMX", None, SDL_bool)
+SDL_Has3DNow = _bind("SDL_Has3DNow", None, SDL_bool)
+SDL_HasSSE = _bind("SDL_HasSSE", None, SDL_bool)
+SDL_HasSSE2 = _bind("SDL_HasSSE2", None, SDL_bool)
+SDL_HasSSE3 = _bind("SDL_HasSSE3", None, SDL_bool)
+SDL_HasSSE41 = _bind("SDL_HasSSE41", None, SDL_bool)
+SDL_HasSSE42 = _bind("SDL_HasSSE42", None, SDL_bool)
-"""DLL wrapper"""
-import os
-import sys
-import warnings
-from ctypes import CDLL
-from ctypes.util import find_library
-
-__all__ = ["get_dll_file"]
-
-
-def _findlib(libnames, path=None):
-    """."""
-    platform = sys.platform
-    if platform in ("win32", "cli"):
-        suffix = ".dll"
-    elif platform == "darwin":
-        suffix = ".dylib"
-    else:
-        suffix = ".so"
-
-    searchfor = libnames
-    if type(libnames) is dict:
-        # different library names for the platforms
-        if platform == "cli" and platform not in libnames:
-            # if not explicitly specified, use the Win32 libs for IronPython
-            platform = "win32"
-        if platform not in libnames:
-            platform = "DEFAULT"
-        searchfor = libnames[platform]
-    results = []
-    if path:
-        for libname in searchfor:
-            dllfile = os.path.join(path, "%s%s" % (libname, suffix))
-            if os.path.exists(dllfile):
-                results.append(dllfile)
-    for libname in searchfor:
-        dllfile = find_library(libname)
-        if dllfile:
-            results.append(dllfile)
-    return results
-
-
-class _DLL(object):
-    """Function wrapper around the different DLL functions. Do not use or
-    instantiate this one directly from your user code.
-    """
-    def __init__(self, libinfo, libnames, path=None):
-        self._dll = None
-        foundlibs = _findlib(libnames, path)
-        if len(foundlibs) == 0:
-            raise RuntimeError("could not find any library for %s" % libinfo)
-        for libfile in foundlibs:
-            try:
-                self._dll = CDLL(libfile)
-                self._libfile = libfile
-                break
-            except Exception as exc:
-                # Could not load it, silently ignore that issue and move
-                # to the next one.
-                warnings.warn(repr(exc), ImportWarning)
-        if self._dll is None:
-            raise RuntimeError("could not load any library for %s" % libinfo)
-        if path is not None and sys.platform in ("win32", "cli") and \
-            path in self._libfile:
-            os.environ["PATH"] += ";%s" % path
-
-    def bind_function(self, funcname, args=None, returns=None, optfunc=None):
-        """Binds the passed argument and return value types to the specified
-        function."""
-        func = getattr(self._dll, funcname, None)
-        if not func:
-            func = optfunc
-        func.argtypes = args
-        func.restype = returns
-        return func
-
-    @property
-    def libfile(self):
-        """Gets the filename of the loaded library."""
-        return self._libfile
-
-
-dll = _DLL("SDL2", ["SDL2", "SDL2-2.0"], os.getenv("PYSDL2_DLL_PATH"))
-
-
-def get_dll_file():
-    """Gets the file name of the loaded SDL2 library."""
-    return dll.libfile
-
-_bind = dll.bind_function
+"""DLL wrapper"""
+import os
+import sys
+import warnings
+from ctypes import CDLL
+from ctypes.util import find_library
+
+__all__ = ["get_dll_file"]
+
+
+def _findlib(libnames, path=None):
+    """."""
+    platform = sys.platform
+    if platform in ("win32", "cli"):
+        suffix = ".dll"
+    elif platform == "darwin":
+        suffix = ".dylib"
+    else:
+        suffix = ".so"
+
+    searchfor = libnames
+    if type(libnames) is dict:
+        # different library names for the platforms
+        if platform == "cli" and platform not in libnames:
+            # if not explicitly specified, use the Win32 libs for IronPython
+            platform = "win32"
+        if platform not in libnames:
+            platform = "DEFAULT"
+        searchfor = libnames[platform]
+    results = []
+    if path:
+        for libname in searchfor:
+            dllfile = os.path.join(path, "%s%s" % (libname, suffix))
+            if os.path.exists(dllfile):
+                results.append(dllfile)
+    for libname in searchfor:
+        dllfile = find_library(libname)
+        if dllfile:
+            results.append(dllfile)
+    return results
+
+
+class _DLL(object):
+    """Function wrapper around the different DLL functions. Do not use or
+    instantiate this one directly from your user code.
+    """
+    def __init__(self, libinfo, libnames, path=None):
+        self._dll = None
+        foundlibs = _findlib(libnames, path)
+        if len(foundlibs) == 0:
+            raise RuntimeError("could not find any library for %s" % libinfo)
+        for libfile in foundlibs:
+            try:
+                self._dll = CDLL(libfile)
+                self._libfile = libfile
+                break
+            except Exception as exc:
+                # Could not load it, silently ignore that issue and move
+                # to the next one.
+                warnings.warn(repr(exc), ImportWarning)
+        if self._dll is None:
+            raise RuntimeError("could not load any library for %s" % libinfo)
+        if path is not None and sys.platform in ("win32", "cli") and \
+            path in self._libfile:
+            os.environ["PATH"] += ";%s" % path
+
+    def bind_function(self, funcname, args=None, returns=None, optfunc=None):
+        """Binds the passed argument and return value types to the specified
+        function."""
+        func = getattr(self._dll, funcname, None)
+        if not func:
+            func = optfunc
+        func.argtypes = args
+        func.restype = returns
+        return func
+
+    @property
+    def libfile(self):
+        """Gets the filename of the loaded library."""
+        return self._libfile
+
+
+dll = _DLL("SDL2", ["SDL2", "SDL2-2.0"], os.getenv("PYSDL2_DLL_PATH"))
+
+
+def get_dll_file():
+    """Gets the file name of the loaded SDL2 library."""
+    return dll.libfile
+
+_bind = dll.bind_function
-import sys
-import array
-
-__all__ = ["SDL_LIL_ENDIAN", "SDL_BIG_ENDIAN", "SDL_BYTEORDER", "SDL_Swap16",
-           "SDL_Swap32", "SDL_Swap64", "SDL_SwapFloat", "SDL_SwapLE16",
-           "SDL_SwapLE32", "SDL_SwapLE64", "SDL_SwapFloatLE", "SDL_SwapBE16",
-           "SDL_SwapBE32", "SDL_SwapBE64", "SDL_SwapFloatBE"
-           ]
-
-SDL_LIL_ENDIAN = 1234
-SDL_BIG_ENDIAN = 4321
-if sys.byteorder == "little":
-    SDL_BYTEORDER = SDL_LIL_ENDIAN
-else:
-    SDL_BYTEORDER = SDL_BIG_ENDIAN
-
-SDL_Swap16 = lambda x: ((x << 8 & 0xFF00) | (x >> 8 & 0x00FF))
-SDL_Swap32 = lambda x: (((x << 24) & 0xFF000000) |
-                        ((x << 8) & 0x00FF0000) |
-                        ((x >> 8) & 0x0000FF00) |
-                        ((x >> 24) & 0x000000FF))
-SDL_Swap64 = lambda x: ((SDL_Swap32(x & 0xFFFFFFFF) << 32) |
-                        (SDL_Swap32(x >> 32 & 0xFFFFFFFF)))
-def SDL_SwapFloat(x):
-    ar = array.array("d", (x,))
-    ar.byteswap()
-    return ar[0]
-
-def _nop(x):
-    return x
-if SDL_BYTEORDER == SDL_LIL_ENDIAN:
-    SDL_SwapLE16 = _nop
-    SDL_SwapLE32 = _nop
-    SDL_SwapLE64 = _nop
-    SDL_SwapFloatLE = _nop
-    SDL_SwapBE16 = SDL_Swap16
-    SDL_SwapBE32 = SDL_Swap32
-    SDL_SwapBE64 = SDL_Swap64
-    SDL_SwapFloatBE = SDL_SwapFloat
-else:
-    SDL_SwapLE16 = SDL_Swap16
-    SDL_SwapLE32 = SDL_Swap32
-    SDL_SwapLE64 = SDL_Swap64
-    SDL_SwapFloatLE = SDL_SwapFloat
-    SDL_SwapBE16 = _nop
-    SDL_SwapBE32 = _nop
-    SDL_SwapBE64 = _nop
-    SDL_SwapFloatBE = _nop
+import sys
+import array
+
+__all__ = ["SDL_LIL_ENDIAN", "SDL_BIG_ENDIAN", "SDL_BYTEORDER", "SDL_Swap16",
+           "SDL_Swap32", "SDL_Swap64", "SDL_SwapFloat", "SDL_SwapLE16",
+           "SDL_SwapLE32", "SDL_SwapLE64", "SDL_SwapFloatLE", "SDL_SwapBE16",
+           "SDL_SwapBE32", "SDL_SwapBE64", "SDL_SwapFloatBE"
+           ]
+
+SDL_LIL_ENDIAN = 1234
+SDL_BIG_ENDIAN = 4321
+if sys.byteorder == "little":
+    SDL_BYTEORDER = SDL_LIL_ENDIAN
+else:
+    SDL_BYTEORDER = SDL_BIG_ENDIAN
+
+SDL_Swap16 = lambda x: ((x << 8 & 0xFF00) | (x >> 8 & 0x00FF))
+SDL_Swap32 = lambda x: (((x << 24) & 0xFF000000) |
+                        ((x << 8) & 0x00FF0000) |
+                        ((x >> 8) & 0x0000FF00) |
+                        ((x >> 24) & 0x000000FF))
+SDL_Swap64 = lambda x: ((SDL_Swap32(x & 0xFFFFFFFF) << 32) |
+                        (SDL_Swap32(x >> 32 & 0xFFFFFFFF)))
+def SDL_SwapFloat(x):
+    ar = array.array("d", (x,))
+    ar.byteswap()
+    return ar[0]
+
+def _nop(x):
+    return x
+if SDL_BYTEORDER == SDL_LIL_ENDIAN:
+    SDL_SwapLE16 = _nop
+    SDL_SwapLE32 = _nop
+    SDL_SwapLE64 = _nop
+    SDL_SwapFloatLE = _nop
+    SDL_SwapBE16 = SDL_Swap16
+    SDL_SwapBE32 = SDL_Swap32
+    SDL_SwapBE64 = SDL_Swap64
+    SDL_SwapFloatBE = SDL_SwapFloat
+else:
+    SDL_SwapLE16 = SDL_Swap16
+    SDL_SwapLE32 = SDL_Swap32
+    SDL_SwapLE64 = SDL_Swap64
+    SDL_SwapFloatLE = SDL_SwapFloat
+    SDL_SwapBE16 = _nop
+    SDL_SwapBE32 = _nop
+    SDL_SwapBE64 = _nop
+    SDL_SwapFloatBE = _nop
-from ctypes import c_char_p, c_int
-from .dll import _bind
-
-__all__ = ["SDL_SetError", "SDL_GetError", "SDL_ClearError", "SDL_ENOMEM",
-           "SDL_EFREAD", "SDL_EFWRITE", "SDL_EFSEEK", "SDL_UNSUPPORTED",
-           "SDL_LASTERROR", "SDL_errorcode", "SDL_Error", "SDL_OutOfMemory",
-           "SDL_Unsupported", "SDL_InvalidParamError"
-           ]
-
-SDL_SetError = _bind("SDL_SetError", [c_char_p], c_int)
-SDL_GetError = _bind("SDL_GetError", None, c_char_p)
-SDL_ClearError = _bind("SDL_ClearError")
-
-SDL_ENOMEM = 0
-SDL_EFREAD = 1
-SDL_EFWRITE = 2
-SDL_EFSEEK = 3
-SDL_UNSUPPORTED = 4
-SDL_LASTERROR = 5
-SDL_errorcode = c_int
-SDL_Error = _bind("SDL_Error", [c_int], c_int)
-SDL_OutOfMemory = SDL_Error(SDL_ENOMEM)
-SDL_Unsupported = SDL_Error(SDL_UNSUPPORTED)
-SDL_InvalidParamError = lambda x: SDL_SetError("Parameter '%s' is invalid" % (x))
+from ctypes import c_char_p, c_int
+from .dll import _bind
+
+__all__ = ["SDL_SetError", "SDL_GetError", "SDL_ClearError", "SDL_ENOMEM",
+           "SDL_EFREAD", "SDL_EFWRITE", "SDL_EFSEEK", "SDL_UNSUPPORTED",
+           "SDL_LASTERROR", "SDL_errorcode", "SDL_Error", "SDL_OutOfMemory",
+           "SDL_Unsupported", "SDL_InvalidParamError"
+           ]
+
+SDL_SetError = _bind("SDL_SetError", [c_char_p], c_int)
+SDL_GetError = _bind("SDL_GetError", None, c_char_p)
+SDL_ClearError = _bind("SDL_ClearError")
+
+SDL_ENOMEM = 0
+SDL_EFREAD = 1
+SDL_EFWRITE = 2
+SDL_EFSEEK = 3
+SDL_UNSUPPORTED = 4
+SDL_LASTERROR = 5
+SDL_errorcode = c_int
+SDL_Error = _bind("SDL_Error", [c_int], c_int)
+SDL_OutOfMemory = SDL_Error(SDL_ENOMEM)
+SDL_Unsupported = SDL_Error(SDL_UNSUPPORTED)
+SDL_InvalidParamError = lambda x: SDL_SetError("Parameter '%s' is invalid" % (x))
-from ctypes import c_char, c_char_p, c_float, c_void_p, c_int, Structure, \
-    Union, CFUNCTYPE, POINTER
-from .dll import _bind
-from .stdinc import Sint16, Sint32, Uint8, Uint16, Uint32, SDL_bool
-from .keyboard import SDL_Keysym
-from .joystick import SDL_JoystickID
-from .touch import SDL_FingerID, SDL_TouchID
-from .gesture import SDL_GestureID
-
-__all__ = ["SDL_FIRSTEVENT", "SDL_QUIT", "SDL_WINDOWEVENT", "SDL_SYSWMEVENT",
-           "SDL_KEYDOWN", "SDL_KEYUP", "SDL_TEXTEDITING", "SDL_TEXTINPUT",
-           "SDL_MOUSEMOTION", "SDL_MOUSEBUTTONDOWN", "SDL_MOUSEBUTTONUP",
-           "SDL_MOUSEWHEEL", "SDL_JOYAXISMOTION", "SDL_JOYBALLMOTION",
-           "SDL_JOYHATMOTION", "SDL_JOYBUTTONDOWN", "SDL_JOYBUTTONUP",
-           "SDL_JOYDEVICEADDED", "SDL_JOYDEVICEREMOVED",
-           "SDL_CONTROLLERAXISMOTION", "SDL_CONTROLLERBUTTONDOWN",
-           "SDL_CONTROLLERBUTTONUP", "SDL_CONTROLLERDEVICEADDED",
-           "SDL_CONTROLLERDEVICEREMOVED", "SDL_CONTROLLERDEVICEREMAPPED",
-           "SDL_FINGERDOWN", "SDL_FINGERUP", "SDL_FINGERMOTION",
-           "SDL_DOLLARGESTURE", "SDL_DOLLARRECORD", "SDL_MULTIGESTURE",
-           "SDL_CLIPBOARDUPDATE", "SDL_DROPFILE", "SDL_USEREVENT",
-           "SDL_LASTEVENT", "SDL_EventType", "SDL_GenericEvent",
-           "SDL_WindowEvent", "SDL_KeyboardEvent",
-           "SDL_TEXTEDITINGEVENT_TEXT_SIZE", "SDL_TextEditingEvent",
-           "SDL_TEXTINPUTEVENT_TEXT_SIZE", "SDL_TextInputEvent",
-           "SDL_MouseMotionEvent", "SDL_MouseButtonEvent",
-           "SDL_MouseWheelEvent", "SDL_JoyAxisEvent", "SDL_JoyBallEvent",
-           "SDL_JoyHatEvent", "SDL_JoyButtonEvent", "SDL_JoyDeviceEvent",
-           "SDL_ControllerAxisEvent", "SDL_ControllerButtonEvent",
-           "SDL_ControllerDeviceEvent", "SDL_TouchFingerEvent",
-           "SDL_MultiGestureEvent", "SDL_DollarGestureEvent", "SDL_DropEvent",
-           "SDL_QuitEvent", "SDL_UserEvent", "SDL_SysWMmsg", "SDL_SysWMEvent",
-           "SDL_Event", "SDL_PumpEvents", "SDL_ADDEVENT", "SDL_PEEKEVENT",
-           "SDL_GETEVENT", "SDL_eventaction", "SDL_PeepEvents", "SDL_HasEvent",
-           "SDL_HasEvents", "SDL_FlushEvent", "SDL_FlushEvents",
-           "SDL_PollEvent", "SDL_WaitEvent", "SDL_WaitEventTimeout",
-           "SDL_PushEvent", "SDL_EventFilter", "SDL_SetEventFilter",
-           "SDL_GetEventFilter", "SDL_AddEventWatch", "SDL_DelEventWatch",
-           "SDL_FilterEvents", "SDL_QUERY", "SDL_IGNORE", "SDL_DISABLE",
-           "SDL_ENABLE", "SDL_EventState", "SDL_GetEventState",
-           "SDL_RegisterEvents", "SDL_QuitRequested"
-           ]
-
-SDL_FIRSTEVENT = 0
-SDL_QUIT = 0x100
-SDL_WINDOWEVENT = 0x200
-SDL_SYSWMEVENT = 0x201
-SDL_KEYDOWN = 0x300
-SDL_KEYUP = 0x301
-SDL_TEXTEDITING = 0x302
-SDL_TEXTINPUT = 0x303
-SDL_MOUSEMOTION = 0x400
-SDL_MOUSEBUTTONDOWN = 0x401
-SDL_MOUSEBUTTONUP = 0x402
-SDL_MOUSEWHEEL = 0x403
-SDL_JOYAXISMOTION = 0x600
-SDL_JOYBALLMOTION = 0x601
-SDL_JOYHATMOTION = 0x602
-SDL_JOYBUTTONDOWN = 0x603
-SDL_JOYBUTTONUP = 0x604
-SDL_JOYDEVICEADDED = 0x605
-SDL_JOYDEVICEREMOVED = 0x606
-SDL_CONTROLLERAXISMOTION = 0x650
-SDL_CONTROLLERBUTTONDOWN = 0x651
-SDL_CONTROLLERBUTTONUP = 0x652
-SDL_CONTROLLERDEVICEADDED = 0x653
-SDL_CONTROLLERDEVICEREMOVED = 0x654
-SDL_CONTROLLERDEVICEREMAPPED = 0x655
-SDL_FINGERDOWN = 0x700
-SDL_FINGERUP = 0x701
-SDL_FINGERMOTION = 0x702
-SDL_DOLLARGESTURE = 0x800
-SDL_DOLLARRECORD = 0x801
-SDL_MULTIGESTURE = 0x802
-SDL_CLIPBOARDUPDATE = 0x900
-SDL_DROPFILE = 0x1000
-SDL_USEREVENT = 0x8000
-SDL_LASTEVENT = 0xFFFF
-SDL_EventType = c_int
-
-class SDL_GenericEvent(Structure):
-    _fields_ = [("type", Uint32), ("timestamp", Uint32)]
-
-class SDL_WindowEvent(Structure):
-    _fields_ = [("type", Uint32),
-                ("timestamp", Uint32),
-                ("windowID", Uint32),
-                ("event", Uint8),
-                ("padding1", Uint8),
-                ("padding2", Uint8),
-                ("padding3", Uint8),
-                ("data1", Sint32),
-                ("data2", Sint32)
-                ]
-
-class SDL_KeyboardEvent(Structure):
-    _fields_ = [("type", Uint32),
-                ("timestamp", Uint32),
-                ("windowID", Uint32),
-                ("state", Uint8),
-                ("repeat", Uint8),
-                ("padding2", Uint8),
-                ("padding3", Uint8),
-                ("keysym", SDL_Keysym)
-                ]
-
-SDL_TEXTEDITINGEVENT_TEXT_SIZE = 32
-
-class SDL_TextEditingEvent(Structure):
-    _fields_ = [("type", Uint32),
-                ("timestamp", Uint32),
-                ("windowID", Uint32),
-                ("text", (c_char * SDL_TEXTEDITINGEVENT_TEXT_SIZE)),
-                ("start", Sint32),
-                ("length", Sint32)
-                ]
-
-SDL_TEXTINPUTEVENT_TEXT_SIZE = 32
-class SDL_TextInputEvent(Structure):
-    _fields_ = [("type", Uint32),
-                ("timestamp", Uint32),
-                ("windowID", Uint32),
-                ("text", (c_char * SDL_TEXTINPUTEVENT_TEXT_SIZE))
-                ]
-
-class SDL_MouseMotionEvent(Structure):
-    _fields_ = [("type", Uint32),
-                ("timestamp", Uint32),
-                ("windowID", Uint32),
-                ("which", Uint32),
-                ("state", Uint8),
-                ("padding1", Uint8),
-                ("padding2", Uint8),
-                ("padding3", Uint8),
-                ("x", Sint32),
-                ("y", Sint32),
-                ("xrel", Sint32),
-                ("yrel", Sint32)
-                ]
-
-class SDL_MouseButtonEvent(Structure):
-    _fields_ = [("type", Uint32),
-                ("timestamp", Uint32),
-                ("windowID", Uint32),
-                ("which", Uint32),
-                ("button", Uint8),
-                ("state", Uint8),
-                ("padding1", Uint8),
-                ("padding2", Uint8),
-                ("x", Sint32),
-                ("y", Sint32)
-                ]
-
-class SDL_MouseWheelEvent(Structure):
-    _fields_ = [("type", Uint32),
-                ("timestamp", Uint32),
-                ("windowID", Uint32),
-                ("which", Uint32),
-                ("x", Sint32),
-                ("y", Sint32)
-                ]
-
-class SDL_JoyAxisEvent(Structure):
-    _fields_ = [("type", Uint32),
-                ("timestamp", Uint32),
-                ("which", SDL_JoystickID),
-                ("axis", Uint8),
-                ("padding1", Uint8),
-                ("padding2", Uint8),
-                ("padding3", Uint8),
-                ("value", Sint16),
-                ("padding4", Uint16)
-                ]
-
-class SDL_JoyBallEvent(Structure):
-    _fields_ = [("type", Uint32),
-                ("timestamp", Uint32),
-                ("which", SDL_JoystickID),
-                ("ball", Uint8),
-                ("padding1", Uint8),
-                ("padding2", Uint8),
-                ("padding3", Uint8),
-                ("xrel", Sint16),
-                ("yrel", Sint16)
-                ]
-
-class SDL_JoyHatEvent(Structure):
-    _fields_ = [("type", Uint32),
-                ("timestamp", Uint32),
-                ("which", SDL_JoystickID),
-                ("hat", Uint8),
-                ("value", Uint8),
-                ("padding1", Uint8),
-                ("padding2", Uint8)
-                ]
-
-class SDL_JoyButtonEvent(Structure):
-    _fields_ = [("type", Uint32),
-                ("timestamp", Uint32),
-                ("which", SDL_JoystickID),
-                ("button", Uint8),
-                ("state", Uint8),
-                ("padding1", Uint8),
-                ("padding2", Uint8)
-                ]
-
-class SDL_JoyDeviceEvent(Structure):
-    _fields_ = [("type", Uint32),
-                ("timestamp", Uint32),
-                ("which", Sint32)
-                ]
-
-class SDL_ControllerAxisEvent(Structure):
-    _fields_ = [("type", Uint32),
-                ("timestamp", Uint32),
-                ("which", SDL_JoystickID),
-                ("axis", Uint8),
-                ("padding1", Uint8),
-                ("padding2", Uint8),
-                ("padding3", Uint8),
-                ("value", Sint16),
-                ("padding4", Uint16)
-                ]
-
-class SDL_ControllerButtonEvent(Structure):
-    _fields_ = [("type", Uint32),
-                ("timestamp", Uint32),
-                ("which", SDL_JoystickID),
-                ("button", Uint8),
-                ("state", Uint8),
-                ("padding1", Uint8),
-                ("padding2", Uint8)
-                ]
-
-class SDL_ControllerDeviceEvent(Structure):
-    _fields_ = [("type", Uint32),
-                ("timestamp", Uint32),
-                ("which", Sint32)
-                ]
-
-class SDL_TouchFingerEvent(Structure):
-    _fields_ = [("type", Uint32),
-                ("timestamp", Uint32),
-                ("touchId", SDL_TouchID),
-                ("fingerId", SDL_FingerID),
-                ("x", c_float),
-                ("y", c_float),
-                ("dx", c_float),
-                ("dy", c_float),
-                ("pressure", c_float)
-                ]
-
-class SDL_MultiGestureEvent(Structure):
-    _fields_ = [("type", Uint32),
-                ("timestamp", Uint32),
-                ("touchId", SDL_TouchID),
-                ("dTheta", c_float),
-                ("dDist", c_float),
-                ("x", c_float),
-                ("y", c_float),
-                ("numFingers", Uint16),
-                ("padding", Uint16)
-                ]
-
-class SDL_DollarGestureEvent(Structure):
-    _fields_ = [("type", Uint32),
-                ("timestamp", Uint32),
-                ("touchId", SDL_TouchID),
-                ("gestureId", SDL_GestureID),
-                ("numFingers", Uint32),
-                ("error", c_float),
-                ("x", c_float),
-                ("y", c_float)
-                ]
-
-class SDL_DropEvent(Structure):
-    _fields_ = [("type", Uint32),
-                ("timestamp", Uint32),
-                ("file", c_char_p)
-                ]
-
-class SDL_QuitEvent(Structure):
-    _fields_ = [("type", Uint32),
-                ("timestamp", Uint32)
-                ]
-
-class SDL_UserEvent(Structure):
-    _fields_ = [("type", Uint32),
-                ("timestamp", Uint32),
-                ("windowID", Uint32),
-                ("code", Sint32),
-                ("data1", c_void_p),
-                ("data2", c_void_p)
-                ]
-
-# TODO
-class SDL_SysWMmsg(Structure):
-    pass
-
-class SDL_SysWMEvent(Structure):
-    _fields_ = [("type", Uint32),
-                ("timestamp", Uint32),
-                ("msg", POINTER(SDL_SysWMmsg))
-                ]
-
-class SDL_Event(Union):
-    _fields_ = [("type", Uint32),
-                ("generic", SDL_GenericEvent),
-                ("window", SDL_WindowEvent),
-                ("key", SDL_KeyboardEvent),
-                ("edit", SDL_TextEditingEvent),
-                ("text", SDL_TextInputEvent),
-                ("motion", SDL_MouseMotionEvent),
-                ("button", SDL_MouseButtonEvent),
-                ("wheel", SDL_MouseWheelEvent),
-                ("jaxis", SDL_JoyAxisEvent),
-                ("jball", SDL_JoyBallEvent),
-                ("jhat", SDL_JoyHatEvent),
-                ("jbutton", SDL_JoyButtonEvent),
-                ("jdevice", SDL_JoyDeviceEvent),
-                ("caxis", SDL_ControllerAxisEvent),
-                ("cbutton", SDL_ControllerButtonEvent),
-                ("cdevice", SDL_ControllerDeviceEvent),
-                ("quit", SDL_QuitEvent),
-                ("user", SDL_UserEvent),
-                ("syswm", SDL_SysWMEvent),
-                ("tfinger", SDL_TouchFingerEvent),
-                ("mgesture", SDL_MultiGestureEvent),
-                ("dgesture", SDL_DollarGestureEvent),
-                ("drop", SDL_DropEvent),
-                ("padding", (Uint8 * 56)),
-                ]
-
-SDL_PumpEvents = _bind("SDL_PumpEvents")
-SDL_ADDEVENT = 0
-SDL_PEEKEVENT = 1
-SDL_GETEVENT = 2
-SDL_eventaction = c_int
-SDL_PeepEvents = _bind("SDL_PeepEvents", [POINTER(SDL_Event), c_int, SDL_eventaction, Uint32, Uint32], c_int)
-SDL_HasEvent = _bind("SDL_HasEvent", [Uint32], SDL_bool)
-SDL_HasEvents = _bind("SDL_HasEvents", [Uint32, Uint32], SDL_bool)
-SDL_FlushEvent = _bind("SDL_FlushEvent", [Uint32])
-SDL_FlushEvents = _bind("SDL_FlushEvents", [Uint32, Uint32])
-SDL_PollEvent = _bind("SDL_PollEvent", [POINTER(SDL_Event)], c_int)
-SDL_WaitEvent = _bind("SDL_WaitEvent", [POINTER(SDL_Event)], c_int)
-SDL_WaitEventTimeout = _bind("SDL_WaitEventTimeout", [POINTER(SDL_Event), c_int], c_int)
-SDL_PushEvent = _bind("SDL_PushEvent", [POINTER(SDL_Event)], c_int)
-SDL_EventFilter = CFUNCTYPE(c_int, c_void_p, POINTER(SDL_Event))
-SDL_SetEventFilter = _bind("SDL_SetEventFilter", [SDL_EventFilter, c_void_p])
-SDL_GetEventFilter = _bind("SDL_GetEventFilter", [POINTER(SDL_EventFilter), POINTER(c_void_p)], SDL_bool)
-SDL_AddEventWatch = _bind("SDL_AddEventWatch", [SDL_EventFilter, c_void_p])
-SDL_DelEventWatch = _bind("SDL_DelEventWatch", [SDL_EventFilter, c_void_p])
-SDL_FilterEvents = _bind("SDL_FilterEvents", [SDL_EventFilter, c_void_p])
-SDL_QUERY = -1
-SDL_IGNORE = 0
-SDL_DISABLE = 0
-SDL_ENABLE = 1
-SDL_EventState = _bind("SDL_EventState", [Uint32, c_int], Uint8)
-SDL_GetEventState = lambda t: SDL_EventState(t, SDL_QUERY)
-SDL_RegisterEvents = _bind("SDL_RegisterEvents", [c_int], Uint32)
-
-
-# SDL_quit.h
-def SDL_QuitRequested():
-    SDL_PumpEvents()
-    return SDL_PeepEvents(None, 0, SDL_PEEKEVENT, SDL_QUIT, SDL_QUIT) > 0
+from ctypes import c_char, c_char_p, c_float, c_void_p, c_int, Structure, \
+    Union, CFUNCTYPE, POINTER
+from .dll import _bind
+from .stdinc import Sint16, Sint32, Uint8, Uint16, Uint32, SDL_bool
+from .keyboard import SDL_Keysym
+from .joystick import SDL_JoystickID
+from .touch import SDL_FingerID, SDL_TouchID
+from .gesture import SDL_GestureID
+
+__all__ = ["SDL_FIRSTEVENT", "SDL_QUIT", "SDL_WINDOWEVENT", "SDL_SYSWMEVENT",
+           "SDL_KEYDOWN", "SDL_KEYUP", "SDL_TEXTEDITING", "SDL_TEXTINPUT",
+           "SDL_MOUSEMOTION", "SDL_MOUSEBUTTONDOWN", "SDL_MOUSEBUTTONUP",
+           "SDL_MOUSEWHEEL", "SDL_JOYAXISMOTION", "SDL_JOYBALLMOTION",
+           "SDL_JOYHATMOTION", "SDL_JOYBUTTONDOWN", "SDL_JOYBUTTONUP",
+           "SDL_JOYDEVICEADDED", "SDL_JOYDEVICEREMOVED",
+           "SDL_CONTROLLERAXISMOTION", "SDL_CONTROLLERBUTTONDOWN",
+           "SDL_CONTROLLERBUTTONUP", "SDL_CONTROLLERDEVICEADDED",
+           "SDL_CONTROLLERDEVICEREMOVED", "SDL_CONTROLLERDEVICEREMAPPED",
+           "SDL_FINGERDOWN", "SDL_FINGERUP", "SDL_FINGERMOTION",
+           "SDL_DOLLARGESTURE", "SDL_DOLLARRECORD", "SDL_MULTIGESTURE",
+           "SDL_CLIPBOARDUPDATE", "SDL_DROPFILE", "SDL_USEREVENT",
+           "SDL_LASTEVENT", "SDL_EventType", "SDL_GenericEvent",
+           "SDL_WindowEvent", "SDL_KeyboardEvent",
+           "SDL_TEXTEDITINGEVENT_TEXT_SIZE", "SDL_TextEditingEvent",
+           "SDL_TEXTINPUTEVENT_TEXT_SIZE", "SDL_TextInputEvent",
+           "SDL_MouseMotionEvent", "SDL_MouseButtonEvent",
+           "SDL_MouseWheelEvent", "SDL_JoyAxisEvent", "SDL_JoyBallEvent",
+           "SDL_JoyHatEvent", "SDL_JoyButtonEvent", "SDL_JoyDeviceEvent",
+           "SDL_ControllerAxisEvent", "SDL_ControllerButtonEvent",
+           "SDL_ControllerDeviceEvent", "SDL_TouchFingerEvent",
+           "SDL_MultiGestureEvent", "SDL_DollarGestureEvent", "SDL_DropEvent",
+           "SDL_QuitEvent", "SDL_UserEvent", "SDL_SysWMmsg", "SDL_SysWMEvent",
+           "SDL_Event", "SDL_PumpEvents", "SDL_ADDEVENT", "SDL_PEEKEVENT",
+           "SDL_GETEVENT", "SDL_eventaction", "SDL_PeepEvents", "SDL_HasEvent",
+           "SDL_HasEvents", "SDL_FlushEvent", "SDL_FlushEvents",
+           "SDL_PollEvent", "SDL_WaitEvent", "SDL_WaitEventTimeout",
+           "SDL_PushEvent", "SDL_EventFilter", "SDL_SetEventFilter",
+           "SDL_GetEventFilter", "SDL_AddEventWatch", "SDL_DelEventWatch",
+           "SDL_FilterEvents", "SDL_QUERY", "SDL_IGNORE", "SDL_DISABLE",
+           "SDL_ENABLE", "SDL_EventState", "SDL_GetEventState",
+           "SDL_RegisterEvents", "SDL_QuitRequested"
+           ]
+
+SDL_FIRSTEVENT = 0
+SDL_QUIT = 0x100
+SDL_WINDOWEVENT = 0x200
+SDL_SYSWMEVENT = 0x201
+SDL_KEYDOWN = 0x300
+SDL_KEYUP = 0x301
+SDL_TEXTEDITING = 0x302
+SDL_TEXTINPUT = 0x303
+SDL_MOUSEMOTION = 0x400
+SDL_MOUSEBUTTONDOWN = 0x401
+SDL_MOUSEBUTTONUP = 0x402
+SDL_MOUSEWHEEL = 0x403
+SDL_JOYAXISMOTION = 0x600
+SDL_JOYBALLMOTION = 0x601
+SDL_JOYHATMOTION = 0x602
+SDL_JOYBUTTONDOWN = 0x603
+SDL_JOYBUTTONUP = 0x604
+SDL_JOYDEVICEADDED = 0x605
+SDL_JOYDEVICEREMOVED = 0x606
+SDL_CONTROLLERAXISMOTION = 0x650
+SDL_CONTROLLERBUTTONDOWN = 0x651
+SDL_CONTROLLERBUTTONUP = 0x652
+SDL_CONTROLLERDEVICEADDED = 0x653
+SDL_CONTROLLERDEVICEREMOVED = 0x654
+SDL_CONTROLLERDEVICEREMAPPED = 0x655
+SDL_FINGERDOWN = 0x700
+SDL_FINGERUP = 0x701
+SDL_FINGERMOTION = 0x702
+SDL_DOLLARGESTURE = 0x800
+SDL_DOLLARRECORD = 0x801
+SDL_MULTIGESTURE = 0x802
+SDL_CLIPBOARDUPDATE = 0x900
+SDL_DROPFILE = 0x1000
+SDL_USEREVENT = 0x8000
+SDL_LASTEVENT = 0xFFFF
+SDL_EventType = c_int
+
+class SDL_GenericEvent(Structure):
+    _fields_ = [("type", Uint32), ("timestamp", Uint32)]
+
+class SDL_WindowEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("windowID", Uint32),
+                ("event", Uint8),
+                ("padding1", Uint8),
+                ("padding2", Uint8),
+                ("padding3", Uint8),
+                ("data1", Sint32),
+                ("data2", Sint32)
+                ]
+
+class SDL_KeyboardEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("windowID", Uint32),
+                ("state", Uint8),
+                ("repeat", Uint8),
+                ("padding2", Uint8),
+                ("padding3", Uint8),
+                ("keysym", SDL_Keysym)
+                ]
+
+SDL_TEXTEDITINGEVENT_TEXT_SIZE = 32
+
+class SDL_TextEditingEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("windowID", Uint32),
+                ("text", (c_char * SDL_TEXTEDITINGEVENT_TEXT_SIZE)),
+                ("start", Sint32),
+                ("length", Sint32)
+                ]
+
+SDL_TEXTINPUTEVENT_TEXT_SIZE = 32
+class SDL_TextInputEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("windowID", Uint32),
+                ("text", (c_char * SDL_TEXTINPUTEVENT_TEXT_SIZE))
+                ]
+
+class SDL_MouseMotionEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("windowID", Uint32),
+                ("which", Uint32),
+                ("state", Uint8),
+                ("padding1", Uint8),
+                ("padding2", Uint8),
+                ("padding3", Uint8),
+                ("x", Sint32),
+                ("y", Sint32),
+                ("xrel", Sint32),
+                ("yrel", Sint32)
+                ]
+
+class SDL_MouseButtonEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("windowID", Uint32),
+                ("which", Uint32),
+                ("button", Uint8),
+                ("state", Uint8),
+                ("padding1", Uint8),
+                ("padding2", Uint8),
+                ("x", Sint32),
+                ("y", Sint32)
+                ]
+
+class SDL_MouseWheelEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("windowID", Uint32),
+                ("which", Uint32),
+                ("x", Sint32),
+                ("y", Sint32)
+                ]
+
+class SDL_JoyAxisEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("which", SDL_JoystickID),
+                ("axis", Uint8),
+                ("padding1", Uint8),
+                ("padding2", Uint8),
+                ("padding3", Uint8),
+                ("value", Sint16),
+                ("padding4", Uint16)
+                ]
+
+class SDL_JoyBallEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("which", SDL_JoystickID),
+                ("ball", Uint8),
+                ("padding1", Uint8),
+                ("padding2", Uint8),
+                ("padding3", Uint8),
+                ("xrel", Sint16),
+                ("yrel", Sint16)
+                ]
+
+class SDL_JoyHatEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("which", SDL_JoystickID),
+                ("hat", Uint8),
+                ("value", Uint8),
+                ("padding1", Uint8),
+                ("padding2", Uint8)
+                ]
+
+class SDL_JoyButtonEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("which", SDL_JoystickID),
+                ("button", Uint8),
+                ("state", Uint8),
+                ("padding1", Uint8),
+                ("padding2", Uint8)
+                ]
+
+class SDL_JoyDeviceEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("which", Sint32)
+                ]
+
+class SDL_ControllerAxisEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("which", SDL_JoystickID),
+                ("axis", Uint8),
+                ("padding1", Uint8),
+                ("padding2", Uint8),
+                ("padding3", Uint8),
+                ("value", Sint16),
+                ("padding4", Uint16)
+                ]
+
+class SDL_ControllerButtonEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("which", SDL_JoystickID),
+                ("button", Uint8),
+                ("state", Uint8),
+                ("padding1", Uint8),
+                ("padding2", Uint8)
+                ]
+
+class SDL_ControllerDeviceEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("which", Sint32)
+                ]
+
+class SDL_TouchFingerEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("touchId", SDL_TouchID),
+                ("fingerId", SDL_FingerID),
+                ("x", c_float),
+                ("y", c_float),
+                ("dx", c_float),
+                ("dy", c_float),
+                ("pressure", c_float)
+                ]
+
+class SDL_MultiGestureEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("touchId", SDL_TouchID),
+                ("dTheta", c_float),
+                ("dDist", c_float),
+                ("x", c_float),
+                ("y", c_float),
+                ("numFingers", Uint16),
+                ("padding", Uint16)
+                ]
+
+class SDL_DollarGestureEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("touchId", SDL_TouchID),
+                ("gestureId", SDL_GestureID),
+                ("numFingers", Uint32),
+                ("error", c_float),
+                ("x", c_float),
+                ("y", c_float)
+                ]
+
+class SDL_DropEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("file", c_char_p)
+                ]
+
+class SDL_QuitEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32)
+                ]
+
+class SDL_UserEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("windowID", Uint32),
+                ("code", Sint32),
+                ("data1", c_void_p),
+                ("data2", c_void_p)
+                ]
+
+# TODO
+class SDL_SysWMmsg(Structure):
+    pass
+
+class SDL_SysWMEvent(Structure):
+    _fields_ = [("type", Uint32),
+                ("timestamp", Uint32),
+                ("msg", POINTER(SDL_SysWMmsg))
+                ]
+
+class SDL_Event(Union):
+    _fields_ = [("type", Uint32),
+                ("generic", SDL_GenericEvent),
+                ("window", SDL_WindowEvent),
+                ("key", SDL_KeyboardEvent),
+                ("edit", SDL_TextEditingEvent),
+                ("text", SDL_TextInputEvent),
+                ("motion", SDL_MouseMotionEvent),
+                ("button", SDL_MouseButtonEvent),
+                ("wheel", SDL_MouseWheelEvent),
+                ("jaxis", SDL_JoyAxisEvent),
+                ("jball", SDL_JoyBallEvent),
+                ("jhat", SDL_JoyHatEvent),
+                ("jbutton", SDL_JoyButtonEvent),
+                ("jdevice", SDL_JoyDeviceEvent),
+                ("caxis", SDL_ControllerAxisEvent),
+                ("cbutton", SDL_ControllerButtonEvent),
+                ("cdevice", SDL_ControllerDeviceEvent),
+                ("quit", SDL_QuitEvent),
+                ("user", SDL_UserEvent),
+                ("syswm", SDL_SysWMEvent),
+                ("tfinger", SDL_TouchFingerEvent),
+                ("mgesture", SDL_MultiGestureEvent),
+                ("dgesture", SDL_DollarGestureEvent),
+                ("drop", SDL_DropEvent),
+                ("padding", (Uint8 * 56)),
+                ]
+
+SDL_PumpEvents = _bind("SDL_PumpEvents")
+SDL_ADDEVENT = 0
+SDL_PEEKEVENT = 1
+SDL_GETEVENT = 2
+SDL_eventaction = c_int
+SDL_PeepEvents = _bind("SDL_PeepEvents", [POINTER(SDL_Event), c_int, SDL_eventaction, Uint32, Uint32], c_int)
+SDL_HasEvent = _bind("SDL_HasEvent", [Uint32], SDL_bool)
+SDL_HasEvents = _bind("SDL_HasEvents", [Uint32, Uint32], SDL_bool)
+SDL_FlushEvent = _bind("SDL_FlushEvent", [Uint32])
+SDL_FlushEvents = _bind("SDL_FlushEvents", [Uint32, Uint32])
+SDL_PollEvent = _bind("SDL_PollEvent", [POINTER(SDL_Event)], c_int)
+SDL_WaitEvent = _bind("SDL_WaitEvent", [POINTER(SDL_Event)], c_int)
+SDL_WaitEventTimeout = _bind("SDL_WaitEventTimeout", [POINTER(SDL_Event), c_int], c_int)
+SDL_PushEvent = _bind("SDL_PushEvent", [POINTER(SDL_Event)], c_int)
+SDL_EventFilter = CFUNCTYPE(c_int, c_void_p, POINTER(SDL_Event))
+SDL_SetEventFilter = _bind("SDL_SetEventFilter", [SDL_EventFilter, c_void_p])
+SDL_GetEventFilter = _bind("SDL_GetEventFilter", [POINTER(SDL_EventFilter), POINTER(c_void_p)], SDL_bool)
+SDL_AddEventWatch = _bind("SDL_AddEventWatch", [SDL_EventFilter, c_void_p])
+SDL_DelEventWatch = _bind("SDL_DelEventWatch", [SDL_EventFilter, c_void_p])
+SDL_FilterEvents = _bind("SDL_FilterEvents", [SDL_EventFilter, c_void_p])
+SDL_QUERY = -1
+SDL_IGNORE = 0
+SDL_DISABLE = 0
+SDL_ENABLE = 1
+SDL_EventState = _bind("SDL_EventState", [Uint32, c_int], Uint8)
+SDL_GetEventState = lambda t: SDL_EventState(t, SDL_QUERY)
+SDL_RegisterEvents = _bind("SDL_RegisterEvents", [c_int], Uint32)
+
+
+# SDL_quit.h
+def SDL_QuitRequested():
+    SDL_PumpEvents()
+    return SDL_PeepEvents(None, 0, SDL_PEEKEVENT, SDL_QUIT, SDL_QUIT) > 0

sdl2/gamecontroller.py

-from ctypes import Structure, Union, c_int, c_char_p, POINTER
-from .dll import _bind
-from .stdinc import SDL_bool, Sint16, Uint8
-from .joystick import SDL_JoystickGUID, SDL_Joystick
-
-__all__ = ["SDL_GameController", "SDL_CONTROLLER_BINDTYPE_NONE",
-           "SDL_CONTROLLER_BINDTYPE_BUTTON", "SDL_CONTROLLER_BINDTYPE_AXIS",
-           "SDL_CONTROLLER_BINDTYPE_HAT", "SDL_GameControllerBindType",
-           "SDL_GameControllerButtonBind", "SDL_GameControllerAddMapping",
-           "SDL_GameControllerMappingForGUID", "SDL_GameControllerMapping",
-           "SDL_IsGameController", "SDL_GameControllerNameForIndex",
-           "SDL_GameControllerOpen", "SDL_GameControllerName",
-           "SDL_GameControllerGetAttached", "SDL_GameControllerGetJoystick",
-           "SDL_GameControllerEventState", "SDL_GameControllerUpdate",
-           "SDL_CONTROLLER_AXIS_INVALID", "SDL_CONTROLLER_AXIS_LEFTX",
-           "SDL_CONTROLLER_AXIS_LEFTY", "SDL_CONTROLLER_AXIS_RIGHTX",
-           "SDL_CONTROLLER_AXIS_RIGHTY", "SDL_CONTROLLER_AXIS_TRIGGERLEFT",
-           "SDL_CONTROLLER_AXIS_TRIGGERRIGHT", "SDL_CONTROLLER_AXIS_MAX",
-           "SDL_GameControllerAxis", "SDL_GameControllerGetAxisFromString",
-           "SDL_GameControllerGetStringForAxis",
-           "SDL_GameControllerGetBindForAxis", "SDL_GameControllerGetAxis",
-           "SDL_CONTROLLER_BUTTON_INVALID", "SDL_CONTROLLER_BUTTON_A",
-           "SDL_CONTROLLER_BUTTON_B", "SDL_CONTROLLER_BUTTON_X",
-           "SDL_CONTROLLER_BUTTON_Y", "SDL_CONTROLLER_BUTTON_BACK",
-           "SDL_CONTROLLER_BUTTON_GUIDE", "SDL_CONTROLLER_BUTTON_START",
-           "SDL_CONTROLLER_BUTTON_LEFTSTICK", "SDL_CONTROLLER_BUTTON_RIGHTSTICK",
-           "SDL_CONTROLLER_BUTTON_LEFTSHOULDER",
-           "SDL_CONTROLLER_BUTTON_RIGHTSHOULDER",
-           "SDL_CONTROLLER_BUTTON_DPAD_UP", "SDL_CONTROLLER_BUTTON_DPAD_DOWN",
-           "SDL_CONTROLLER_BUTTON_DPAD_LEFT", "SDL_CONTROLLER_BUTTON_DPAD_RIGHT",
-           "SDL_CONTROLLER_BUTTON_MAX", "SDL_GameControllerButton",
-           "SDL_GameControllerGetButtonFromString",
-           "SDL_GameControllerGetStringForButton",
-           "SDL_GameControllerGetBindForButton", "SDL_GameControllerGetButton",
-           "SDL_GameControllerClose"
-           ]
-
-class SDL_GameController(Structure):
-    pass
-
-SDL_CONTROLLER_BINDTYPE_NONE = 0
-SDL_CONTROLLER_BINDTYPE_BUTTON = 1
-SDL_CONTROLLER_BINDTYPE_AXIS = 2
-SDL_CONTROLLER_BINDTYPE_HAT = 3
-SDL_GameControllerBindType = c_int
-
-class _gchat(Structure):
-    _fields_ = [("hat", c_int), ("hat_mask", c_int)]
-
-class _gcvalue(Union):
-    _fields_ = [("button", c_int), ("axis", c_int), ("hat", _gchat)]
-
-class SDL_GameControllerButtonBind(Structure):
-    _fields_ = [("bindType", SDL_GameControllerBindType), ("value", _gcvalue)]
-
-SDL_GameControllerAddMapping = _bind("SDL_GameControllerAddMapping", [c_char_p], c_int)
-SDL_GameControllerMappingForGUID = _bind("SDL_GameControllerMappingForGUID", [SDL_JoystickGUID], c_char_p)
-SDL_GameControllerMapping = _bind("SDL_GameControllerMapping", [POINTER(SDL_GameController)], c_char_p)
-SDL_IsGameController = _bind("SDL_IsGameController", [c_int], SDL_bool)
-SDL_GameControllerNameForIndex = _bind("SDL_GameControllerNameForIndex", [c_int], c_char_p)
-SDL_GameControllerOpen = _bind("SDL_GameControllerOpen", [c_int], POINTER(SDL_GameController))
-SDL_GameControllerName = _bind("SDL_GameControllerName", [POINTER(SDL_GameController)], c_char_p)
-SDL_GameControllerGetAttached = _bind("SDL_GameControllerGetAttached", [POINTER(SDL_GameController)], SDL_bool)
-SDL_GameControllerGetJoystick = _bind("SDL_GameControllerGetJoystick", [POINTER(SDL_GameController)], POINTER(SDL_Joystick))
-SDL_GameControllerEventState = _bind("SDL_GameControllerEventState", [c_int], c_int)
-SDL_GameControllerUpdate = _bind("SDL_GameControllerUpdate")
-SDL_CONTROLLER_AXIS_INVALID = -1
-SDL_CONTROLLER_AXIS_LEFTX = 0
-SDL_CONTROLLER_AXIS_LEFTY = 1
-SDL_CONTROLLER_AXIS_RIGHTX = 2
-SDL_CONTROLLER_AXIS_RIGHTY = 3
-SDL_CONTROLLER_AXIS_TRIGGERLEFT = 4
-SDL_CONTROLLER_AXIS_TRIGGERRIGHT = 5
-SDL_CONTROLLER_AXIS_MAX = 6
-SDL_GameControllerAxis = c_int
-SDL_GameControllerGetAxisFromString = _bind("SDL_GameControllerGetAxisFromString", [c_char_p], SDL_GameControllerAxis)
-SDL_GameControllerGetStringForAxis = _bind("SDL_GameControllerGetStringForAxis", [SDL_GameControllerAxis], c_char_p)
-SDL_GameControllerGetBindForAxis = _bind("SDL_GameControllerGetBindForAxis", [POINTER(SDL_GameController), SDL_GameControllerAxis], SDL_GameControllerButtonBind)
-SDL_GameControllerGetAxis = _bind("SDL_GameControllerGetAxis", [POINTER(SDL_GameController), SDL_GameControllerAxis], Sint16)
-SDL_CONTROLLER_BUTTON_INVALID = -1
-SDL_CONTROLLER_BUTTON_A = 0
-SDL_CONTROLLER_BUTTON_B = 1
-SDL_CONTROLLER_BUTTON_X = 2
-SDL_CONTROLLER_BUTTON_Y = 3
-SDL_CONTROLLER_BUTTON_BACK = 4
-SDL_CONTROLLER_BUTTON_GUIDE = 5
-SDL_CONTROLLER_BUTTON_START = 6
-SDL_CONTROLLER_BUTTON_LEFTSTICK = 7
-SDL_CONTROLLER_BUTTON_RIGHTSTICK = 8
-SDL_CONTROLLER_BUTTON_LEFTSHOULDER = 9
-SDL_CONTROLLER_BUTTON_RIGHTSHOULDER = 10
-SDL_CONTROLLER_BUTTON_DPAD_UP = 11
-SDL_CONTROLLER_BUTTON_DPAD_DOWN = 12
-SDL_CONTROLLER_BUTTON_DPAD_LEFT = 13
-SDL_CONTROLLER_BUTTON_DPAD_RIGHT = 14
-SDL_CONTROLLER_BUTTON_MAX = 15
-SDL_GameControllerButton = c_int
-SDL_GameControllerGetButtonFromString = _bind("SDL_GameControllerGetButtonFromString", [c_char_p], SDL_GameControllerButton)
-SDL_GameControllerGetStringForButton = _bind("SDL_GameControllerGetStringForButton", [SDL_GameControllerButton], c_char_p)
-SDL_GameControllerGetBindForButton = _bind("SDL_GameControllerGetBindForButton", [POINTER(SDL_GameController), SDL_GameControllerButton], SDL_GameControllerButtonBind)
-SDL_GameControllerGetButton = _bind("SDL_GameControllerGetButton", [POINTER(SDL_GameController), SDL_GameControllerButton], Uint8)
-SDL_GameControllerClose = _bind("SDL_GameControllerClose", [POINTER(SDL_GameController)])
+from ctypes import Structure, Union, c_int, c_char_p, POINTER
+from .dll import _bind
+from .stdinc import SDL_bool, Sint16, Uint8
+from .joystick import SDL_JoystickGUID, SDL_Joystick
+
+__all__ = ["SDL_GameController", "SDL_CONTROLLER_BINDTYPE_NONE",
+           "SDL_CONTROLLER_BINDTYPE_BUTTON", "SDL_CONTROLLER_BINDTYPE_AXIS",
+           "SDL_CONTROLLER_BINDTYPE_HAT", "SDL_GameControllerBindType",
+           "SDL_GameControllerButtonBind", "SDL_GameControllerAddMapping",
+           "SDL_GameControllerMappingForGUID", "SDL_GameControllerMapping",
+           "SDL_IsGameController", "SDL_GameControllerNameForIndex",
+           "SDL_GameControllerOpen", "SDL_GameControllerName",
+           "SDL_GameControllerGetAttached", "SDL_GameControllerGetJoystick",
+           "SDL_GameControllerEventState", "SDL_GameControllerUpdate",
+           "SDL_CONTROLLER_AXIS_INVALID", "SDL_CONTROLLER_AXIS_LEFTX",
+           "SDL_CONTROLLER_AXIS_LEFTY", "SDL_CONTROLLER_AXIS_RIGHTX",
+           "SDL_CONTROLLER_AXIS_RIGHTY", "SDL_CONTROLLER_AXIS_TRIGGERLEFT",
+           "SDL_CONTROLLER_AXIS_TRIGGERRIGHT", "SDL_CONTROLLER_AXIS_MAX",
+           "SDL_GameControllerAxis", "SDL_GameControllerGetAxisFromString",
+           "SDL_GameControllerGetStringForAxis",
+           "SDL_GameControllerGetBindForAxis", "SDL_GameControllerGetAxis",
+           "SDL_CONTROLLER_BUTTON_INVALID", "SDL_CONTROLLER_BUTTON_A",
+           "SDL_CONTROLLER_BUTTON_B", "SDL_CONTROLLER_BUTTON_X",
+           "SDL_CONTROLLER_BUTTON_Y", "SDL_CONTROLLER_BUTTON_BACK",
+           "SDL_CONTROLLER_BUTTON_GUIDE", "SDL_CONTROLLER_BUTTON_START",
+           "SDL_CONTROLLER_BUTTON_LEFTSTICK", "SDL_CONTROLLER_BUTTON_RIGHTSTICK",
+           "SDL_CONTROLLER_BUTTON_LEFTSHOULDER",
+           "SDL_CONTROLLER_BUTTON_RIGHTSHOULDER",
+           "SDL_CONTROLLER_BUTTON_DPAD_UP", "SDL_CONTROLLER_BUTTON_DPAD_DOWN",
+           "SDL_CONTROLLER_BUTTON_DPAD_LEFT", "SDL_CONTROLLER_BUTTON_DPAD_RIGHT",
+           "SDL_CONTROLLER_BUTTON_MAX", "SDL_GameControllerButton",
+           "SDL_GameControllerGetButtonFromString",
+           "SDL_GameControllerGetStringForButton",
+           "SDL_GameControllerGetBindForButton", "SDL_GameControllerGetButton",
+           "SDL_GameControllerClose"
+           ]
+
+class SDL_GameController(Structure):
+    pass
+
+SDL_CONTROLLER_BINDTYPE_NONE = 0
+SDL_CONTROLLER_BINDTYPE_BUTTON = 1
+SDL_CONTROLLER_BINDTYPE_AXIS = 2
+SDL_CONTROLLER_BINDTYPE_HAT = 3
+SDL_GameControllerBindType = c_int
+
+class _gchat(Structure):
+    _fields_ = [("hat", c_int), ("hat_mask", c_int)]
+
+class _gcvalue(Union):
+    _fields_ = [("button", c_int), ("axis", c_int), ("hat", _gchat)]
+
+class SDL_GameControllerButtonBind(Structure):
+    _fields_ = [("bindType", SDL_GameControllerBindType), ("value", _gcvalue)]
+
+SDL_GameControllerAddMapping = _bind("SDL_GameControllerAddMapping", [c_char_p], c_int)
+SDL_GameControllerMappingForGUID = _bind("SDL_GameControllerMappingForGUID", [SDL_JoystickGUID], c_char_p)
+SDL_GameControllerMapping = _bind("SDL_GameControllerMapping", [POINTER(SDL_GameController)], c_char_p)
+SDL_IsGameController = _bind("SDL_IsGameController", [c_int], SDL_bool)
+SDL_GameControllerNameForIndex = _bind("SDL_GameControllerNameForIndex", [c_int], c_char_p)
+SDL_GameControllerOpen = _bind("SDL_GameControllerOpen", [c_int], POINTER(SDL_GameController))
+SDL_GameControllerName = _bind("SDL_GameControllerName", [POINTER(SDL_GameController)], c_char_p)
+SDL_GameControllerGetAttached = _bind("SDL_GameControllerGetAttached", [POINTER(SDL_GameController)], SDL_bool)
+SDL_GameControllerGetJoystick = _bind("SDL_GameControllerGetJoystick", [POINTER(SDL_GameController)], POINTER(SDL_Joystick))
+SDL_GameControllerEventState = _bind("SDL_GameControllerEventState", [c_int], c_int)
+SDL_GameControllerUpdate = _bind("SDL_GameControllerUpdate")
+SDL_CONTROLLER_AXIS_INVALID = -1
+SDL_CONTROLLER_AXIS_LEFTX = 0
+SDL_CONTROLLER_AXIS_LEFTY = 1
+SDL_CONTROLLER_AXIS_RIGHTX = 2
+SDL_CONTROLLER_AXIS_RIGHTY = 3
+SDL_CONTROLLER_AXIS_TRIGGERLEFT = 4
+SDL_CONTROLLER_AXIS_TRIGGERRIGHT = 5
+SDL_CONTROLLER_AXIS_MAX = 6
+SDL_GameControllerAxis = c_int
+SDL_GameControllerGetAxisFromString = _bind("SDL_GameControllerGetAxisFromString", [c_char_p], SDL_GameControllerAxis)
+SDL_GameControllerGetStringForAxis = _bind("SDL_GameControllerGetStringForAxis", [SDL_GameControllerAxis], c_char_p)
+SDL_GameControllerGetBindForAxis = _bind("SDL_GameControllerGetBindForAxis", [POINTER(SDL_GameController), SDL_GameControllerAxis], SDL_GameControllerButtonBind)
+SDL_GameControllerGetAxis = _bind("SDL_GameControllerGetAxis", [POINTER(SDL_GameController), SDL_GameControllerAxis], Sint16)
+SDL_CONTROLLER_BUTTON_INVALID = -1
+SDL_CONTROLLER_BUTTON_A = 0
+SDL_CONTROLLER_BUTTON_B = 1
+SDL_CONTROLLER_BUTTON_X = 2
+SDL_CONTROLLER_BUTTON_Y = 3
+SDL_CONTROLLER_BUTTON_BACK = 4
+SDL_CONTROLLER_BUTTON_GUIDE = 5
+SDL_CONTROLLER_BUTTON_START = 6
+SDL_CONTROLLER_BUTTON_LEFTSTICK = 7
+SDL_CONTROLLER_BUTTON_RIGHTSTICK = 8
+SDL_CONTROLLER_BUTTON_LEFTSHOULDER = 9
+SDL_CONTROLLER_BUTTON_RIGHTSHOULDER = 10
+SDL_CONTROLLER_BUTTON_DPAD_UP = 11
+SDL_CONTROLLER_BUTTON_DPAD_DOWN = 12
+SDL_CONTROLLER_BUTTON_DPAD_LEFT = 13
+SDL_CONTROLLER_BUTTON_DPAD_RIGHT = 14
+SDL_CONTROLLER_BUTTON_MAX = 15
+SDL_GameControllerButton = c_int
+SDL_GameControllerGetButtonFromString = _bind("SDL_GameControllerGetButtonFromString", [c_char_p], SDL_GameControllerButton)
+SDL_GameControllerGetStringForButton = _bind("SDL_GameControllerGetStringForButton", [SDL_GameControllerButton], c_char_p)
+SDL_GameControllerGetBindForButton = _bind("SDL_GameControllerGetBindForButton", [POINTER(SDL_GameController), SDL_GameControllerButton], SDL_GameControllerButtonBind)
+SDL_GameControllerGetButton = _bind("SDL_GameControllerGetButton", [POINTER(SDL_GameController), SDL_GameControllerButton], Uint8)
+SDL_GameControllerClose = _bind("SDL_GameControllerClose", [POINTER(SDL_GameController)])
-from ctypes import c_int, POINTER
-from .dll import _bind
-from .stdinc import Sint64
-from .touch import SDL_TouchID
-from .rwops import SDL_RWops
-
-__all__ = ["SDL_GestureID", "SDL_RecordGesture", "SDL_SaveAllDollarTemplates",
-           "SDL_SaveDollarTemplate", "SDL_LoadDollarTemplates"
-           ]
-
-SDL_GestureID = Sint64
-SDL_RecordGesture = _bind("SDL_RecordGesture", [SDL_TouchID], c_int)
-SDL_SaveAllDollarTemplates = _bind("SDL_SaveAllDollarTemplates", [POINTER(SDL_RWops)], c_int)
-SDL_SaveDollarTemplate = _bind("SDL_SaveDollarTemplate", [SDL_GestureID, POINTER(SDL_RWops)], c_int)
-SDL_LoadDollarTemplates = _bind("SDL_LoadDollarTemplates", [SDL_TouchID, POINTER(SDL_RWops)], c_int)
+from ctypes import c_int, POINTER
+from .dll import _bind
+from .stdinc import Sint64
+from .touch import SDL_TouchID
+from .rwops import SDL_RWops
+
+__all__ = ["SDL_GestureID", "SDL_RecordGesture", "SDL_SaveAllDollarTemplates",
+           "SDL_SaveDollarTemplate", "SDL_LoadDollarTemplates"
+           ]
+
+SDL_GestureID = Sint64
+SDL_RecordGesture = _bind("SDL_RecordGesture", [SDL_TouchID], c_int)
+SDL_SaveAllDollarTemplates = _bind("SDL_SaveAllDollarTemplates", [POINTER(SDL_RWops)], c_int)
+SDL_SaveDollarTemplate = _bind("SDL_SaveDollarTemplate", [SDL_GestureID, POINTER(SDL_RWops)], c_int)
+SDL_LoadDollarTemplates = _bind("SDL_LoadDollarTemplates", [SDL_TouchID, POINTER(SDL_RWops)], c_int)
-from ctypes import Structure, Union, POINTER, c_int, c_uint, c_float, c_char_p
-from .dll import _bind
-from .stdinc import Uint8, Uint16, Uint32, Sint16, Sint32
-from .joystick import SDL_Joystick
-
-__all__ = ["SDL_Haptic", "SDL_HAPTIC_CONSTANT", "SDL_HAPTIC_SINE",
-           "SDL_HAPTIC_SQUARE", "SDL_HAPTIC_TRIANGLE", "SDL_HAPTIC_SAWTOOTHUP",
-           "SDL_HAPTIC_SAWTOOTHDOWN", "SDL_HAPTIC_RAMP", "SDL_HAPTIC_SPRING",
-           "SDL_HAPTIC_DAMPER", "SDL_HAPTIC_INERTIA", "SDL_HAPTIC_FRICTION",
-           "SDL_HAPTIC_CUSTOM", "SDL_HAPTIC_GAIN", "SDL_HAPTIC_AUTOCENTER",
-           "SDL_HAPTIC_STATUS", "SDL_HAPTIC_PAUSE", "SDL_HAPTIC_POLAR",
-           "SDL_HAPTIC_CARTESIAN", "SDL_HAPTIC_SPHERICAL", "SDL_HAPTIC_INFINITY",
-           "SDL_HapticDirection", "SDL_HapticConstant", "SDL_HapticPeriodic",
-           "SDL_HapticCondition", "SDL_HapticRamp", "SDL_HapticCustom",
-           "SDL_HapticEffect", "SDL_NumHaptics", "SDL_HapticName",
-           "SDL_HapticOpen", "SDL_HapticOpened", "SDL_HapticIndex",
-           "SDL_MouseIsHaptic", "SDL_HapticOpenFromMouse",
-           "SDL_JoystickIsHaptic", "SDL_HapticOpenFromJoystick",
-           "SDL_HapticClose", "SDL_HapticNumEffects",
-           "SDL_HapticNumEffectsPlaying", "SDL_HapticQuery", "SDL_HapticNumAxes",
-           "SDL_HapticEffectSupported", "SDL_HapticNewEffect",
-           "SDL_HapticUpdateEffect", "SDL_HapticRunEffect",
-           "SDL_HapticStopEffect", "SDL_HapticDestroyEffect",
-           "SDL_HapticGetEffectStatus", "SDL_HapticSetGain",
-           "SDL_HapticSetAutocenter", "SDL_HapticPause", "SDL_HapticUnpause",
-           "SDL_HapticStopAll", "SDL_HapticRumbleSupported",
-           "SDL_HapticRumbleInit", "SDL_HapticRumblePlay",
-           "SDL_HapticRumbleStop"
-           ]
-
-class SDL_Haptic(Structure):
-    pass
-
-SDL_HAPTIC_CONSTANT = 1 << 0
-SDL_HAPTIC_SINE = 1 << 1
-SDL_HAPTIC_SQUARE = 1 << 2
-SDL_HAPTIC_TRIANGLE = 1 << 3
-SDL_HAPTIC_SAWTOOTHUP = 1 << 4
-SDL_HAPTIC_SAWTOOTHDOWN = 1 << 5
-SDL_HAPTIC_RAMP = 1 << 6
-SDL_HAPTIC_SPRING = 1 << 7
-SDL_HAPTIC_DAMPER = 1 << 8
-SDL_HAPTIC_INERTIA = 1 << 9
-SDL_HAPTIC_FRICTION = 1 << 10
-SDL_HAPTIC_CUSTOM = 1 << 11
-SDL_HAPTIC_GAIN = 1 << 12
-SDL_HAPTIC_AUTOCENTER = 1 << 13
-SDL_HAPTIC_STATUS = 1 << 14
-SDL_HAPTIC_PAUSE = 1 << 15
-SDL_HAPTIC_POLAR = 0
-SDL_HAPTIC_CARTESIAN = 1
-SDL_HAPTIC_SPHERICAL = 2
-SDL_HAPTIC_INFINITY = 4294967295
-
-class SDL_HapticDirection(Structure):
-    _fields_ = [("type", Uint8), ("dir", (Sint32 * 3))]
-
-class SDL_HapticConstant(Structure):
-    _fields_ = [("type", Uint16),
-                ("direction", SDL_HapticDirection),
-                ("length", Uint32),
-                ("delay", Uint16),
-                ("button", Uint16),
-                ("interval", Uint16),
-                ("level", Sint16),
-                ("attack_length", Uint16),
-                ("attack_level", Uint16),
-                ("fade_length", Uint16),
-                ("fade_level", Uint16),
-                ]
-
-
-class SDL_HapticPeriodic(Structure):
-    _fields_ = [("type", Uint16),
-                ("direction", SDL_HapticDirection),
-                ("length", Uint32),
-                ("delay", Uint16),
-                ("button", Uint16),
-                ("interval", Uint16),
-                ("period", Uint16),
-                ("magnitude", Sint16),
-                ("offset", Sint16),
-                ("phase", Uint16),
-                ("attack_length", Uint16),
-                ("attack_level", Uint16),
-                ("fade_length", Uint16),
-                ("fade_level", Uint16),
-                ]
-
-
-class SDL_HapticCondition(Structure):
-    """A conditionally running effect."""
-    _fields_ = [("type", Uint16),
-                ("direction", SDL_HapticDirection),
-                ("length", Uint32),
-                ("delay", Uint16),
-                ("button", Uint16),
-                ("interval", Uint16),
-                ("right_sat", (Uint16 * 3)),
-                ("left_sat", (Uint16 * 3)),
-                ("right_coeff", (Sint16 * 3)),
-                ("left_coeff", (Sint16 * 3)),
-                ("deadband", (Uint16 * 3)),
-                ("center", (Sint16 * 3)),
-                ]
-
-
-class SDL_HapticRamp(Structure):
-    """A ramp-like effect."""
-    _fields_ = [("type", Uint16),
-                ("direction", SDL_HapticDirection),
-                ("length", Uint32),
-                ("delay", Uint16),
-                ("button", Uint16),
-                ("interval", Uint16),
-                ("start", Sint16),
-                ("end", Sint16),
-                ("attack_length", Uint16),
-                ("attack_level", Uint16),
-                ("fade_length", Uint16),
-                ("fade_level", Uint16),
-                ]
-
-
-class SDL_HapticCustom(Structure):
-    """A custom effect."""
-    _fields_ = [("type", Uint16),
-                ("direction", SDL_HapticDirection),
-                ("length", Uint32),
-                ("delay", Uint16),
-                ("button", Uint16),
-                ("interval", Uint16),
-                ("channels", Uint8),
-                ("period", Uint16),
-                ("samples", Uint16),
-                ("data", POINTER(Uint16)),
-                ("attack_length", Uint16),
-                ("attack_level", Uint16),
-                ("fade_length", Uint16),
-                ("fade_level", Uint16),
-                ]
-
-
-class SDL_HapticEffect(Union):
-    """A generic haptic effect, containing the concrete haptic effect."""
-    _fields_ = [("type", Uint16),
-                ("constant", SDL_HapticConstant),
-                ("periodic", SDL_HapticPeriodic),
-                ("condition", SDL_HapticCondition),
-                ("ramp", SDL_HapticRamp),
-                ("custom", SDL_HapticCustom),
-                ]
-
-SDL_NumHaptics = _bind("SDL_NumHaptics", None, c_int)
-SDL_HapticName = _bind("SDL_HapticName", [c_int], c_char_p)
-SDL_HapticOpen = _bind("SDL_HapticOpen", [c_int], POINTER(SDL_Haptic))
-SDL_HapticOpened = _bind("SDL_HapticOpened", [c_int], c_int)
-SDL_HapticIndex = _bind("SDL_HapticIndex", [POINTER(SDL_Haptic)], c_int)
-SDL_MouseIsHaptic = _bind("SDL_MouseIsHaptic", None, c_int)
-SDL_HapticOpenFromMouse = _bind("SDL_HapticOpenFromMouse", None, POINTER(SDL_Haptic))
-SDL_JoystickIsHaptic = _bind("SDL_JoystickIsHaptic", [POINTER(SDL_Joystick)], c_int)
-SDL_HapticOpenFromJoystick = _bind("SDL_HapticOpenFromJoystick", [POINTER(SDL_Joystick)], POINTER(SDL_Haptic))
-SDL_HapticClose = _bind("SDL_HapticClose", [POINTER(SDL_Haptic)])
-SDL_HapticNumEffects = _bind("SDL_HapticNumEffects", [POINTER(SDL_Haptic)], c_int)
-SDL_HapticNumEffectsPlaying = _bind("SDL_HapticNumEffectsPlaying", [POINTER(SDL_Haptic)], c_int)
-SDL_HapticQuery = _bind("SDL_HapticQuery", [POINTER(SDL_Haptic)], c_uint)
-SDL_HapticNumAxes = _bind("SDL_HapticNumAxes", [POINTER(SDL_Haptic)], c_int)
-SDL_HapticEffectSupported = _bind("SDL_HapticEffectSupported", [POINTER(SDL_Haptic), POINTER(SDL_HapticEffect)], c_int)
-SDL_HapticNewEffect = _bind("SDL_HapticNewEffect", [POINTER(SDL_Haptic), POINTER(SDL_HapticEffect)], c_int)
-SDL_HapticUpdateEffect = _bind("SDL_HapticUpdateEffect", [POINTER(SDL_Haptic), c_int, POINTER(SDL_HapticEffect)], c_int)
-SDL_HapticRunEffect = _bind("SDL_HapticRunEffect", [POINTER(SDL_Haptic), c_int, Uint32], c_int)
-SDL_HapticStopEffect = _bind("SDL_HapticStopEffect", [POINTER(SDL_Haptic), c_int], c_int)
-SDL_HapticDestroyEffect = _bind("SDL_HapticDestroyEffect", [POINTER(SDL_Haptic), c_int])
-SDL_HapticGetEffectStatus = _bind("SDL_HapticGetEffectStatus", [POINTER(SDL_Haptic), c_int], c_int)
-SDL_HapticSetGain = _bind("SDL_HapticSetGain", [POINTER(SDL_Haptic), c_int], c_int)
-SDL_HapticSetAutocenter = _bind("SDL_HapticSetAutocenter", [POINTER(SDL_Haptic), c_int], c_int)
-SDL_HapticPause = _bind("SDL_HapticPause", [POINTER(SDL_Haptic)], c_int)
-SDL_HapticUnpause = _bind("SDL_HapticUnpause", [POINTER(SDL_Haptic)], c_int)
-SDL_HapticStopAll = _bind("SDL_HapticStopAll", [POINTER(SDL_Haptic)], c_int)
-SDL_HapticRumbleSupported = _bind("SDL_HapticRumbleSupported", [POINTER(SDL_Haptic)], c_int)
-SDL_HapticRumbleInit = _bind("SDL_HapticRumbleInit", [POINTER(SDL_Haptic)], c_int)
-SDL_HapticRumblePlay = _bind("SDL_HapticRumblePlay", [POINTER(SDL_Haptic), c_float, Uint32], c_int)
-SDL_HapticRumbleStop = _bind("SDL_HapticRumbleStop", [POINTER(SDL_Haptic)], c_int)
-
+from ctypes import Structure, Union, POINTER, c_int, c_uint, c_float, c_char_p
+from .dll import _bind
+from .stdinc import Uint8, Uint16, Uint32, Sint16, Sint32
+from .joystick import SDL_Joystick
+
+__all__ = ["SDL_Haptic", "SDL_HAPTIC_CONSTANT", "SDL_HAPTIC_SINE",
+           "SDL_HAPTIC_SQUARE", "SDL_HAPTIC_TRIANGLE", "SDL_HAPTIC_SAWTOOTHUP",
+           "SDL_HAPTIC_SAWTOOTHDOWN", "SDL_HAPTIC_RAMP", "SDL_HAPTIC_SPRING",
+           "SDL_HAPTIC_DAMPER", "SDL_HAPTIC_INERTIA", "SDL_HAPTIC_FRICTION",
+           "SDL_HAPTIC_CUSTOM", "SDL_HAPTIC_GAIN", "SDL_HAPTIC_AUTOCENTER",
+           "SDL_HAPTIC_STATUS", "SDL_HAPTIC_PAUSE", "SDL_HAPTIC_POLAR",
+           "SDL_HAPTIC_CARTESIAN", "SDL_HAPTIC_SPHERICAL", "SDL_HAPTIC_INFINITY",
+           "SDL_HapticDirection", "SDL_HapticConstant", "SDL_HapticPeriodic",
+           "SDL_HapticCondition", "SDL_HapticRamp", "SDL_HapticCustom",
+           "SDL_HapticEffect", "SDL_NumHaptics", "SDL_HapticName",
+           "SDL_HapticOpen", "SDL_HapticOpened", "SDL_HapticIndex",
+           "SDL_MouseIsHaptic", "SDL_HapticOpenFromMouse",
+           "SDL_JoystickIsHaptic", "SDL_HapticOpenFromJoystick",
+           "SDL_HapticClose", "SDL_HapticNumEffects",
+           "SDL_HapticNumEffectsPlaying", "SDL_HapticQuery", "SDL_HapticNumAxes",
+           "SDL_HapticEffectSupported", "SDL_HapticNewEffect",
+           "SDL_HapticUpdateEffect", "SDL_HapticRunEffect",
+           "SDL_HapticStopEffect", "SDL_HapticDestroyEffect",
+           "SDL_HapticGetEffectStatus", "SDL_HapticSetGain",
+           "SDL_HapticSetAutocenter", "SDL_HapticPause", "SDL_HapticUnpause",
+           "SDL_HapticStopAll", "SDL_HapticRumbleSupported",
+           "SDL_HapticRumbleInit", "SDL_HapticRumblePlay",
+           "SDL_HapticRumbleStop"
+           ]
+
+class SDL_Haptic(Structure):
+    pass
+
+SDL_HAPTIC_CONSTANT = 1 << 0
+SDL_HAPTIC_SINE = 1 << 1
+SDL_HAPTIC_SQUARE = 1 << 2
+SDL_HAPTIC_TRIANGLE = 1 << 3
+SDL_HAPTIC_SAWTOOTHUP = 1 << 4
+SDL_HAPTIC_SAWTOOTHDOWN = 1 << 5
+SDL_HAPTIC_RAMP = 1 << 6
+SDL_HAPTIC_SPRING = 1 << 7
+SDL_HAPTIC_DAMPER = 1 << 8
+SDL_HAPTIC_INERTIA = 1 << 9
+SDL_HAPTIC_FRICTION = 1 << 10
+SDL_HAPTIC_CUSTOM = 1 << 11
+SDL_HAPTIC_GAIN = 1 << 12
+SDL_HAPTIC_AUTOCENTER = 1 << 13
+SDL_HAPTIC_STATUS = 1 << 14
+SDL_HAPTIC_PAUSE = 1 << 15
+SDL_HAPTIC_POLAR = 0
+SDL_HAPTIC_CARTESIAN = 1
+SDL_HAPTIC_SPHERICAL = 2
+SDL_HAPTIC_INFINITY = 4294967295
+
+class SDL_HapticDirection(Structure):
+    _fields_ = [("type", Uint8), ("dir", (Sint32 * 3))]
+
+class SDL_HapticConstant(Structure):
+    _fields_ = [("type", Uint16),
+                ("direction", SDL_HapticDirection),
+                ("length", Uint32),
+                ("delay", Uint16),
+                ("button", Uint16),
+                ("interval", Uint16),
+                ("level", Sint16),
+                ("attack_length", Uint16),
+                ("attack_level", Uint16),
+                ("fade_length", Uint16),
+                ("fade_level", Uint16),
+                ]
+
+
+class SDL_HapticPeriodic(Structure):
+    _fields_ = [("type", Uint16),
+                ("direction", SDL_HapticDirection),
+                ("length", Uint32),
+                ("delay", Uint16),
+                ("button", Uint16),
+                ("interval", Uint16),
+                ("period", Uint16),
+                ("magnitude", Sint16),
+                ("offset", Sint16),
+                ("phase", Uint16),
+                ("attack_length", Uint16),
+                ("attack_level", Uint16),
+                ("fade_length", Uint16),
+                ("fade_level", Uint16),
+                ]
+
+
+class SDL_HapticCondition(Structure):
+    """A conditionally running effect."""
+    _fields_ = [("type", Uint16),
+                ("direction", SDL_HapticDirection),
+                ("length", Uint32),
+                ("delay", Uint16),
+                ("button", Uint16),
+                ("interval", Uint16),
+                ("right_sat", (Uint16 * 3)),
+                ("left_sat", (Uint16 * 3)),
+                ("right_coeff", (Sint16 * 3)),
+                ("left_coeff", (Sint16 * 3)),
+                ("deadband", (Uint16 * 3)),
+                ("center", (Sint16 * 3)),
+                ]
+
+
+class SDL_HapticRamp(Structure):
+    """A ramp-like effect."""
+    _fields_ = [("type", Uint16),
+                ("direction", SDL_HapticDirection),