Skip to content

Commit 6b8d26d

Browse files
pinghedmHexDecimal
andauthored
Update tcod/sdl/joystick.py
Co-authored-by: Kyle Benesch <4b796c65+github@gmail.com>
1 parent d54bebf commit 6b8d26d

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

tcod/sdl/joystick.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -356,13 +356,8 @@ def _get_instance_ids() -> list[int]:
356356
"""
357357
init()
358358
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)
359+
joysticks_p = _check_p(ffi.gc(lib.SDL_GetJoysticks(count), lib.SDL_free)) # SDL_JoystickID array
360+
return [int(i) for i in joysticks_p[0:count[0]]]
366361

367362

368363
def get_joysticks() -> list[Joystick]:

0 commit comments

Comments
 (0)