Skip to content

Commit 030671c

Browse files
committed
add option for inverting roll axis
1 parent 968a14a commit 030671c

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

src/hhd/controller/virtual/dualsense/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def __init__(
6060
enable_touchpad: bool = True,
6161
enable_rgb: bool = True,
6262
sync_gyro: bool = False,
63+
flip_z: bool = True,
6364
paddles_to_clicks: bool = False,
6465
) -> None:
6566
self.available = False
@@ -73,6 +74,7 @@ def __init__(
7374
self.enable_touchpad = enable_touchpad
7475
self.enable_rgb = enable_rgb
7576
self.sync_gyro = sync_gyro
77+
self.flip_z = flip_z
7678
self.paddles_to_clicks = paddles_to_clicks
7779

7880
self.ofs = (
@@ -300,6 +302,12 @@ def consume(self, events: Sequence[Event]):
300302
if not self.enable_touchpad and ev["code"].startswith("touchpad"):
301303
continue
302304
if ev["code"] in self.axis_map:
305+
if not self.flip_z and ev["code"] == "gyro_z":
306+
# Due to hhd's initial focus on steam input, all
307+
# devices were calibrated with an inverted x axis
308+
# compared to a real dualsense controller
309+
# So to not invert x, you have to invert x.
310+
ev["value"] = -ev["value"]
303311
encode_axis(new_rep, self.axis_map[ev["code"]], ev["value"])
304312
# DPAD is weird
305313
match ev["code"]:

src/hhd/plugins/outputs.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def get_outputs(
4444
fake_timestamps=not motion,
4545
sync_gyro=conf["dualsense_edge.sync_gyro"].to(bool) and motion,
4646
paddles_to_clicks=False,
47+
flip_z=conf["dualsense_edge.flip_z"].to(bool),
4748
)
4849
producers.append(d)
4950
consumers.append(d)
@@ -59,6 +60,7 @@ def get_outputs(
5960
fake_timestamps=not motion,
6061
sync_gyro=conf["dualsense.sync_gyro"].to(bool) and motion,
6162
paddles_to_clicks=conf["dualsense.paddles_to_clicks"].to(bool),
63+
flip_z=conf["dualsense.flip_z"].to(bool),
6264
)
6365
producers.append(d)
6466
consumers.append(d)

src/hhd/plugins/outputs.yml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ modes:
4141
Passes through the LEDs to the controller, which allows games
4242
to control them.
4343
default: True
44-
44+
4545
paddles_to_clicks:
4646
type: bool
4747
title: Paddles to Clicks
@@ -64,6 +64,15 @@ modes:
6464
If the IMU is not working, this setting will break the controller.
6565
default: False
6666

67+
flip_z:
68+
type: bool
69+
title: Invert Roll Axis
70+
default: True
71+
hint: >-
72+
Inverts the roll (Z) axis compared to a real Dualsense controller.
73+
Useful for Steam Input, since you want it to be inverted to look
74+
left to right, but an issue in emulators.
75+
6776
bluetooth_mode:
6877
type: bool
6978
title: Bluetooth Mode
@@ -106,6 +115,15 @@ modes:
106115
If the IMU is not working, this setting will break the controller.
107116
default: False
108117

118+
flip_z:
119+
type: bool
120+
title: Invert Roll Axis
121+
default: True
122+
hint: >-
123+
Inverts the roll (Z) axis compared to a real Dualsense controller.
124+
Useful for Steam Input, since you want it to be inverted to look
125+
left to right, but an issue in emulators.
126+
109127
bluetooth_mode:
110128
type: bool
111129
title: Bluetooth Mode
@@ -116,4 +134,4 @@ modes:
116134
interact with the controller.
117135
However, using USB mode can improve LED support (?) in some games.
118136
Test and report back!
119-
default: True
137+
default: True

0 commit comments

Comments
 (0)