You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
490 B
Python

import sys
import sdl2
import sdl2.ext
import time
def main():
if sdl2.SDL_Init(sdl2.SDL_INIT_GAMECONTROLLER | sdl2.SDL_INIT_EVENTS) != 0:
print(f"SDL_Init error: {sdl2.SDL_GetError().decode()}")
return 1
num_joysticks = sdl2.SDL_NumJoysticks()
print("Joystick count: ", num_joysticks)
for i in range(num_joysticks):
print(i)
name = sdl2.SDL_GameControllerNameForIndex(i)
print(name)
if __name__ == "__main__":
sys.exit(main())