Open
Description
import pygame
import time
from pynput.mouse import Controller as MouseController
pygame.init()
mouse = MouseController()
pygame.joystick.init()
print("Press Ctrl+C to exit.")
joystick_count = pygame.joystick.get_count()
if joystick_count == 0:
print("No joystick detected.")
pygame.quit()
exit()
joystick = pygame.joystick.Joystick(0)
joystick.init()
print(f"Joystick initialized: {joystick.get_name()}")
try:
while True:
for event in pygame.event.get():
if event.type == pygame.JOYAXISMOTION:
if event.axis == 0:
steering_wheel = event.value
print(f"Steering Wheel Position: {steering_wheel:.2f}")
if abs(steering_wheel) > 0.1: # Deadzone
mouse_movement_x = steering_wheel * 100 # Sensitivity factor
mouse.move(int(mouse_movement_x), 0)
print(f"Mouse moved by: {int(mouse_movement_x)}")
time.sleep(0.01)
except KeyboardInterrupt:
print("Exiting...")
finally:
pygame.quit()
Metadata
Metadata
Assignees
Labels
No labels