-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjoytest.py
More file actions
executable file
·33 lines (23 loc) · 887 Bytes
/
joytest.py
File metadata and controls
executable file
·33 lines (23 loc) · 887 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env python3
import pygame, sys
# Get state of joysticks and print events
pygame.init()
if not pygame.joystick.get_init():
print("Joystick module not initialised")
sys.exit(0)
jscount = pygame.joystick.get_count()
print(f"Joystick module initialised, {jscount} joystick(s) found")
for js_n in range(jscount):
js = pygame.joystick.Joystick(js_n)
print(f"Joystick {js_n}:", js.get_name())
print(" Instance ID: ", js.get_instance_id())
print(" GUID: ", js.get_guid())
print(" Power: ", js.get_power_level())
print(" Axes: ", js.get_numaxes())
print(" Balls: ", js.get_numballs())
print(" Hats: ", js.get_numhats())
print(" Buttons: ", js.get_numbuttons())
print(" Rumble: ", js.rumble(1,1,100))
while True:
event = pygame.event.wait()
print(event)