11import sys
2- from ctypes import Structure , c_int , c_char_p , c_void_p
2+ from ctypes import Structure , c_int , c_char_p , c_void_p , CFUNCTYPE
33from ctypes import POINTER as _P
44from .dll import _bind , SDLFunc , AttributeDict
55from .stdinc import Sint16 , Sint32 , Uint32 , Uint16 , Uint8 , SDL_bool
6+ from .guid import SDL_GUID
67
78__all__ = [
89 # Structs & Opaque Types
9- "SDL_Joystick" , "SDL_JoystickGUID" ,
10+ "SDL_Joystick" , "SDL_JoystickGUID" , "SDL_VirtualJoystickDesc" ,
1011
1112 # Defines
1213 "SDL_JoystickID" , "SDL_HAT_CENTERED" , "SDL_HAT_UP" , "SDL_HAT_RIGHT" ,
1314 "SDL_HAT_DOWN" , "SDL_HAT_LEFT" , "SDL_HAT_RIGHTUP" , "SDL_HAT_RIGHTDOWN" ,
1415 "SDL_HAT_LEFTUP" , "SDL_HAT_LEFTDOWN" , "SDL_IPHONE_MAX_GFORCE" ,
16+ "SDL_VIRTUAL_JOYSTICK_DESC_VERSION" ,
1517
1618 # Enums
1719 "SDL_JoystickType" ,
6466SDL_HAT_LEFTUP = SDL_HAT_LEFT | SDL_HAT_UP
6567SDL_HAT_LEFTDOWN = SDL_HAT_LEFT | SDL_HAT_DOWN
6668
69+ SDL_VIRTUAL_JOYSTICK_DESC_VERSION = 1
70+
6771
6872# Structs & typedefs
6973
7074SDL_JoystickID = Sint32
75+ SDL_JoystickGUID = SDL_GUID
7176
7277class SDL_Joystick (c_void_p ):
7378 pass
7479
75- class SDL_JoystickGUID (Structure ):
76- _fields_ = [("data" , (Uint8 * 16 ))]
80+ # TODO: Document these somewhere
81+ CFUNC_Update = CFUNCTYPE (None , c_void_p )
82+ CFUNC_SetPlayerIndex = CFUNCTYPE (None , c_void_p , c_int )
83+ CFUNC_Rumble = CFUNCTYPE (c_int , c_void_p , Uint16 , Uint16 )
84+ CFUNC_RumbleTriggers = CFUNCTYPE (c_int , c_void_p , Uint16 , Uint16 )
85+ CFUNC_SetLED = CFUNCTYPE (c_int , c_void_p , Uint8 , Uint8 , Uint8 )
86+ CFUNC_SendEffect = CFUNCTYPE (c_int , c_void_p , c_void_p , c_int )
87+
88+ class SDL_VirtualJoystickDesc (Structure ):
89+ _fields_ = [
90+ ("version" , Uint16 ),
91+ ("type" , Uint16 ),
92+ ("naxes" , Uint16 ),
93+ ("nbuttons" , Uint16 ),
94+ ("nhats" , Uint16 ),
95+ ("vendor_id" , Uint16 ),
96+ ("product_id" , Uint16 ),
97+ ("padding" , Uint16 ),
98+ ("button_mask" , Uint32 ),
99+ ("axis_mask" , Uint32 ),
100+ ("name" , c_char_p ),
101+ ("userdata" , c_void_p ),
102+ ("Update" , CFUNC_Update ),
103+ ("SetPlayerIndex" , CFUNC_SetPlayerIndex ),
104+ ("Rumble" , CFUNC_Rumble ),
105+ ("RumbleTriggers" , CFUNC_RumbleTriggers ),
106+ ("SetLED" , CFUNC_SetLED ),
107+ ("SendEffect" , CFUNC_SendEffect ),
108+ ]
77109
78110
79111# Raw ctypes function definitions
@@ -83,6 +115,7 @@ class SDL_JoystickGUID(Structure):
83115 SDLFunc ("SDL_UnlockJoysticks" , None , None , added = '2.0.7' ),
84116 SDLFunc ("SDL_NumJoysticks" , None , c_int ),
85117 SDLFunc ("SDL_JoystickNameForIndex" , [c_int ], c_char_p ),
118+ SDLFunc ("SDL_JoystickPathForIndex" , [c_int ], c_char_p , added = '2.23.1' ),
86119 SDLFunc ("SDL_JoystickGetDevicePlayerIndex" , [c_int ], c_int , added = '2.0.9' ),
87120 SDLFunc ("SDL_JoystickGetDeviceGUID" , [c_int ], SDL_JoystickGUID ),
88121 SDLFunc ("SDL_JoystickGetDeviceVendor" , [c_int ], Uint16 , added = '2.0.6' ),
@@ -97,6 +130,7 @@ class SDL_JoystickGUID(Structure):
97130 [SDL_JoystickType , c_int , c_int , c_int ],
98131 returns = c_int , added = '2.0.14'
99132 ),
133+ SDLFunc ("SDL_JoystickAttachVirtualEx" , [_P (SDL_VirtualJoystickDesc )], c_int , added = '2.23.1' ),
100134 SDLFunc ("SDL_JoystickDetachVirtual" , [c_int ], c_int , added = '2.0.14' ),
101135 SDLFunc ("SDL_JoystickIsVirtual" , [c_int ], SDL_bool , added = '2.0.14' ),
102136 SDLFunc ("SDL_JoystickSetVirtualAxis" ,
@@ -108,13 +142,15 @@ class SDL_JoystickGUID(Structure):
108142 returns = c_int , added = '2.0.14'
109143 ),
110144 SDLFunc ("SDL_JoystickSetVirtualHat" , [_P (SDL_Joystick ), c_int , Uint8 ], c_int , added = '2.0.14' ),
111- SDLFunc ("SDL_JoystickName" , [_P (SDL_Joystick )], c_char_p ),
145+ SDLFunc ("SDL_JoystickName" , [_P (SDL_Joystick )], c_char_p ),
146+ SDLFunc ("SDL_JoystickPath" , [_P (SDL_Joystick )], c_char_p , added = '2.23.1' ),
112147 SDLFunc ("SDL_JoystickGetPlayerIndex" , [_P (SDL_Joystick )], c_int , added = '2.0.9' ),
113148 SDLFunc ("SDL_JoystickSetPlayerIndex" , [_P (SDL_Joystick ), c_int ], added = '2.0.12' ),
114149 SDLFunc ("SDL_JoystickGetGUID" , [_P (SDL_Joystick )], SDL_JoystickGUID ),
115150 SDLFunc ("SDL_JoystickGetVendor" , [_P (SDL_Joystick )], Uint16 , added = '2.0.6' ),
116151 SDLFunc ("SDL_JoystickGetProduct" , [_P (SDL_Joystick )], Uint16 , added = '2.0.6' ),
117152 SDLFunc ("SDL_JoystickGetProductVersion" , [_P (SDL_Joystick )], Uint16 , added = '2.0.6' ),
153+ SDLFunc ("SDL_JoystickGetFirmwareVersion" , [_P (SDL_Joystick )], Uint16 , added = '2.23.1' ),
118154 SDLFunc ("SDL_JoystickGetSerial" , [_P (SDL_Joystick )], c_char_p , added = '2.0.14' ),
119155 SDLFunc ("SDL_JoystickGetType" , [_P (SDL_Joystick )], SDL_JoystickType , added = '2.0.6' ),
120156 SDLFunc ("SDL_JoystickGetGUIDString" , [SDL_JoystickGUID , c_char_p , c_int ]),
@@ -164,8 +200,10 @@ class SDL_JoystickGUID(Structure):
164200
165201SDL_NumJoysticks = _ctypes ["SDL_NumJoysticks" ]
166202SDL_JoystickNameForIndex = _ctypes ["SDL_JoystickNameForIndex" ]
203+ SDL_JoystickPathForIndex = _ctypes ["SDL_JoystickPathForIndex" ]
167204SDL_JoystickOpen = _ctypes ["SDL_JoystickOpen" ]
168205SDL_JoystickName = _ctypes ["SDL_JoystickName" ]
206+ SDL_JoystickPath = _ctypes ["SDL_JoystickPath" ]
169207SDL_JoystickGetDeviceGUID = _ctypes ["SDL_JoystickGetDeviceGUID" ]
170208SDL_JoystickGetGUID = _ctypes ["SDL_JoystickGetGUID" ]
171209SDL_JoystickGetGUIDFromString = _ctypes ["SDL_JoystickGetGUIDFromString" ]
@@ -186,6 +224,7 @@ class SDL_JoystickGUID(Structure):
186224SDL_JoystickFromInstanceID = _ctypes ["SDL_JoystickFromInstanceID" ]
187225SDL_JoystickFromPlayerIndex = _ctypes ["SDL_JoystickFromPlayerIndex" ]
188226SDL_JoystickAttachVirtual = _ctypes ["SDL_JoystickAttachVirtual" ]
227+ SDL_JoystickAttachVirtualEx = _ctypes ["SDL_JoystickAttachVirtualEx" ]
189228SDL_JoystickDetachVirtual = _ctypes ["SDL_JoystickDetachVirtual" ]
190229SDL_JoystickIsVirtual = _ctypes ["SDL_JoystickIsVirtual" ]
191230SDL_JoystickSetVirtualAxis = _ctypes ["SDL_JoystickSetVirtualAxis" ]
@@ -194,6 +233,7 @@ class SDL_JoystickGUID(Structure):
194233SDL_JoystickGetVendor = _ctypes ["SDL_JoystickGetVendor" ]
195234SDL_JoystickGetProduct = _ctypes ["SDL_JoystickGetProduct" ]
196235SDL_JoystickGetProductVersion = _ctypes ["SDL_JoystickGetProductVersion" ]
236+ SDL_JoystickGetFirmwareVersion = _ctypes ["SDL_JoystickGetFirmwareVersion" ]
197237SDL_JoystickGetSerial = _ctypes ["SDL_JoystickGetSerial" ]
198238SDL_JoystickGetAxisInitialState = _ctypes ["SDL_JoystickGetAxisInitialState" ]
199239SDL_JoystickGetType = _ctypes ["SDL_JoystickGetType" ]
0 commit comments