mirror of
https://github.com/mupen64plus/mupen64plus-ui-python.git
synced 2025-04-02 10:51:53 -04:00
add SDL2 library
This commit is contained in:
parent
bcc7edcbec
commit
64157a5c60
58 changed files with 3972 additions and 0 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
65
src/m64py/SDL2/__init__.py
Normal file
65
src/m64py/SDL2/__init__.py
Normal file
|
@ -0,0 +1,65 @@
|
|||
"""SDL2 wrapper package"""
|
||||
from .dll import get_dll_file, _bind
|
||||
from ctypes import c_int as _cint
|
||||
|
||||
from .audio import *
|
||||
from .blendmode import *
|
||||
from .clipboard import *
|
||||
from .cpuinfo import *
|
||||
from .endian import *
|
||||
from .error import *
|
||||
from .events import *
|
||||
from .filesystem 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 *
|
||||
|
||||
# At least Win32 platforms need this now.
|
||||
_SDL_SetMainReady = _bind("SDL_SetMainReady")
|
||||
_SDL_SetMainReady()
|
||||
|
||||
|
||||
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_EVENTS = 0x00004000
|
||||
SDL_INIT_NOPARACHUTE = 0x00100000
|
||||
SDL_INIT_EVERYTHING = (SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO |
|
||||
SDL_INIT_EVENTS | SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC |
|
||||
SDL_INIT_GAMECONTROLLER)
|
||||
|
||||
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.6.0"
|
||||
version_info = (0, 6, 0, "")
|
162
src/m64py/SDL2/audio.py
Normal file
162
src/m64py/SDL2/audio.py
Normal file
|
@ -0,0 +1,162 @@
|
|||
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])
|
||||
|
11
src/m64py/SDL2/blendmode.py
Normal file
11
src/m64py/SDL2/blendmode.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
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
|
10
src/m64py/SDL2/clipboard.py
Normal file
10
src/m64py/SDL2/clipboard.py
Normal file
|
@ -0,0 +1,10 @@
|
|||
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)
|
22
src/m64py/SDL2/cpuinfo.py
Normal file
22
src/m64py/SDL2/cpuinfo.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
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)
|
112
src/m64py/SDL2/dll.py
Normal file
112
src/m64py/SDL2/dll.py
Normal file
|
@ -0,0 +1,112 @@
|
|||
"""DLL wrapper"""
|
||||
import os
|
||||
import sys
|
||||
import warnings
|
||||
from ctypes import CDLL
|
||||
#from ctypes.util import find_library
|
||||
from m64py.loader import find_library
|
||||
|
||||
__all__ = ["get_dll_file"]
|
||||
|
||||
|
||||
def _findlib(libnames, path=None):
|
||||
"""."""
|
||||
platform = sys.platform
|
||||
if platform in ("win32", "cli"):
|
||||
pattern = "%s.dll"
|
||||
elif platform == "darwin":
|
||||
pattern = "lib%s.dylib"
|
||||
else:
|
||||
pattern = "lib%s.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, pattern % libname)
|
||||
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;%s" % (path, os.environ["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:
|
||||
if optfunc:
|
||||
#warnings.warn\
|
||||
# ("function '%s' not found in %r, using replacement" %
|
||||
# (funcname, self._dll))
|
||||
func = _nonexistent(funcname, optfunc)
|
||||
else:
|
||||
raise ValueError("could not find function '%s' in %r" %
|
||||
(funcname, self._dll))
|
||||
func.argtypes = args
|
||||
func.restype = returns
|
||||
return func
|
||||
|
||||
@property
|
||||
def libfile(self):
|
||||
"""Gets the filename of the loaded library."""
|
||||
return self._libfile
|
||||
|
||||
def _nonexistent(funcname, func):
|
||||
"""A simple wrapper to mark functions and methods as nonexistent."""
|
||||
def wrapper(*fargs, **kw):
|
||||
warnings.warn("%s does not exist" % funcname,
|
||||
category=RuntimeWarning, stacklevel=2)
|
||||
return func(*fargs, **kw)
|
||||
wrapper.__name__ = func.__name__
|
||||
return wrapper
|
||||
|
||||
|
||||
try:
|
||||
dll = _DLL("SDL2", ["SDL2", "SDL2-2.0"], os.getenv("PYSDL2_DLL_PATH"))
|
||||
except RuntimeError as exc:
|
||||
raise ImportError(exc)
|
||||
|
||||
def nullfunc(*args):
|
||||
"""A simple no-op function to be used as dll replacement."""
|
||||
return
|
||||
|
||||
def get_dll_file():
|
||||
"""Gets the file name of the loaded SDL2 library."""
|
||||
return dll.libfile
|
||||
|
||||
_bind = dll.bind_function
|
48
src/m64py/SDL2/endian.py
Normal file
48
src/m64py/SDL2/endian.py
Normal file
|
@ -0,0 +1,48 @@
|
|||
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
|
24
src/m64py/SDL2/error.py
Normal file
24
src/m64py/SDL2/error.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
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))
|
377
src/m64py/SDL2/events.py
Normal file
377
src/m64py/SDL2/events.py
Normal file
|
@ -0,0 +1,377 @@
|
|||
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_APP_TERMINATING",
|
||||
"SDL_APP_LOWMEMORY", "SDL_APP_WILLENTERBACKGROUND",
|
||||
"SDL_APP_DIDENTERBACKGROUND", "SDL_APP_WILLENTERFOREGROUND",
|
||||
"SDL_APP_DIDENTERFOREGROUND", "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_APP_TERMINATING = 0x101
|
||||
SDL_APP_LOWMEMORY = 0x102
|
||||
SDL_APP_WILLENTERBACKGROUND = 0x103
|
||||
SDL_APP_DIDENTERBACKGROUND = 0x104
|
||||
SDL_APP_WILLENTERFOREGROUND = 0x105
|
||||
SDL_APP_DIDENTERFOREGROUND = 0x106
|
||||
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", Uint32),
|
||||
("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_OSEvent(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
|
9
src/m64py/SDL2/filesystem.py
Normal file
9
src/m64py/SDL2/filesystem.py
Normal file
|
@ -0,0 +1,9 @@
|
|||
from ctypes import c_char, c_char_p, POINTER
|
||||
from .dll import _bind, nullfunc
|
||||
|
||||
__all__ = ["SDL_GetBasePath", "SDL_GetPrefPath"]
|
||||
|
||||
# The filesystem API came in after the 2.0 release
|
||||
SDL_GetBasePath = _bind("SDL_GetBasePath", None, POINTER(c_char), nullfunc)
|
||||
SDL_GetPrefPath = _bind("SDL_GetPrefPath", [c_char_p, c_char_p], POINTER(c_char),
|
||||
nullfunc)
|
102
src/m64py/SDL2/gamecontroller.py
Normal file
102
src/m64py/SDL2/gamecontroller.py
Normal file
|
@ -0,0 +1,102 @@
|
|||
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)])
|
15
src/m64py/SDL2/gesture.py
Normal file
15
src/m64py/SDL2/gesture.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
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)
|
193
src/m64py/SDL2/haptic.py
Normal file
193
src/m64py/SDL2/haptic.py
Normal file
|
@ -0,0 +1,193 @@
|
|||
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_LEFTRIGHT", "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_HapticLeftRight", "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_LEFTRIGHT = 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_HapticLeftRight(Structure):
|
||||
"""A left-right effect."""
|
||||
_fields_ = [("type", Uint16),
|
||||
("length", Uint32),
|
||||
("large_magnitude", Uint16),
|
||||
("small_magnitude", 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)
|
46
src/m64py/SDL2/hints.py
Normal file
46
src/m64py/SDL2/hints.py
Normal file
|
@ -0,0 +1,46 @@
|
|||
from ctypes import CFUNCTYPE, c_int, c_char_p, c_void_p
|
||||
from .dll import _bind
|
||||
from .stdinc import SDL_bool
|
||||
|
||||
__all__ = ["SDL_HINT_FRAMEBUFFER_ACCELERATION", "SDL_HINT_RENDER_DRIVER",
|
||||
"SDL_HINT_RENDER_OPENGL_SHADERS", "SDL_HINT_RENDER_SCALE_QUALITY",
|
||||
"SDL_HINT_RENDER_VSYNC", "SDL_HINT_VIDEO_X11_XVIDMODE",
|
||||
"SDL_HINT_VIDEO_X11_XINERAMA", "SDL_HINT_VIDEO_X11_XRANDR",
|
||||
"SDL_HINT_GRAB_KEYBOARD", "SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS",
|
||||
"SDL_HINT_IDLE_TIMER_DISABLED", "SDL_HINT_ORIENTATIONS",
|
||||
"SDL_HINT_XINPUT_ENABLED", "SDL_HINT_GAMECONTROLLERCONFIG",
|
||||
"SDL_HINT_ALLOW_TOPMOST", "SDL_HINT_DEFAULT", "SDL_HINT_NORMAL",
|
||||
"SDL_HINT_OVERRIDE", "SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS",
|
||||
"SDL_HintPriority", "SDL_SetHintWithPriority", "SDL_SetHint",
|
||||
"SDL_GetHint", "SDL_ClearHints"
|
||||
]
|
||||
|
||||
SDL_HINT_FRAMEBUFFER_ACCELERATION = b"SDL_FRAMEBUFFER_ACCELERATION"
|
||||
SDL_HINT_RENDER_DRIVER = b"SDL_RENDER_DRIVER"
|
||||
SDL_HINT_RENDER_OPENGL_SHADERS = b"SDL_RENDER_OPENGL_SHADERS"
|
||||
SDL_HINT_RENDER_SCALE_QUALITY = b"SDL_RENDER_SCALE_QUALITY"
|
||||
SDL_HINT_RENDER_VSYNC = b"SDL_RENDER_VSYNC"
|
||||
SDL_HINT_VIDEO_X11_XVIDMODE = b"SDL_VIDEO_X11_XVIDMODE"
|
||||
SDL_HINT_VIDEO_X11_XINERAMA = b"SDL_VIDEO_X11_XINERAMA"
|
||||
SDL_HINT_VIDEO_X11_XRANDR = b"SDL_VIDEO_X11_XRANDR"
|
||||
SDL_HINT_GRAB_KEYBOARD = b"SDL_GRAB_KEYBOARD"
|
||||
SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS = b"SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS"
|
||||
SDL_HINT_IDLE_TIMER_DISABLED = b"SDL_IOS_IDLE_TIMER_DISABLED"
|
||||
SDL_HINT_ORIENTATIONS = b"SDL_IOS_ORIENTATIONS"
|
||||
SDL_HINT_XINPUT_ENABLED = b"SDL_XINPUT_ENABLED"
|
||||
SDL_HINT_GAMECONTROLLERCONFIG = b"SDL_GAMECONTROLLERCONFIG"
|
||||
SDL_HINT_ALLOW_TOPMOST = b"SDL_ALLOW_TOPMOST"
|
||||
SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS = b"SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS"
|
||||
SDL_HINT_TIMER_RESOLUTION = b"SDL_TIMER_RESOLUTION"
|
||||
|
||||
SDL_HINT_DEFAULT = 0
|
||||
SDL_HINT_NORMAL = 1
|
||||
SDL_HINT_OVERRIDE = 2
|
||||
SDL_HintPriority = c_int
|
||||
SDL_SetHintWithPriority = _bind("SDL_SetHintWithPriority", [c_char_p, c_char_p, SDL_HintPriority], SDL_bool)
|
||||
SDL_SetHint = _bind("SDL_SetHint", [c_char_p, c_char_p], SDL_bool)
|
||||
SDL_GetHint = _bind("SDL_GetHint", [c_char_p], c_char_p)
|
||||
SDL_ClearHints = _bind("SDL_ClearHints")
|
||||
SDL_HintCallback = CFUNCTYPE(None, c_void_p, c_char_p, c_char_p, c_char_p)
|
||||
SDL_AddHintCallback = _bind("SDL_AddHintCallback", [c_char_p, SDL_HintCallback, c_void_p])
|
||||
SDL_DelHintCallback = _bind("SDL_DelHintCallback",[c_char_p, SDL_HintCallback, c_void_p])
|
57
src/m64py/SDL2/joystick.py
Normal file
57
src/m64py/SDL2/joystick.py
Normal file
|
@ -0,0 +1,57 @@
|
|||
from ctypes import Structure, c_int, c_char_p, POINTER
|
||||
from .dll import _bind
|
||||
from .stdinc import Sint16, Sint32, Uint8, SDL_bool
|
||||
|
||||
__all__ = ["SDL_Joystick", "SDL_JoystickGUID", "SDL_JoystickID",
|
||||
"SDL_NumJoysticks", "SDL_JoystickNameForIndex", "SDL_JoystickOpen",
|
||||
"SDL_JoystickName", "SDL_JoystickGetDeviceGUID",
|
||||
"SDL_JoystickGetGUID", "SDL_JoystickGetGUIDString",
|
||||
"SDL_JoystickGetGUIDFromString", "SDL_JoystickGetAttached",
|
||||
"SDL_JoystickInstanceID", "SDL_JoystickNumAxes",
|
||||
"SDL_JoystickNumBalls", "SDL_JoystickNumHats",
|
||||
"SDL_JoystickNumButtons", "SDL_JoystickUpdate",
|
||||
"SDL_JoystickEventState", "SDL_JoystickGetAxis", "SDL_HAT_CENTERED",
|
||||
"SDL_HAT_UP", "SDL_HAT_RIGHT", "SDL_HAT_DOWN", "SDL_HAT_LEFT",
|
||||
"SDL_HAT_RIGHTUP", "SDL_HAT_RIGHTDOWN", "SDL_HAT_LEFTUP",
|
||||
"SDL_HAT_LEFTDOWN", "SDL_JoystickGetHat", "SDL_JoystickGetBall",
|
||||
"SDL_JoystickGetButton", "SDL_JoystickClose"
|
||||
]
|
||||
|
||||
class SDL_Joystick(Structure):
|
||||
pass
|
||||
|
||||
class SDL_JoystickGUID(Structure):
|
||||
_fields_ = [("data", (Uint8 * 16))]
|
||||
|
||||
SDL_JoystickID = Sint32
|
||||
|
||||
SDL_NumJoysticks = _bind("SDL_NumJoysticks", None, c_int)
|
||||
SDL_JoystickNameForIndex = _bind("SDL_JoystickNameForIndex", [c_int], c_char_p)
|
||||
SDL_JoystickOpen = _bind("SDL_JoystickOpen", [c_int], POINTER(SDL_Joystick))
|
||||
SDL_JoystickName = _bind("SDL_JoystickName", [POINTER(SDL_Joystick)], c_char_p)
|
||||
SDL_JoystickGetDeviceGUID = _bind("SDL_JoystickGetDeviceGUID", [c_int], SDL_JoystickGUID)
|
||||
SDL_JoystickGetGUID = _bind("SDL_JoystickGetGUID", [POINTER(SDL_Joystick)], SDL_JoystickGUID)
|
||||
SDL_JoystickGetGUIDString = _bind("SDL_JoystickGetGUIDString", [SDL_JoystickGUID, c_char_p, c_int])
|
||||
SDL_JoystickGetGUIDFromString = _bind("SDL_JoystickGetGUIDFromString", [c_char_p], SDL_JoystickGUID)
|
||||
SDL_JoystickGetAttached = _bind("SDL_JoystickGetAttached", [POINTER(SDL_Joystick)], SDL_bool)
|
||||
SDL_JoystickInstanceID = _bind("SDL_JoystickInstanceID", [POINTER(SDL_Joystick)], SDL_JoystickID)
|
||||
SDL_JoystickNumAxes = _bind("SDL_JoystickNumAxes", [POINTER(SDL_Joystick)], c_int)
|
||||
SDL_JoystickNumBalls = _bind("SDL_JoystickNumBalls", [POINTER(SDL_Joystick)], c_int)
|
||||
SDL_JoystickNumHats = _bind("SDL_JoystickNumHats", [POINTER(SDL_Joystick)], c_int)
|
||||
SDL_JoystickNumButtons = _bind("SDL_JoystickNumButtons", [POINTER(SDL_Joystick)], c_int)
|
||||
SDL_JoystickUpdate = _bind("SDL_JoystickUpdate")
|
||||
SDL_JoystickEventState = _bind("SDL_JoystickEventState", [c_int], c_int)
|
||||
SDL_JoystickGetAxis = _bind("SDL_JoystickGetAxis", [POINTER(SDL_Joystick), c_int], Sint16)
|
||||
SDL_HAT_CENTERED = 0x00
|
||||
SDL_HAT_UP = 0x01
|
||||
SDL_HAT_RIGHT = 0x02
|
||||
SDL_HAT_DOWN = 0x04
|
||||
SDL_HAT_LEFT = 0x08
|
||||
SDL_HAT_RIGHTUP = SDL_HAT_RIGHT | SDL_HAT_UP
|
||||
SDL_HAT_RIGHTDOWN = SDL_HAT_RIGHT | SDL_HAT_DOWN
|
||||
SDL_HAT_LEFTUP = SDL_HAT_LEFT | SDL_HAT_UP
|
||||
SDL_HAT_LEFTDOWN = SDL_HAT_LEFT | SDL_HAT_DOWN
|
||||
SDL_JoystickGetHat = _bind("SDL_JoystickGetHat", [POINTER(SDL_Joystick), c_int], Uint8)
|
||||
SDL_JoystickGetBall = _bind("SDL_JoystickGetBall", [POINTER(SDL_Joystick), c_int, POINTER(c_int), POINTER(c_int)], c_int)
|
||||
SDL_JoystickGetButton = _bind("SDL_JoystickGetButton", [POINTER(SDL_Joystick), c_int], Uint8)
|
||||
SDL_JoystickClose = _bind("SDL_JoystickClose", [POINTER(SDL_Joystick)])
|
40
src/m64py/SDL2/keyboard.py
Normal file
40
src/m64py/SDL2/keyboard.py
Normal file
|
@ -0,0 +1,40 @@
|
|||
from ctypes import Structure, c_int, c_char_p, POINTER
|
||||
from .dll import _bind
|
||||
from .stdinc import Uint8, Uint16, Uint32, SDL_bool
|
||||
from .keycode import SDL_Keycode, SDL_Keymod
|
||||
from .scancode import SDL_Scancode
|
||||
from .rect import SDL_Rect
|
||||
from .video import SDL_Window
|
||||
|
||||
__all__ = ["SDL_Keysym", "SDL_GetKeyboardFocus", "SDL_GetKeyboardState",
|
||||
"SDL_GetModState", "SDL_SetModState", "SDL_GetKeyFromScancode",
|
||||
"SDL_GetScancodeFromKey", "SDL_GetScancodeName",
|
||||
"SDL_GetScancodeFromName", "SDL_GetKeyName", "SDL_GetKeyFromName",
|
||||
"SDL_StartTextInput", "SDL_IsTextInputActive", "SDL_StopTextInput",
|
||||
"SDL_SetTextInputRect", "SDL_HasScreenKeyboardSupport",
|
||||
"SDL_IsScreenKeyboardShown"
|
||||
]
|
||||
|
||||
class SDL_Keysym(Structure):
|
||||
_fields_ = [("scancode", SDL_Scancode),
|
||||
("sym", SDL_Keycode),
|
||||
("mod", Uint16),
|
||||
("unicode", Uint32)
|
||||
]
|
||||
|
||||
SDL_GetKeyboardFocus = _bind("SDL_GetKeyboardFocus", None, POINTER(SDL_Window))
|
||||
SDL_GetKeyboardState = _bind("SDL_GetKeyboardState", [POINTER(c_int)], POINTER(Uint8))
|
||||
SDL_GetModState = _bind("SDL_GetModState", None, SDL_Keymod)
|
||||
SDL_SetModState = _bind("SDL_SetModState", [SDL_Keymod])
|
||||
SDL_GetKeyFromScancode = _bind("SDL_GetKeyFromScancode", [SDL_Scancode], SDL_Keycode)
|
||||
SDL_GetScancodeFromKey = _bind("SDL_GetScancodeFromKey", [SDL_Keycode], SDL_Scancode)
|
||||
SDL_GetScancodeName = _bind("SDL_GetScancodeName", [SDL_Scancode], c_char_p)
|
||||
SDL_GetScancodeFromName = _bind("SDL_GetScancodeFromName", [c_char_p], SDL_Scancode)
|
||||
SDL_GetKeyName = _bind("SDL_GetKeyName", [SDL_Keycode], c_char_p)
|
||||
SDL_GetKeyFromName = _bind("SDL_GetKeyFromName", [c_char_p], SDL_Keycode)
|
||||
SDL_StartTextInput = _bind("SDL_StartTextInput")
|
||||
SDL_IsTextInputActive = _bind("SDL_IsTextInputActive", None, SDL_bool)
|
||||
SDL_StopTextInput = _bind("SDL_StopTextInput")
|
||||
SDL_SetTextInputRect = _bind("SDL_SetTextInputRect", [POINTER(SDL_Rect)])
|
||||
SDL_HasScreenKeyboardSupport = _bind("SDL_HasScreenKeyboardSupport", None, SDL_bool)
|
||||
SDL_IsScreenKeyboardShown = _bind("SDL_IsScreenKeyboardShown", [POINTER(SDL_Window)], SDL_bool)
|
288
src/m64py/SDL2/keycode.py
Normal file
288
src/m64py/SDL2/keycode.py
Normal file
|
@ -0,0 +1,288 @@
|
|||
from .stdinc import Sint32
|
||||
from .scancode import *
|
||||
|
||||
SDL_Keycode = Sint32
|
||||
SDLK_SCANCODE_MASK = 1 << 30
|
||||
SDL_SCANCODE_TO_KEYCODE = lambda x: (x | SDLK_SCANCODE_MASK)
|
||||
|
||||
SDL_Keymod = c_int
|
||||
|
||||
KMOD_NONE = 0x0000
|
||||
KMOD_LSHIFT = 0x0001
|
||||
KMOD_RSHIFT = 0x0002
|
||||
KMOD_LCTRL = 0x0040
|
||||
KMOD_RCTRL = 0x0080
|
||||
KMOD_LALT = 0x0100
|
||||
KMOD_RALT = 0x0200
|
||||
KMOD_LGUI = 0x0400
|
||||
KMOD_RGUI = 0x0800
|
||||
KMOD_NUM = 0x1000
|
||||
KMOD_CAPS = 0x2000
|
||||
KMOD_MODE = 0x4000
|
||||
KMOD_RESERVED = 0x8000
|
||||
|
||||
KMOD_CTRL = KMOD_LCTRL | KMOD_RCTRL
|
||||
KMOD_SHIFT = KMOD_LSHIFT | KMOD_RSHIFT
|
||||
KMOD_ALT = KMOD_LALT | KMOD_RALT
|
||||
KMOD_GUI = KMOD_LGUI | KMOD_RGUI
|
||||
|
||||
SDLK_UNKNOWN = 0
|
||||
|
||||
SDLK_RETURN = ord('\r')
|
||||
SDLK_ESCAPE = ord('\033')
|
||||
SDLK_BACKSPACE = ord('\b')
|
||||
SDLK_TAB = ord('\t')
|
||||
SDLK_SPACE = ord(' ')
|
||||
SDLK_EXCLAIM = ord('!')
|
||||
SDLK_QUOTEDBL = ord('"')
|
||||
SDLK_HASH = ord('#')
|
||||
SDLK_PERCENT = ord('%')
|
||||
SDLK_DOLLAR = ord('$')
|
||||
SDLK_AMPERSAND = ord('&')
|
||||
SDLK_QUOTE = ord('\'')
|
||||
SDLK_LEFTPAREN = ord('(')
|
||||
SDLK_RIGHTPAREN = ord(')')
|
||||
SDLK_ASTERISK = ord('*')
|
||||
SDLK_PLUS = ord('+')
|
||||
SDLK_COMMA = ord(',')
|
||||
SDLK_MINUS = ord('-')
|
||||
SDLK_PERIOD = ord('.')
|
||||
SDLK_SLASH = ord('/')
|
||||
|
||||
SDLK_0 = ord('0')
|
||||
SDLK_1 = ord('1')
|
||||
SDLK_2 = ord('2')
|
||||
SDLK_3 = ord('3')
|
||||
SDLK_4 = ord('4')
|
||||
SDLK_5 = ord('5')
|
||||
SDLK_6 = ord('6')
|
||||
SDLK_7 = ord('7')
|
||||
SDLK_8 = ord('8')
|
||||
SDLK_9 = ord('9')
|
||||
|
||||
SDLK_COLON = ord(':')
|
||||
SDLK_SEMICOLON = ord(';')
|
||||
SDLK_LESS = ord('<')
|
||||
SDLK_EQUALS = ord('=')
|
||||
SDLK_GREATER = ord('>')
|
||||
SDLK_QUESTION = ord('?')
|
||||
SDLK_AT = ord('@')
|
||||
|
||||
SDLK_LEFTBRACKET = ord('[')
|
||||
SDLK_BACKSLASH = ord('\\')
|
||||
SDLK_RIGHTBRACKET = ord(']')
|
||||
SDLK_CARET = ord('^')
|
||||
SDLK_UNDERSCORE = ord('_')
|
||||
SDLK_BACKQUOTE = ord('`')
|
||||
|
||||
SDLK_a = ord('a')
|
||||
SDLK_b = ord('b')
|
||||
SDLK_c = ord('c')
|
||||
SDLK_d = ord('d')
|
||||
SDLK_e = ord('e')
|
||||
SDLK_f = ord('f')
|
||||
SDLK_g = ord('g')
|
||||
SDLK_h = ord('h')
|
||||
SDLK_i = ord('i')
|
||||
SDLK_j = ord('j')
|
||||
SDLK_k = ord('k')
|
||||
SDLK_l = ord('l')
|
||||
SDLK_m = ord('m')
|
||||
SDLK_n = ord('n')
|
||||
SDLK_o = ord('o')
|
||||
SDLK_p = ord('p')
|
||||
SDLK_q = ord('q')
|
||||
SDLK_r = ord('r')
|
||||
SDLK_s = ord('s')
|
||||
SDLK_t = ord('t')
|
||||
SDLK_u = ord('u')
|
||||
SDLK_v = ord('v')
|
||||
SDLK_w = ord('w')
|
||||
SDLK_x = ord('x')
|
||||
SDLK_y = ord('y')
|
||||
SDLK_z = ord('z')
|
||||
|
||||
SDLK_CAPSLOCK = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CAPSLOCK)
|
||||
|
||||
SDLK_F1 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F1)
|
||||
SDLK_F2 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F2)
|
||||
SDLK_F3 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F3)
|
||||
SDLK_F4 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F4)
|
||||
SDLK_F5 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F5)
|
||||
SDLK_F6 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F6)
|
||||
SDLK_F7 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F7)
|
||||
SDLK_F8 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F8)
|
||||
SDLK_F9 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F9)
|
||||
SDLK_F10 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F10)
|
||||
SDLK_F11 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F11)
|
||||
SDLK_F12 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F12)
|
||||
|
||||
SDLK_PRINTSCREEN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PRINTSCREEN)
|
||||
SDLK_SCROLLLOCK = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SCROLLLOCK)
|
||||
SDLK_PAUSE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PAUSE)
|
||||
SDLK_INSERT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_INSERT)
|
||||
SDLK_HOME = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_HOME)
|
||||
SDLK_PAGEUP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PAGEUP)
|
||||
SDLK_DELETE = ord('\177')
|
||||
SDLK_END = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_END)
|
||||
SDLK_PAGEDOWN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PAGEDOWN)
|
||||
SDLK_RIGHT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RIGHT)
|
||||
SDLK_LEFT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LEFT)
|
||||
SDLK_DOWN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_DOWN)
|
||||
SDLK_UP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_UP)
|
||||
|
||||
SDLK_NUMLOCKCLEAR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_NUMLOCKCLEAR)
|
||||
SDLK_KP_DIVIDE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DIVIDE)
|
||||
SDLK_KP_MULTIPLY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MULTIPLY)
|
||||
SDLK_KP_MINUS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MINUS)
|
||||
SDLK_KP_PLUS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PLUS)
|
||||
SDLK_KP_ENTER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_ENTER)
|
||||
SDLK_KP_1 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_1)
|
||||
SDLK_KP_2 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_2)
|
||||
SDLK_KP_3 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_3)
|
||||
SDLK_KP_4 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_4)
|
||||
SDLK_KP_5 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_5)
|
||||
SDLK_KP_6 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_6)
|
||||
SDLK_KP_7 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_7)
|
||||
SDLK_KP_8 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_8)
|
||||
SDLK_KP_9 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_9)
|
||||
SDLK_KP_0 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_0)
|
||||
SDLK_KP_PERIOD = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PERIOD)
|
||||
|
||||
SDLK_APPLICATION = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_APPLICATION)
|
||||
SDLK_POWER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_POWER)
|
||||
SDLK_KP_EQUALS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_EQUALS)
|
||||
|
||||
SDLK_F13 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F13)
|
||||
SDLK_F14 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F14)
|
||||
SDLK_F15 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F15)
|
||||
SDLK_F16 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F16)
|
||||
SDLK_F17 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F17)
|
||||
SDLK_F18 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F18)
|
||||
SDLK_F19 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F19)
|
||||
SDLK_F20 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F20)
|
||||
SDLK_F21 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F21)
|
||||
SDLK_F22 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F22)
|
||||
SDLK_F23 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F23)
|
||||
SDLK_F24 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F24)
|
||||
|
||||
SDLK_EXECUTE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_EXECUTE)
|
||||
SDLK_HELP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_HELP)
|
||||
SDLK_MENU = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MENU)
|
||||
SDLK_SELECT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SELECT)
|
||||
SDLK_STOP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_STOP)
|
||||
SDLK_AGAIN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AGAIN)
|
||||
SDLK_UNDO = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_UNDO)
|
||||
SDLK_CUT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CUT)
|
||||
SDLK_COPY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_COPY)
|
||||
SDLK_PASTE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PASTE)
|
||||
SDLK_FIND = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_FIND)
|
||||
SDLK_MUTE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MUTE)
|
||||
SDLK_VOLUMEUP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_VOLUMEUP)
|
||||
SDLK_VOLUMEDOWN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_VOLUMEDOWN)
|
||||
SDLK_KP_COMMA = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_COMMA)
|
||||
|
||||
SDLK_KP_EQUALSAS400 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_EQUALSAS400)
|
||||
|
||||
SDLK_ALTERASE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_ALTERASE)
|
||||
SDLK_SYSREQ = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SYSREQ)
|
||||
SDLK_CANCEL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CANCEL)
|
||||
SDLK_CLEAR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CLEAR)
|
||||
SDLK_PRIOR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PRIOR)
|
||||
SDLK_RETURN2 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RETURN2)
|
||||
SDLK_SEPARATOR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SEPARATOR)
|
||||
SDLK_OUT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_OUT)
|
||||
SDLK_OPER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_OPER)
|
||||
SDLK_CLEARAGAIN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CLEARAGAIN)
|
||||
SDLK_CRSEL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CRSEL)
|
||||
SDLK_EXSEL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_EXSEL)
|
||||
|
||||
SDLK_KP_00 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_00)
|
||||
SDLK_KP_000 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_000)
|
||||
|
||||
SDLK_THOUSANDSSEPARATOR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_THOUSANDSSEPARATOR)
|
||||
SDLK_DECIMALSEPARATOR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_DECIMALSEPARATOR)
|
||||
SDLK_CURRENCYUNIT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CURRENCYUNIT)
|
||||
SDLK_CURRENCYSUBUNIT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CURRENCYSUBUNIT)
|
||||
|
||||
SDLK_KP_LEFTPAREN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_LEFTPAREN)
|
||||
SDLK_KP_RIGHTPAREN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_RIGHTPAREN)
|
||||
SDLK_KP_LEFTBRACE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_LEFTBRACE)
|
||||
SDLK_KP_RIGHTBRACE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_RIGHTBRACE)
|
||||
|
||||
SDLK_KP_TAB = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_TAB)
|
||||
SDLK_KP_BACKSPACE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_BACKSPACE)
|
||||
|
||||
SDLK_KP_A = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_A)
|
||||
SDLK_KP_B = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_B)
|
||||
SDLK_KP_C = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_C)
|
||||
SDLK_KP_D = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_D)
|
||||
SDLK_KP_E = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_E)
|
||||
SDLK_KP_F = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_F)
|
||||
|
||||
SDLK_KP_XOR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_XOR)
|
||||
SDLK_KP_POWER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_POWER)
|
||||
SDLK_KP_PERCENT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PERCENT)
|
||||
SDLK_KP_LESS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_LESS)
|
||||
SDLK_KP_GREATER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_GREATER)
|
||||
SDLK_KP_AMPERSAND = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_AMPERSAND)
|
||||
SDLK_KP_DBLAMPERSAND = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DBLAMPERSAND)
|
||||
SDLK_KP_VERTICALBAR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_VERTICALBAR)
|
||||
SDLK_KP_DBLVERTICALBAR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DBLVERTICALBAR)
|
||||
SDLK_KP_COLON = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_COLON)
|
||||
SDLK_KP_HASH = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_HASH)
|
||||
SDLK_KP_SPACE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_SPACE)
|
||||
SDLK_KP_AT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_AT)
|
||||
SDLK_KP_EXCLAM = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_EXCLAM)
|
||||
SDLK_KP_MEMSTORE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMSTORE)
|
||||
SDLK_KP_MEMRECALL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMRECALL)
|
||||
SDLK_KP_MEMCLEAR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMCLEAR)
|
||||
SDLK_KP_MEMADD = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMADD)
|
||||
SDLK_KP_MEMSUBTRACT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMSUBTRACT)
|
||||
SDLK_KP_MEMMULTIPLY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMMULTIPLY)
|
||||
SDLK_KP_MEMDIVIDE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMDIVIDE)
|
||||
SDLK_KP_PLUSMINUS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PLUSMINUS)
|
||||
SDLK_KP_CLEAR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_CLEAR)
|
||||
SDLK_KP_CLEARENTRY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_CLEARENTRY)
|
||||
SDLK_KP_BINARY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_BINARY)
|
||||
SDLK_KP_OCTAL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_OCTAL)
|
||||
SDLK_KP_DECIMAL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DECIMAL)
|
||||
SDLK_KP_HEXADECIMAL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_HEXADECIMAL)
|
||||
|
||||
SDLK_LCTRL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LCTRL)
|
||||
SDLK_LSHIFT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LSHIFT)
|
||||
SDLK_LALT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LALT)
|
||||
SDLK_LGUI = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LGUI)
|
||||
SDLK_RCTRL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RCTRL)
|
||||
SDLK_RSHIFT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RSHIFT)
|
||||
SDLK_RALT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RALT)
|
||||
SDLK_RGUI = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RGUI)
|
||||
|
||||
SDLK_MODE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MODE)
|
||||
|
||||
SDLK_AUDIONEXT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIONEXT)
|
||||
SDLK_AUDIOPREV = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOPREV)
|
||||
SDLK_AUDIOSTOP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOSTOP)
|
||||
SDLK_AUDIOPLAY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOPLAY)
|
||||
SDLK_AUDIOMUTE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOMUTE)
|
||||
SDLK_MEDIASELECT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIASELECT)
|
||||
SDLK_WWW = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_WWW)
|
||||
SDLK_MAIL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MAIL)
|
||||
SDLK_CALCULATOR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CALCULATOR)
|
||||
SDLK_COMPUTER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_COMPUTER)
|
||||
SDLK_AC_SEARCH = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_SEARCH)
|
||||
SDLK_AC_HOME = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_HOME)
|
||||
SDLK_AC_BACK = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_BACK)
|
||||
SDLK_AC_FORWARD = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_FORWARD)
|
||||
SDLK_AC_STOP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_STOP)
|
||||
SDLK_AC_REFRESH = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_REFRESH)
|
||||
SDLK_AC_BOOKMARKS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_BOOKMARKS)
|
||||
|
||||
SDLK_BRIGHTNESSDOWN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_BRIGHTNESSDOWN)
|
||||
SDLK_BRIGHTNESSUP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_BRIGHTNESSUP)
|
||||
SDLK_DISPLAYSWITCH = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_DISPLAYSWITCH)
|
||||
SDLK_KBDILLUMTOGGLE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KBDILLUMTOGGLE)
|
||||
SDLK_KBDILLUMDOWN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KBDILLUMDOWN)
|
||||
SDLK_KBDILLUMUP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KBDILLUMUP)
|
||||
SDLK_EJECT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_EJECT)
|
||||
SDLK_SLEEP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SLEEP)
|
8
src/m64py/SDL2/loadso.py
Normal file
8
src/m64py/SDL2/loadso.py
Normal file
|
@ -0,0 +1,8 @@
|
|||
from ctypes import c_char_p, c_void_p
|
||||
from .dll import _bind
|
||||
|
||||
__all__ = ["SDL_LoadObject", "SDL_LoadFunction", "SDL_UnloadObject"]
|
||||
|
||||
SDL_LoadObject = _bind("SDL_LoadObject", [c_char_p], c_void_p)
|
||||
SDL_LoadFunction = _bind("SDL_LoadFunction", [c_void_p, c_char_p], c_void_p)
|
||||
SDL_UnloadObject = _bind("SDL_UnloadObject", [c_void_p])
|
71
src/m64py/SDL2/log.py
Normal file
71
src/m64py/SDL2/log.py
Normal file
|
@ -0,0 +1,71 @@
|
|||
from ctypes import c_int, c_char_p, c_void_p, CFUNCTYPE, POINTER, py_object
|
||||
from .dll import _bind
|
||||
|
||||
__all__ = ["SDL_MAX_LOG_MESSAGE", "SDL_LOG_CATEGORY_APPLICATION",
|
||||
"SDL_LOG_CATEGORY_ERROR", "SDL_LOG_CATEGORY_ASSERT",
|
||||
"SDL_LOG_CATEGORY_SYSTEM", "SDL_LOG_CATEGORY_AUDIO",
|
||||
"SDL_LOG_CATEGORY_VIDEO", "SDL_LOG_CATEGORY_RENDER",
|
||||
"SDL_LOG_CATEGORY_INPUT", "SDL_LOG_CATEGORY_TEST",
|
||||
"SDL_LOG_CATEGORY_RESERVED1", "SDL_LOG_CATEGORY_RESERVED2",
|
||||
"SDL_LOG_CATEGORY_RESERVED3", "SDL_LOG_CATEGORY_RESERVED4",
|
||||
"SDL_LOG_CATEGORY_RESERVED5", "SDL_LOG_CATEGORY_RESERVED6",
|
||||
"SDL_LOG_CATEGORY_RESERVED7", "SDL_LOG_CATEGORY_RESERVED8",
|
||||
"SDL_LOG_CATEGORY_RESERVED9", "SDL_LOG_CATEGORY_RESERVED10",
|
||||
"SDL_LOG_CATEGORY_CUSTOM", "SDL_LOG_PRIORITY_VERBOSE",
|
||||
"SDL_LOG_PRIORITY_DEBUG", "SDL_LOG_PRIORITY_INFO",
|
||||
"SDL_LOG_PRIORITY_WARN", "SDL_LOG_PRIORITY_ERROR",
|
||||
"SDL_LOG_PRIORITY_CRITICAL", "SDL_NUM_LOG_PRIORITIES",
|
||||
"SDL_LogPriority", "SDL_LogSetAllPriority", "SDL_LogSetPriority",
|
||||
"SDL_LogGetPriority", "SDL_LogResetPriorities", "SDL_Log",
|
||||
"SDL_LogVerbose", "SDL_LogDebug", "SDL_LogInfo", "SDL_LogWarn",
|
||||
"SDL_LogError", "SDL_LogCritical", "SDL_LogMessage",
|
||||
"SDL_LogOutputFunction", "SDL_LogGetOutputFunction",
|
||||
"SDL_LogSetOutputFunction"
|
||||
]
|
||||
|
||||
SDL_MAX_LOG_MESSAGE = 4096
|
||||
SDL_LOG_CATEGORY_APPLICATION = 0
|
||||
SDL_LOG_CATEGORY_ERROR = 1
|
||||
SDL_LOG_CATEGORY_ASSERT = 2
|
||||
SDL_LOG_CATEGORY_SYSTEM = 3
|
||||
SDL_LOG_CATEGORY_AUDIO = 4
|
||||
SDL_LOG_CATEGORY_VIDEO = 5
|
||||
SDL_LOG_CATEGORY_RENDER = 6
|
||||
SDL_LOG_CATEGORY_INPUT = 7
|
||||
SDL_LOG_CATEGORY_TEST = 8
|
||||
SDL_LOG_CATEGORY_RESERVED1 = 9
|
||||
SDL_LOG_CATEGORY_RESERVED2 = 10
|
||||
SDL_LOG_CATEGORY_RESERVED3 = 11
|
||||
SDL_LOG_CATEGORY_RESERVED4 = 12
|
||||
SDL_LOG_CATEGORY_RESERVED5 = 13
|
||||
SDL_LOG_CATEGORY_RESERVED6 = 14
|
||||
SDL_LOG_CATEGORY_RESERVED7 = 15
|
||||
SDL_LOG_CATEGORY_RESERVED8 = 16
|
||||
SDL_LOG_CATEGORY_RESERVED9 = 17
|
||||
SDL_LOG_CATEGORY_RESERVED10 = 18
|
||||
SDL_LOG_CATEGORY_CUSTOM = 19
|
||||
SDL_LOG_PRIORITY_VERBOSE = 1
|
||||
SDL_LOG_PRIORITY_DEBUG = 2
|
||||
SDL_LOG_PRIORITY_INFO = 3
|
||||
SDL_LOG_PRIORITY_WARN = 4
|
||||
SDL_LOG_PRIORITY_ERROR = 5
|
||||
SDL_LOG_PRIORITY_CRITICAL = 6
|
||||
SDL_NUM_LOG_PRIORITIES = 7
|
||||
SDL_LogPriority = c_int
|
||||
|
||||
SDL_LogSetAllPriority = _bind("SDL_LogSetAllPriority", [SDL_LogPriority])
|
||||
SDL_LogSetPriority = _bind("SDL_LogSetPriority", [c_int, SDL_LogPriority])
|
||||
SDL_LogGetPriority = _bind("SDL_LogGetPriority", [c_int], SDL_LogPriority)
|
||||
SDL_LogResetPriorities = _bind("SDL_LogResetPriorities")
|
||||
SDL_Log = _bind("SDL_Log", [c_char_p])
|
||||
SDL_LogVerbose = _bind("SDL_LogVerbose", [c_int, c_char_p])
|
||||
SDL_LogDebug = _bind("SDL_LogDebug", [c_int, c_char_p])
|
||||
SDL_LogInfo = _bind("SDL_LogInfo", [c_int, c_char_p])
|
||||
SDL_LogWarn = _bind("SDL_LogWarn", [c_int, c_char_p])
|
||||
SDL_LogError = _bind("SDL_LogError", [c_int, c_char_p])
|
||||
SDL_LogCritical = _bind("SDL_LogCritical", [c_int, c_char_p])
|
||||
SDL_LogMessage = _bind("SDL_LogMessage", [c_int, SDL_LogPriority, c_char_p])
|
||||
# TODO: do we want SDL_LogMessageV?
|
||||
SDL_LogOutputFunction = CFUNCTYPE(None, c_void_p, c_int, SDL_LogPriority, c_char_p)
|
||||
SDL_LogGetOutputFunction = _bind("SDL_LogGetOutputFunction", [POINTER(SDL_LogOutputFunction), c_void_p])
|
||||
SDL_LogSetOutputFunction = _bind("SDL_LogSetOutputFunction", [SDL_LogOutputFunction, c_void_p])
|
54
src/m64py/SDL2/messagebox.py
Normal file
54
src/m64py/SDL2/messagebox.py
Normal file
|
@ -0,0 +1,54 @@
|
|||
from ctypes import Structure, c_int, c_char_p, POINTER
|
||||
from .dll import _bind
|
||||
from .stdinc import Uint8, Uint32
|
||||
from .video import SDL_Window
|
||||
|
||||
__all__ = ["SDL_MESSAGEBOX_ERROR", "SDL_MESSAGEBOX_WARNING",
|
||||
"SDL_MESSAGEBOX_INFORMATION", "SDL_MessageBoxFlags",
|
||||
"SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT",
|
||||
"SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT",
|
||||
"SDL_MessageBoxButtonFlags", "SDL_MessageBoxButtonData",
|
||||
"SDL_MessageBoxColor", "SDL_MESSAGEBOX_COLOR_BACKGROUND",
|
||||
"SDL_MESSAGEBOX_COLOR_TEXT", "SDL_MESSAGEBOX_COLOR_BUTTON_BORDER",
|
||||
"SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND",
|
||||
"SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED", "SDL_MESSAGEBOX_COLOR_MAX",
|
||||
"SDL_MessageBoxColorType", "SDL_MessageBoxColorScheme",
|
||||
"SDL_MessageBoxData", "SDL_ShowMessageBox",
|
||||
"SDL_ShowSimpleMessageBox"
|
||||
]
|
||||
|
||||
SDL_MESSAGEBOX_ERROR = 0x00000010
|
||||
SDL_MESSAGEBOX_WARNING = 0x00000020
|
||||
SDL_MESSAGEBOX_INFORMATION = 0x00000040
|
||||
SDL_MessageBoxFlags = c_int
|
||||
SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT = 0x00000001
|
||||
SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT = 0x00000002
|
||||
SDL_MessageBoxButtonFlags = c_int
|
||||
class SDL_MessageBoxButtonData(Structure):
|
||||
_fields_ = [("flags", Uint32), ("buttonid", c_int), ("text", c_char_p)]
|
||||
|
||||
class SDL_MessageBoxColor(Structure):
|
||||
_fields_ = [("r", Uint8), ("g", Uint8), ("b", Uint8)]
|
||||
|
||||
SDL_MESSAGEBOX_COLOR_BACKGROUND = 0
|
||||
SDL_MESSAGEBOX_COLOR_TEXT = 1
|
||||
SDL_MESSAGEBOX_COLOR_BUTTON_BORDER = 2
|
||||
SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND = 3
|
||||
SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED = 4
|
||||
SDL_MESSAGEBOX_COLOR_MAX = 5
|
||||
SDL_MessageBoxColorType = c_int
|
||||
|
||||
class SDL_MessageBoxColorScheme(Structure):
|
||||
_fields_ = [("colors", (SDL_MessageBoxColor * SDL_MESSAGEBOX_COLOR_MAX))]
|
||||
|
||||
class SDL_MessageBoxData(Structure):
|
||||
_fields_ = [("flags", Uint32),
|
||||
("window", POINTER(SDL_Window)),
|
||||
("title", c_char_p),
|
||||
("message", c_char_p),
|
||||
("numbuttons", c_int),
|
||||
("buttons", POINTER(SDL_MessageBoxButtonData)),
|
||||
("colorScheme", POINTER(SDL_MessageBoxColorScheme))
|
||||
]
|
||||
SDL_ShowMessageBox = _bind("SDL_ShowMessageBox", [POINTER(SDL_MessageBoxData), POINTER(c_int)], c_int)
|
||||
SDL_ShowSimpleMessageBox = _bind("SDL_ShowSimpleMessageBox", [Uint32, c_char_p, c_char_p, POINTER(SDL_Window)], c_int)
|
68
src/m64py/SDL2/mouse.py
Normal file
68
src/m64py/SDL2/mouse.py
Normal file
|
@ -0,0 +1,68 @@
|
|||
from ctypes import Structure, POINTER, c_int
|
||||
from .dll import _bind
|
||||
from .stdinc import Uint8, Uint32, SDL_bool
|
||||
from .video import SDL_Window
|
||||
from .surface import SDL_Surface
|
||||
|
||||
__all__ = ["SDL_Cursor", "SDL_SYSTEM_CURSOR_ARROW", "SDL_SYSTEM_CURSOR_IBEAM",
|
||||
"SDL_SYSTEM_CURSOR_WAIT", "SDL_SYSTEM_CURSOR_CROSSHAIR",
|
||||
"SDL_SYSTEM_CURSOR_WAITARROW", "SDL_SYSTEM_CURSOR_SIZENWSE",
|
||||
"SDL_SYSTEM_CURSOR_SIZENESW", "SDL_SYSTEM_CURSOR_SIZEWE",
|
||||
"SDL_SYSTEM_CURSOR_SIZENS", "SDL_SYSTEM_CURSOR_SIZEALL",
|
||||
"SDL_SYSTEM_CURSOR_NO", "SDL_SYSTEM_CURSOR_HAND",
|
||||
"SDL_NUM_SYSTEM_CURSORS", "SDL_SystemCursor", "SDL_GetMouseFocus",
|
||||
"SDL_GetMouseState", "SDL_GetRelativeMouseState",
|
||||
"SDL_WarpMouseInWindow", "SDL_SetRelativeMouseMode",
|
||||
"SDL_GetRelativeMouseMode", "SDL_CreateCursor",
|
||||
"SDL_CreateColorCursor", "SDL_CreateSystemCursor", "SDL_SetCursor",
|
||||
"SDL_GetCursor", "SDL_GetDefaultCursor", "SDL_FreeCursor",
|
||||
"SDL_ShowCursor", "SDL_BUTTON", "SDL_BUTTON_LEFT",
|
||||
"SDL_BUTTON_MIDDLE", "SDL_BUTTON_RIGHT", "SDL_BUTTON_X1",
|
||||
"SDL_BUTTON_X2", "SDL_BUTTON_LMASK", "SDL_BUTTON_MMASK",
|
||||
"SDL_BUTTON_RMASK", "SDL_BUTTON_X1MASK", "SDL_BUTTON_X2MASK"
|
||||
]
|
||||
|
||||
|
||||
class SDL_Cursor(Structure):
|
||||
pass
|
||||
|
||||
|
||||
SDL_SYSTEM_CURSOR_ARROW = 0
|
||||
SDL_SYSTEM_CURSOR_IBEAM = 1
|
||||
SDL_SYSTEM_CURSOR_WAIT = 2
|
||||
SDL_SYSTEM_CURSOR_CROSSHAIR = 3
|
||||
SDL_SYSTEM_CURSOR_WAITARROW = 4
|
||||
SDL_SYSTEM_CURSOR_SIZENWSE = 5
|
||||
SDL_SYSTEM_CURSOR_SIZENESW = 6
|
||||
SDL_SYSTEM_CURSOR_SIZEWE = 7
|
||||
SDL_SYSTEM_CURSOR_SIZENS = 8
|
||||
SDL_SYSTEM_CURSOR_SIZEALL = 9
|
||||
SDL_SYSTEM_CURSOR_NO = 10
|
||||
SDL_SYSTEM_CURSOR_HAND = 11
|
||||
SDL_NUM_SYSTEM_CURSORS = 12
|
||||
SDL_SystemCursor = c_int
|
||||
SDL_GetMouseFocus = _bind("SDL_GetMouseFocus", None, POINTER(SDL_Window))
|
||||
SDL_GetMouseState = _bind("SDL_GetMouseState", [POINTER(c_int), POINTER(c_int)], Uint32)
|
||||
SDL_GetRelativeMouseState = _bind("SDL_GetRelativeMouseState", [POINTER(c_int), POINTER(c_int)], Uint32)
|
||||
SDL_WarpMouseInWindow = _bind("SDL_WarpMouseInWindow", [POINTER(SDL_Window), c_int, c_int])
|
||||
SDL_SetRelativeMouseMode = _bind("SDL_SetRelativeMouseMode", [SDL_bool], c_int)
|
||||
SDL_GetRelativeMouseMode = _bind("SDL_GetRelativeMouseMode", None, SDL_bool)
|
||||
SDL_CreateCursor = _bind("SDL_CreateCursor", [POINTER(Uint8), POINTER(Uint8), c_int, c_int, c_int, c_int], POINTER(SDL_Cursor))
|
||||
SDL_CreateColorCursor = _bind("SDL_CreateColorCursor", [POINTER(SDL_Surface), c_int, c_int], POINTER(SDL_Cursor))
|
||||
SDL_CreateSystemCursor = _bind("SDL_CreateSystemCursor", [SDL_SystemCursor], POINTER(SDL_Cursor))
|
||||
SDL_SetCursor = _bind("SDL_SetCursor", [POINTER(SDL_Cursor)])
|
||||
SDL_GetCursor = _bind("SDL_GetCursor", None, POINTER(SDL_Cursor))
|
||||
SDL_GetDefaultCursor = _bind("SDL_GetDefaultCursor", None, POINTER(SDL_Cursor))
|
||||
SDL_FreeCursor = _bind("SDL_FreeCursor", [POINTER(SDL_Cursor)])
|
||||
SDL_ShowCursor = _bind("SDL_ShowCursor", [c_int], c_int)
|
||||
SDL_BUTTON = lambda X: (1 << ((X) - 1))
|
||||
SDL_BUTTON_LEFT = 1
|
||||
SDL_BUTTON_MIDDLE = 2
|
||||
SDL_BUTTON_RIGHT = 3
|
||||
SDL_BUTTON_X1 = 4
|
||||
SDL_BUTTON_X2 = 5
|
||||
SDL_BUTTON_LMASK = SDL_BUTTON(SDL_BUTTON_LEFT)
|
||||
SDL_BUTTON_MMASK = SDL_BUTTON(SDL_BUTTON_MIDDLE)
|
||||
SDL_BUTTON_RMASK = SDL_BUTTON(SDL_BUTTON_RIGHT)
|
||||
SDL_BUTTON_X1MASK = SDL_BUTTON(SDL_BUTTON_X1)
|
||||
SDL_BUTTON_X2MASK = SDL_BUTTON(SDL_BUTTON_X2)
|
298
src/m64py/SDL2/pixels.py
Normal file
298
src/m64py/SDL2/pixels.py
Normal file
|
@ -0,0 +1,298 @@
|
|||
from ctypes import Structure, POINTER, c_int, c_char_p, c_float
|
||||
from .dll import _bind
|
||||
from .stdinc import Uint8, Uint16, Uint32, SDL_bool
|
||||
|
||||
SDL_ALPHA_OPAQUE = 255
|
||||
SDL_ALPHA_TRANSPARENT = 0
|
||||
|
||||
SDL_PIXELTYPE_UNKNOWN = 0
|
||||
SDL_PIXELTYPE_INDEX1 = 1
|
||||
SDL_PIXELTYPE_INDEX4 = 2
|
||||
SDL_PIXELTYPE_INDEX8 = 3
|
||||
SDL_PIXELTYPE_PACKED8 = 4
|
||||
SDL_PIXELTYPE_PACKED16 = 5
|
||||
SDL_PIXELTYPE_PACKED32 = 6
|
||||
SDL_PIXELTYPE_ARRAYU8 = 7
|
||||
SDL_PIXELTYPE_ARRAYU16 = 8
|
||||
SDL_PIXELTYPE_ARRAYU32 = 9
|
||||
SDL_PIXELTYPE_ARRAYF16 = 10
|
||||
SDL_PIXELTYPE_ARRAYF32 = 11
|
||||
|
||||
SDL_BITMAPORDER_NONE = 0
|
||||
SDL_BITMAPORDER_4321 = 1
|
||||
SDL_BITMAPORDER_1234 = 2
|
||||
|
||||
SDL_PACKEDORDER_NONE = 0
|
||||
SDL_PACKEDORDER_XRGB = 1
|
||||
SDL_PACKEDORDER_RGBX = 2
|
||||
SDL_PACKEDORDER_ARGB = 3
|
||||
SDL_PACKEDORDER_RGBA = 4
|
||||
SDL_PACKEDORDER_XBGR = 5
|
||||
SDL_PACKEDORDER_BGRX = 6
|
||||
SDL_PACKEDORDER_ABGR = 7
|
||||
SDL_PACKEDORDER_BGRA = 8
|
||||
|
||||
SDL_ARRAYORDER_NONE = 0
|
||||
SDL_ARRAYORDER_RGB = 1
|
||||
SDL_ARRAYORDER_RGBA = 2
|
||||
SDL_ARRAYORDER_ARGB = 3
|
||||
SDL_ARRAYORDER_BGR = 4
|
||||
SDL_ARRAYORDER_BGRA = 5
|
||||
SDL_ARRAYORDER_ABGR = 6
|
||||
|
||||
SDL_PACKEDLAYOUT_NONE = 0
|
||||
SDL_PACKEDLAYOUT_332 = 1
|
||||
SDL_PACKEDLAYOUT_4444 = 2
|
||||
SDL_PACKEDLAYOUT_1555 = 3
|
||||
SDL_PACKEDLAYOUT_5551 = 4
|
||||
SDL_PACKEDLAYOUT_565 = 5
|
||||
SDL_PACKEDLAYOUT_8888 = 6
|
||||
SDL_PACKEDLAYOUT_2101010 = 7
|
||||
SDL_PACKEDLAYOUT_1010102 = 8
|
||||
|
||||
SDL_FOURCC = lambda a, b, c, d: (ord(a) << 0) | (ord(b) << 8) | (ord(c) << 16) | (ord(d) << 24)
|
||||
SDL_DEFINE_PIXELFOURCC = SDL_FOURCC
|
||||
SDL_DEFINE_PIXELFORMAT = lambda ptype, order, layout, bits, pbytes: ((1 << 28) | ((ptype) << 24) | ((order) << 20) | ((layout) << 16) | ((bits) << 8) | ((pbytes) << 0))
|
||||
SDL_PIXELFLAG = lambda X: (((X) >> 28) & 0x0F)
|
||||
SDL_PIXELTYPE = lambda X: (((X) >> 24) & 0x0F)
|
||||
SDL_PIXELORDER = lambda X: (((X) >> 20) & 0x0F)
|
||||
SDL_PIXELLAYOUT = lambda X: (((X) >> 16) & 0x0F)
|
||||
SDL_BITSPERPIXEL = lambda X: (((X) >> 8) & 0xFF)
|
||||
def SDL_BYTESPERPIXEL(x):
|
||||
valid = (SDL_PIXELFORMAT_YUY2, SDL_PIXELFORMAT_UYVY, SDL_PIXELFORMAT_YVYU)
|
||||
if SDL_ISPIXELFORMAT_FOURCC(x):
|
||||
if x in valid:
|
||||
return 2
|
||||
else:
|
||||
return 1
|
||||
else:
|
||||
return(((x) >> 0) & 0xFF)
|
||||
def SDL_ISPIXELFORMAT_INDEXED(pformat):
|
||||
"""Checks, if the passed format value is an indexed format."""
|
||||
return ((not SDL_ISPIXELFORMAT_FOURCC(pformat)) and
|
||||
((SDL_PIXELTYPE(pformat) == SDL_PIXELTYPE_INDEX1) or
|
||||
(SDL_PIXELTYPE(pformat) == SDL_PIXELTYPE_INDEX4) or
|
||||
(SDL_PIXELTYPE(pformat) == SDL_PIXELTYPE_INDEX8)))
|
||||
def SDL_ISPIXELFORMAT_ALPHA(pformat):
|
||||
"""Checks, if the passed format value is an alpha channel supporting
|
||||
format.
|
||||
"""
|
||||
return ((not SDL_ISPIXELFORMAT_FOURCC(pformat)) and
|
||||
((SDL_PIXELORDER(pformat) == SDL_PACKEDORDER_ARGB) or
|
||||
(SDL_PIXELORDER(pformat) == SDL_PACKEDORDER_RGBA) or
|
||||
(SDL_PIXELORDER(pformat) == SDL_PACKEDORDER_ABGR) or
|
||||
(SDL_PIXELORDER(pformat) == SDL_PACKEDORDER_BGRA)))
|
||||
|
||||
SDL_ISPIXELFORMAT_FOURCC = lambda fmt: ((fmt) and (SDL_PIXELFLAG(fmt) != 1))
|
||||
SDL_PIXELFORMAT_UNKNOWN = 0
|
||||
SDL_PIXELFORMAT_INDEX1LSB = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1,
|
||||
SDL_BITMAPORDER_4321,
|
||||
0, 1, 0)
|
||||
SDL_PIXELFORMAT_INDEX1MSB = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1,
|
||||
SDL_BITMAPORDER_1234,
|
||||
0, 1, 0)
|
||||
SDL_PIXELFORMAT_INDEX4LSB = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4,
|
||||
SDL_BITMAPORDER_4321,
|
||||
0, 4, 0)
|
||||
SDL_PIXELFORMAT_INDEX4MSB = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4,
|
||||
SDL_BITMAPORDER_1234,
|
||||
0, 4, 0)
|
||||
SDL_PIXELFORMAT_INDEX8 = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX8, 0,
|
||||
0, 8, 1)
|
||||
SDL_PIXELFORMAT_RGB332 = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED8,
|
||||
SDL_PACKEDORDER_XRGB,
|
||||
SDL_PACKEDLAYOUT_332, 8, 1)
|
||||
SDL_PIXELFORMAT_RGB444 = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16,
|
||||
SDL_PACKEDORDER_XRGB,
|
||||
SDL_PACKEDLAYOUT_4444, 12, 2)
|
||||
SDL_PIXELFORMAT_RGB555 = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16,
|
||||
SDL_PACKEDORDER_XRGB,
|
||||
SDL_PACKEDLAYOUT_1555, 15, 2)
|
||||
SDL_PIXELFORMAT_BGR555 = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16,
|
||||
SDL_PACKEDORDER_XBGR,
|
||||
SDL_PACKEDLAYOUT_1555, 15, 2)
|
||||
SDL_PIXELFORMAT_ARGB4444 = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16,
|
||||
SDL_PACKEDORDER_ARGB,
|
||||
SDL_PACKEDLAYOUT_4444, 16, 2)
|
||||
SDL_PIXELFORMAT_RGBA4444 = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16,
|
||||
SDL_PACKEDORDER_RGBA,
|
||||
SDL_PACKEDLAYOUT_4444, 16, 2)
|
||||
SDL_PIXELFORMAT_ABGR4444 = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16,
|
||||
SDL_PACKEDORDER_ABGR,
|
||||
SDL_PACKEDLAYOUT_4444, 16, 2)
|
||||
SDL_PIXELFORMAT_BGRA4444 = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16,
|
||||
SDL_PACKEDORDER_BGRA,
|
||||
SDL_PACKEDLAYOUT_4444, 16, 2)
|
||||
SDL_PIXELFORMAT_ARGB1555 = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16,
|
||||
SDL_PACKEDORDER_ARGB,
|
||||
SDL_PACKEDLAYOUT_1555, 16, 2)
|
||||
SDL_PIXELFORMAT_RGBA5551 = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16,
|
||||
SDL_PACKEDORDER_RGBA,
|
||||
SDL_PACKEDLAYOUT_5551, 16, 2)
|
||||
SDL_PIXELFORMAT_ABGR1555 = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16,
|
||||
SDL_PACKEDORDER_ABGR,
|
||||
SDL_PACKEDLAYOUT_1555, 16, 2)
|
||||
SDL_PIXELFORMAT_BGRA5551 = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16,
|
||||
SDL_PACKEDORDER_BGRA,
|
||||
SDL_PACKEDLAYOUT_5551, 16, 2)
|
||||
SDL_PIXELFORMAT_RGB565 = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16,
|
||||
SDL_PACKEDORDER_XRGB,
|
||||
SDL_PACKEDLAYOUT_565, 16, 2)
|
||||
SDL_PIXELFORMAT_BGR565 = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16,
|
||||
SDL_PACKEDORDER_XBGR,
|
||||
SDL_PACKEDLAYOUT_565, 16, 2)
|
||||
SDL_PIXELFORMAT_RGB24 = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8,
|
||||
SDL_ARRAYORDER_RGB, 0, 24, 3)
|
||||
SDL_PIXELFORMAT_BGR24 = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8,
|
||||
SDL_ARRAYORDER_BGR, 0, 24, 3)
|
||||
SDL_PIXELFORMAT_RGB888 = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32,
|
||||
SDL_PACKEDORDER_XRGB,
|
||||
SDL_PACKEDLAYOUT_8888, 24, 4)
|
||||
SDL_PIXELFORMAT_RGBX8888 = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32,
|
||||
SDL_PACKEDORDER_RGBX,
|
||||
SDL_PACKEDLAYOUT_8888, 24, 4)
|
||||
SDL_PIXELFORMAT_BGR888 = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32,
|
||||
SDL_PACKEDORDER_XBGR,
|
||||
SDL_PACKEDLAYOUT_8888, 24, 4)
|
||||
SDL_PIXELFORMAT_BGRX8888 = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32,
|
||||
SDL_PACKEDORDER_BGRX,
|
||||
SDL_PACKEDLAYOUT_8888, 24, 4)
|
||||
SDL_PIXELFORMAT_ARGB8888 = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32,
|
||||
SDL_PACKEDORDER_ARGB,
|
||||
SDL_PACKEDLAYOUT_8888, 32, 4)
|
||||
SDL_PIXELFORMAT_RGBA8888 = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32,
|
||||
SDL_PACKEDORDER_RGBA,
|
||||
SDL_PACKEDLAYOUT_8888, 32, 4)
|
||||
SDL_PIXELFORMAT_ABGR8888 = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32,
|
||||
SDL_PACKEDORDER_ABGR,
|
||||
SDL_PACKEDLAYOUT_8888, 32, 4)
|
||||
SDL_PIXELFORMAT_BGRA8888 = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32,
|
||||
SDL_PACKEDORDER_BGRA,
|
||||
SDL_PACKEDLAYOUT_8888, 32, 4)
|
||||
SDL_PIXELFORMAT_ARGB2101010 = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32,
|
||||
SDL_PACKEDORDER_ARGB,
|
||||
SDL_PACKEDLAYOUT_2101010,
|
||||
32, 4)
|
||||
SDL_PIXELFORMAT_YV12 = SDL_DEFINE_PIXELFOURCC('Y', 'V', '1', '2')
|
||||
SDL_PIXELFORMAT_IYUV = SDL_DEFINE_PIXELFOURCC('I', 'Y', 'U', 'V')
|
||||
SDL_PIXELFORMAT_YUY2 = SDL_DEFINE_PIXELFOURCC('Y', 'U', 'Y', '2')
|
||||
SDL_PIXELFORMAT_UYVY = SDL_DEFINE_PIXELFOURCC('U', 'Y', 'V', 'Y')
|
||||
SDL_PIXELFORMAT_YVYU = SDL_DEFINE_PIXELFOURCC('Y', 'V', 'Y', 'U')
|
||||
|
||||
ALL_PIXELFORMATS = (
|
||||
SDL_PIXELFORMAT_INDEX1LSB,
|
||||
SDL_PIXELFORMAT_INDEX1MSB,
|
||||
SDL_PIXELFORMAT_INDEX4LSB,
|
||||
SDL_PIXELFORMAT_INDEX4MSB,
|
||||
SDL_PIXELFORMAT_INDEX8,
|
||||
SDL_PIXELFORMAT_RGB332,
|
||||
SDL_PIXELFORMAT_RGB444,
|
||||
SDL_PIXELFORMAT_RGB555,
|
||||
SDL_PIXELFORMAT_BGR555,
|
||||
SDL_PIXELFORMAT_ARGB4444,
|
||||
SDL_PIXELFORMAT_RGBA4444,
|
||||
SDL_PIXELFORMAT_ABGR4444,
|
||||
SDL_PIXELFORMAT_BGRA4444,
|
||||
SDL_PIXELFORMAT_ARGB1555,
|
||||
SDL_PIXELFORMAT_RGBA5551,
|
||||
SDL_PIXELFORMAT_ABGR1555,
|
||||
SDL_PIXELFORMAT_BGRA5551,
|
||||
SDL_PIXELFORMAT_RGB565,
|
||||
SDL_PIXELFORMAT_BGR565,
|
||||
SDL_PIXELFORMAT_RGB24,
|
||||
SDL_PIXELFORMAT_BGR24,
|
||||
SDL_PIXELFORMAT_RGB888,
|
||||
SDL_PIXELFORMAT_RGBX8888,
|
||||
SDL_PIXELFORMAT_BGR888,
|
||||
SDL_PIXELFORMAT_BGRX8888,
|
||||
SDL_PIXELFORMAT_ARGB8888,
|
||||
SDL_PIXELFORMAT_RGBA8888,
|
||||
SDL_PIXELFORMAT_ABGR8888,
|
||||
SDL_PIXELFORMAT_BGRA8888,
|
||||
SDL_PIXELFORMAT_ARGB2101010,
|
||||
SDL_PIXELFORMAT_YV12,
|
||||
SDL_PIXELFORMAT_IYUV,
|
||||
SDL_PIXELFORMAT_YUY2,
|
||||
SDL_PIXELFORMAT_UYVY,
|
||||
SDL_PIXELFORMAT_YVYU,
|
||||
)
|
||||
|
||||
|
||||
class SDL_Color(Structure):
|
||||
_fields_ = [("r", Uint8),
|
||||
("g", Uint8),
|
||||
("b", Uint8),
|
||||
("a", Uint8),
|
||||
]
|
||||
|
||||
def __init__(self, r=255, g=255, b=255, a=255):
|
||||
super(SDL_Color, self).__init__()
|
||||
self.r = r
|
||||
self.g = g
|
||||
self.b = b
|
||||
self.a = a
|
||||
|
||||
def __repr__(self):
|
||||
return "SDL_Color(r=%d, g=%d, b=%d, a=%d)" % (self.r, self.g, self.b,
|
||||
self.a)
|
||||
|
||||
def __copy__(self):
|
||||
return SDL_Color(self.r, self.g, self.b, self.a)
|
||||
|
||||
def __deepcopy__(self, memo):
|
||||
return SDL_Color(self.r, self.g, self.b, self.a)
|
||||
|
||||
def __eq__(self, color):
|
||||
return self.r == color.r and self.g == color.g and \
|
||||
self.b == color.b and self.a == color.a
|
||||
|
||||
def __ne__(self, color):
|
||||
return self.r != color.r or self.g != color.g or self.b != color.b or \
|
||||
self.a != color.a
|
||||
|
||||
SDL_Colour = SDL_Color
|
||||
|
||||
class SDL_Palette(Structure):
|
||||
_fields_ = [("ncolors", c_int),
|
||||
("colors", POINTER(SDL_Color)),
|
||||
("version", Uint32),
|
||||
("refcount", c_int)]
|
||||
|
||||
|
||||
class SDL_PixelFormat(Structure):
|
||||
pass
|
||||
SDL_PixelFormat._fields_ = \
|
||||
[("format", Uint32),
|
||||
("palette", POINTER(SDL_Palette)),
|
||||
("BitsPerPixel", Uint8),
|
||||
("BytesPerPixel", Uint8),
|
||||
("padding", Uint8 * 2),
|
||||
("Rmask", Uint32),
|
||||
("Gmask", Uint32),
|
||||
("Bmask", Uint32),
|
||||
("Amask", Uint32),
|
||||
("Rloss", Uint8),
|
||||
("Gloss", Uint8),
|
||||
("Bloss", Uint8),
|
||||
("Aloss", Uint8),
|
||||
("Rshift", Uint8),
|
||||
("Gshift", Uint8),
|
||||
("Bshift", Uint8),
|
||||
("Ashift", Uint8),
|
||||
("refcount", c_int),
|
||||
("next", POINTER(SDL_PixelFormat))]
|
||||
|
||||
SDL_GetPixelFormatName = _bind("SDL_GetPixelFormatName", [Uint32], c_char_p)
|
||||
SDL_PixelFormatEnumToMasks = _bind("SDL_PixelFormatEnumToMasks", [Uint32, POINTER(c_int), POINTER(Uint32), POINTER(Uint32), POINTER(Uint32), POINTER(Uint32)], SDL_bool)
|
||||
SDL_MasksToPixelFormatEnum = _bind("SDL_MasksToPixelFormatEnum", [c_int, Uint32, Uint32, Uint32, Uint32], Uint32)
|
||||
SDL_AllocFormat = _bind("SDL_AllocFormat", [Uint32], POINTER(SDL_PixelFormat))
|
||||
SDL_FreeFormat = _bind("SDL_FreeFormat", [POINTER(SDL_PixelFormat)])
|
||||
SDL_AllocPalette = _bind("SDL_AllocPalette", [c_int], POINTER(SDL_Palette))
|
||||
SDL_SetPixelFormatPalette = _bind("SDL_SetPixelFormatPalette", [POINTER(SDL_PixelFormat), POINTER(SDL_Palette)], c_int)
|
||||
SDL_SetPaletteColors = _bind("SDL_SetPaletteColors", [POINTER(SDL_Palette), POINTER(SDL_Color), c_int, c_int], c_int)
|
||||
SDL_FreePalette = _bind("SDL_FreePalette", [POINTER(SDL_Palette)])
|
||||
SDL_MapRGB = _bind("SDL_MapRGB", [POINTER(SDL_PixelFormat), Uint8, Uint8, Uint8], Uint32)
|
||||
SDL_MapRGBA = _bind("SDL_MapRGBA", [POINTER(SDL_PixelFormat), Uint8, Uint8, Uint8, Uint8], Uint32)
|
||||
SDL_GetRGB = _bind("SDL_GetRGB", [Uint32, POINTER(SDL_PixelFormat), POINTER(Uint8), POINTER(Uint8), POINTER(Uint8)])
|
||||
SDL_GetRGBA = _bind("SDL_GetRGBA", [Uint32, POINTER(SDL_PixelFormat), POINTER(Uint8), POINTER(Uint8), POINTER(Uint8), POINTER(Uint8)])
|
||||
SDL_CalculateGammaRamp = _bind("SDL_CalculateGammaRamp", [c_float, POINTER(Uint16)])
|
6
src/m64py/SDL2/platform.py
Normal file
6
src/m64py/SDL2/platform.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
from ctypes import c_char_p
|
||||
from .dll import _bind
|
||||
|
||||
__all__ = ["SDL_GetPlatform"]
|
||||
|
||||
SDL_GetPlatform = _bind("SDL_GetPlatform", None, c_char_p)
|
17
src/m64py/SDL2/power.py
Normal file
17
src/m64py/SDL2/power.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
from ctypes import POINTER, c_int
|
||||
from .dll import _bind
|
||||
|
||||
__all__ = ["SDL_PowerState", "SDL_POWERSTATE_UNKNOWN",
|
||||
"SDL_POWERSTATE_ON_BATTERY", "SDL_POWERSTATE_NO_BATTERY",
|
||||
"SDL_POWERSTATE_CHARGING", "SDL_POWERSTATE_CHARGED",
|
||||
"SDL_GetPowerInfo"
|
||||
]
|
||||
|
||||
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
|
||||
|
||||
SDL_GetPowerInfo = _bind("SDL_GetPowerInfo", [POINTER(c_int), POINTER(c_int)], SDL_PowerState)
|
72
src/m64py/SDL2/rect.py
Normal file
72
src/m64py/SDL2/rect.py
Normal file
|
@ -0,0 +1,72 @@
|
|||
from ctypes import Structure, c_int, POINTER
|
||||
from .dll import _bind
|
||||
from .stdinc import SDL_bool
|
||||
|
||||
__all__ = ["SDL_Point", "SDL_Rect", "SDL_RectEmpty", "SDL_RectEquals",
|
||||
"SDL_HasIntersection", "SDL_IntersectRect", "SDL_UnionRect",
|
||||
"SDL_EnclosePoints", "SDL_IntersectRectAndLine"
|
||||
]
|
||||
|
||||
|
||||
class SDL_Point(Structure):
|
||||
_fields_ = [("x", c_int), ("y", c_int)]
|
||||
|
||||
def __init__(self, x=0, y=0):
|
||||
super(SDL_Point, self).__init__()
|
||||
self.x = x
|
||||
self.y = y
|
||||
|
||||
def __repr__(self):
|
||||
return "SDL_Point(x=%d, y=%d)" % (self.x, self.y)
|
||||
|
||||
def __copy__(self):
|
||||
return SDL_Point(self.x, self.y)
|
||||
|
||||
def __deepcopy__(self, memo):
|
||||
return SDL_Point(self.x, self.y)
|
||||
|
||||
def __eq__(self, pt):
|
||||
return self.x == pt.x and self.y == pt.y
|
||||
|
||||
def __ne__(self, pt):
|
||||
return self.x != pt.x or self.y != pt.y
|
||||
|
||||
|
||||
class SDL_Rect(Structure):
|
||||
_fields_ = [("x", c_int), ("y", c_int),
|
||||
("w", c_int), ("h", c_int)]
|
||||
|
||||
def __init__(self, x=0, y=0, w=0, h=0):
|
||||
super(SDL_Rect, self).__init__()
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.w = w
|
||||
self.h = h
|
||||
|
||||
def __repr__(self):
|
||||
return "SDL_Rect(x=%d, y=%d, w=%d, h=%d)" % (self.x, self.y, self.w,
|
||||
self.h)
|
||||
|
||||
def __copy__(self):
|
||||
return SDL_Rect(self.x, self.y, self.w, self.h)
|
||||
|
||||
def __deepcopy__(self, memo):
|
||||
return SDL_Rect(self.x, self.y, self.w, self.h)
|
||||
|
||||
def __eq__(self, rt):
|
||||
return self.x == rt.x and self.y == rt.y and \
|
||||
self.w == rt.w and self.h == rt.h
|
||||
|
||||
def __ne__(self, rt):
|
||||
return self.x != rt.x or self.y != rt.y or \
|
||||
self.w != rt.w or self.h != rt.h
|
||||
|
||||
|
||||
SDL_RectEmpty = lambda x: ((not x) or (x.w <= 0) or (x.h <= 0))
|
||||
SDL_RectEquals = lambda a, b: ((a.x == b.x) and (a.y == b.y) and
|
||||
(a.w == b.w) and (a.h == b.h))
|
||||
SDL_HasIntersection = _bind("SDL_HasIntersection", [POINTER(SDL_Rect), POINTER(SDL_Rect)], SDL_bool)
|
||||
SDL_IntersectRect = _bind("SDL_IntersectRect", [POINTER(SDL_Rect), POINTER(SDL_Rect), POINTER(SDL_Rect)], SDL_bool)
|
||||
SDL_UnionRect = _bind("SDL_UnionRect", [POINTER(SDL_Rect), POINTER(SDL_Rect), POINTER(SDL_Rect)])
|
||||
SDL_EnclosePoints = _bind("SDL_EnclosePoints", [POINTER(SDL_Point), c_int, POINTER(SDL_Rect), POINTER(SDL_Rect)], SDL_bool)
|
||||
SDL_IntersectRectAndLine = _bind("SDL_IntersectRectAndLine", [POINTER(SDL_Rect), POINTER(c_int), POINTER(c_int), POINTER(c_int), POINTER(c_int)], SDL_bool)
|
128
src/m64py/SDL2/render.py
Normal file
128
src/m64py/SDL2/render.py
Normal file
|
@ -0,0 +1,128 @@
|
|||
from ctypes import Structure, POINTER, c_int, c_char_p, c_void_p, c_float, \
|
||||
c_double
|
||||
from .dll import _bind
|
||||
from .stdinc import Uint8, Uint32, SDL_bool
|
||||
from .blendmode import SDL_BlendMode
|
||||
from .rect import SDL_Point, SDL_Rect
|
||||
from .surface import SDL_Surface
|
||||
from .video import SDL_Window
|
||||
|
||||
__all__ = ["SDL_RendererFlags", "SDL_RENDERER_SOFTWARE",
|
||||
"SDL_RENDERER_ACCELERATED", "SDL_RENDERER_PRESENTVSYNC",
|
||||
"SDL_RENDERER_TARGETTEXTURE", "SDL_RendererInfo",
|
||||
"SDL_TextureAccess", "SDL_TEXTUREACCESS_STATIC",
|
||||
"SDL_TEXTUREACCESS_STREAMING", "SDL_TEXTUREACCESS_TARGET",
|
||||
"SDL_TextureModulate", "SDL_TEXTUREMODULATE_NONE",
|
||||
"SDL_TEXTUREMODULATE_COLOR", "SDL_TEXTUREMODULATE_ALPHA",
|
||||
"SDL_RendererFlip", "SDL_FLIP_NONE", "SDL_FLIP_HORIZONTAL",
|
||||
"SDL_FLIP_VERTICAL", "SDL_Renderer", "SDL_Texture",
|
||||
"SDL_GetNumRenderDrivers", "SDL_GetRenderDriverInfo",
|
||||
"SDL_CreateWindowAndRenderer", "SDL_CreateRenderer",
|
||||
"SDL_CreateSoftwareRenderer", "SDL_GetRenderer",
|
||||
"SDL_GetRendererInfo", "SDL_CreateTexture",
|
||||
"SDL_CreateTextureFromSurface", "SDL_QueryTexture",
|
||||
"SDL_SetTextureColorMod", "SDL_GetTextureColorMod",
|
||||
"SDL_SetTextureAlphaMod", "SDL_GetTextureAlphaMod",
|
||||
"SDL_SetTextureBlendMode", "SDL_GetTextureBlendMode",
|
||||
"SDL_UpdateTexture", "SDL_LockTexture", "SDL_UnlockTexture",
|
||||
"SDL_RenderTargetSupported", "SDL_SetRenderTarget",
|
||||
"SDL_GetRenderTarget", "SDL_RenderSetLogicalSize",
|
||||
"SDL_RenderGetLogicalSize", "SDL_RenderSetViewport",
|
||||
"SDL_RenderGetClipRect", "SDL_RenderSetClipRect",
|
||||
"SDL_RenderGetViewport", "SDL_RenderSetScale", "SDL_RenderGetScale",
|
||||
"SDL_SetRenderDrawColor", "SDL_GetRenderDrawColor",
|
||||
"SDL_SetRenderDrawBlendMode", "SDL_GetRenderDrawBlendMode",
|
||||
"SDL_RenderClear", "SDL_RenderDrawPoint", "SDL_RenderDrawPoints",
|
||||
"SDL_RenderDrawLine", "SDL_RenderDrawLines", "SDL_RenderDrawRect",
|
||||
"SDL_RenderDrawRects", "SDL_RenderFillRect", "SDL_RenderFillRects",
|
||||
"SDL_RenderCopy", "SDL_RenderCopyEx", "SDL_RenderReadPixels",
|
||||
"SDL_RenderPresent", "SDL_DestroyTexture", "SDL_DestroyRenderer",
|
||||
"SDL_GL_BindTexture", "SDL_GL_UnbindTexture"
|
||||
]
|
||||
|
||||
SDL_RendererFlags = c_int
|
||||
SDL_RENDERER_SOFTWARE = 0x00000001
|
||||
SDL_RENDERER_ACCELERATED = 0x00000002
|
||||
SDL_RENDERER_PRESENTVSYNC = 0x00000004
|
||||
SDL_RENDERER_TARGETTEXTURE = 0x00000008
|
||||
|
||||
class SDL_RendererInfo(Structure):
|
||||
_fields_ = [("name", c_char_p),
|
||||
("flags", Uint32),
|
||||
("num_texture_formats", Uint32),
|
||||
("texture_formats", Uint32 * 16),
|
||||
("max_texture_width", c_int),
|
||||
("max_texture_height", c_int)]
|
||||
|
||||
SDL_TextureAccess = c_int
|
||||
SDL_TEXTUREACCESS_STATIC = 0
|
||||
SDL_TEXTUREACCESS_STREAMING = 1
|
||||
SDL_TEXTUREACCESS_TARGET = 2
|
||||
|
||||
SDL_TextureModulate = c_int
|
||||
SDL_TEXTUREMODULATE_NONE = 0x00000000
|
||||
SDL_TEXTUREMODULATE_COLOR = 0x00000001
|
||||
SDL_TEXTUREMODULATE_ALPHA = 0x00000002
|
||||
|
||||
SDL_RendererFlip = c_int
|
||||
SDL_FLIP_NONE = 0x00000000
|
||||
SDL_FLIP_HORIZONTAL = 0x00000001
|
||||
SDL_FLIP_VERTICAL = 0x00000002
|
||||
|
||||
class SDL_Renderer(Structure):
|
||||
pass
|
||||
class SDL_Texture(Structure):
|
||||
pass
|
||||
|
||||
SDL_GetNumRenderDrivers = _bind("SDL_GetNumRenderDrivers", None, c_int)
|
||||
SDL_GetRenderDriverInfo = _bind("SDL_GetRenderDriverInfo", [c_int, POINTER(SDL_RendererInfo)], c_int)
|
||||
SDL_CreateWindowAndRenderer = _bind("SDL_CreateWindowAndRenderer", [c_int, c_int, Uint32, POINTER(POINTER(SDL_Window)), POINTER(POINTER(SDL_Renderer))], c_int)
|
||||
SDL_CreateRenderer = _bind("SDL_CreateRenderer", [POINTER(SDL_Window), c_int, Uint32], POINTER(SDL_Renderer))
|
||||
SDL_CreateSoftwareRenderer = _bind("SDL_CreateSoftwareRenderer", [POINTER(SDL_Surface)], POINTER(SDL_Renderer))
|
||||
SDL_GetRenderer = _bind("SDL_GetRenderer", [POINTER(SDL_Window)], POINTER(SDL_Renderer))
|
||||
SDL_GetRendererInfo = _bind("SDL_GetRendererInfo", [POINTER(SDL_Renderer), POINTER(SDL_RendererInfo)], c_int)
|
||||
SDL_GetRendererOutputSize = _bind("SDL_GetRendererOutputSize", [POINTER(SDL_Renderer), POINTER(c_int), POINTER(c_int)], c_int)
|
||||
SDL_CreateTexture = _bind("SDL_CreateTexture", [POINTER(SDL_Renderer), Uint32, c_int, c_int, c_int], POINTER(SDL_Texture))
|
||||
SDL_CreateTextureFromSurface = _bind("SDL_CreateTextureFromSurface", [POINTER(SDL_Renderer), POINTER(SDL_Surface)], POINTER(SDL_Texture))
|
||||
SDL_QueryTexture = _bind("SDL_QueryTexture", [POINTER(SDL_Texture), POINTER(Uint32), POINTER(c_int), POINTER(c_int), POINTER(c_int)], c_int)
|
||||
SDL_SetTextureColorMod = _bind("SDL_SetTextureColorMod", [POINTER(SDL_Texture), Uint8, Uint8, Uint8], c_int)
|
||||
SDL_GetTextureColorMod = _bind("SDL_GetTextureColorMod", [POINTER(SDL_Texture), POINTER(Uint8), POINTER(Uint8), POINTER(Uint8)], c_int)
|
||||
SDL_SetTextureAlphaMod = _bind("SDL_SetTextureAlphaMod", [POINTER(SDL_Texture), Uint8], c_int)
|
||||
SDL_GetTextureAlphaMod = _bind("SDL_GetTextureAlphaMod", [POINTER(SDL_Texture), POINTER(Uint8)], c_int)
|
||||
SDL_SetTextureBlendMode = _bind("SDL_SetTextureBlendMode", [POINTER(SDL_Texture), SDL_BlendMode], c_int)
|
||||
SDL_GetTextureBlendMode = _bind("SDL_GetTextureBlendMode", [POINTER(SDL_Texture), POINTER(SDL_BlendMode)], c_int)
|
||||
SDL_UpdateTexture = _bind("SDL_UpdateTexture", [POINTER(SDL_Texture), POINTER(SDL_Rect), c_void_p, c_int], c_int)
|
||||
SDL_LockTexture = _bind("SDL_LockTexture", [POINTER(SDL_Texture), POINTER(SDL_Rect), POINTER(c_void_p), POINTER(c_int)], c_int)
|
||||
SDL_UnlockTexture = _bind("SDL_UnlockTexture", [POINTER(SDL_Texture)])
|
||||
SDL_RenderTargetSupported = _bind("SDL_RenderTargetSupported", [POINTER(SDL_Renderer)], SDL_bool)
|
||||
SDL_SetRenderTarget = _bind("SDL_SetRenderTarget", [POINTER(SDL_Renderer), POINTER(SDL_Texture)], c_int)
|
||||
SDL_GetRenderTarget = _bind("SDL_GetRenderTarget", [POINTER(SDL_Renderer)], POINTER(SDL_Texture))
|
||||
SDL_RenderSetLogicalSize = _bind("SDL_RenderSetLogicalSize", [POINTER(SDL_Renderer), c_int, c_int], c_int)
|
||||
SDL_RenderGetLogicalSize = _bind("SDL_RenderGetLogicalSize", [POINTER(SDL_Renderer), POINTER(c_int), POINTER(c_int)])
|
||||
SDL_RenderSetViewport = _bind("SDL_RenderSetViewport", [POINTER(SDL_Renderer), POINTER(SDL_Rect)], c_int)
|
||||
SDL_RenderGetViewport = _bind("SDL_RenderGetViewport", [POINTER(SDL_Renderer), POINTER(SDL_Rect)])
|
||||
SDL_RenderGetClipRect = _bind("SDL_RenderGetClipRect", [POINTER(SDL_Renderer), POINTER(SDL_Rect)])
|
||||
SDL_RenderSetClipRect = _bind("SDL_RenderSetClipRect", [POINTER(SDL_Renderer), POINTER(SDL_Rect)], c_int)
|
||||
SDL_RenderSetScale = _bind("SDL_RenderSetScale", [POINTER(SDL_Renderer), c_float, c_float], c_int)
|
||||
SDL_RenderGetScale = _bind("SDL_RenderGetScale", [POINTER(SDL_Renderer), POINTER(c_float), POINTER(c_float)])
|
||||
SDL_SetRenderDrawColor = _bind("SDL_SetRenderDrawColor", [POINTER(SDL_Renderer), Uint8, Uint8, Uint8, Uint8], c_int)
|
||||
SDL_GetRenderDrawColor = _bind("SDL_GetRenderDrawColor", [POINTER(SDL_Renderer), POINTER(Uint8), POINTER(Uint8), POINTER(Uint8), POINTER(Uint8)], c_int)
|
||||
SDL_SetRenderDrawBlendMode = _bind("SDL_SetRenderDrawBlendMode", [POINTER(SDL_Renderer), SDL_BlendMode], c_int)
|
||||
SDL_GetRenderDrawBlendMode = _bind("SDL_GetRenderDrawBlendMode", [POINTER(SDL_Renderer), POINTER(SDL_BlendMode)], c_int)
|
||||
SDL_RenderClear = _bind("SDL_RenderClear", [POINTER(SDL_Renderer)], c_int)
|
||||
SDL_RenderDrawPoint = _bind("SDL_RenderDrawPoint", [POINTER(SDL_Renderer), c_int, c_int], c_int)
|
||||
SDL_RenderDrawPoints = _bind("SDL_RenderDrawPoints", [POINTER(SDL_Renderer), POINTER(SDL_Point), c_int], c_int)
|
||||
SDL_RenderDrawLine = _bind("SDL_RenderDrawLine", [POINTER(SDL_Renderer), c_int, c_int, c_int, c_int], c_int)
|
||||
SDL_RenderDrawLines = _bind("SDL_RenderDrawLines", [POINTER(SDL_Renderer), POINTER(SDL_Point), c_int], c_int)
|
||||
SDL_RenderDrawRect = _bind("SDL_RenderDrawRect", [POINTER(SDL_Renderer), POINTER(SDL_Rect)], c_int)
|
||||
SDL_RenderDrawRects = _bind("SDL_RenderDrawRects", [POINTER(SDL_Renderer), POINTER(SDL_Rect), c_int], c_int)
|
||||
SDL_RenderFillRect = _bind("SDL_RenderFillRect", [POINTER(SDL_Renderer), POINTER(SDL_Rect)], c_int)
|
||||
SDL_RenderFillRects = _bind("SDL_RenderFillRects", [POINTER(SDL_Renderer), POINTER(SDL_Rect), c_int], c_int)
|
||||
SDL_RenderCopy = _bind("SDL_RenderCopy", [POINTER(SDL_Renderer), POINTER(SDL_Texture), POINTER(SDL_Rect), POINTER(SDL_Rect)], c_int)
|
||||
SDL_RenderCopyEx = _bind("SDL_RenderCopyEx", [POINTER(SDL_Renderer), POINTER(SDL_Texture), POINTER(SDL_Rect), POINTER(SDL_Rect), c_double, POINTER(SDL_Point), SDL_RendererFlip], c_int)
|
||||
SDL_RenderReadPixels = _bind("SDL_RenderReadPixels", [POINTER(SDL_Renderer), POINTER(SDL_Rect), Uint32, c_void_p, c_int], c_int)
|
||||
SDL_RenderPresent = _bind("SDL_RenderPresent", [POINTER(SDL_Renderer)])
|
||||
SDL_DestroyTexture = _bind("SDL_DestroyTexture", [POINTER(SDL_Texture)])
|
||||
SDL_DestroyRenderer = _bind("SDL_DestroyRenderer", [POINTER(SDL_Renderer)])
|
||||
SDL_GL_BindTexture = _bind("SDL_GL_BindTexture", [POINTER(SDL_Texture), POINTER(c_float), POINTER(c_float)], c_int)
|
||||
SDL_GL_UnbindTexture = _bind("SDL_GL_UnbindTexture", [POINTER(SDL_Texture)], c_int)
|
197
src/m64py/SDL2/rwops.py
Normal file
197
src/m64py/SDL2/rwops.py
Normal file
|
@ -0,0 +1,197 @@
|
|||
import sys
|
||||
from ctypes import Structure, POINTER, CFUNCTYPE, c_int, c_size_t, c_void_p, \
|
||||
c_char_p, memmove, string_at
|
||||
from .dll import _bind
|
||||
from .stdinc import Sint64, Uint8, Uint16, Uint32, Uint64, SDL_bool
|
||||
|
||||
__all__ = ["SDL_RWOPS_UNKNOWN", "SDL_RWOPS_WINFILE", "SDL_RWOPS_STDFILE",
|
||||
"SDL_RWOPS_JNIFILE", "SDL_RWOPS_MEMORY", "SDL_RWOPS_MEMORY_RO",
|
||||
"SDL_RWops", "SDL_RWFromFile", "SDL_RWFromFP", "SDL_RWFromMem",
|
||||
"SDL_RWFromConstMem", "SDL_AllocRW", "SDL_FreeRW", "RW_SEEK_SET",
|
||||
"RW_SEEK_CUR", "RW_SEEK_END", "SDL_RWsize", "SDL_RWseek",
|
||||
"SDL_RWtell", "SDL_RWread", "SDL_RWwrite", "SDL_RWclose",
|
||||
"SDL_ReadU8", "SDL_ReadLE16", "SDL_ReadBE16", "SDL_ReadLE32",
|
||||
"SDL_ReadBE32", "SDL_ReadLE64", "SDL_ReadBE64", "SDL_WriteU8",
|
||||
"SDL_WriteLE16", "SDL_WriteBE16", "SDL_WriteLE32", "SDL_WriteBE32",
|
||||
"SDL_WriteLE64", "SDL_WriteBE64", "rw_from_object"
|
||||
]
|
||||
|
||||
SDL_RWOPS_UNKNOWN = 0
|
||||
SDL_RWOPS_WINFILE = 1
|
||||
SDL_RWOPS_STDFILE = 2
|
||||
SDL_RWOPS_JNIFILE = 3
|
||||
SDL_RWOPS_MEMORY = 4
|
||||
SDL_RWOPS_MEMORY_RO = 5
|
||||
|
||||
class SDL_RWops(Structure):
|
||||
pass
|
||||
|
||||
_sdlsize = CFUNCTYPE(Sint64, POINTER(SDL_RWops))
|
||||
_sdlseek = CFUNCTYPE(Sint64, POINTER(SDL_RWops), Sint64, c_int)
|
||||
_sdlread = CFUNCTYPE(c_size_t, POINTER(SDL_RWops), c_void_p, c_size_t, c_size_t)
|
||||
_sdlwrite = CFUNCTYPE(c_size_t, POINTER(SDL_RWops), c_void_p, c_size_t, c_size_t)
|
||||
_sdlclose = CFUNCTYPE(c_int, POINTER(SDL_RWops))
|
||||
SDL_RWops._fields_ = [("size", _sdlsize),
|
||||
("seek", _sdlseek),
|
||||
("read", _sdlread),
|
||||
("write", _sdlwrite),
|
||||
("close", _sdlclose),
|
||||
("type", Uint32),
|
||||
# TODO: Union hidden
|
||||
]
|
||||
|
||||
SDL_RWFromFile = _bind("SDL_RWFromFile", [c_char_p, c_char_p], POINTER(SDL_RWops))
|
||||
SDL_RWFromFP = _bind("SDL_RWFromFP", [c_void_p, SDL_bool], POINTER(SDL_RWops))
|
||||
SDL_RWFromMem = _bind("SDL_RWFromMem", [c_void_p, c_int], POINTER(SDL_RWops))
|
||||
SDL_RWFromConstMem = _bind("SDL_RWFromConstMem", [c_void_p, c_int], POINTER(SDL_RWops))
|
||||
SDL_AllocRW = _bind("SDL_AllocRW", None, POINTER(SDL_RWops))
|
||||
SDL_FreeRW = _bind("SDL_AllocRW", [POINTER(SDL_RWops)])
|
||||
|
||||
RW_SEEK_SET = 0
|
||||
RW_SEEK_CUR = 1
|
||||
RW_SEEK_END = 2
|
||||
|
||||
SDL_RWsize = lambda ctx: ctx.size(ctx)
|
||||
SDL_RWseek = lambda ctx, offset, whence: ctx.seek(ctx, offset, whence)
|
||||
SDL_RWtell = lambda ctx: ctx.seek(ctx, 0, RW_SEEK_CUR)
|
||||
SDL_RWread = lambda ctx, ptr, size, n: ctx.read(ctx, ptr, size, n)
|
||||
SDL_RWwrite = lambda ctx, ptr, size, n: ctx.write(ctx, ptr, size, n)
|
||||
SDL_RWclose = lambda ctx: ctx.close(ctx)
|
||||
|
||||
SDL_ReadU8 = _bind("SDL_ReadU8", [POINTER(SDL_RWops)], Uint8)
|
||||
SDL_ReadLE16 = _bind("SDL_ReadLE16", [POINTER(SDL_RWops)], Uint16)
|
||||
SDL_ReadBE16 = _bind("SDL_ReadBE16", [POINTER(SDL_RWops)], Uint16)
|
||||
SDL_ReadLE32 = _bind("SDL_ReadLE32", [POINTER(SDL_RWops)], Uint32)
|
||||
SDL_ReadBE32 = _bind("SDL_ReadBE32", [POINTER(SDL_RWops)], Uint32)
|
||||
SDL_ReadLE64 = _bind("SDL_ReadLE64", [POINTER(SDL_RWops)], Uint64)
|
||||
SDL_ReadBE64 = _bind("SDL_ReadBE64", [POINTER(SDL_RWops)], Uint64)
|
||||
|
||||
SDL_WriteU8 = _bind("SDL_WriteU8", [POINTER(SDL_RWops), Uint8], c_size_t)
|
||||
SDL_WriteLE16 = _bind("SDL_WriteLE16", [POINTER(SDL_RWops), Uint16], c_size_t)
|
||||
SDL_WriteBE16 = _bind("SDL_WriteBE16", [POINTER(SDL_RWops), Uint16], c_size_t)
|
||||
SDL_WriteLE32 = _bind("SDL_WriteLE32", [POINTER(SDL_RWops), Uint32], c_size_t)
|
||||
SDL_WriteBE32 = _bind("SDL_WriteBE32", [POINTER(SDL_RWops), Uint32], c_size_t)
|
||||
SDL_WriteLE64 = _bind("SDL_WriteLE64", [POINTER(SDL_RWops), Uint64], c_size_t)
|
||||
SDL_WriteBE64 = _bind("SDL_WriteBE64", [POINTER(SDL_RWops), Uint64], c_size_t)
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
import collections
|
||||
callable = lambda x: isinstance(x, collections.Callable)
|
||||
|
||||
def rw_from_object(obj):
|
||||
"""Creats a SDL_RWops from any Python object.
|
||||
|
||||
The Python object must at least support the following methods:
|
||||
|
||||
read(length) -> data
|
||||
length is the size in bytes to be read. A call to len(data) must
|
||||
return the correct amount of bytes for the data, so that
|
||||
len(data) / [size in bytes for a single element from data] returns
|
||||
the amount of elements.
|
||||
Must raise an error on failure.
|
||||
|
||||
seek(offset, whence) -> int
|
||||
offset denotes the offset to move the read/write pointer of the
|
||||
object to. whence indicates the movement behaviour and can be one
|
||||
of the following values:
|
||||
RW_SEEK_SET - move to offset from the start of the file
|
||||
RW_SEEK_CUR - move by offset from the relative location
|
||||
RW_SEEK_END - move to offset from the end of the file
|
||||
If it could not move read/write pointer to the desired location,
|
||||
an error must be raised.
|
||||
|
||||
tell() -> int
|
||||
Must return the current offset. This method must only be
|
||||
provided, if seek() does not return any value.
|
||||
|
||||
close() -> None
|
||||
Closes the object(or its internal data access methods). Must raise
|
||||
an error on failure.
|
||||
|
||||
write(data) -> None
|
||||
Writes the passed data(which is a string of bytes) to the object.
|
||||
Must raise an error on failure.
|
||||
|
||||
Note: The write() method is optional and only necessary, if the passed
|
||||
object should be able to write data.
|
||||
|
||||
The returned SDL_RWops is a pure Python object and must not be freed via
|
||||
free_rw().
|
||||
"""
|
||||
if not hasattr(obj, "read"):
|
||||
raise TypeError("obj must have a read(len) -> data method")
|
||||
if not hasattr(obj, "seek") or not callable(obj.seek):
|
||||
raise TypeError("obj must have a seek(offset, whence) method")
|
||||
if not hasattr(obj, "close") or not callable(obj.close):
|
||||
raise TypeError("obj must have a close() -> int method")
|
||||
|
||||
rwops = SDL_RWops()
|
||||
|
||||
def _rwsize(context):
|
||||
try:
|
||||
if hasattr(obj, "size"):
|
||||
if callable(obj.size):
|
||||
return obj.size()
|
||||
else:
|
||||
return obj.size
|
||||
else:
|
||||
cur = obj.seek(0, RW_SEEK_CUR)
|
||||
length = obj.seek(0, RW_SEEK_END)
|
||||
obj.seek(cur, RW_SEEK_CUR)
|
||||
return length
|
||||
except Exception:
|
||||
#print(e)
|
||||
return -1
|
||||
rwops.size = _sdlsize(_rwsize)
|
||||
|
||||
def _rwseek(context, offset, whence):
|
||||
try:
|
||||
retval = obj.seek(offset, whence)
|
||||
if retval is None:
|
||||
retval = obj.tell()
|
||||
return retval
|
||||
except Exception:
|
||||
#print(e)
|
||||
return -1
|
||||
rwops.seek = _sdlseek(_rwseek)
|
||||
|
||||
def _rwread(context, ptr, size, maxnum):
|
||||
try:
|
||||
data = obj.read(size * maxnum)
|
||||
num = len(data)
|
||||
memmove(ptr, data, num)
|
||||
return num // size
|
||||
except Exception:
|
||||
#print(e)
|
||||
return 0
|
||||
rwops.read = _sdlread(_rwread)
|
||||
|
||||
def _rwclose(context):
|
||||
try:
|
||||
retval = obj.close()
|
||||
if retval is None:
|
||||
# No return value; we assume that everything is okay.
|
||||
return 0
|
||||
return retval
|
||||
except Exception:
|
||||
#print(e)
|
||||
return -1
|
||||
rwops.close = _sdlclose(_rwclose)
|
||||
|
||||
def _rwwrite(context, ptr, size, num):
|
||||
try:
|
||||
# string_at feels wrong, since we access a raw byte buffer...
|
||||
retval = obj.write(string_at(ptr, size * num))
|
||||
if retval is None:
|
||||
# No return value; we assume that everything is okay.
|
||||
return num
|
||||
return retval
|
||||
except Exception:
|
||||
#print(e)
|
||||
return 0
|
||||
|
||||
if hasattr(obj, "write") and callable(obj.write):
|
||||
rwops.write = _sdlwrite(_rwwrite)
|
||||
else:
|
||||
rwops.write = _sdlwrite()
|
||||
return rwops
|
267
src/m64py/SDL2/scancode.py
Normal file
267
src/m64py/SDL2/scancode.py
Normal file
|
@ -0,0 +1,267 @@
|
|||
from ctypes import c_int
|
||||
|
||||
SDL_Scancode = c_int
|
||||
|
||||
SDL_SCANCODE_UNKNOWN = 0
|
||||
SDL_SCANCODE_A = 4
|
||||
SDL_SCANCODE_B = 5
|
||||
SDL_SCANCODE_C = 6
|
||||
SDL_SCANCODE_D = 7
|
||||
SDL_SCANCODE_E = 8
|
||||
SDL_SCANCODE_F = 9
|
||||
SDL_SCANCODE_G = 10
|
||||
SDL_SCANCODE_H = 11
|
||||
SDL_SCANCODE_I = 12
|
||||
SDL_SCANCODE_J = 13
|
||||
SDL_SCANCODE_K = 14
|
||||
SDL_SCANCODE_L = 15
|
||||
SDL_SCANCODE_M = 16
|
||||
SDL_SCANCODE_N = 17
|
||||
SDL_SCANCODE_O = 18
|
||||
SDL_SCANCODE_P = 19
|
||||
SDL_SCANCODE_Q = 20
|
||||
SDL_SCANCODE_R = 21
|
||||
SDL_SCANCODE_S = 22
|
||||
SDL_SCANCODE_T = 23
|
||||
SDL_SCANCODE_U = 24
|
||||
SDL_SCANCODE_V = 25
|
||||
SDL_SCANCODE_W = 26
|
||||
SDL_SCANCODE_X = 27
|
||||
SDL_SCANCODE_Y = 28
|
||||
SDL_SCANCODE_Z = 29
|
||||
|
||||
SDL_SCANCODE_1 = 30
|
||||
SDL_SCANCODE_2 = 31
|
||||
SDL_SCANCODE_3 = 32
|
||||
SDL_SCANCODE_4 = 33
|
||||
SDL_SCANCODE_5 = 34
|
||||
SDL_SCANCODE_6 = 35
|
||||
SDL_SCANCODE_7 = 36
|
||||
SDL_SCANCODE_8 = 37
|
||||
SDL_SCANCODE_9 = 38
|
||||
SDL_SCANCODE_0 = 39
|
||||
|
||||
SDL_SCANCODE_RETURN = 40
|
||||
SDL_SCANCODE_ESCAPE = 41
|
||||
SDL_SCANCODE_BACKSPACE = 42
|
||||
SDL_SCANCODE_TAB = 43
|
||||
SDL_SCANCODE_SPACE = 44
|
||||
|
||||
SDL_SCANCODE_MINUS = 45
|
||||
SDL_SCANCODE_EQUALS = 46
|
||||
SDL_SCANCODE_LEFTBRACKET = 47
|
||||
SDL_SCANCODE_RIGHTBRACKET = 48
|
||||
SDL_SCANCODE_BACKSLASH = 49
|
||||
|
||||
SDL_SCANCODE_NONUSHASH = 50
|
||||
|
||||
SDL_SCANCODE_SEMICOLON = 51
|
||||
SDL_SCANCODE_APOSTROPHE = 52
|
||||
SDL_SCANCODE_GRAVE = 53
|
||||
|
||||
SDL_SCANCODE_COMMA = 54
|
||||
SDL_SCANCODE_PERIOD = 55
|
||||
SDL_SCANCODE_SLASH = 56
|
||||
|
||||
SDL_SCANCODE_CAPSLOCK = 57
|
||||
|
||||
SDL_SCANCODE_F1 = 58
|
||||
SDL_SCANCODE_F2 = 59
|
||||
SDL_SCANCODE_F3 = 60
|
||||
SDL_SCANCODE_F4 = 61
|
||||
SDL_SCANCODE_F5 = 62
|
||||
SDL_SCANCODE_F6 = 63
|
||||
SDL_SCANCODE_F7 = 64
|
||||
SDL_SCANCODE_F8 = 65
|
||||
SDL_SCANCODE_F9 = 66
|
||||
SDL_SCANCODE_F10 = 67
|
||||
SDL_SCANCODE_F11 = 68
|
||||
SDL_SCANCODE_F12 = 69
|
||||
|
||||
SDL_SCANCODE_PRINTSCREEN = 70
|
||||
SDL_SCANCODE_SCROLLLOCK = 71
|
||||
SDL_SCANCODE_PAUSE = 72
|
||||
SDL_SCANCODE_INSERT = 73
|
||||
|
||||
SDL_SCANCODE_HOME = 74
|
||||
SDL_SCANCODE_PAGEUP = 75
|
||||
SDL_SCANCODE_DELETE = 76
|
||||
SDL_SCANCODE_END = 77
|
||||
SDL_SCANCODE_PAGEDOWN = 78
|
||||
SDL_SCANCODE_RIGHT = 79
|
||||
SDL_SCANCODE_LEFT = 80
|
||||
SDL_SCANCODE_DOWN = 81
|
||||
SDL_SCANCODE_UP = 82
|
||||
|
||||
SDL_SCANCODE_NUMLOCKCLEAR = 83
|
||||
SDL_SCANCODE_KP_DIVIDE = 84
|
||||
SDL_SCANCODE_KP_MULTIPLY = 85
|
||||
SDL_SCANCODE_KP_MINUS = 86
|
||||
SDL_SCANCODE_KP_PLUS = 87
|
||||
SDL_SCANCODE_KP_ENTER = 88
|
||||
SDL_SCANCODE_KP_1 = 89
|
||||
SDL_SCANCODE_KP_2 = 90
|
||||
SDL_SCANCODE_KP_3 = 91
|
||||
SDL_SCANCODE_KP_4 = 92
|
||||
SDL_SCANCODE_KP_5 = 93
|
||||
SDL_SCANCODE_KP_6 = 94
|
||||
SDL_SCANCODE_KP_7 = 95
|
||||
SDL_SCANCODE_KP_8 = 96
|
||||
SDL_SCANCODE_KP_9 = 97
|
||||
SDL_SCANCODE_KP_0 = 98
|
||||
SDL_SCANCODE_KP_PERIOD = 99
|
||||
|
||||
SDL_SCANCODE_NONUSBACKSLASH = 100
|
||||
|
||||
SDL_SCANCODE_APPLICATION = 101
|
||||
SDL_SCANCODE_POWER = 102
|
||||
|
||||
SDL_SCANCODE_KP_EQUALS = 103
|
||||
|
||||
SDL_SCANCODE_F13 = 104
|
||||
SDL_SCANCODE_F14 = 105
|
||||
SDL_SCANCODE_F15 = 106
|
||||
SDL_SCANCODE_F16 = 107
|
||||
SDL_SCANCODE_F17 = 108
|
||||
SDL_SCANCODE_F18 = 109
|
||||
SDL_SCANCODE_F19 = 110
|
||||
SDL_SCANCODE_F20 = 111
|
||||
SDL_SCANCODE_F21 = 112
|
||||
SDL_SCANCODE_F22 = 113
|
||||
SDL_SCANCODE_F23 = 114
|
||||
SDL_SCANCODE_F24 = 115
|
||||
SDL_SCANCODE_EXECUTE = 116
|
||||
SDL_SCANCODE_HELP = 117
|
||||
SDL_SCANCODE_MENU = 118
|
||||
SDL_SCANCODE_SELECT = 119
|
||||
SDL_SCANCODE_STOP = 120
|
||||
SDL_SCANCODE_AGAIN = 121
|
||||
SDL_SCANCODE_UNDO = 122
|
||||
SDL_SCANCODE_CUT = 123
|
||||
SDL_SCANCODE_COPY = 124
|
||||
SDL_SCANCODE_PASTE = 125
|
||||
SDL_SCANCODE_FIND = 126
|
||||
SDL_SCANCODE_MUTE = 127
|
||||
SDL_SCANCODE_VOLUMEUP = 128
|
||||
SDL_SCANCODE_VOLUMEDOWN = 129
|
||||
SDL_SCANCODE_KP_COMMA = 133
|
||||
SDL_SCANCODE_KP_EQUALSAS400 = 134
|
||||
|
||||
SDL_SCANCODE_INTERNATIONAL1 = 135
|
||||
SDL_SCANCODE_INTERNATIONAL2 = 136
|
||||
SDL_SCANCODE_INTERNATIONAL3 = 137
|
||||
SDL_SCANCODE_INTERNATIONAL4 = 138
|
||||
SDL_SCANCODE_INTERNATIONAL5 = 139
|
||||
SDL_SCANCODE_INTERNATIONAL6 = 140
|
||||
SDL_SCANCODE_INTERNATIONAL7 = 141
|
||||
SDL_SCANCODE_INTERNATIONAL8 = 142
|
||||
SDL_SCANCODE_INTERNATIONAL9 = 143
|
||||
|
||||
SDL_SCANCODE_LANG1 = 144
|
||||
SDL_SCANCODE_LANG2 = 145
|
||||
SDL_SCANCODE_LANG3 = 146
|
||||
SDL_SCANCODE_LANG4 = 147
|
||||
SDL_SCANCODE_LANG5 = 148
|
||||
SDL_SCANCODE_LANG6 = 149
|
||||
SDL_SCANCODE_LANG7 = 150
|
||||
SDL_SCANCODE_LANG8 = 151
|
||||
SDL_SCANCODE_LANG9 = 152
|
||||
|
||||
SDL_SCANCODE_ALTERASE = 153
|
||||
SDL_SCANCODE_SYSREQ = 154
|
||||
SDL_SCANCODE_CANCEL = 155
|
||||
SDL_SCANCODE_CLEAR = 156
|
||||
SDL_SCANCODE_PRIOR = 157
|
||||
SDL_SCANCODE_RETURN2 = 158
|
||||
SDL_SCANCODE_SEPARATOR = 159
|
||||
SDL_SCANCODE_OUT = 160
|
||||
SDL_SCANCODE_OPER = 161
|
||||
SDL_SCANCODE_CLEARAGAIN = 162
|
||||
SDL_SCANCODE_CRSEL = 163
|
||||
SDL_SCANCODE_EXSEL = 164
|
||||
|
||||
SDL_SCANCODE_KP_00 = 176
|
||||
SDL_SCANCODE_KP_000 = 177
|
||||
SDL_SCANCODE_THOUSANDSSEPARATOR = 178
|
||||
SDL_SCANCODE_DECIMALSEPARATOR = 179
|
||||
SDL_SCANCODE_CURRENCYUNIT = 180
|
||||
SDL_SCANCODE_CURRENCYSUBUNIT = 181
|
||||
SDL_SCANCODE_KP_LEFTPAREN = 182
|
||||
SDL_SCANCODE_KP_RIGHTPAREN = 183
|
||||
SDL_SCANCODE_KP_LEFTBRACE = 184
|
||||
SDL_SCANCODE_KP_RIGHTBRACE = 185
|
||||
SDL_SCANCODE_KP_TAB = 186
|
||||
SDL_SCANCODE_KP_BACKSPACE = 187
|
||||
SDL_SCANCODE_KP_A = 188
|
||||
SDL_SCANCODE_KP_B = 189
|
||||
SDL_SCANCODE_KP_C = 190
|
||||
SDL_SCANCODE_KP_D = 191
|
||||
SDL_SCANCODE_KP_E = 192
|
||||
SDL_SCANCODE_KP_F = 193
|
||||
SDL_SCANCODE_KP_XOR = 194
|
||||
SDL_SCANCODE_KP_POWER = 195
|
||||
SDL_SCANCODE_KP_PERCENT = 196
|
||||
SDL_SCANCODE_KP_LESS = 197
|
||||
SDL_SCANCODE_KP_GREATER = 198
|
||||
SDL_SCANCODE_KP_AMPERSAND = 199
|
||||
SDL_SCANCODE_KP_DBLAMPERSAND = 200
|
||||
SDL_SCANCODE_KP_VERTICALBAR = 201
|
||||
SDL_SCANCODE_KP_DBLVERTICALBAR = 202
|
||||
SDL_SCANCODE_KP_COLON = 203
|
||||
SDL_SCANCODE_KP_HASH = 204
|
||||
SDL_SCANCODE_KP_SPACE = 205
|
||||
SDL_SCANCODE_KP_AT = 206
|
||||
SDL_SCANCODE_KP_EXCLAM = 207
|
||||
SDL_SCANCODE_KP_MEMSTORE = 208
|
||||
SDL_SCANCODE_KP_MEMRECALL = 209
|
||||
SDL_SCANCODE_KP_MEMCLEAR = 210
|
||||
SDL_SCANCODE_KP_MEMADD = 211
|
||||
SDL_SCANCODE_KP_MEMSUBTRACT = 212
|
||||
SDL_SCANCODE_KP_MEMMULTIPLY = 213
|
||||
SDL_SCANCODE_KP_MEMDIVIDE = 214
|
||||
SDL_SCANCODE_KP_PLUSMINUS = 215
|
||||
SDL_SCANCODE_KP_CLEAR = 216
|
||||
SDL_SCANCODE_KP_CLEARENTRY = 217
|
||||
SDL_SCANCODE_KP_BINARY = 218
|
||||
SDL_SCANCODE_KP_OCTAL = 219
|
||||
SDL_SCANCODE_KP_DECIMAL = 220
|
||||
SDL_SCANCODE_KP_HEXADECIMAL = 221
|
||||
|
||||
SDL_SCANCODE_LCTRL = 224
|
||||
SDL_SCANCODE_LSHIFT = 225
|
||||
SDL_SCANCODE_LALT = 226
|
||||
SDL_SCANCODE_LGUI = 227
|
||||
SDL_SCANCODE_RCTRL = 228
|
||||
SDL_SCANCODE_RSHIFT = 229
|
||||
SDL_SCANCODE_RALT = 230
|
||||
SDL_SCANCODE_RGUI = 231
|
||||
|
||||
SDL_SCANCODE_MODE = 257
|
||||
|
||||
SDL_SCANCODE_AUDIONEXT = 258
|
||||
SDL_SCANCODE_AUDIOPREV = 259
|
||||
SDL_SCANCODE_AUDIOSTOP = 260
|
||||
SDL_SCANCODE_AUDIOPLAY = 261
|
||||
SDL_SCANCODE_AUDIOMUTE = 262
|
||||
SDL_SCANCODE_MEDIASELECT = 263
|
||||
SDL_SCANCODE_WWW = 264
|
||||
SDL_SCANCODE_MAIL = 265
|
||||
SDL_SCANCODE_CALCULATOR = 266
|
||||
SDL_SCANCODE_COMPUTER = 267
|
||||
SDL_SCANCODE_AC_SEARCH = 268
|
||||
SDL_SCANCODE_AC_HOME = 269
|
||||
SDL_SCANCODE_AC_BACK = 270
|
||||
SDL_SCANCODE_AC_FORWARD = 271
|
||||
SDL_SCANCODE_AC_STOP = 272
|
||||
SDL_SCANCODE_AC_REFRESH = 273
|
||||
SDL_SCANCODE_AC_BOOKMARKS = 274
|
||||
SDL_SCANCODE_BRIGHTNESSDOWN = 275
|
||||
SDL_SCANCODE_BRIGHTNESSUP = 276
|
||||
SDL_SCANCODE_DISPLAYSWITCH = 277
|
||||
SDL_SCANCODE_KBDILLUMTOGGLE = 278
|
||||
SDL_SCANCODE_KBDILLUMDOWN = 279
|
||||
SDL_SCANCODE_KBDILLUMUP = 280
|
||||
SDL_SCANCODE_EJECT = 281
|
||||
SDL_SCANCODE_SLEEP = 282
|
||||
|
||||
SDL_NUM_SCANCODES = 512
|
142
src/m64py/SDL2/sdlgfx.py
Normal file
142
src/m64py/SDL2/sdlgfx.py
Normal file
|
@ -0,0 +1,142 @@
|
|||
import os
|
||||
from ctypes import Structure, POINTER, c_int, c_float, c_void_p, c_char, \
|
||||
c_char_p, c_double
|
||||
from .dll import _DLL
|
||||
from .stdinc import Uint8, Uint32, Sint16
|
||||
from .render import SDL_Renderer
|
||||
from .surface import SDL_Surface
|
||||
|
||||
__all__ = ["get_dll_file", "FPS_UPPER_LIMIT", "FPS_LOWER_LIMIT", "FPS_DEFAULT",
|
||||
"FPSManager", "SDL_initFramerate", "SDL_getFramerate",
|
||||
"SDL_setFramerate", "SDL_getFramecount", "SDL_framerateDelay",
|
||||
"SDL2_GFXPRIMITIVES_MAJOR", "SDL2_GFXPRIMITIVES_MAJOR",
|
||||
"SDL2_GFXPRIMITIVES_MICRO", "pixelColor", "pixelRGBA", "hlineColor",
|
||||
"hlineRGBA", "vlineColor", "vlineRGBA", "rectangleColor",
|
||||
"rectangleRGBA", "roundedRectangleColor", "roundedRectangleRGBA",
|
||||
"boxColor", "boxRGBA", "roundedBoxColor", "roundedBoxRGBA",
|
||||
"lineColor", "lineRGBA", "aalineColor", "aalineRGBA",
|
||||
"thickLineColor", "thickLineRGBA", "circleColor", "circleRGBA",
|
||||
"arcColor", "arcRGBA", "aacircleColor", "aacircleRGBA",
|
||||
"filledCircleColor", "filledCircleRGBA", "ellipseColor",
|
||||
"ellipseRGBA", "aaellipseColor", "aaellipseRGBA",
|
||||
"filledEllipseColor", "filledEllipseRGBA", "pieColor", "pieRGBA",
|
||||
"filledPieColor", "filledPieRGBA", "trigonColor", "trigonRGBA",
|
||||
"aatrigonColor", "aatrigonRGBA", "filledTrigonColor",
|
||||
"filledTrigonRGBA", "polygonColor", "polygonRGBA", "aapolygonColor",
|
||||
"aapolygonRGBA", "filledPolygonColor", "filledPolygonRGBA",
|
||||
"texturedPolygon", "bezierColor", "bezierRGBA",
|
||||
"gfxPrimitivesSetFont", "gfxPrimitivesSetFontRotation",
|
||||
"characterColor", "characterRGBA", "stringColor", "stringRGBA",
|
||||
"SMOOTHING_OFF", "SMOOTHING_ON", "rotozoomSurface",
|
||||
"rotozoomSurfaceXY", "rotozoomSurfaceSize", "rotozoomSurfaceSizeXY",
|
||||
"zoomSurface", "zoomSurfaceSize", "shrinkSurface",
|
||||
"rotateSurface90Degrees"
|
||||
]
|
||||
|
||||
try:
|
||||
dll = _DLL("SDL2_gfx", ["SDL2_gfx", "SDL2_gfx-1.0"],
|
||||
os.getenv("PYSDL2_DLL_PATH"))
|
||||
except RuntimeError as exc:
|
||||
raise ImportError(exc)
|
||||
|
||||
|
||||
def get_dll_file():
|
||||
"""Gets the file name of the loaded SDL2_gfx library."""
|
||||
return dll.libfile
|
||||
|
||||
_bind = dll.bind_function
|
||||
|
||||
|
||||
FPS_UPPER_LIMIT = 200
|
||||
FPS_LOWER_LIMIT = 1
|
||||
FPS_DEFAULT = 30
|
||||
|
||||
|
||||
class FPSManager(Structure):
|
||||
_fields_ = [("framecount", Uint32),
|
||||
("rateticks", c_float),
|
||||
("baseticks", Uint32),
|
||||
("lastticks", Uint32),
|
||||
("rate", Uint32)
|
||||
]
|
||||
|
||||
SDL_initFramerate = _bind("SDL_initFramerate", [POINTER(FPSManager)])
|
||||
SDL_setFramerate = _bind("SDL_setFramerate", [POINTER(FPSManager), Uint32], c_int)
|
||||
SDL_getFramerate = _bind("SDL_getFramerate", [POINTER(FPSManager)], c_int)
|
||||
SDL_getFramecount = _bind("SDL_getFramecount", [POINTER(FPSManager)], Uint32)
|
||||
SDL_framerateDelay = _bind("SDL_framerateDelay", [POINTER(FPSManager)], Uint32)
|
||||
|
||||
SDL2_GFXPRIMITIVES_MAJOR = 1
|
||||
SDL2_GFXPRIMITIVES_MINOR = 0
|
||||
SDL2_GFXPRIMITIVES_MICRO = 0
|
||||
|
||||
pixelColor = _bind("pixelColor", [POINTER(SDL_Renderer), Sint16, Sint16, Uint32], c_int)
|
||||
pixelRGBA = _bind("pixelRGBA", [POINTER(SDL_Renderer), Sint16, Sint16, Uint8, Uint8, Uint8, Uint8], c_int)
|
||||
hlineColor = _bind("hlineColor", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Uint32], c_int)
|
||||
hlineRGBA = _bind("hlineRGBA", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Uint8, Uint8, Uint8, Uint8], c_int)
|
||||
vlineColor = _bind("vlineColor", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Uint32], c_int)
|
||||
vlineRGBA = _bind("vlineRGBA", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Uint8, Uint8, Uint8, Uint8], c_int)
|
||||
rectangleColor = _bind("rectangleColor", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Sint16, Uint32], c_int)
|
||||
rectangleRGBA = _bind("rectangleRGBA", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Sint16, Uint8, Uint8, Uint8, Uint8], c_int)
|
||||
roundedRectangleColor = _bind("roundedRectangleColor", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Sint16, Sint16, Uint32], c_int)
|
||||
roundedRectangleRGBA = _bind("roundedRectangleRGBA", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Sint16, Sint16, Uint8, Uint8, Uint8, Uint8], c_int)
|
||||
boxColor = _bind("boxColor", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Sint16, Uint32], c_int)
|
||||
boxRGBA = _bind("boxRGBA", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Sint16, Uint8, Uint8, Uint8, Uint8], c_int)
|
||||
roundedBoxColor = _bind("roundedBoxColor", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Sint16, Sint16, Uint32], c_int)
|
||||
roundedBoxRGBA = _bind("roundedBoxRGBA", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Sint16, Sint16, Uint8, Uint8, Uint8, Uint8], c_int)
|
||||
lineColor = _bind("lineColor", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Sint16, Uint32], c_int)
|
||||
lineRGBA = _bind("lineRGBA", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Sint16, Uint8, Uint8, Uint8, Uint8], c_int)
|
||||
aalineColor = _bind("aalineColor", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Sint16, Uint32], c_int)
|
||||
aalineRGBA = _bind("aalineRGBA", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Sint16, Uint8, Uint8, Uint8, Uint8], c_int)
|
||||
thickLineColor = _bind("thickLineColor", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Sint16, Uint8, Uint32], c_int)
|
||||
thickLineRGBA = _bind("thickLineRGBA", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Sint16, Uint8, Uint8, Uint8, Uint8, Uint8], c_int)
|
||||
circleColor = _bind("circleColor", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Uint32], c_int)
|
||||
circleRGBA = _bind("circleRGBA", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Uint8, Uint8, Uint8, Uint8], c_int)
|
||||
arcColor = _bind("arcColor", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Sint16, Sint16, Uint32], c_int)
|
||||
arcRGBA = _bind("arcRGBA", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Sint16, Sint16, Uint8, Uint8, Uint8, Uint8], c_int)
|
||||
aacircleColor = _bind("aacircleColor", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Uint32], c_int)
|
||||
aacircleRGBA = _bind("aacircleRGBA", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Uint8, Uint8, Uint8, Uint8], c_int)
|
||||
filledCircleColor = _bind("filledCircleColor", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Uint32], c_int)
|
||||
filledCircleRGBA = _bind("filledCircleRGBA", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Uint8, Uint8, Uint8, Uint8], c_int)
|
||||
ellipseColor = _bind("ellipseColor", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Sint16, Uint32], c_int)
|
||||
ellipseRGBA = _bind("ellipseRGBA", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Sint16, Uint8, Uint8, Uint8, Uint8], c_int)
|
||||
aaellipseColor = _bind("aaellipseColor", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Sint16, Uint32], c_int)
|
||||
aaellipseRGBA = _bind("aaellipseRGBA", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Sint16, Uint8, Uint8, Uint8, Uint8], c_int)
|
||||
filledEllipseColor = _bind("filledEllipseColor", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Sint16, Uint32], c_int)
|
||||
filledEllipseRGBA = _bind("filledEllipseRGBA", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Sint16, Uint8, Uint8, Uint8, Uint8], c_int)
|
||||
pieColor = _bind("pieColor", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Sint16, Sint16, Uint32], c_int)
|
||||
pieRGBA = _bind("pieRGBA", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Sint16, Sint16, Uint8, Uint8, Uint8, Uint8], c_int)
|
||||
filledPieColor = _bind("filledPieColor", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Sint16, Sint16, Uint32], c_int)
|
||||
filledPieRGBA = _bind("filledPieRGBA", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Sint16, Sint16, Uint8, Uint8, Uint8, Uint8], c_int)
|
||||
trigonColor = _bind("trigonColor", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Sint16, Sint16, Sint16, Uint32], c_int)
|
||||
trigonRGBA = _bind("trigonRGBA", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Sint16, Sint16, Sint16, Uint8, Uint8, Uint8, Uint8], c_int)
|
||||
aatrigonColor = _bind("aatrigonColor", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Sint16, Sint16, Sint16, Uint32], c_int)
|
||||
aatrigonRGBA = _bind("aatrigonRGBA", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Sint16, Sint16, Sint16, Uint8, Uint8, Uint8, Uint8], c_int)
|
||||
filledTrigonColor = _bind("filledTrigonColor", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Sint16, Sint16, Sint16, Uint32], c_int)
|
||||
filledTrigonRGBA = _bind("filledTrigonRGBA", [POINTER(SDL_Renderer), Sint16, Sint16, Sint16, Sint16, Sint16, Sint16, Uint8, Uint8, Uint8, Uint8], c_int)
|
||||
polygonColor = _bind("polygonColor", [POINTER(SDL_Renderer), POINTER(Sint16), POINTER(Sint16), c_int, Uint32], c_int)
|
||||
polygonRGBA = _bind("polygonRGBA", [POINTER(SDL_Renderer), POINTER(Sint16), POINTER(Sint16), c_int, Uint8, Uint8, Uint8, Uint8], c_int)
|
||||
aapolygonColor = _bind("aapolygonColor", [POINTER(SDL_Renderer), POINTER(Sint16), POINTER(Sint16), c_int, Uint32], c_int)
|
||||
aapolygonRGBA = _bind("aapolygonRGBA", [POINTER(SDL_Renderer), POINTER(Sint16), POINTER(Sint16), c_int, Uint8, Uint8, Uint8, Uint8], c_int)
|
||||
filledPolygonColor = _bind("filledPolygonColor", [POINTER(SDL_Renderer), POINTER(Sint16), POINTER(Sint16), c_int, Uint32], c_int)
|
||||
filledPolygonRGBA = _bind("filledPolygonRGBA", [POINTER(SDL_Renderer), POINTER(Sint16), POINTER(Sint16), c_int, Uint8, Uint8, Uint8, Uint8], c_int)
|
||||
texturedPolygon = _bind("texturedPolygon", [POINTER(SDL_Renderer), POINTER(Sint16), POINTER(Sint16), c_int, POINTER(SDL_Surface), c_int, c_int], c_int)
|
||||
bezierColor = _bind("bezierColor", [POINTER(SDL_Renderer), POINTER(Sint16), POINTER(Sint16), c_int, c_int, Uint32], c_int)
|
||||
bezierRGBA = _bind("bezierRGBA", [POINTER(SDL_Renderer), POINTER(Sint16), POINTER(Sint16), c_int, c_int, Uint8, Uint8, Uint8, Uint8], c_int)
|
||||
gfxPrimitivesSetFont = _bind("gfxPrimitivesSetFont", [c_void_p, Uint32, Uint32])
|
||||
gfxPrimitivesSetFontRotation = _bind("gfxPrimitivesSetFontRotation", [Uint32])
|
||||
characterColor = _bind("characterColor", [POINTER(SDL_Renderer), Sint16, Sint16, c_char, Uint32], c_int)
|
||||
characterRGBA = _bind("characterRGBA", [POINTER(SDL_Renderer), Sint16, Sint16, c_char, Uint8, Uint8, Uint8, Uint8], c_int)
|
||||
stringColor = _bind("stringColor", [POINTER(SDL_Renderer), Sint16, Sint16, c_char_p, Uint32], c_int)
|
||||
stringRGBA = _bind("stringRGBA", [POINTER(SDL_Renderer), Sint16, Sint16, c_char_p, Uint8, Uint8, Uint8, Uint8], c_int)
|
||||
|
||||
SMOOTHING_OFF = 0
|
||||
SMOOTHING_ON = 1
|
||||
rotozoomSurface = _bind("rotozoomSurface", [POINTER(SDL_Surface), c_double, c_double, c_int], POINTER(SDL_Surface))
|
||||
rotozoomSurfaceXY = _bind("rotozoomSurfaceXY", [POINTER(SDL_Surface), c_double, c_double, c_double, c_int], POINTER(SDL_Surface))
|
||||
rotozoomSurfaceSize = _bind("rotozoomSurfaceSize", [c_int, c_int, c_double, c_double, POINTER(c_int), POINTER(c_int)])
|
||||
rotozoomSurfaceSizeXY = _bind("rotozoomSurfaceSizeXY", [c_int, c_int, c_double, c_double, c_double, POINTER(c_int), POINTER(c_int)])
|
||||
zoomSurface = _bind("zoomSurface", [POINTER(SDL_Surface), c_double, c_double, c_int], POINTER(SDL_Surface))
|
||||
zoomSurfaceSize = _bind("zoomSurfaceSize", [c_int, c_int, c_double, c_double, POINTER(c_int), POINTER(c_int)])
|
||||
shrinkSurface = _bind("shrinkSurface", [POINTER(SDL_Surface), c_int, c_int], POINTER(SDL_Surface))
|
||||
rotateSurface90Degrees = _bind("rotateSurface90Degrees", [POINTER(SDL_Surface), c_int], POINTER(SDL_Surface))
|
105
src/m64py/SDL2/sdlimage.py
Normal file
105
src/m64py/SDL2/sdlimage.py
Normal file
|
@ -0,0 +1,105 @@
|
|||
import os
|
||||
from ctypes import POINTER, c_int, c_char_p
|
||||
from .dll import _DLL
|
||||
from .version import SDL_version
|
||||
from .surface import SDL_Surface
|
||||
from .rwops import SDL_RWops
|
||||
from .render import SDL_Texture, SDL_Renderer
|
||||
from .error import SDL_SetError, SDL_GetError
|
||||
|
||||
__all__ = ["SDL_IMAGE_MAJOR_VERSION", "SDL_IMAGE_MINOR_VERSION", \
|
||||
"SDL_IMAGE_PATCHLEVEL", "SDL_IMAGE_VERSION", "IMG_Linked_Version",
|
||||
"IMG_InitFlags", "IMG_INIT_JPG", "IMG_INIT_PNG", "IMG_INIT_TIF",
|
||||
"IMG_INIT_WEBP", "IMG_Init", "IMG_Quit", "IMG_LoadTyped_RW",
|
||||
"IMG_Load", "IMG_Load_RW", "IMG_LoadTexture", "IMG_LoadTexture_RW",
|
||||
"IMG_LoadTextureTyped_RW", "IMG_isICO", "IMG_isCUR", "IMG_isBMP",
|
||||
"IMG_isGIF", "IMG_isJPG", "IMG_isLBM", "IMG_isPNG", "IMG_isPNM",
|
||||
"IMG_isPCX", "IMG_isTIF", "IMG_isXCF", "IMG_isXV", "IMG_isWEBP",
|
||||
"IMG_LoadBMP_RW", "IMG_LoadCUR_RW", "IMG_LoadCUR_RW",
|
||||
"IMG_LoadGIF_RW", "IMG_LoadICO_RW", "IMG_LoadJPG_RW",
|
||||
"IMG_LoadLBM_RW", "IMG_LoadPCX_RW", "IMG_LoadPNM_RW",
|
||||
"IMG_LoadPNG_RW", "IMG_LoadTGA_RW", "IMG_LoadTIF_RW",
|
||||
"IMG_LoadXCF_RW", "IMG_LoadWEBP_RW", "IMG_LoadXPM_RW",
|
||||
"IMG_LoadXV_RW", "IMG_ReadXPMFromArray",
|
||||
"IMG_GetError", "IMG_SetError",
|
||||
"get_dll_file"
|
||||
]
|
||||
|
||||
try:
|
||||
dll = _DLL("SDL2_image", ["SDL2_image", "SDL2_image-2.0"],
|
||||
os.getenv("PYSDL2_DLL_PATH"))
|
||||
except RuntimeError as exc:
|
||||
raise ImportError(exc)
|
||||
|
||||
|
||||
def get_dll_file():
|
||||
"""Gets the file name of the loaded SDL2_image library."""
|
||||
return dll.libfile
|
||||
|
||||
_bind = dll.bind_function
|
||||
|
||||
SDL_IMAGE_MAJOR_VERSION = 2
|
||||
SDL_IMAGE_MINOR_VERSION = 0
|
||||
SDL_IMAGE_PATCHLEVEL = 0
|
||||
|
||||
|
||||
def SDL_IMAGE_VERSION(x):
|
||||
x.major = SDL_IMAGE_MAJOR_VERSION
|
||||
x.minor = SDL_IMAGE_MINOR_VERSION
|
||||
x.patch = SDL_IMAGE_PATCHLEVEL
|
||||
|
||||
IMG_Linked_Version = _bind("IMG_Linked_Version", None, POINTER(SDL_version))
|
||||
|
||||
IMG_InitFlags = c_int
|
||||
IMG_INIT_JPG = 0x00000001
|
||||
IMG_INIT_PNG = 0x00000002
|
||||
IMG_INIT_TIF = 0x00000004
|
||||
IMG_INIT_WEBP = 0x00000008
|
||||
|
||||
IMG_Init = _bind("IMG_Init", [c_int], c_int)
|
||||
IMG_Quit = _bind("IMG_Quit")
|
||||
IMG_LoadTyped_RW = _bind("IMG_LoadTyped_RW", [POINTER(SDL_RWops), c_int, c_char_p], POINTER(SDL_Surface))
|
||||
IMG_Load = _bind("IMG_Load", [c_char_p], POINTER(SDL_Surface))
|
||||
IMG_Load_RW = _bind("IMG_Load_RW", [POINTER(SDL_RWops), c_int], POINTER(SDL_Surface))
|
||||
IMG_LoadTexture = _bind("IMG_LoadTexture", [POINTER(SDL_Renderer), c_char_p], POINTER(SDL_Texture))
|
||||
IMG_LoadTexture_RW = _bind("IMG_LoadTexture_RW", [POINTER(SDL_Renderer), POINTER(SDL_RWops), c_int], POINTER(SDL_Texture))
|
||||
IMG_LoadTextureTyped_RW = _bind("IMG_LoadTextureTyped_RW", [POINTER(SDL_Renderer), POINTER(SDL_RWops), c_int, c_char_p], POINTER(SDL_Texture))
|
||||
|
||||
IMG_isICO = _bind("IMG_isICO", [POINTER(SDL_RWops)], c_int)
|
||||
IMG_isCUR = _bind("IMG_isCUR", [POINTER(SDL_RWops)], c_int)
|
||||
IMG_isBMP = _bind("IMG_isBMP", [POINTER(SDL_RWops)], c_int)
|
||||
IMG_isGIF = _bind("IMG_isGIF", [POINTER(SDL_RWops)], c_int)
|
||||
IMG_isJPG = _bind("IMG_isJPG", [POINTER(SDL_RWops)], c_int)
|
||||
IMG_isLBM = _bind("IMG_isLBM", [POINTER(SDL_RWops)], c_int)
|
||||
IMG_isPCX = _bind("IMG_isPCX", [POINTER(SDL_RWops)], c_int)
|
||||
IMG_isPNG = _bind("IMG_isPNG", [POINTER(SDL_RWops)], c_int)
|
||||
IMG_isPNM = _bind("IMG_isPNM", [POINTER(SDL_RWops)], c_int)
|
||||
IMG_isTIF = _bind("IMG_isTIF", [POINTER(SDL_RWops)], c_int)
|
||||
IMG_isXCF = _bind("IMG_isXCF", [POINTER(SDL_RWops)], c_int)
|
||||
IMG_isXPM = _bind("IMG_isXPM", [POINTER(SDL_RWops)], c_int)
|
||||
IMG_isXV = _bind("IMG_isXV", [POINTER(SDL_RWops)], c_int)
|
||||
IMG_isWEBP = _bind("IMG_isWEBP", [POINTER(SDL_RWops)], c_int)
|
||||
|
||||
IMG_LoadICO_RW = _bind("IMG_LoadICO_RW", [POINTER(SDL_RWops)], POINTER(SDL_Surface))
|
||||
IMG_LoadCUR_RW = _bind("IMG_LoadCUR_RW", [POINTER(SDL_RWops)], POINTER(SDL_Surface))
|
||||
IMG_LoadBMP_RW = _bind("IMG_LoadBMP_RW", [POINTER(SDL_RWops)], POINTER(SDL_Surface))
|
||||
IMG_LoadGIF_RW = _bind("IMG_LoadGIF_RW", [POINTER(SDL_RWops)], POINTER(SDL_Surface))
|
||||
IMG_LoadJPG_RW = _bind("IMG_LoadJPG_RW", [POINTER(SDL_RWops)], POINTER(SDL_Surface))
|
||||
IMG_LoadLBM_RW = _bind("IMG_LoadLBM_RW", [POINTER(SDL_RWops)], POINTER(SDL_Surface))
|
||||
IMG_LoadPCX_RW = _bind("IMG_LoadPCX_RW", [POINTER(SDL_RWops)], POINTER(SDL_Surface))
|
||||
IMG_LoadPNG_RW = _bind("IMG_LoadPNG_RW", [POINTER(SDL_RWops)], POINTER(SDL_Surface))
|
||||
IMG_LoadPNM_RW = _bind("IMG_LoadPNM_RW", [POINTER(SDL_RWops)], POINTER(SDL_Surface))
|
||||
IMG_LoadTGA_RW = _bind("IMG_LoadTGA_RW", [POINTER(SDL_RWops)], POINTER(SDL_Surface))
|
||||
IMG_LoadTIF_RW = _bind("IMG_LoadTIF_RW", [POINTER(SDL_RWops)], POINTER(SDL_Surface))
|
||||
IMG_LoadXCF_RW = _bind("IMG_LoadXCF_RW", [POINTER(SDL_RWops)], POINTER(SDL_Surface))
|
||||
IMG_LoadXPM_RW = _bind("IMG_LoadXPM_RW", [POINTER(SDL_RWops)], POINTER(SDL_Surface))
|
||||
IMG_LoadXV_RW = _bind("IMG_LoadXV_RW", [POINTER(SDL_RWops)], POINTER(SDL_Surface))
|
||||
IMG_LoadWEBP_RW = _bind("IMG_LoadWEBP_RW", [POINTER(SDL_RWops)], POINTER(SDL_Surface))
|
||||
|
||||
IMG_ReadXPMFromArray = _bind("IMG_ReadXPMFromArray", [POINTER(c_char_p)], POINTER(SDL_Surface))
|
||||
|
||||
IMG_SavePNG = _bind("IMG_SavePNG", [POINTER(SDL_Surface), c_char_p], c_int)
|
||||
IMG_SavePNG_RW = _bind("IMG_SavePNG_RW", [POINTER(SDL_Surface), POINTER(SDL_RWops), c_int], c_int)
|
||||
|
||||
IMG_SetError = SDL_SetError
|
||||
IMG_GetError = SDL_GetError
|
207
src/m64py/SDL2/sdlmixer.py
Normal file
207
src/m64py/SDL2/sdlmixer.py
Normal file
|
@ -0,0 +1,207 @@
|
|||
import os
|
||||
from ctypes import Structure, POINTER, CFUNCTYPE, c_int, c_char_p, c_void_p, \
|
||||
c_double
|
||||
from .dll import _DLL
|
||||
from .version import SDL_version
|
||||
from .audio import AUDIO_S16LSB, AUDIO_S16MSB
|
||||
from .stdinc import Uint8, Uint16, Uint32, Sint16
|
||||
from .endian import SDL_LIL_ENDIAN, SDL_BYTEORDER
|
||||
from .rwops import SDL_RWops, SDL_RWFromFile
|
||||
from .error import SDL_SetError, SDL_GetError
|
||||
|
||||
__all__ = ["get_dll_file", "SDL_MIXER_MAJOR_VERSION", "SDL_MIXER_MINOR_VERSION",
|
||||
"SDL_MIXER_PATCHLEVEL", "SDL_MIXER_VERSION", "MIX_MAJOR_VERSION",
|
||||
"MIX_MINOR_VERSION", "MIX_PATCHLEVEL", "MIX_VERSION",
|
||||
"Mix_Linked_Version", "MIX_InitFlags", "MIX_INIT_FLAC",
|
||||
"MIX_INIT_MOD", "MIX_INIT_MP3", "MIX_INIT_OGG",
|
||||
"MIX_INIT_FLUIDSYNTH", "Mix_Init", "Mix_Quit", "MIX_CHANNELS",
|
||||
"MIX_DEFAULT_FREQUENCY" , "MIX_DEFAULT_FORMAT",
|
||||
"MIX_DEFAULT_CHANNELS", "MIX_MAX_VOLUME", "Mix_Chunk", "Mix_Fading",
|
||||
"MIX_NO_FADING", "MIX_FADING_OUT", "MIX_FADING_IN", "Mix_MusicType",
|
||||
"MUS_NONE", "MUS_CMD", "MUS_WAV", "MUS_MOD", "MUS_MID", "MUS_OGG",
|
||||
"MUS_MP3", "MUS_MP3_MAD", "MUS_FLAC", "MUS_MODPLUG", "Mix_Music",
|
||||
"Mix_OpenAudio", "Mix_AllocateChannels", "Mix_QuerySpec",
|
||||
"Mix_LoadWAV_RW", "Mix_LoadWAV", "Mix_LoadMUS", "Mix_LoadMUS_RW",
|
||||
"Mix_LoadMUSType_RW", "Mix_QuickLoad_WAV", "Mix_QuickLoad_RAW",
|
||||
"Mix_FreeChunk", "Mix_FreeMusic", "Mix_GetNumChunkDecoders",
|
||||
"Mix_GetChunkDecoder", "Mix_GetNumMusicDecoders",
|
||||
"Mix_GetMusicDecoder", "Mix_GetMusicType", "mix_func",
|
||||
"Mix_SetPostMix", "Mix_HookMusic", "music_finished",
|
||||
"Mix_HookMusicFinished", "Mix_GetMusicHookData", "channel_finished",
|
||||
"Mix_ChannelFinished", "MIX_CHANNEL_POST", "Mix_EffectFunc_t",
|
||||
"Mix_EffectDone_t", "Mix_RegisterEffect", "Mix_UnregisterEffect",
|
||||
"Mix_UnregisterAllEffects", "MIX_EFFECTSMAXSPEED", "Mix_SetPanning",
|
||||
"Mix_SetPosition", "Mix_SetDistance", "Mix_SetReverseStereo",
|
||||
"Mix_ReserveChannels", "Mix_GroupChannel", "Mix_GroupChannels",
|
||||
"Mix_GroupAvailable", "Mix_GroupCount", "Mix_GroupOldest",
|
||||
"Mix_GroupNewer", "Mix_PlayChannel", "Mix_PlayChannelTimed",
|
||||
"Mix_PlayMusic", "Mix_FadeInMusic", "Mix_FadeInMusicPos",
|
||||
"Mix_FadeInChannel", "Mix_FadeInChannelTimed", "Mix_Volume",
|
||||
"Mix_VolumeChunk", "Mix_VolumeMusic", "Mix_HaltChannel",
|
||||
"Mix_HaltGroup", "Mix_HaltMusic", "Mix_ExpireChannel",
|
||||
"Mix_FadeOutChannel", "Mix_FadeOutGroup", "Mix_FadeOutMusic",
|
||||
"Mix_FadingMusic", "Mix_FadingChannel", "Mix_Pause", "Mix_Resume",
|
||||
"Mix_Paused", "Mix_PauseMusic", "Mix_ResumeMusic", "Mix_RewindMusic",
|
||||
"Mix_PausedMusic", "Mix_SetMusicPosition", "Mix_Playing",
|
||||
"Mix_PlayingMusic", "Mix_SetMusicCMD", "Mix_SetSynchroValue",
|
||||
"Mix_GetSynchroValue", "Mix_SetSoundFonts", "Mix_GetSoundFonts",
|
||||
"soundfont_function", "Mix_EachSoundFont", "Mix_GetChunk",
|
||||
"Mix_CloseAudio", "Mix_SetError", "Mix_GetError"
|
||||
]
|
||||
|
||||
try:
|
||||
dll = _DLL("SDL2_mixer", ["SDL2_mixer", "SDL2_mixer-2.0"],
|
||||
os.getenv("PYSDL2_DLL_PATH"))
|
||||
except RuntimeError as exc:
|
||||
raise ImportError(exc)
|
||||
|
||||
|
||||
def get_dll_file():
|
||||
"""Gets the file name of the loaded SDL2_mixer library."""
|
||||
return dll.libfile
|
||||
|
||||
_bind = dll.bind_function
|
||||
|
||||
SDL_MIXER_MAJOR_VERSION = 2
|
||||
SDL_MIXER_MINOR_VERSION = 0
|
||||
SDL_MIXER_PATCHLEVEL = 0
|
||||
|
||||
|
||||
def SDL_MIXER_VERSION(x):
|
||||
x.major = SDL_TTF_MAJOR_VERSION
|
||||
x.minor = SDL_TTF_MINOR_VERSION
|
||||
x.patch = SDL_TTF_PATCHLEVEL
|
||||
|
||||
MIX_MAJOR_VERSION = SDL_MIXER_MAJOR_VERSION
|
||||
MIX_MINOR_VERSION = SDL_MIXER_MINOR_VERSION
|
||||
MIX_PATCHLEVEL = SDL_MIXER_PATCHLEVEL
|
||||
MIX_VERSION = SDL_MIXER_VERSION
|
||||
|
||||
Mix_Linked_Version = _bind("Mix_Linked_Version", None, POINTER(SDL_version))
|
||||
MIX_InitFlags = c_int
|
||||
MIX_INIT_FLAC = 0x00000001
|
||||
MIX_INIT_MOD = 0x00000002
|
||||
MIX_INIT_MP3 = 0x00000004
|
||||
MIX_INIT_OGG = 0x00000008
|
||||
MIX_INIT_FLUIDSYNTH = 0x00000010
|
||||
|
||||
Mix_Init = _bind("Mix_Init", [c_int], c_int)
|
||||
Mix_Quit = _bind("Mix_Quit")
|
||||
|
||||
MIX_CHANNELS = 8
|
||||
MIX_DEFAULT_FREQUENCY = 22050
|
||||
if SDL_BYTEORDER == SDL_LIL_ENDIAN:
|
||||
MIX_DEFAULT_FORMAT = AUDIO_S16LSB
|
||||
else:
|
||||
MIX_DEFAULT_FORMAT = AUDIO_S16MSB
|
||||
MIX_DEFAULT_CHANNELS = 2
|
||||
MIX_MAX_VOLUME = 128
|
||||
|
||||
class Mix_Chunk(Structure):
|
||||
_fields_ = [("allocated", c_int),
|
||||
("abuf", POINTER(Uint8)),
|
||||
("alen", Uint32),
|
||||
("volume", Uint8)]
|
||||
|
||||
Mix_Fading = c_int
|
||||
MIX_NO_FADING = 0
|
||||
MIX_FADING_OUT = 1
|
||||
MIX_FADING_IN = 2
|
||||
Mix_MusicType = c_int
|
||||
MUS_NONE = 0
|
||||
MUS_CMD = 1
|
||||
MUS_WAV = 2
|
||||
MUS_MOD = 3
|
||||
MUS_MID = 4
|
||||
MUS_OGG = 5
|
||||
MUS_MP3 = 6
|
||||
MUS_MP3_MAD = 7
|
||||
MUS_FLAC = 8
|
||||
MUS_MODPLUG = 9
|
||||
|
||||
class Mix_Music(Structure):
|
||||
pass
|
||||
|
||||
Mix_OpenAudio = _bind("Mix_OpenAudio", [c_int, Uint16, c_int, c_int], c_int)
|
||||
Mix_AllocateChannels = _bind("Mix_AllocateChannels", [c_int], c_int)
|
||||
Mix_QuerySpec = _bind("Mix_QuerySpec", [POINTER(c_int), POINTER(Uint16), POINTER(c_int)], c_int)
|
||||
Mix_LoadWAV_RW = _bind("Mix_LoadWAV_RW", [POINTER(SDL_RWops), c_int], POINTER(Mix_Chunk))
|
||||
Mix_LoadWAV = lambda fname: Mix_LoadWAV_RW(SDL_RWFromFile(fname, b"rb"), 1)
|
||||
Mix_LoadMUS = _bind("Mix_LoadMUS", [c_char_p], POINTER(Mix_Music))
|
||||
Mix_LoadMUS_RW = _bind("Mix_LoadMUS_RW", [POINTER(SDL_RWops)], POINTER(Mix_Music))
|
||||
Mix_LoadMUSType_RW = _bind("Mix_LoadMUSType_RW", [POINTER(SDL_RWops), Mix_MusicType, c_int], POINTER(Mix_Music))
|
||||
Mix_QuickLoad_WAV = _bind("Mix_QuickLoad_WAV", [POINTER(Uint8)], POINTER(Mix_Chunk))
|
||||
Mix_QuickLoad_RAW = _bind("Mix_QuickLoad_RAW", [POINTER(Uint8), Uint32], POINTER(Mix_Chunk))
|
||||
Mix_FreeChunk = _bind("Mix_FreeChunk", [POINTER(Mix_Chunk)])
|
||||
Mix_FreeMusic = _bind("Mix_FreeMusic", [POINTER(Mix_Music)])
|
||||
Mix_GetNumChunkDecoders = _bind("Mix_GetNumChunkDecoders", None, c_int)
|
||||
Mix_GetChunkDecoder = _bind("Mix_GetChunkDecoder", [c_int], c_char_p)
|
||||
Mix_GetNumMusicDecoders = _bind("Mix_GetNumMusicDecoders", None, c_int)
|
||||
Mix_GetMusicDecoder = _bind("Mix_GetMusicDecoder", [c_int], c_char_p)
|
||||
Mix_GetMusicType = _bind("Mix_GetMusicType", [POINTER(Mix_Music)], Mix_MusicType)
|
||||
mix_func = CFUNCTYPE(None, c_void_p, POINTER(Uint8), c_int)
|
||||
Mix_SetPostMix = _bind("Mix_SetPostMix", [mix_func, c_void_p])
|
||||
Mix_HookMusic = _bind("Mix_HookMusic", [mix_func, c_void_p])
|
||||
music_finished = CFUNCTYPE(None)
|
||||
Mix_HookMusicFinished = _bind("Mix_HookMusicFinished", [music_finished])
|
||||
Mix_GetMusicHookData = _bind("Mix_GetMusicHookData", None, c_void_p)
|
||||
channel_finished = CFUNCTYPE(None, c_int)
|
||||
Mix_ChannelFinished = _bind("Mix_ChannelFinished", [channel_finished])
|
||||
MIX_CHANNEL_POST = -2
|
||||
Mix_EffectFunc_t = CFUNCTYPE(None, c_int, c_void_p, c_int, c_void_p)
|
||||
Mix_EffectDone_t = CFUNCTYPE(None, c_int, c_void_p)
|
||||
Mix_RegisterEffect = _bind("Mix_RegisterEffect", [c_int, Mix_EffectFunc_t, Mix_EffectDone_t, c_void_p], c_int)
|
||||
Mix_UnregisterEffect = _bind("Mix_UnregisterEffect", [c_int, Mix_EffectFunc_t], c_int)
|
||||
Mix_UnregisterAllEffects = _bind("Mix_UnregisterAllEffects", [c_int])
|
||||
MIX_EFFECTSMAXSPEED = "MIX_EFFECTSMAXSPEED"
|
||||
Mix_SetPanning = _bind("Mix_SetPanning", [c_int, Uint8, Uint8], c_int)
|
||||
Mix_SetPosition = _bind("Mix_SetPosition", [c_int, Sint16, Uint8], c_int)
|
||||
Mix_SetDistance = _bind("Mix_SetDistance", [c_int, Uint8])
|
||||
Mix_SetReverseStereo = _bind("Mix_SetReverseStereo", [c_int, c_int], c_int)
|
||||
Mix_ReserveChannels = _bind("Mix_ReserveChannels", [c_int], c_int)
|
||||
Mix_GroupChannel = _bind("Mix_GroupChannel", [c_int, c_int], c_int)
|
||||
Mix_GroupChannels = _bind("Mix_GroupChannels", [c_int, c_int, c_int], c_int)
|
||||
Mix_GroupAvailable = _bind("Mix_GroupAvailable", [c_int], c_int)
|
||||
Mix_GroupCount = _bind("Mix_GroupCount", [c_int], c_int)
|
||||
Mix_GroupOldest = _bind("Mix_GroupOldest", [c_int], c_int)
|
||||
Mix_GroupNewer = _bind("Mix_GroupNewer", [c_int], c_int)
|
||||
Mix_PlayChannel = lambda channel, chunk, loops: Mix_PlayChannelTimed(channel, chunk, loops, -1)
|
||||
Mix_PlayChannelTimed = _bind("Mix_PlayChannelTimed", [c_int, POINTER(Mix_Chunk), c_int, c_int], c_int)
|
||||
Mix_PlayMusic = _bind("Mix_PlayMusic", [POINTER(Mix_Music), c_int], c_int)
|
||||
Mix_FadeInMusic = _bind("Mix_FadeInMusic", [POINTER(Mix_Music), c_int, c_int], c_int)
|
||||
Mix_FadeInMusicPos = _bind("Mix_FadeInMusicPos", [POINTER(Mix_Music), c_int, c_int, c_double], c_int)
|
||||
Mix_FadeInChannel = lambda channel, chunk, loops, ms: Mix_FadeInChannelTimed(channel, chunk, loops, ms, -1)
|
||||
Mix_FadeInChannelTimed = _bind("Mix_FadeInChannelTimed", [c_int, POINTER(Mix_Chunk), c_int, c_int, c_int], c_int)
|
||||
Mix_Volume = _bind("Mix_Volume", [c_int, c_int], c_int)
|
||||
Mix_VolumeChunk = _bind("Mix_VolumeChunk", [POINTER(Mix_Chunk), c_int], c_int)
|
||||
Mix_VolumeMusic = _bind("Mix_VolumeMusic", [c_int], c_int)
|
||||
Mix_HaltChannel = _bind("Mix_HaltChannel", [c_int], c_int)
|
||||
Mix_HaltGroup = _bind("Mix_HaltGroup", [c_int], c_int)
|
||||
Mix_HaltMusic = _bind("Mix_HaltMusic", None, c_int)
|
||||
Mix_ExpireChannel = _bind("Mix_ExpireChannel", [c_int, c_int], c_int)
|
||||
Mix_FadeOutChannel = _bind("Mix_FadeOutChannel", [c_int, c_int], c_int)
|
||||
Mix_FadeOutGroup = _bind("Mix_FadeOutGroup", [c_int, c_int], c_int)
|
||||
Mix_FadeOutMusic = _bind("Mix_FadeOutMusic", [c_int], c_int)
|
||||
Mix_FadingMusic = _bind("Mix_FadingMusic", None, Mix_Fading)
|
||||
Mix_FadingChannel = _bind("Mix_FadingChannel", [c_int], Mix_Fading)
|
||||
Mix_Pause = _bind("Mix_Pause", [c_int])
|
||||
Mix_Resume = _bind("Mix_Resume", [c_int])
|
||||
Mix_Paused = _bind("Mix_Paused", [c_int], c_int)
|
||||
Mix_PauseMusic = _bind("Mix_PauseMusic")
|
||||
Mix_ResumeMusic = _bind("Mix_ResumeMusic")
|
||||
Mix_RewindMusic = _bind("Mix_RewindMusic")
|
||||
Mix_PausedMusic = _bind("Mix_PauseMusic", None, c_int)
|
||||
Mix_SetMusicPosition = _bind("Mix_SetMusicPosition", [c_double], c_int)
|
||||
Mix_Playing = _bind("Mix_Playing", [c_int], c_int)
|
||||
Mix_PlayingMusic = _bind("Mix_PlayingMusic", None, c_int)
|
||||
Mix_SetMusicCMD = _bind("Mix_SetMusicCMD", [c_char_p], c_int)
|
||||
Mix_SetSynchroValue = _bind("Mix_SetSynchroValue", [c_int], c_int)
|
||||
Mix_GetSynchroValue = _bind("Mix_GetSynchroValue", None, c_int)
|
||||
Mix_SetSoundFonts = _bind("Mix_SetSoundFonts", [c_char_p], c_int)
|
||||
Mix_GetSoundFonts = _bind("Mix_GetSoundFonts", None, c_char_p)
|
||||
soundfont_function = CFUNCTYPE(c_int, c_char_p, c_void_p)
|
||||
Mix_EachSoundFont = _bind("Mix_EachSoundFont", [soundfont_function, c_void_p], c_int)
|
||||
Mix_GetChunk = _bind("Mix_GetChunk", [c_int], POINTER(Mix_Chunk))
|
||||
Mix_CloseAudio = _bind("Mix_CloseAudio")
|
||||
Mix_SetError = SDL_SetError
|
||||
Mix_GetError = SDL_GetError
|
138
src/m64py/SDL2/sdlttf.py
Normal file
138
src/m64py/SDL2/sdlttf.py
Normal file
|
@ -0,0 +1,138 @@
|
|||
import os
|
||||
from ctypes import Structure, POINTER, c_int, c_long, c_char_p
|
||||
from .dll import _DLL
|
||||
from .version import SDL_version
|
||||
from .rwops import SDL_RWops
|
||||
from .stdinc import Uint16, Uint32
|
||||
from .pixels import SDL_Color
|
||||
from .surface import SDL_Surface
|
||||
from .error import SDL_GetError, SDL_SetError
|
||||
|
||||
__all__ = ["get_dll_file", "SDL_TTF_MAJOR_VERSION", "SDL_TTF_MINOR_VERSION",
|
||||
"SDL_TTF_PATCHLEVEL", "SDL_TTF_VERSION", "TTF_MAJOR_VERSION",
|
||||
"TTF_MINOR_VERSION", "TTF_PATCHLEVEL", "TTF_VERSION",
|
||||
"TTF_Linked_Version", "UNICODE_BOM_NATIVE", "UNICODE_BOM_SWAPPED",
|
||||
"TTF_ByteSwappedUNICODE", "TTF_Font", "TTF_Init", "TTF_OpenFont",
|
||||
"TTF_OpenFontIndex", "TTF_OpenFontRW", "TTF_OpenFontIndexRW",
|
||||
"TTF_STYLE_NORMAL", "TTF_STYLE_BOLD", "TTF_STYLE_ITALIC",
|
||||
"TTF_STYLE_UNDERLINE", "TTF_STYLE_STRIKETHROUGH", "TTF_GetFontStyle",
|
||||
"TTF_SetFontStyle", "TTF_GetFontOutline", "TTF_SetFontOutline",
|
||||
"TTF_HINTING_NORMAL", "TTF_HINTING_LIGHT", "TTF_HINTING_MONO",
|
||||
"TTF_HINTING_NONE", "TTF_GetFontHinting", "TTF_SetFontHinting",
|
||||
"TTF_FontHeight", "TTF_FontAscent", "TTF_FontDescent",
|
||||
"TTF_FontLineSkip", "TTF_GetFontKerning", "TTF_SetFontKerning",
|
||||
"TTF_FontFaces", "TTF_FontFaceIsFixedWidth", "TTF_FontFaceFamilyName",
|
||||
"TTF_FontFaceStyleName", "TTF_GlyphIsProvided", "TTF_GlyphMetrics",
|
||||
"TTF_SizeText", "TTF_SizeUTF8", "TTF_SizeUNICODE",
|
||||
"TTF_RenderText_Solid", "TTF_RenderUTF8_Solid",
|
||||
"TTF_RenderUNICODE_Solid", "TTF_RenderGlyph_Solid",
|
||||
"TTF_RenderText_Shaded", "TTF_RenderUTF8_Shaded",
|
||||
"TTF_RenderUNICODE_Shaded", "TTF_RenderGlyph_Shaded",
|
||||
"TTF_RenderText_Blended", "TTF_RenderUTF8_Blended",
|
||||
"TTF_RenderUNICODE_Blended", "TTF_RenderText_Blended_Wrapped",
|
||||
"TTF_RenderUTF8_Blended_Wrapped", "TTF_RenderUNICODE_Blended_Wrapped",
|
||||
"TTF_RenderGlyph_Blended", "TTF_RenderText", "TTF_RenderUTF",
|
||||
"TTF_RenderUNICODE", "TTF_CloseFont", "TTF_Quit", "TTF_WasInit",
|
||||
"TTF_GetFontKerningSize", "TTF_SetError", "TTF_GetError"
|
||||
]
|
||||
|
||||
try:
|
||||
dll = _DLL("SDL2_ttf", ["SDL2_ttf", "SDL2_ttf-2.0"],
|
||||
os.getenv("PYSDL2_DLL_PATH"))
|
||||
except RuntimeError as exc:
|
||||
raise ImportError(exc)
|
||||
|
||||
def get_dll_file():
|
||||
"""Gets the file name of the loaded SDL2_ttf library."""
|
||||
return dll.libfile
|
||||
|
||||
_bind = dll.bind_function
|
||||
|
||||
SDL_TTF_MAJOR_VERSION = 2
|
||||
SDL_TTF_MINOR_VERSION = 0
|
||||
SDL_TTF_PATCHLEVEL = 12
|
||||
|
||||
|
||||
def SDL_TTF_VERSION(x):
|
||||
x.major = SDL_TTF_MAJOR_VERSION
|
||||
x.minor = SDL_TTF_MINOR_VERSION
|
||||
x.patch = SDL_TTF_PATCHLEVEL
|
||||
|
||||
TTF_MAJOR_VERSION = SDL_TTF_MAJOR_VERSION
|
||||
TTF_MINOR_VERSION = SDL_TTF_MINOR_VERSION
|
||||
TTF_PATCHLEVEL = SDL_TTF_PATCHLEVEL
|
||||
TTF_VERSION = SDL_TTF_VERSION
|
||||
|
||||
TTF_Linked_Version = _bind("TTF_Linked_Version", None, POINTER(SDL_version))
|
||||
UNICODE_BOM_NATIVE = 0xFEFF
|
||||
UNICODE_BOM_SWAPPED = 0xFFFE
|
||||
|
||||
TTF_ByteSwappedUNICODE = _bind("TTF_ByteSwappedUNICODE", [c_int])
|
||||
|
||||
|
||||
class TTF_Font(Structure):
|
||||
pass
|
||||
|
||||
TTF_Init = _bind("TTF_Init", None, c_int)
|
||||
TTF_OpenFont = _bind("TTF_OpenFont", [c_char_p, c_int], POINTER(TTF_Font))
|
||||
TTF_OpenFontIndex = _bind("TTF_OpenFontIndex", [c_char_p, c_int, c_long], POINTER(TTF_Font))
|
||||
TTF_OpenFontRW = _bind("TTF_OpenFontRW", [POINTER(SDL_RWops), c_int, c_int], POINTER(TTF_Font))
|
||||
TTF_OpenFontIndexRW = _bind("TTF_OpenFontIndexRW", [POINTER(SDL_RWops), c_int, c_int, c_long], POINTER(TTF_Font))
|
||||
|
||||
TTF_STYLE_NORMAL = 0x00
|
||||
TTF_STYLE_BOLD = 0x01
|
||||
TTF_STYLE_ITALIC = 0x02
|
||||
TTF_STYLE_UNDERLINE = 0x04
|
||||
TTF_STYLE_STRIKETHROUGH = 0x08
|
||||
TTF_GetFontStyle = _bind("TTF_GetFontStyle", [POINTER(TTF_Font)], c_int)
|
||||
TTF_SetFontStyle = _bind("TTF_SetFontStyle", [POINTER(TTF_Font), c_int])
|
||||
TTF_GetFontOutline = _bind("TTF_GetFontOutline", [POINTER(TTF_Font)], c_int)
|
||||
TTF_SetFontOutline = _bind("TTF_SetFontOutline", [POINTER(TTF_Font), c_int])
|
||||
|
||||
TTF_HINTING_NORMAL = 0
|
||||
TTF_HINTING_LIGHT = 1
|
||||
TTF_HINTING_MONO = 2
|
||||
TTF_HINTING_NONE = 3
|
||||
TTF_GetFontHinting = _bind("TTF_GetFontHinting", [POINTER(TTF_Font)], c_int)
|
||||
TTF_SetFontHinting = _bind("TTF_SetFontHinting", [POINTER(TTF_Font), c_int])
|
||||
|
||||
TTF_FontHeight = _bind("TTF_FontHeight", [POINTER(TTF_Font)], c_int)
|
||||
TTF_FontAscent = _bind("TTF_FontAscent", [POINTER(TTF_Font)], c_int)
|
||||
TTF_FontDescent = _bind("TTF_FontDescent", [POINTER(TTF_Font)], c_int)
|
||||
TTF_FontLineSkip = _bind("TTF_FontLineSkip", [POINTER(TTF_Font)], c_int)
|
||||
TTF_GetFontKerning = _bind("TTF_GetFontKerning", [POINTER(TTF_Font)], c_int)
|
||||
TTF_SetFontKerning = _bind("TTF_SetFontKerning", [POINTER(TTF_Font), c_int])
|
||||
TTF_FontFaces = _bind("TTF_FontFaces", [POINTER(TTF_Font)], c_long)
|
||||
TTF_FontFaceIsFixedWidth = _bind("TTF_FontFaceIsFixedWidth", [POINTER(TTF_Font)], c_int)
|
||||
TTF_FontFaceFamilyName = _bind("TTF_FontFaceFamilyName", [POINTER(TTF_Font)], c_char_p)
|
||||
TTF_FontFaceStyleName = _bind("TTF_FontFaceStyleName", [POINTER(TTF_Font)], c_char_p)
|
||||
TTF_GlyphIsProvided = _bind("TTF_GlyphIsProvided", [POINTER(TTF_Font), Uint16], c_int)
|
||||
TTF_GlyphMetrics = _bind("TTF_GlyphMetrics", [POINTER(TTF_Font), Uint16, POINTER(c_int), POINTER(c_int), POINTER(c_int), POINTER(c_int), POINTER(c_int)], c_int)
|
||||
TTF_SizeText = _bind("TTF_SizeText", [POINTER(TTF_Font), c_char_p, POINTER(c_int), POINTER(c_int)], c_int)
|
||||
TTF_SizeUTF8 = _bind("TTF_SizeUTF8", [POINTER(TTF_Font), c_char_p, POINTER(c_int), POINTER(c_int)], c_int)
|
||||
TTF_SizeUNICODE = _bind("TTF_SizeUNICODE", [POINTER(TTF_Font), POINTER(Uint16), POINTER(c_int), POINTER(c_int)], c_int)
|
||||
TTF_RenderText_Solid = _bind("TTF_RenderText_Solid", [POINTER(TTF_Font), c_char_p, SDL_Color], POINTER(SDL_Surface))
|
||||
TTF_RenderUTF8_Solid = _bind("TTF_RenderUTF8_Solid", [POINTER(TTF_Font), c_char_p, SDL_Color], POINTER(SDL_Surface))
|
||||
TTF_RenderUNICODE_Solid = _bind("TTF_RenderUNICODE_Solid", [POINTER(TTF_Font), POINTER(Uint16), SDL_Color], POINTER(SDL_Surface))
|
||||
TTF_RenderGlyph_Solid = _bind("TTF_RenderGlyph_Solid", [POINTER(TTF_Font), Uint16, SDL_Color], POINTER(SDL_Surface))
|
||||
TTF_RenderText_Shaded = _bind("TTF_RenderText_Shaded", [POINTER(TTF_Font), c_char_p, SDL_Color, SDL_Color], POINTER(SDL_Surface))
|
||||
TTF_RenderUTF8_Shaded = _bind("TTF_RenderUTF8_Shaded", [POINTER(TTF_Font), c_char_p, SDL_Color, SDL_Color], POINTER(SDL_Surface))
|
||||
TTF_RenderUNICODE_Shaded = _bind("TTF_RenderUNICODE_Shaded", [POINTER(TTF_Font), POINTER(Uint16), SDL_Color, SDL_Color], POINTER(SDL_Surface))
|
||||
TTF_RenderGlyph_Shaded = _bind("TTF_RenderGlyph_Shaded", [POINTER(TTF_Font), Uint16, SDL_Color, SDL_Color], POINTER(SDL_Surface))
|
||||
TTF_RenderText_Blended = _bind("TTF_RenderText_Blended", [POINTER(TTF_Font), c_char_p, SDL_Color], POINTER(SDL_Surface))
|
||||
TTF_RenderUTF8_Blended = _bind("TTF_RenderUTF8_Blended", [POINTER(TTF_Font), c_char_p, SDL_Color], POINTER(SDL_Surface))
|
||||
TTF_RenderUNICODE_Blended = _bind("TTF_RenderUNICODE_Blended", [POINTER(TTF_Font), POINTER(Uint16), SDL_Color], POINTER(SDL_Surface))
|
||||
TTF_RenderText_Blended_Wrapped = _bind("TTF_RenderText_Blended_Wrapped", [POINTER(TTF_Font), c_char_p, SDL_Color, Uint32], POINTER(SDL_Surface))
|
||||
TTF_RenderUTF8_Blended_Wrapped = _bind("TTF_RenderUTF8_Blended_Wrapped", [POINTER(TTF_Font), c_char_p, SDL_Color, Uint32], POINTER(SDL_Surface))
|
||||
TTF_RenderUNICODE_Blended_Wrapped = _bind("TTF_RenderUNICODE_Blended_Wrapped", [POINTER(TTF_Font), POINTER(Uint16), SDL_Color, Uint32], POINTER(SDL_Surface))
|
||||
TTF_RenderGlyph_Blended = _bind("TTF_RenderGlyph_Blended", [POINTER(TTF_Font), Uint16, SDL_Color], POINTER(SDL_Surface))
|
||||
TTF_RenderText = TTF_RenderText_Shaded
|
||||
TTF_RenderUTF = TTF_RenderUTF8_Shaded
|
||||
TTF_RenderUNICODE = TTF_RenderUNICODE_Shaded
|
||||
TTF_CloseFont = _bind("TTF_CloseFont", [POINTER(TTF_Font)])
|
||||
TTF_Quit = _bind("TTF_Quit")
|
||||
TTF_WasInit = _bind("TTF_WasInit", None, c_int)
|
||||
TTF_GetFontKerningSize = _bind("TTF_GetFontKerningSize", [POINTER(TTF_Font), c_int, c_int], c_int)
|
||||
TTF_SetError = SDL_SetError
|
||||
TTF_GetError = SDL_GetError
|
||||
|
42
src/m64py/SDL2/shape.py
Normal file
42
src/m64py/SDL2/shape.py
Normal file
|
@ -0,0 +1,42 @@
|
|||
from ctypes import Union, Structure, POINTER, c_char_p, c_uint, c_int
|
||||
from .dll import _bind
|
||||
from .stdinc import Uint8, Uint32, SDL_bool
|
||||
from .pixels import SDL_Color
|
||||
from .surface import SDL_Surface
|
||||
from .video import SDL_Window
|
||||
|
||||
__all__ = ["SDL_NONSHAPEABLE_WINDOW", "SDL_INVALID_SHAPE_ARGUMENT",
|
||||
"SDL_WINDOW_LACKS_SHAPE", "SDL_CreateShapedWindow",
|
||||
"SDL_IsShapedWindow", "WindowShapeMode", "ShapeModeDefault",
|
||||
"ShapeModeBinarizeAlpha", "ShapeModeReverseBinarizeAlpha",
|
||||
"ShapeModeColorKey", "SDL_SHAPEMODEALPHA", "SDL_WindowShapeParams",
|
||||
"SDL_WindowShapeMode", "SDL_SetWindowShape",
|
||||
"SDL_GetShapedWindowMode"
|
||||
]
|
||||
|
||||
SDL_NONSHAPEABLE_WINDOW = -1
|
||||
SDL_INVALID_SHAPE_ARGUMENT = -2
|
||||
SDL_WINDOW_LACKS_SHAPE = -3
|
||||
|
||||
SDL_CreateShapedWindow = _bind("SDL_CreateShapedWindow", [c_char_p, c_uint, c_uint, c_uint, c_uint, Uint32], POINTER(SDL_Window))
|
||||
SDL_IsShapedWindow = _bind("SDL_IsShapedWindow", [POINTER(SDL_Window)], SDL_bool)
|
||||
|
||||
WindowShapeMode = c_int
|
||||
ShapeModeDefault = 0
|
||||
ShapeModeBinarizeAlpha = 1
|
||||
ShapeModeReverseBinarizeAlpha = 2
|
||||
ShapeModeColorKey = 3
|
||||
|
||||
SDL_SHAPEMODEALPHA = lambda mode: (mode == ShapeModeDefault or mode == ShapeModeBinarizeAlpha or mode == ShapeModeReverseBinarizeAlpha)
|
||||
|
||||
class SDL_WindowShapeParams(Union):
|
||||
_fields_ = [("binarizationCutoff", Uint8),
|
||||
("colorKey", SDL_Color)
|
||||
]
|
||||
class SDL_WindowShapeMode(Structure):
|
||||
_fields_ = [("mode", WindowShapeMode),
|
||||
("parameters", SDL_WindowShapeParams)
|
||||
]
|
||||
|
||||
SDL_SetWindowShape = _bind("SDL_SetWindowShape", [POINTER(SDL_Window), POINTER(SDL_Surface), POINTER(SDL_WindowShapeMode)], c_int)
|
||||
SDL_GetShapedWindowMode = _bind("SDL_GetShapedWindowMode", [POINTER(SDL_Window), POINTER(SDL_WindowShapeMode)], c_int)
|
37
src/m64py/SDL2/stdinc.py
Normal file
37
src/m64py/SDL2/stdinc.py
Normal file
|
@ -0,0 +1,37 @@
|
|||
import sys
|
||||
from .dll import _bind
|
||||
from ctypes import c_int, c_int8, c_uint8, c_int16, c_uint16, c_int32, \
|
||||
c_uint32, c_int64, c_uint64, cdll, c_size_t, c_void_p, c_char_p
|
||||
from ctypes.util import find_library
|
||||
|
||||
__all__ = ["SDL_FALSE", "SDL_TRUE", "SDL_bool", "Sint8", "Uint8", "Sint16",
|
||||
"Uint16", "Sint32", "Uint32", "Sint64", "Uint64", "SDL_malloc",
|
||||
"SDL_calloc", "SDL_realloc", "SDL_free", "SDL_getenv",
|
||||
"SDL_setenv", "SDL_abs", "SDL_min", "SDL_max", "SDL_memset",
|
||||
"SDL_memcpy"
|
||||
]
|
||||
|
||||
SDL_FALSE = 0
|
||||
SDL_TRUE = 1
|
||||
|
||||
SDL_bool = c_int
|
||||
Sint8 = c_int8
|
||||
Uint8 = c_uint8
|
||||
Sint16 = c_int16
|
||||
Uint16 = c_uint16
|
||||
Sint32 = c_int32
|
||||
Uint32 = c_uint32
|
||||
Sint64 = c_int64
|
||||
Uint64 = c_uint64
|
||||
|
||||
SDL_malloc = _bind("SDL_malloc", [c_size_t], c_void_p)
|
||||
SDL_calloc = _bind("SDL_calloc", [c_size_t, c_size_t], c_void_p)
|
||||
SDL_realloc = _bind("SDL_realloc", [c_void_p, c_size_t], c_void_p)
|
||||
SDL_free = _bind("SDL_free", [c_void_p], None)
|
||||
SDL_getenv = _bind("SDL_getenv", [c_char_p], c_char_p)
|
||||
SDL_setenv = _bind("SDL_setenv", [c_char_p, c_char_p, c_int], c_int)
|
||||
SDL_abs = abs
|
||||
SDL_min = min
|
||||
SDL_max = max
|
||||
SDL_memset = _bind("SDL_memset", [c_void_p, c_int, c_size_t], c_void_p)
|
||||
SDL_memcpy = _bind("SDL_memcpy", [c_void_p, c_void_p, c_size_t], c_void_p)
|
87
src/m64py/SDL2/surface.py
Normal file
87
src/m64py/SDL2/surface.py
Normal file
|
@ -0,0 +1,87 @@
|
|||
from ctypes import CFUNCTYPE, Structure, POINTER, c_int, c_void_p
|
||||
from .dll import _bind
|
||||
from .stdinc import Uint8, Uint32, SDL_bool
|
||||
from .blendmode import SDL_BlendMode
|
||||
from .rect import SDL_Rect
|
||||
from .pixels import SDL_PixelFormat, SDL_Palette
|
||||
from .rwops import SDL_RWops, SDL_RWFromFile
|
||||
|
||||
__all__ = ["SDL_SWSURFACE", "SDL_PREALLOC", "SDL_RLEACCEL", "SDL_DONTFREE",
|
||||
"SDL_MUSTLOCK", "SDL_BlitMap", "SDL_Surface", "SDL_Blit",
|
||||
"SDL_CreateRGBSurface", "SDL_CreateRGBSurfaceFrom", "SDL_FreeSurface",
|
||||
"SDL_SetSurfacePalette", "SDL_LockSurface", "SDL_UnlockSurface",
|
||||
"SDL_LoadBMP_RW", "SDL_LoadBMP", "SDL_SaveBMP_RW", "SDL_SaveBMP",
|
||||
"SDL_SetSurfaceRLE", "SDL_SetColorKey", "SDL_GetColorKey",
|
||||
"SDL_SetSurfaceColorMod", "SDL_GetSurfaceColorMod",
|
||||
"SDL_SetSurfaceAlphaMod", "SDL_GetSurfaceAlphaMod",
|
||||
"SDL_SetSurfaceBlendMode", "SDL_GetSurfaceBlendMode",
|
||||
"SDL_SetClipRect", "SDL_GetClipRect", "SDL_ConvertSurface",
|
||||
"SDL_ConvertSurfaceFormat", "SDL_ConvertPixels", "SDL_FillRect",
|
||||
"SDL_FillRects", "SDL_UpperBlit", "SDL_BlitSurface", "SDL_LowerBlit",
|
||||
"SDL_SoftStretch", "SDL_UpperBlitScaled", "SDL_BlitScaled",
|
||||
"SDL_LowerBlitScaled"
|
||||
]
|
||||
|
||||
SDL_SWSURFACE = 0
|
||||
SDL_PREALLOC = 0x00000001
|
||||
SDL_RLEACCEL = 0x00000002
|
||||
SDL_DONTFREE = 0x00000004
|
||||
|
||||
SDL_MUSTLOCK = lambda s: ((s.flags & SDL_RLEACCEL) != 0)
|
||||
|
||||
class SDL_BlitMap(Structure):
|
||||
pass
|
||||
|
||||
class SDL_Surface(Structure):
|
||||
_fields_ = [("flags", Uint32),
|
||||
("format", POINTER(SDL_PixelFormat)),
|
||||
("w", c_int), ("h", c_int),
|
||||
("pitch", c_int),
|
||||
("pixels", c_void_p),
|
||||
("userdata", c_void_p),
|
||||
("locked", c_int),
|
||||
("lock_data", c_void_p),
|
||||
("clip_rect", SDL_Rect),
|
||||
("map", POINTER(SDL_BlitMap)),
|
||||
("refcount", c_int)
|
||||
]
|
||||
|
||||
SDL_Blit = CFUNCTYPE(c_int, POINTER(SDL_Surface), POINTER(SDL_Rect), POINTER(SDL_Surface), POINTER(SDL_Rect))
|
||||
|
||||
SDL_CreateRGBSurface = _bind("SDL_CreateRGBSurface", [Uint32, c_int, c_int, c_int, Uint32, Uint32, Uint32, Uint32], POINTER(SDL_Surface))
|
||||
SDL_CreateRGBSurfaceFrom = _bind("SDL_CreateRGBSurfaceFrom", [c_void_p, c_int, c_int, c_int, c_int, Uint32, Uint32, Uint32, Uint32], POINTER(SDL_Surface))
|
||||
SDL_FreeSurface = _bind("SDL_FreeSurface", [POINTER(SDL_Surface)])
|
||||
SDL_SetSurfacePalette = _bind("SDL_SetSurfacePalette", [POINTER(SDL_Surface), POINTER(SDL_Palette)], c_int)
|
||||
SDL_LockSurface = _bind("SDL_LockSurface", [POINTER(SDL_Surface)], c_int)
|
||||
SDL_UnlockSurface = _bind("SDL_UnlockSurface", [POINTER(SDL_Surface)])
|
||||
|
||||
SDL_LoadBMP_RW = _bind("SDL_LoadBMP_RW", [POINTER(SDL_RWops), c_int], POINTER(SDL_Surface))
|
||||
SDL_LoadBMP = lambda fname: SDL_LoadBMP_RW(SDL_RWFromFile(fname, b"rb"), 1)
|
||||
SDL_SaveBMP_RW = _bind("SDL_SaveBMP_RW", [POINTER(SDL_Surface), POINTER(SDL_RWops), c_int], c_int)
|
||||
SDL_SaveBMP = lambda surface, fname: SDL_SaveBMP_RW(surface, SDL_RWFromFile(fname, b"wb"), 1)
|
||||
|
||||
SDL_SetSurfaceRLE = _bind("SDL_SetSurfaceRLE", [POINTER(SDL_Surface), c_int], c_int)
|
||||
SDL_SetColorKey = _bind("SDL_SetColorKey", [POINTER(SDL_Surface), c_int, Uint32], c_int)
|
||||
SDL_GetColorKey = _bind("SDL_GetColorKey", [POINTER(SDL_Surface), POINTER(Uint32)], c_int)
|
||||
SDL_SetSurfaceColorMod = _bind("SDL_SetSurfaceColorMod", [POINTER(SDL_Surface), Uint8, Uint8, Uint8], c_int)
|
||||
SDL_GetSurfaceColorMod = _bind("SDL_GetSurfaceColorMod", [POINTER(SDL_Surface), POINTER(Uint8), POINTER(Uint8), POINTER(Uint8)], c_int)
|
||||
SDL_SetSurfaceAlphaMod = _bind("SDL_SetSurfaceAlphaMod", [POINTER(SDL_Surface), Uint8], c_int)
|
||||
SDL_GetSurfaceAlphaMod = _bind("SDL_GetSurfaceAlphaMod", [POINTER(SDL_Surface), POINTER(Uint8)], c_int)
|
||||
SDL_SetSurfaceBlendMode = _bind("SDL_SetSurfaceBlendMode", [POINTER(SDL_Surface), SDL_BlendMode], c_int)
|
||||
SDL_GetSurfaceBlendMode = _bind("SDL_GetSurfaceBlendMode", [POINTER(SDL_Surface), POINTER(SDL_BlendMode)], c_int)
|
||||
SDL_SetClipRect = _bind("SDL_SetClipRect", [POINTER(SDL_Surface), POINTER(SDL_Rect)], SDL_bool)
|
||||
SDL_GetClipRect = _bind("SDL_GetClipRect", [POINTER(SDL_Surface), POINTER(SDL_Rect)])
|
||||
SDL_ConvertSurface = _bind("SDL_ConvertSurface", [POINTER(SDL_Surface), POINTER(SDL_PixelFormat), Uint32], POINTER(SDL_Surface))
|
||||
SDL_ConvertSurfaceFormat = _bind("SDL_ConvertSurfaceFormat", [POINTER(SDL_Surface), Uint32, Uint32], POINTER(SDL_Surface))
|
||||
SDL_ConvertPixels = _bind("SDL_ConvertPixels", [c_int, c_int, Uint32, c_void_p, c_int, Uint32, c_void_p, c_int], c_int)
|
||||
SDL_FillRect = _bind("SDL_FillRect", [POINTER(SDL_Surface), POINTER(SDL_Rect), Uint32], c_int)
|
||||
SDL_FillRects = _bind("SDL_FillRects", [POINTER(SDL_Surface), POINTER(SDL_Rect), c_int, Uint32], c_int)
|
||||
|
||||
|
||||
SDL_UpperBlit = _bind("SDL_UpperBlit", [POINTER(SDL_Surface), POINTER(SDL_Rect), POINTER(SDL_Surface), POINTER(SDL_Rect)], c_int)
|
||||
SDL_BlitSurface = SDL_UpperBlit
|
||||
SDL_LowerBlit = _bind("SDL_LowerBlit", [POINTER(SDL_Surface), POINTER(SDL_Rect), POINTER(SDL_Surface), POINTER(SDL_Rect)], c_int)
|
||||
SDL_SoftStretch = _bind("SDL_SoftStretch", [POINTER(SDL_Surface), POINTER(SDL_Rect), POINTER(SDL_Surface), POINTER(SDL_Rect)], c_int)
|
||||
SDL_UpperBlitScaled = _bind("SDL_UpperBlitScaled", [POINTER(SDL_Surface), POINTER(SDL_Rect), POINTER(SDL_Surface), POINTER(SDL_Rect)], c_int)
|
||||
SDL_BlitScaled = SDL_UpperBlitScaled
|
||||
SDL_LowerBlitScaled = _bind("SDL_LowerBlitScaled", [POINTER(SDL_Surface), POINTER(SDL_Rect), POINTER(SDL_Surface), POINTER(SDL_Rect)], c_int)
|
123
src/m64py/SDL2/syswm.py
Normal file
123
src/m64py/SDL2/syswm.py
Normal file
|
@ -0,0 +1,123 @@
|
|||
from ctypes import Union, Structure, c_int, c_void_p, c_long, c_ulong, \
|
||||
c_longlong, c_ulonglong, c_uint, sizeof, POINTER
|
||||
from .dll import _bind
|
||||
from .stdinc import SDL_bool
|
||||
from .version import SDL_version
|
||||
from .video import SDL_Window
|
||||
|
||||
__all__ = ["SDL_SYSWM_TYPE", "SDL_SYSWM_UNKNOWN", "SDL_SYSWM_WINDOWS",
|
||||
"SDL_SYSWM_X11", "SDL_SYSWM_DIRECTFB", "SDL_SYSWM_COCOA",
|
||||
"SDL_SYSWM_UIKIT", "SDL_SysWMmsg", "SDL_SysWMinfo",
|
||||
"SDL_GetWindowWMInfo"
|
||||
]
|
||||
|
||||
SDL_SYSWM_TYPE = c_int
|
||||
SDL_SYSWM_UNKNOWN = 0
|
||||
SDL_SYSWM_WINDOWS = 1
|
||||
SDL_SYSWM_X11 = 2
|
||||
SDL_SYSWM_DIRECTFB = 3
|
||||
SDL_SYSWM_COCOA = 4
|
||||
SDL_SYSWM_UIKIT = 5
|
||||
|
||||
# FIXME: Hack around the ctypes "_type_ 'v' not supported" bug - remove
|
||||
# once this has been fixed properly in Python 2.7+
|
||||
HWND = c_void_p
|
||||
UINT = c_uint
|
||||
if sizeof(c_long) == sizeof(c_void_p):
|
||||
WPARAM = c_ulong
|
||||
LPARAM = c_long
|
||||
elif sizeof(c_longlong) == sizeof(c_void_p):
|
||||
WPARAM = c_ulonglong
|
||||
LPARAM = c_longlong
|
||||
# FIXME: end
|
||||
|
||||
class _winmsg(Structure):
|
||||
_fields_ = [("hwnd", HWND),
|
||||
("msg", UINT),
|
||||
("wParam", WPARAM),
|
||||
("lParam", LPARAM),
|
||||
]
|
||||
|
||||
|
||||
class _x11msg(Structure):
|
||||
_fields_ = [("event", c_void_p)]
|
||||
|
||||
|
||||
class _dfbmsg(Structure):
|
||||
_fields_ = [("event", c_void_p)]
|
||||
|
||||
|
||||
class _cocoamsg(Structure):
|
||||
pass
|
||||
|
||||
|
||||
class _uikitmsg(Structure):
|
||||
pass
|
||||
|
||||
|
||||
class _msg(Union):
|
||||
_fields_ = [("win", _winmsg),
|
||||
("x11", _x11msg),
|
||||
("dfb", _dfbmsg),
|
||||
("cocoa", _cocoamsg),
|
||||
("uikit", _uikitmsg),
|
||||
("dummy", c_int)
|
||||
]
|
||||
|
||||
|
||||
class SDL_SysWMmsg(Structure):
|
||||
_fields_ = [("version", SDL_version),
|
||||
("subsystem", SDL_SYSWM_TYPE),
|
||||
("msg", _msg)
|
||||
]
|
||||
|
||||
|
||||
class _wininfo(Structure):
|
||||
_fields_ = [("window", HWND)]
|
||||
|
||||
|
||||
class _x11info(Structure):
|
||||
"""Window information for X11."""
|
||||
_fields_ = [("display", c_void_p),
|
||||
("window", c_ulong)]
|
||||
|
||||
|
||||
class _dfbinfo(Structure):
|
||||
"""Window information for DirectFB."""
|
||||
_fields_ = [("dfb", c_void_p),
|
||||
("window", c_void_p),
|
||||
("surface", c_void_p)]
|
||||
|
||||
|
||||
class _cocoainfo(Structure):
|
||||
"""Window information for MacOS X."""
|
||||
_fields_ = [("window", c_void_p)]
|
||||
|
||||
|
||||
class _uikitinfo(Structure):
|
||||
"""Window information for iOS."""
|
||||
_fields_ = [("window", c_void_p)]
|
||||
|
||||
|
||||
class _info(Union):
|
||||
"""The platform-specific information of a window."""
|
||||
_fields_ = [("win", _wininfo),
|
||||
("x11", _x11info),
|
||||
("dfb", _dfbinfo),
|
||||
("cocoa", _cocoainfo),
|
||||
("uikit", _uikitinfo),
|
||||
("dummy", c_int)
|
||||
]
|
||||
|
||||
|
||||
class SDL_SysWMinfo(Structure):
|
||||
"""System-specific window manager information.
|
||||
|
||||
This holds the low-level information about the window.
|
||||
"""
|
||||
_fields_ = [("version", SDL_version),
|
||||
("subsystem", SDL_SYSWM_TYPE),
|
||||
("info", _info)
|
||||
]
|
||||
|
||||
SDL_GetWindowWMInfo = _bind("SDL_GetWindowWMInfo", [POINTER(SDL_Window), POINTER(SDL_SysWMinfo)], SDL_bool)
|
19
src/m64py/SDL2/timer.py
Normal file
19
src/m64py/SDL2/timer.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
from ctypes import CFUNCTYPE, c_void_p, c_int
|
||||
from .dll import _bind
|
||||
from .stdinc import Uint32, Uint64, SDL_bool
|
||||
|
||||
__all__ = ["SDL_GetTicks", "SDL_GetPerformanceCounter",
|
||||
"SDL_GetPerformanceFrequency", "SDL_Delay", "SDL_TimerCallback",
|
||||
"SDL_TimerID", "SDL_AddTimer", "SDL_RemoveTimer"
|
||||
]
|
||||
|
||||
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)
|
24
src/m64py/SDL2/touch.py
Normal file
24
src/m64py/SDL2/touch.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
from ctypes import Structure, POINTER, c_float, c_int
|
||||
from .dll import _bind
|
||||
from .stdinc import Sint64
|
||||
|
||||
__all__ = ["SDL_TouchID", "SDL_FingerID", "SDL_Finger", "SDL_GetNumTouchDevices",
|
||||
"SDL_GetTouchDevice", "SDL_GetNumTouchFingers", "SDL_GetTouchFinger"
|
||||
]
|
||||
|
||||
SDL_TouchID = Sint64
|
||||
SDL_FingerID = Sint64
|
||||
|
||||
class SDL_Finger(Structure):
|
||||
_fields_ = [("id", SDL_FingerID),
|
||||
("x", c_float),
|
||||
("y", c_float),
|
||||
("pressure", c_float)
|
||||
]
|
||||
|
||||
# TODO: #define SDL_TOUCH_MOUSEID ((Uint32)-1)
|
||||
|
||||
SDL_GetNumTouchDevices = _bind("SDL_GetNumTouchDevices", None, c_int)
|
||||
SDL_GetTouchDevice = _bind("SDL_GetTouchDevice", [c_int], SDL_TouchID)
|
||||
SDL_GetNumTouchFingers = _bind("SDL_GetNumTouchFingers", [SDL_TouchID], c_int)
|
||||
SDL_GetTouchFinger = _bind("SDL_GetTouchFinger", [SDL_TouchID, c_int], POINTER(SDL_Finger))
|
31
src/m64py/SDL2/version.py
Normal file
31
src/m64py/SDL2/version.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
from ctypes import Structure, POINTER, c_char_p, c_int
|
||||
from .dll import _bind
|
||||
from .stdinc import Uint8
|
||||
|
||||
__all__ = ["SDL_version", "SDL_MAJOR_VERSION", "SDL_MINOR_VERSION",
|
||||
"SDL_PATCHLEVEL", "SDL_VERSION", "SDL_VERSIONNUM",
|
||||
"SDL_COMPILEDVERSION", "SDL_VERSION_ATLEAST", "SDL_GetVersion",
|
||||
"SDL_GetRevision", "SDL_GetRevisionNumber"
|
||||
]
|
||||
|
||||
class SDL_version(Structure):
|
||||
_fields_ = [("major", Uint8),
|
||||
("minor", Uint8),
|
||||
("patch", Uint8),
|
||||
]
|
||||
|
||||
SDL_MAJOR_VERSION = 2
|
||||
SDL_MINOR_VERSION = 0
|
||||
SDL_PATCHLEVEL = 0
|
||||
|
||||
def SDL_VERSION(x):
|
||||
x.major = SDL_MAJOR_VERSION
|
||||
x.minor = SDL_MINOR_VERSION
|
||||
x.patch = SDL_PATCHLEVEL
|
||||
|
||||
SDL_VERSIONNUM = lambda x, y, z: (x * 1000 + y * 100 + z)
|
||||
SDL_COMPILEDVERSION = SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL)
|
||||
SDL_VERSION_ATLEAST = lambda x, y, z: (SDL_COMPILEDVERSION >= SDL_VERSIONNUM(x, y, z))
|
||||
SDL_GetVersion = _bind("SDL_GetVersion", [POINTER(SDL_version)])
|
||||
SDL_GetRevision = _bind("SDL_GetRevision", None, c_char_p)
|
||||
SDL_GetRevisionNumber = _bind("SDL_GetRevisionNumber", None, c_int)
|
250
src/m64py/SDL2/video.py
Normal file
250
src/m64py/SDL2/video.py
Normal file
|
@ -0,0 +1,250 @@
|
|||
from ctypes import Structure, POINTER, c_int, c_void_p, c_char_p, c_float, \
|
||||
py_object
|
||||
from .dll import _bind
|
||||
from .stdinc import Uint16, Uint32, SDL_bool
|
||||
from .rect import SDL_Rect
|
||||
from .surface import SDL_Surface
|
||||
|
||||
__all__ = ["SDL_DisplayMode", "SDL_Window", "SDL_WindowFlags",
|
||||
"SDL_WINDOW_FULLSCREEN", "SDL_WINDOW_OPENGL", "SDL_WINDOW_SHOWN",
|
||||
"SDL_WINDOW_HIDDEN", "SDL_WINDOW_BORDERLESS", "SDL_WINDOW_RESIZABLE",
|
||||
"SDL_WINDOW_MINIMIZED", "SDL_WINDOW_MAXIMIZED",
|
||||
"SDL_WINDOW_INPUT_GRABBED", "SDL_WINDOW_INPUT_FOCUS",
|
||||
"SDL_WINDOW_MOUSE_FOCUS", "SDL_WINDOW_FULLSCREEN_DESKTOP",
|
||||
"SDL_WINDOW_FOREIGN", "SDL_WINDOWPOS_UNDEFINED_MASK",
|
||||
"SDL_WINDOWPOS_UNDEFINED_DISPLAY", "SDL_WINDOWPOS_UNDEFINED",
|
||||
"SDL_WINDOWPOS_ISUNDEFINED", "SDL_WINDOWPOS_CENTERED_MASK",
|
||||
"SDL_WINDOWPOS_CENTERED_DISPLAY", "SDL_WINDOWPOS_CENTERED",
|
||||
"SDL_WINDOWPOS_ISCENTERED", "SDL_WindowEventID",
|
||||
"SDL_WINDOWEVENT_NONE", "SDL_WINDOWEVENT_SHOWN",
|
||||
"SDL_WINDOWEVENT_HIDDEN", "SDL_WINDOWEVENT_EXPOSED",
|
||||
"SDL_WINDOWEVENT_MOVED", "SDL_WINDOWEVENT_RESIZED",
|
||||
"SDL_WINDOWEVENT_SIZE_CHANGED", "SDL_WINDOWEVENT_MINIMIZED",
|
||||
"SDL_WINDOWEVENT_MAXIMIZED", "SDL_WINDOWEVENT_RESTORED",
|
||||
"SDL_WINDOWEVENT_ENTER", "SDL_WINDOWEVENT_LEAVE",
|
||||
"SDL_WINDOWEVENT_FOCUS_GAINED", "SDL_WINDOWEVENT_FOCUS_LOST",
|
||||
"SDL_WINDOWEVENT_CLOSE", "SDL_GLContext", "SDL_GLattr",
|
||||
"SDL_GL_RED_SIZE", "SDL_GL_GREEN_SIZE", "SDL_GL_BLUE_SIZE",
|
||||
"SDL_GL_ALPHA_SIZE", "SDL_GL_BUFFER_SIZE", "SDL_GL_DOUBLEBUFFER",
|
||||
"SDL_GL_DEPTH_SIZE", "SDL_GL_STENCIL_SIZE", "SDL_GL_ACCUM_RED_SIZE",
|
||||
"SDL_GL_ACCUM_GREEN_SIZE", "SDL_GL_ACCUM_BLUE_SIZE",
|
||||
"SDL_GL_ACCUM_ALPHA_SIZE", "SDL_GL_STEREO",
|
||||
"SDL_GL_MULTISAMPLEBUFFERS", "SDL_GL_MULTISAMPLESAMPLES",
|
||||
"SDL_GL_ACCELERATED_VISUAL", "SDL_GL_RETAINED_BACKING",
|
||||
"SDL_GL_CONTEXT_MAJOR_VERSION", "SDL_GL_CONTEXT_MINOR_VERSION",
|
||||
"SDL_GL_CONTEXT_EGL", "SDL_GL_CONTEXT_FLAGS",
|
||||
"SDL_GL_CONTEXT_PROFILE_MASK", "SDL_GL_SHARE_WITH_CURRENT_CONTEXT",
|
||||
"SDL_GLprofile", "SDL_GL_CONTEXT_PROFILE_CORE",
|
||||
"SDL_GL_CONTEXT_PROFILE_COMPATIBILITY", "SDL_GL_CONTEXT_PROFILE_ES",
|
||||
"SDL_GLcontextFlag", "SDL_GL_CONTEXT_DEBUG_FLAG",
|
||||
"SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG",
|
||||
"SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG",
|
||||
"SDL_GL_CONTEXT_RESET_ISOLATION_FLAG", "SDL_GetNumVideoDrivers",
|
||||
"SDL_GetVideoDriver", "SDL_VideoInit", "SDL_VideoQuit",
|
||||
"SDL_GetCurrentVideoDriver", "SDL_GetNumVideoDisplays",
|
||||
"SDL_GetDisplayName", "SDL_GetDisplayBounds",
|
||||
"SDL_GetNumDisplayModes", "SDL_GetDisplayMode",
|
||||
"SDL_GetDesktopDisplayMode", "SDL_GetCurrentDisplayMode",
|
||||
"SDL_GetClosestDisplayMode", "SDL_GetWindowDisplayIndex",
|
||||
"SDL_SetWindowDisplayMode", "SDL_GetWindowDisplayMode",
|
||||
"SDL_GetWindowPixelFormat", "SDL_CreateWindow", "SDL_CreateWindowFrom",
|
||||
"SDL_GetWindowID", "SDL_GetWindowFromID", "SDL_GetWindowFlags",
|
||||
"SDL_SetWindowTitle", "SDL_GetWindowTitle", "SDL_SetWindowIcon",
|
||||
"SDL_SetWindowData", "SDL_GetWindowData", "SDL_SetWindowPosition",
|
||||
"SDL_GetWindowPosition", "SDL_SetWindowSize", "SDL_GetWindowSize",
|
||||
"SDL_SetWindowMinimumSize", "SDL_GetWindowMinimumSize",
|
||||
"SDL_SetWindowMaximumSize", "SDL_GetWindowMaximumSize",
|
||||
"SDL_SetWindowBordered", "SDL_ShowWindow", "SDL_HideWindow",
|
||||
"SDL_RaiseWindow", "SDL_MaximizeWindow", "SDL_MinimizeWindow",
|
||||
"SDL_RestoreWindow", "SDL_SetWindowFullscreen", "SDL_GetWindowSurface",
|
||||
"SDL_UpdateWindowSurface", "SDL_UpdateWindowSurfaceRects",
|
||||
"SDL_SetWindowGrab", "SDL_GetWindowGrab", "SDL_SetWindowBrightness",
|
||||
"SDL_GetWindowBrightness", "SDL_SetWindowGammaRamp",
|
||||
"SDL_GetWindowGammaRamp", "SDL_DestroyWindow", "SDL_DisableScreenSaver",
|
||||
"SDL_IsScreenSaverEnabled", "SDL_EnableScreenSaver",
|
||||
"SDL_GL_LoadLibrary", "SDL_GL_GetProcAddress", "SDL_GL_UnloadLibrary",
|
||||
"SDL_GL_ExtensionSupported", "SDL_GL_SetAttribute",
|
||||
"SDL_GL_GetAttribute", "SDL_GL_CreateContext", "SDL_GL_MakeCurrent",
|
||||
"SDL_GL_SetSwapInterval", "SDL_GL_GetSwapInterval",
|
||||
"SDL_GL_SwapWindow", "SDL_GL_DeleteContext"
|
||||
]
|
||||
|
||||
class SDL_DisplayMode(Structure):
|
||||
_fields_ = [("format", Uint32),
|
||||
("w", c_int),
|
||||
("h", c_int),
|
||||
("refresh_rate", c_int),
|
||||
("driverdata", c_void_p)
|
||||
]
|
||||
def __init__(self, format_=0, w=0, h=0, refresh_rate=0):
|
||||
super(SDL_DisplayMode, self).__init__()
|
||||
self.format = format_
|
||||
self.w = w
|
||||
self.h = h
|
||||
self.refresh_rate = refresh_rate
|
||||
|
||||
def __repr__(self):
|
||||
return "SDL_DisplayMode(format=%d, w=%d, h=%d, refresh_rate=%d)" % \
|
||||
(self.format, self.w, self.h, self.refresh_rate)
|
||||
|
||||
def __eq__(self, mode):
|
||||
return self.format == mode.format and self.w == mode.w and \
|
||||
self.h == mode.h and self.refresh_rate == mode.refresh_rate
|
||||
|
||||
def __ne__(self, mode):
|
||||
return self.format != mode.format or self.w != mode.w or \
|
||||
self.h != mode.h or self.refresh_rate != mode.refresh_rate
|
||||
|
||||
class SDL_Window(Structure):
|
||||
pass
|
||||
|
||||
SDL_WindowFlags = c_int
|
||||
SDL_WINDOW_FULLSCREEN = 0x00000001
|
||||
SDL_WINDOW_OPENGL = 0x00000002
|
||||
SDL_WINDOW_SHOWN = 0x00000004
|
||||
SDL_WINDOW_HIDDEN = 0x00000008
|
||||
SDL_WINDOW_BORDERLESS = 0x00000010
|
||||
SDL_WINDOW_RESIZABLE = 0x00000020
|
||||
SDL_WINDOW_MINIMIZED = 0x00000040
|
||||
SDL_WINDOW_MAXIMIZED = 0x00000080
|
||||
SDL_WINDOW_INPUT_GRABBED = 0x00000100
|
||||
SDL_WINDOW_INPUT_FOCUS = 0x00000200
|
||||
SDL_WINDOW_MOUSE_FOCUS = 0x00000400
|
||||
SDL_WINDOW_FULLSCREEN_DESKTOP = (SDL_WINDOW_FULLSCREEN | 0x00001000)
|
||||
SDL_WINDOW_FOREIGN = 0x00000800
|
||||
|
||||
SDL_WINDOWPOS_UNDEFINED_MASK = 0x1FFF0000
|
||||
SDL_WINDOWPOS_UNDEFINED_DISPLAY = lambda x: (SDL_WINDOWPOS_UNDEFINED_MASK | x)
|
||||
SDL_WINDOWPOS_UNDEFINED = SDL_WINDOWPOS_UNDEFINED_DISPLAY(0)
|
||||
SDL_WINDOWPOS_ISUNDEFINED = lambda x: ((x & 0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK)
|
||||
|
||||
SDL_WINDOWPOS_CENTERED_MASK = 0x2FFF0000
|
||||
SDL_WINDOWPOS_CENTERED_DISPLAY = lambda x: (SDL_WINDOWPOS_CENTERED_MASK | x)
|
||||
SDL_WINDOWPOS_CENTERED = SDL_WINDOWPOS_CENTERED_DISPLAY(0)
|
||||
SDL_WINDOWPOS_ISCENTERED = lambda x: ((x & 0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK)
|
||||
|
||||
SDL_WindowEventID = c_int
|
||||
|
||||
SDL_WINDOWEVENT_NONE = 0
|
||||
SDL_WINDOWEVENT_SHOWN = 1
|
||||
SDL_WINDOWEVENT_HIDDEN = 2
|
||||
SDL_WINDOWEVENT_EXPOSED = 3
|
||||
SDL_WINDOWEVENT_MOVED = 4
|
||||
SDL_WINDOWEVENT_RESIZED = 5
|
||||
SDL_WINDOWEVENT_SIZE_CHANGED = 6
|
||||
SDL_WINDOWEVENT_MINIMIZED = 7
|
||||
SDL_WINDOWEVENT_MAXIMIZED = 8
|
||||
SDL_WINDOWEVENT_RESTORED = 9
|
||||
SDL_WINDOWEVENT_ENTER = 10
|
||||
SDL_WINDOWEVENT_LEAVE = 11
|
||||
SDL_WINDOWEVENT_FOCUS_GAINED = 12
|
||||
SDL_WINDOWEVENT_FOCUS_LOST = 13
|
||||
SDL_WINDOWEVENT_CLOSE = 14
|
||||
|
||||
SDL_GLContext = c_void_p
|
||||
SDL_GLattr = c_int
|
||||
SDL_GL_RED_SIZE = 0
|
||||
SDL_GL_GREEN_SIZE = 1
|
||||
SDL_GL_BLUE_SIZE = 2
|
||||
SDL_GL_ALPHA_SIZE = 3
|
||||
SDL_GL_BUFFER_SIZE = 4
|
||||
SDL_GL_DOUBLEBUFFER = 5
|
||||
SDL_GL_DEPTH_SIZE = 6
|
||||
SDL_GL_STENCIL_SIZE = 7
|
||||
SDL_GL_ACCUM_RED_SIZE = 8
|
||||
SDL_GL_ACCUM_GREEN_SIZE = 9
|
||||
SDL_GL_ACCUM_BLUE_SIZE = 10
|
||||
SDL_GL_ACCUM_ALPHA_SIZE = 11
|
||||
SDL_GL_STEREO = 12
|
||||
SDL_GL_MULTISAMPLEBUFFERS = 13
|
||||
SDL_GL_MULTISAMPLESAMPLES = 14
|
||||
SDL_GL_ACCELERATED_VISUAL = 15
|
||||
SDL_GL_RETAINED_BACKING = 16
|
||||
SDL_GL_CONTEXT_MAJOR_VERSION = 17
|
||||
SDL_GL_CONTEXT_MINOR_VERSION = 18
|
||||
SDL_GL_CONTEXT_EGL = 19
|
||||
SDL_GL_CONTEXT_FLAGS = 20
|
||||
SDL_GL_CONTEXT_PROFILE_MASK = 21
|
||||
SDL_GL_SHARE_WITH_CURRENT_CONTEXT = 22
|
||||
|
||||
SDL_GLprofile = c_int
|
||||
SDL_GL_CONTEXT_PROFILE_CORE = 0x0001
|
||||
SDL_GL_CONTEXT_PROFILE_COMPATIBILITY = 0x0002
|
||||
SDL_GL_CONTEXT_PROFILE_ES = 0x0004
|
||||
|
||||
SDL_GLcontextFlag = c_int
|
||||
SDL_GL_CONTEXT_DEBUG_FLAG = 0x0001
|
||||
SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG = 0x0002
|
||||
SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG = 0x0004
|
||||
SDL_GL_CONTEXT_RESET_ISOLATION_FLAG = 0x0008
|
||||
|
||||
|
||||
SDL_GetNumVideoDrivers = _bind("SDL_GetNumVideoDrivers", None, c_int)
|
||||
SDL_GetVideoDriver = _bind("SDL_GetVideoDriver", [c_int], c_char_p)
|
||||
SDL_VideoInit = _bind("SDL_VideoInit", [c_char_p], c_int)
|
||||
SDL_VideoQuit = _bind("SDL_VideoQuit")
|
||||
SDL_GetCurrentVideoDriver = _bind("SDL_GetCurrentVideoDriver", None, c_char_p)
|
||||
SDL_GetNumVideoDisplays = _bind("SDL_GetNumVideoDisplays", None, c_int)
|
||||
SDL_GetDisplayName = _bind("SDL_GetDisplayName", [c_int], c_char_p)
|
||||
SDL_GetDisplayBounds = _bind("SDL_GetDisplayBounds", [c_int, POINTER(SDL_Rect)], c_int)
|
||||
SDL_GetNumDisplayModes = _bind("SDL_GetNumDisplayModes", [c_int], c_int)
|
||||
SDL_GetDisplayMode = _bind("SDL_GetDisplayMode", [c_int, c_int, POINTER(SDL_DisplayMode)], c_int)
|
||||
SDL_GetDesktopDisplayMode = _bind("SDL_GetDesktopDisplayMode", [c_int, POINTER(SDL_DisplayMode)], c_int)
|
||||
SDL_GetCurrentDisplayMode = _bind("SDL_GetCurrentDisplayMode", [c_int, POINTER(SDL_DisplayMode)], c_int)
|
||||
SDL_GetClosestDisplayMode = _bind("SDL_GetClosestDisplayMode", [c_int, POINTER(SDL_DisplayMode), POINTER(SDL_DisplayMode)], POINTER(SDL_DisplayMode))
|
||||
SDL_GetWindowDisplayIndex = _bind("SDL_GetWindowDisplayIndex", [POINTER(SDL_Window)], c_int)
|
||||
SDL_SetWindowDisplayMode = _bind("SDL_SetWindowDisplayMode", [POINTER(SDL_Window), POINTER(SDL_DisplayMode)], c_int)
|
||||
SDL_GetWindowDisplayMode = _bind("SDL_GetWindowDisplayMode", [POINTER(SDL_Window), POINTER(SDL_DisplayMode)], c_int)
|
||||
SDL_GetWindowPixelFormat = _bind("SDL_GetWindowPixelFormat", [POINTER(SDL_Window)], Uint32)
|
||||
SDL_CreateWindow = _bind("SDL_CreateWindow", [c_char_p, c_int, c_int, c_int, c_int, Uint32], POINTER(SDL_Window))
|
||||
SDL_CreateWindowFrom = _bind("SDL_CreateWindowFrom", [c_void_p], POINTER(SDL_Window))
|
||||
SDL_GetWindowID = _bind("SDL_GetWindowID", [POINTER(SDL_Window)], Uint32)
|
||||
SDL_GetWindowFromID = _bind("SDL_GetWindowFromID", [Uint32], POINTER(SDL_Window))
|
||||
SDL_GetWindowFlags = _bind("SDL_GetWindowFlags", [POINTER(SDL_Window)], Uint32)
|
||||
SDL_SetWindowTitle = _bind("SDL_SetWindowTitle", [POINTER(SDL_Window), c_char_p])
|
||||
SDL_GetWindowTitle = _bind("SDL_GetWindowTitle", [POINTER(SDL_Window)], c_char_p)
|
||||
SDL_SetWindowIcon = _bind("SDL_SetWindowIcon", [POINTER(SDL_Window), POINTER(SDL_Surface)])
|
||||
SDL_SetWindowData = _bind("SDL_SetWindowData", [POINTER(SDL_Window), c_char_p, POINTER(py_object)], POINTER(py_object))
|
||||
SDL_GetWindowData = _bind("SDL_GetWindowData", [POINTER(SDL_Window), c_char_p], POINTER(py_object))
|
||||
SDL_SetWindowPosition = _bind("SDL_SetWindowPosition", [POINTER(SDL_Window), c_int, c_int])
|
||||
SDL_GetWindowPosition = _bind("SDL_GetWindowPosition", [POINTER(SDL_Window), POINTER(c_int), POINTER(c_int)])
|
||||
SDL_SetWindowSize = _bind("SDL_SetWindowSize", [POINTER(SDL_Window), c_int, c_int])
|
||||
SDL_GetWindowSize = _bind("SDL_GetWindowSize", [POINTER(SDL_Window), POINTER(c_int), POINTER(c_int)])
|
||||
SDL_SetWindowMinimumSize = _bind("SDL_SetWindowMinimumSize", [POINTER(SDL_Window), c_int, c_int])
|
||||
SDL_GetWindowMinimumSize = _bind("SDL_GetWindowMinimumSize", [POINTER(SDL_Window), POINTER(c_int), POINTER(c_int)])
|
||||
SDL_SetWindowMaximumSize = _bind("SDL_SetWindowMaximumSize", [POINTER(SDL_Window), c_int, c_int])
|
||||
SDL_GetWindowMaximumSize = _bind("SDL_GetWindowMaximumSize", [POINTER(SDL_Window), POINTER(c_int), POINTER(c_int)])
|
||||
SDL_SetWindowBordered = _bind("SDL_SetWindowBordered", [POINTER(SDL_Window), SDL_bool])
|
||||
SDL_ShowWindow = _bind("SDL_ShowWindow", [POINTER(SDL_Window)])
|
||||
SDL_HideWindow = _bind("SDL_HideWindow", [POINTER(SDL_Window)])
|
||||
SDL_RaiseWindow = _bind("SDL_RaiseWindow", [POINTER(SDL_Window)])
|
||||
SDL_MaximizeWindow = _bind("SDL_MaximizeWindow", [POINTER(SDL_Window)])
|
||||
SDL_MinimizeWindow = _bind("SDL_MinimizeWindow", [POINTER(SDL_Window)])
|
||||
SDL_RestoreWindow = _bind("SDL_RestoreWindow", [POINTER(SDL_Window)])
|
||||
SDL_SetWindowFullscreen = _bind("SDL_SetWindowFullscreen", [POINTER(SDL_Window), Uint32], c_int)
|
||||
SDL_GetWindowSurface = _bind("SDL_GetWindowSurface", [POINTER(SDL_Window)], POINTER(SDL_Surface))
|
||||
SDL_UpdateWindowSurface = _bind("SDL_UpdateWindowSurface", [POINTER(SDL_Window)], c_int)
|
||||
SDL_UpdateWindowSurfaceRects = _bind("SDL_UpdateWindowSurfaceRects", [POINTER(SDL_Window), POINTER(SDL_Rect), c_int], c_int)
|
||||
SDL_SetWindowGrab = _bind("SDL_SetWindowGrab", [POINTER(SDL_Window), SDL_bool])
|
||||
SDL_GetWindowGrab = _bind("SDL_GetWindowGrab", [POINTER(SDL_Window)], SDL_bool)
|
||||
SDL_SetWindowBrightness = _bind("SDL_SetWindowBrightness", [POINTER(SDL_Window), c_float], c_int)
|
||||
SDL_GetWindowBrightness = _bind("SDL_GetWindowBrightness", [POINTER(SDL_Window)], c_float)
|
||||
SDL_SetWindowGammaRamp = _bind("SDL_SetWindowGammaRamp", [POINTER(SDL_Window), POINTER(Uint16), POINTER(Uint16), POINTER(Uint16)], c_int)
|
||||
SDL_GetWindowGammaRamp = _bind("SDL_GetWindowGammaRamp", [POINTER(SDL_Window), POINTER(Uint16), POINTER(Uint16), POINTER(Uint16)], c_int)
|
||||
SDL_DestroyWindow = _bind("SDL_DestroyWindow", [POINTER(SDL_Window)])
|
||||
SDL_IsScreenSaverEnabled = _bind("SDL_IsScreenSaverEnabled", None, SDL_bool)
|
||||
SDL_EnableScreenSaver = _bind("SDL_EnableScreenSaver")
|
||||
SDL_DisableScreenSaver = _bind("SDL_DisableScreenSaver")
|
||||
|
||||
SDL_GL_LoadLibrary = _bind("SDL_GL_LoadLibrary", [c_char_p], c_int)
|
||||
SDL_GL_GetProcAddress = _bind("SDL_GL_GetProcAddress", [c_char_p], c_void_p)
|
||||
SDL_GL_UnloadLibrary = _bind("SDL_GL_UnloadLibrary")
|
||||
SDL_GL_ExtensionSupported = _bind("SDL_GL_ExtensionSupported", [c_char_p], SDL_bool)
|
||||
SDL_GL_SetAttribute = _bind("SDL_GL_SetAttribute", [SDL_GLattr, c_int], c_int)
|
||||
SDL_GL_GetAttribute = _bind("SDL_GL_GetAttribute", [SDL_GLattr, POINTER(c_int)], c_int)
|
||||
SDL_GL_CreateContext = _bind("SDL_GL_CreateContext", [POINTER(SDL_Window)], SDL_GLContext)
|
||||
SDL_GL_MakeCurrent = _bind("SDL_GL_MakeCurrent", [POINTER(SDL_Window), SDL_GLContext], c_int)
|
||||
SDL_GL_SetSwapInterval = _bind("SDL_GL_SetSwapInterval", [c_int], c_int)
|
||||
SDL_GL_GetSwapInterval = _bind("SDL_GL_GetSwapInterval", None, c_int)
|
||||
SDL_GL_SwapWindow = _bind("SDL_GL_SwapWindow", [POINTER(SDL_Window)])
|
||||
SDL_GL_DeleteContext = _bind("SDL_GL_DeleteContext", [SDL_GLContext])
|
Loading…
Add table
Reference in a new issue