uno-q-modulino-joystick-input.py
Python script using the evdev library to capture hardware inputs from the Modulino Joystick node connected to the UNO Q.
Connect the Modulino Joystick node to one of the Q-Bus ports on the UNO Q board. Ensure the generic HID driver is loaded. Identify the device using 'ls /dev/input/' or 'evtest'. Run the script with 'python3 joystick_read.py' to view real-time events.
uno-q-modulino-joystick-input.py
#!/usr/bin/env python3
import evdev
import sys
# Identifiant du device joystick (à vérifier avec 'evtest')
DEVICE_PATH = '/dev/input/event2'
def main():
try:
device = evdev.InputDevice(DEVICE_PATH)
print(f"Device: {device.name}")
print("Appuyez sur le joystick pour voir les événements...")
for event in device.read_loop():
if event.type == evdev.ecodes.EV_KEY:
# Événement bouton (clic sur le joystick)
print(f"Bouton: {evdev.categorize(event)}")
elif event.type == evdev.ecodes.EV_ABS:
# Événement axe (mouvement joystick)
print(f"Axe: {evdev.categorize(event)}")
except FileNotFoundError:
print("Erreur: Périphérique introuvable. Vérifiez le chemin /dev/input/eventX")
sys.exit(1)
if __name__ == '__main__':
main()