1. Duangle
  2. Untitled project
  3. pysdl-cffi

Commits

Leonard Ritter  committed 99d0d72

mouse support functions

  • Participants
  • Parent commits 15e1d15
  • Branches default

Comments (0)

Files changed (5)

File predefs/sdl.pypredef

View file
 def SDL_LowerBlitScaled(*argv):
     """SDL_LowerBlitScaled"""
 
-SDL_JOYHATMOTION = int
+SDL_WINDOW_MAXIMIZED = int
 SDL_JOYBALLMOTION = int
 def SDL_JoystickNumHats(*argv):
     """SDL_JoystickNumHats"""
 def SDL_GL_SetAttribute(*argv):
     """SDL_GL_SetAttribute"""
 
-SDL_BUTTON_MIDDLE = int
+SDL_WINDOWEVENT_SIZE_CHANGED = int
 SDL_PEEKEVENT = int
 SDL_SCANCODE_F24 = int
 SDL_SCANCODE_F23 = int
 SDL_SCANCODE_MEDIASELECT = int
 SDL_WINDOWEVENT_FOCUS_GAINED = int
 KMOD_LGUI = int
-SDL_PRESSED = int
+SDL_SCANCODE_F11 = int
 def SDL_ConvertSurfaceFormat(*argv):
     """SDL_ConvertSurfaceFormat"""
 
     """SDL_DisableScreenSaver"""
 
 SDL_SCANCODE_CURRENCYSUBUNIT = int
-SDL_GL_MULTISAMPLESAMPLES = int
+KMOD_GUI = int
 SDL_WINDOWEVENT_RESTORED = int
 def SDL_GetModState(*argv):
     """SDL_GetModState"""
 SDL_SCANCODE_VOLUMEDOWN = int
 SDL_SCANCODE_F13 = int
 SDL_SCANCODE_F10 = int
-SDL_SCANCODE_F11 = int
+SDL_PRESSED = int
 SDL_SCANCODE_F16 = int
 SDL_SCANCODE_F17 = int
 SDL_SCANCODE_F14 = int
 def SDL_FlushEvents(*argv):
     """SDL_FlushEvents"""
 
-SDL_BlitSurface = long
+SDL_BlitSurface = int
 SDL_SCANCODE_KP_RIGHTBRACE = int
 SDL_BLENDMODE_NONE = int
 def SDL_SetWindowFullscreen(*argv):
     """SDL_FilterEvents"""
 
 SDL_ALPHA_TRANSPARENT = int
-SDL_WINDOWEVENT_SIZE_CHANGED = int
+SDL_BUTTON_MIDDLE = int
 def SDL_DelEventWatch(*argv):
     """SDL_DelEventWatch"""
 
     """SDL_UpdateWindowSurface"""
 
 SDL_SCANCODE_EXECUTE = int
-SDL_HAT_LEFTDOWN = int
+SDL_GL_MULTISAMPLESAMPLES = int
 SDLK_SCANCODE_MASK = int
 def SDL_WriteBE64(*argv):
     """SDL_WriteBE64"""
 
 SDL_SCANCODE_KP_AMPERSAND = int
 SDL_SCANCODE_UNDO = int
-SDL_BlitScaled = long
+SDL_BlitScaled = int
 SDL_SCANCODE_SLEEP = int
 SDL_SCANCODE_CRSEL = int
 SDL_LASTEVENT = int
 SDL_SCANCODE_KP_GREATER = int
 SDL_SCANCODE_KBDILLUMUP = int
+SDL_HAT_LEFTDOWN = int
 SDL_SCANCODE_KP_COMMA = int
 def SDL_GetEventFilter(*argv):
     """SDL_GetEventFilter"""
 
 SDL_SCANCODE_KP_DBLVERTICALBAR = int
 SDL_SCANCODE_RIGHT = int
-KMOD_GUI = int
 SDL_LASTERROR = int
 def SDL_Init(*argv):
     """SDL_Init"""
 def SDL_JoystickEventState(*argv):
     """SDL_JoystickEventState"""
 
-SDL_WINDOW_MAXIMIZED = int
+SDL_JOYHATMOTION = int
 def SDL_GL_UnloadLibrary(*argv):
     """SDL_GL_UnloadLibrary"""
 

File sdl/__init__.py

View file
     _SDL_GetWindowSize(window, w, h)
     return w[0], h[0]
 
+def SDL_GetMouseState():
+    x = _ffi.new('int *')
+    y = _ffi.new('int *')
+    state = _SDL_GetMouseState(x, y)
+    return state, x[0], y[0]
+
 ################################################################################
 
 # add wrapped functions

File sdl/_sdl.py

View file
 from cffi import FFI
 
 UNMANGLED_EXPORTS = [
+"_SDL_GetMouseState",
 "_SDL_GetError",
 "_SDL_Init",
 "_SDL_PollEvent",
 "SDL_UnionRect",
 "SDL_JoystickNumBalls",
 "SDL_SCANCODE_KP_PERCENT",
-"SDL_GetMouseState",
 "SDL_KEYDOWN",
 "SDL_ShowCursor",
 "SDL_SCANCODE_RETURN2",
 "SDL_HAT_RIGHTUP",
 "SDL_RWFromMem",
 "SDL_LowerBlitScaled",
-"SDL_JOYHATMOTION",
+"SDL_WINDOW_MAXIMIZED",
 "SDL_JOYBALLMOTION",
 "SDL_JoystickNumHats",
 "SDL_JoystickOpened",
 "SDL_SCANCODE_RCTRL",
 "SDL_ReadLE64",
 "SDL_GL_SetAttribute",
-"SDL_BUTTON_MIDDLE",
+"SDL_WINDOWEVENT_SIZE_CHANGED",
 "SDL_PEEKEVENT",
 "SDL_SCANCODE_F24",
 "SDL_SCANCODE_F23",
 "SDL_SCANCODE_MEDIASELECT",
 "SDL_WINDOWEVENT_FOCUS_GAINED",
 "KMOD_LGUI",
-"SDL_PRESSED",
+"SDL_SCANCODE_F11",
 "SDL_ConvertSurfaceFormat",
 "SDL_RWFromFP",
 "SDL_DisableScreenSaver",
 "SDL_SCANCODE_CURRENCYSUBUNIT",
-"SDL_GL_MULTISAMPLESAMPLES",
+"KMOD_GUI",
 "SDL_WINDOWEVENT_RESTORED",
 "SDL_GetModState",
 "SDL_SCANCODE_PAUSE",
 "SDL_SCANCODE_VOLUMEDOWN",
 "SDL_SCANCODE_F13",
 "SDL_SCANCODE_F10",
-"SDL_SCANCODE_F11",
+"SDL_PRESSED",
 "SDL_SCANCODE_F16",
 "SDL_SCANCODE_F17",
 "SDL_SCANCODE_F14",
 "SDL_HAT_LEFTUP",
 "SDL_FilterEvents",
 "SDL_ALPHA_TRANSPARENT",
-"SDL_WINDOWEVENT_SIZE_CHANGED",
+"SDL_BUTTON_MIDDLE",
 "SDL_DelEventWatch",
 "SDL_SCANCODE_KP_OCTAL",
 "SDL_SetSurfaceAlphaMod",
 "SDL_HAT_RIGHTDOWN",
 "SDL_UpdateWindowSurface",
 "SDL_SCANCODE_EXECUTE",
-"SDL_HAT_LEFTDOWN",
+"SDL_GL_MULTISAMPLESAMPLES",
 "SDLK_SCANCODE_MASK",
 "SDL_WriteBE64",
 "SDL_SetSurfaceColorMod",
 "SDL_LASTEVENT",
 "SDL_SCANCODE_KP_GREATER",
 "SDL_SCANCODE_KBDILLUMUP",
+"SDL_HAT_LEFTDOWN",
 "SDL_SCANCODE_KP_COMMA",
 "SDL_GetEventFilter",
 "SDL_SCANCODE_KP_DBLVERTICALBAR",
 "SDL_SCANCODE_RIGHT",
-"KMOD_GUI",
 "SDL_LASTERROR",
 "SDL_GL_STENCIL_SIZE",
 "SDL_SCANCODE_KP_LEFTBRACE",
 "SDL_SCANCODE_AC_BOOKMARKS",
 "SDL_GL_RETAINED_BACKING",
 "SDL_JoystickEventState",
-"SDL_WINDOW_MAXIMIZED",
+"SDL_JOYHATMOTION",
 "SDL_GL_UnloadLibrary",
 "SDL_JOYBUTTONUP",
 "SDL_SCANCODE_INTERNATIONAL5",
 SDL_UnionRect = guard(lookup('SDL_UnionRect'))
 SDL_JoystickNumBalls = guard(lookup('SDL_JoystickNumBalls'))
 SDL_SCANCODE_KP_PERCENT = 196
-SDL_GetMouseState = guard(lookup('SDL_GetMouseState'))
+_SDL_GetMouseState = guard(lookup('SDL_GetMouseState'))
 SDL_KEYDOWN = 768
 SDL_ShowCursor = guard(lookup('SDL_ShowCursor'))
 SDL_SCANCODE_RETURN2 = 158
 SDL_HAT_RIGHTUP = 3
 SDL_RWFromMem = guard(lookup('SDL_RWFromMem'))
 SDL_LowerBlitScaled = guard(lookup('SDL_LowerBlitScaled'))
-SDL_JOYHATMOTION = 1538
+SDL_WINDOW_MAXIMIZED = 128
 SDL_JOYBALLMOTION = 1537
 SDL_JoystickNumHats = guard(lookup('SDL_JoystickNumHats'))
 SDL_JoystickOpened = guard(lookup('SDL_JoystickOpened'))
 SDL_SCANCODE_RCTRL = 228
 SDL_ReadLE64 = guard(lookup('SDL_ReadLE64'))
 SDL_GL_SetAttribute = guard(lookup('SDL_GL_SetAttribute'))
-SDL_BUTTON_MIDDLE = 2
+SDL_WINDOWEVENT_SIZE_CHANGED = 6
 SDL_PEEKEVENT = 1
 SDL_SCANCODE_F24 = 115
 SDL_SCANCODE_F23 = 114
 SDL_SCANCODE_MEDIASELECT = 263
 SDL_WINDOWEVENT_FOCUS_GAINED = 12
 KMOD_LGUI = 1024
-SDL_PRESSED = 1
+SDL_SCANCODE_F11 = 68
 SDL_ConvertSurfaceFormat = guard(lookup('SDL_ConvertSurfaceFormat'))
 SDL_RWFromFP = guard(lookup('SDL_RWFromFP'))
 SDL_DisableScreenSaver = guard(lookup('SDL_DisableScreenSaver'))
 SDL_SCANCODE_CURRENCYSUBUNIT = 181
-SDL_GL_MULTISAMPLESAMPLES = 14
+KMOD_GUI = 3072
 SDL_WINDOWEVENT_RESTORED = 9
 SDL_GetModState = guard(lookup('SDL_GetModState'))
 SDL_SCANCODE_PAUSE = 72
 SDL_SCANCODE_VOLUMEDOWN = 129
 SDL_SCANCODE_F13 = 104
 SDL_SCANCODE_F10 = 67
-SDL_SCANCODE_F11 = 68
+SDL_PRESSED = 1
 SDL_SCANCODE_F16 = 107
 SDL_SCANCODE_F17 = 108
 SDL_SCANCODE_F14 = 105
 SDL_GetRGBA = guard(lookup('SDL_GetRGBA'))
 SDL_UnlockSurface = guard(lookup('SDL_UnlockSurface'))
 SDL_FlushEvents = guard(lookup('SDL_FlushEvents'))
-SDL_BlitSurface = 140436402701552
+SDL_BlitSurface = 140232686646512
 SDL_SCANCODE_KP_RIGHTBRACE = 185
 SDL_BLENDMODE_NONE = 0
 SDL_SetWindowFullscreen = guard(lookup('SDL_SetWindowFullscreen'))
 SDL_HAT_LEFTUP = 9
 SDL_FilterEvents = guard(lookup('SDL_FilterEvents'))
 SDL_ALPHA_TRANSPARENT = 0
-SDL_WINDOWEVENT_SIZE_CHANGED = 6
+SDL_BUTTON_MIDDLE = 2
 SDL_DelEventWatch = guard(lookup('SDL_DelEventWatch'))
 SDL_SCANCODE_KP_OCTAL = 219
 SDL_SetSurfaceAlphaMod = guard(lookup('SDL_SetSurfaceAlphaMod'))
 SDL_HAT_RIGHTDOWN = 6
 SDL_UpdateWindowSurface = guard(lookup('SDL_UpdateWindowSurface'))
 SDL_SCANCODE_EXECUTE = 116
-SDL_HAT_LEFTDOWN = 12
+SDL_GL_MULTISAMPLESAMPLES = 14
 SDLK_SCANCODE_MASK = 1073741824
 SDL_WriteBE64 = guard(lookup('SDL_WriteBE64'))
 SDL_SetSurfaceColorMod = guard(lookup('SDL_SetSurfaceColorMod'))
 SDL_PeepEvents = guard(lookup('SDL_PeepEvents'))
 SDL_SCANCODE_KP_AMPERSAND = 199
 SDL_SCANCODE_UNDO = 122
-SDL_BlitScaled = 140436402702320
+SDL_BlitScaled = 140232686647280
 SDL_SCANCODE_SLEEP = 282
 SDL_SCANCODE_CRSEL = 163
 SDL_LASTEVENT = 65535
 SDL_SCANCODE_KP_GREATER = 198
 SDL_SCANCODE_KBDILLUMUP = 280
+SDL_HAT_LEFTDOWN = 12
 SDL_SCANCODE_KP_COMMA = 133
 SDL_GetEventFilter = guard(lookup('SDL_GetEventFilter'))
 SDL_SCANCODE_KP_DBLVERTICALBAR = 202
 SDL_SCANCODE_RIGHT = 79
-KMOD_GUI = 3072
 SDL_LASTERROR = 5
 _SDL_Init = lookup('SDL_Init')
 SDL_GL_STENCIL_SIZE = 7
 SDL_SCANCODE_AC_BOOKMARKS = 274
 SDL_GL_RETAINED_BACKING = 16
 SDL_JoystickEventState = guard(lookup('SDL_JoystickEventState'))
-SDL_WINDOW_MAXIMIZED = 128
+SDL_JOYHATMOTION = 1538
 SDL_GL_UnloadLibrary = guard(lookup('SDL_GL_UnloadLibrary'))
 SDL_JOYBUTTONUP = 1540
 SDL_SCANCODE_INTERNATIONAL5 = 139

File sdl/builder.py

View file
         'SDL_GetError',
         'SDL_Init',
         'SDL_PollEvent',
+        'SDL_GetMouseState',
         'SDL_GetWindowSize',
     ],
     AUTOCHECK_BLACKLIST = [

File sdl/internal.py

View file
 _LIB = None
 
 IS_WIN32 = sys.platform == 'win32'
-_THISDIR = os.path.dirname(__file__)  
+IS_LINUX = sys.platform == 'linux2'
+_THISDIR = os.path.abspath(os.path.dirname(__file__))  
 
 def load_lib(cdefs):
     global _LIB
+    libname = 'SDL2'
     if IS_WIN32:
-        libname = os.path.join(_THISDIR, 'SDL2.dll')
+        local_dl = os.path.join(_THISDIR, 'SDL2.dll')
+    elif IS_LINUX:
+        local_dl = os.path.join(_THISDIR, 'libSDL2.so')
     else:
-        libname = 'SDL2'
+        local_dl = None
+        
+    if local_dl and os.path.isfile(local_dl):
+        libname = local_dl 
+        
     #import time
     #t = time.time()
     _ffi.cdef(cdefs)