Skip to content

Commit

Permalink
joystickd: mapping for PC (commaai#33500)
Browse files Browse the repository at this point in the history
work on PC
  • Loading branch information
sshane authored Sep 7, 2024
1 parent 68257da commit eecac10
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions tools/joystick/joystickd.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from openpilot.common.realtime import Ratekeeper
from openpilot.common.numpy_fast import interp, clip
from openpilot.common.params import Params
from openpilot.system.hardware import HARDWARE
from openpilot.tools.lib.kbhit import KBHit

JS_EXPO = 0.4
Expand Down Expand Up @@ -43,12 +44,17 @@ class Joystick:
def __init__(self):
# This class supports a PlayStation 5 DualSense controller on the comma 3X
# TODO: find a way to get this from API or detect gamepad/PC, perhaps "inputs" doesn't support it
# TODO: the mapping can also be wrong on PC depending on the driver
self.cancel_button = 'BTN_NORTH' # BTN_NORTH=X/triangle
accel_axis = 'ABS_RX'
steer_axis = 'ABS_Z'
# TODO: once the longcontrol API is finalized, we can replace this with outputting gas/brake and steering
self.flip_map = {'ABS_RY': accel_axis}
if HARDWARE.get_device_type() == 'pc':
accel_axis = 'ABS_Z'
steer_axis = 'ABS_RX'
# TODO: once the longcontrol API is finalized, we can replace this with outputting gas/brake and steering
self.flip_map = {'ABS_RZ': accel_axis}
else:
accel_axis = 'ABS_RX'
steer_axis = 'ABS_Z'
self.flip_map = {'ABS_RY': accel_axis}

self.min_axis_value = {accel_axis: 0., steer_axis: 0.}
self.max_axis_value = {accel_axis: 255., steer_axis: 255.}
self.axes_values = {accel_axis: 0., steer_axis: 0.}
Expand Down

0 comments on commit eecac10

Please sign in to comment.