We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d54bebf commit 6b8d26dCopy full SHA for 6b8d26d
1 file changed
tcod/sdl/joystick.py
@@ -356,13 +356,8 @@ def _get_instance_ids() -> list[int]:
356
"""
357
init()
358
count = ffi.new("int*")
359
- joysticks_p = lib.SDL_GetJoysticks(count) # SDL-owned SDL_JoystickID array.
360
- if not joysticks_p:
361
- return []
362
- try:
363
- return [int(joysticks_p[i]) for i in range(int(count[0]))]
364
- finally:
365
- lib.SDL_free(joysticks_p)
+ joysticks_p = _check_p(ffi.gc(lib.SDL_GetJoysticks(count), lib.SDL_free)) # SDL_JoystickID array
+ return [int(i) for i in joysticks_p[0:count[0]]]
366
367
368
def get_joysticks() -> list[Joystick]:
0 commit comments