aboutsummaryrefslogtreecommitdiff
path: root/helper.py
diff options
context:
space:
mode:
authorB Stack <bgstack15@gmail.com>2022-07-03 23:06:09 -0400
committerB Stack <bgstack15@gmail.com>2022-07-03 23:06:09 -0400
commitb72841e3ff7220c7db44ae523c173321d5750497 (patch)
tree7535d0bf912e4a4e87399a719f56e5fe1755f1b7 /helper.py
downloadpyjstest-b72841e3ff7220c7db44ae523c173321d5750497.tar.gz
pyjstest-b72841e3ff7220c7db44ae523c173321d5750497.tar.bz2
pyjstest-b72841e3ff7220c7db44ae523c173321d5750497.zip
initial commit
Diffstat (limited to 'helper.py')
-rwxr-xr-xhelper.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/helper.py b/helper.py
new file mode 100755
index 0000000..b94ded6
--- /dev/null
+++ b/helper.py
@@ -0,0 +1,21 @@
+#!/usr/bin/env python3
+# Purpose: Display the name of the attached game controller
+from sdl2 import *
+import sdl2.ext, ctypes
+
+def get_joystick():
+ running = True
+ SDL_Init(SDL_INIT_JOYSTICK)
+ sdl2.ext.init()
+ while running:
+ event = SDL_Event()
+ while SDL_PollEvent(ctypes.byref(event)) != 0:
+ if event.type == SDL_JOYDEVICEADDED:
+ b = SDL_JoystickOpen(event.jdevice.which)
+ c = SDL_JoystickName(b).decode('UTF-8')
+ print(f"Device: {c}")
+ #running = False
+ #return b
+
+if __name__ == "__main__":
+ get_joystick()
bgstack15