Mouse movement
- Pygame captures steering wheel movement
- This function takes the steering output that ranges from -1 to 1 and maps it to a desired mouse movement value based on a specified range (range depends on sensitivity preference)
def map(val, min1, max1, min2, max2):
range1 = max1 - min1
range2 = max2 - min2
scale = range2 / range1
return (val - min1) * scale + min2
- Pynput Moves mouse by value received from map function
Mouse clicking
Keyboard control
- Pygame captures steering button presses and foot pedal movement
- Pynput simulates keyboard key presses for steering wheel and foot pedal controls pressing gas pedal would press the 'w' key and the brake pedal would press the 's' key to move forward and backward for WASD game movement.
Mapped controls:
Steering/footpedal input | Mouse/keyboard output |
---|---|
gearshift up | left click |
col 2 is | right click |
right turn | right mouse-x movement |
left turn | left mouse-x movement |
upward hat switch placement | upward mouse-y movement |
downward hat switch placement | downward mouse-y movement |
gas pedal | 'w' key |
break pedal | 's' key |
break pedal | 's' key |