Skip to content

Commit 3ebe8a9

Browse files
authored
Fixed inability to use trackball mode on Steam Deck and RSTICK mouse registering (#70)
* Fixed inability to use trackball mode on Steam Deck * Fixed GUI error when loading mouse option for analog sticks * Fixed RSTICK not registering mouse events (and possibly others)
1 parent e3cac1c commit 3ebe8a9

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

scc/actions.py

+14-6
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
OUTPUT_360_STICK_MIN, OUTPUT_360_STICK_MAX)
1818
from scc.constants import STICK_PAD_MAX_HALF, TRIGGER_MIN, TRIGGER_HALF
1919
from scc.constants import HIPFIRE_NORMAL, HIPFIRE_SENSIBLE, HIPFIRE_EXCLUSIVE
20-
from scc.constants import LEFT, RIGHT, CPAD, STICK, PITCH, YAW, ROLL
20+
from scc.constants import LEFT, RIGHT, CPAD, STICK, RSTICK, PITCH, YAW, ROLL
2121
from scc.constants import PARSER_CONSTANTS, ControllerFlags
2222
from scc.constants import FE_STICK, FE_TRIGGER, FE_PAD
2323
from scc.constants import TRIGGER_CLICK, TRIGGER_MAX
@@ -445,6 +445,13 @@ def __init__(self, what, op, value):
445445
self.children = RangeOP(SCButtons.X, op, value), RangeOP(SCButtons.Y, op, value)
446446
self.min, self.max = float(STICK_PAD_MIN), float(STICK_PAD_MAX)
447447
self.op_method = self.cmp_or
448+
elif what == RSTICK:
449+
# Most special case of all special cases
450+
self.axis_name = RSTICK
451+
op = "ABS" + op.replace("=", "")
452+
self.children = RangeOP(SCButtons.X, op, value), RangeOP(SCButtons.Y, op, value)
453+
self.min, self.max = float(STICK_PAD_MIN), float(STICK_PAD_MAX)
454+
self.op_method = self.cmp_or
448455
else:
449456
raise ValueError("'%s' is not trigger nor axis" % (nameof(what), ))
450457

@@ -915,6 +922,7 @@ def whole(self, mapper: Mapper, x, y, what):
915922
# mapper.mouse_move(x * self.speed[0] * 0.01, y * self.speed[1] * 0.01)
916923
# mapper.force_event.add(FE_STICK)
917924
if ((what == STICK) or
925+
(what == RSTICK) or
918926
(what == RIGHT and mapper.controller_flags() & ControllerFlags.HAS_RSTICK)):
919927
ratio_x = x / (STICK_PAD_MAX if x > 0 else STICK_PAD_MIN) * copysign(1, x)
920928
ratio_y = y / (STICK_PAD_MAX if y > 0 else STICK_PAD_MIN) * copysign(1, y)
@@ -1609,7 +1617,7 @@ def button_release(self, mapper: Mapper):
16091617

16101618

16111619
def whole(self, mapper: Mapper, x, y, what):
1612-
if what == STICK:
1620+
if what == STICK or what == RSTICK:
16131621
# Stick used used as one big button (probably as part of ring bindings)
16141622
if abs(x) < ButtonAction.STICK_DEADZONE and abs(y) < ButtonAction.STICK_DEADZONE:
16151623
if self._pressed_key == self.button:
@@ -2128,7 +2136,7 @@ def to_string(self, multiline=False, pad=0):
21282136

21292137

21302138
def whole(self, mapper: Mapper, x, y, what):
2131-
if what == STICK or mapper.is_touched(what):
2139+
if what == STICK or what == RSTICK or mapper.is_touched(what):
21322140
angle = atan2(x, y)
21332141
distance = sqrt(x*x + y*y)
21342142
if distance < self._radius_m:
@@ -2143,7 +2151,7 @@ def whole(self, mapper: Mapper, x, y, what):
21432151

21442152
if action == self._active:
21452153
action.whole(mapper, x, y, what)
2146-
elif what == STICK:
2154+
elif what == STICK or what == RSTICK:
21472155
# Stck crossed radius border, so active action is changing.
21482156
# Simulate centering stick for former...
21492157
self._active.whole(mapper, 0, 0, what)
@@ -2166,7 +2174,7 @@ def whole(self, mapper: Mapper, x, y, what):
21662174
# Pad just released
21672175
self._active.whole(mapper, x, y, what)
21682176
self._active = NoAction()
2169-
elif self._active and what == STICK and x == 0 and y == 0:
2177+
elif self._active and (what == STICK or what == RSTICK) and x == 0 and y == 0:
21702178
# Stick is centered
21712179
self._active.whole(mapper, x, y, what)
21722180
self._active = NoAction()
@@ -2292,7 +2300,7 @@ def whole(self, mapper: Mapper, x, y, what):
22922300
else:
22932301
self._old_pos = None
22942302

2295-
if mapper.controller_flags() & ControllerFlags.HAS_RSTICK and what == RIGHT:
2303+
if mapper.controller_flags() & ControllerFlags.HAS_RSTICK and (what == RIGHT or what == RSTICK):
22962304
self.x.axis(mapper, x, what)
22972305
self.y.axis(mapper, y, what)
22982306
mapper.force_event.add(FE_PAD)

scc/gui/ae/axis_action.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,12 @@ def load_mouse_action(self, action):
174174
cbAxisOutput = self.builder.get_object("cbAxisOutput")
175175
self._recursing = True
176176
if isinstance(action, MouseAction):
177-
self.set_cb(cbMouseOutput, "mouse", 1)
178-
self.set_cb(cbAxisOutput, "mouse", 2)
177+
if self.editor.get_id() in STICKS:
178+
self.set_cb(cbMouseOutput, "mouse_stick", 1)
179+
self.set_cb(cbAxisOutput, "mouse_stick", 2)
180+
else:
181+
self.set_cb(cbMouseOutput, "mouse", 1)
182+
self.set_cb(cbAxisOutput, "mouse", 2)
179183
elif isinstance(action, XYAction):
180184
if isinstance(action.x, AxisAction):
181185
if action.x.parameters[0] == Axes.ABS_X:

scc/modifiers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ def change(self, mapper, dx, dy, what):
565565

566566

567567
def whole(self, mapper, x, y, what):
568-
if mapper.controller_flags() & ControllerFlags.HAS_RSTICK and what == RIGHT:
568+
if mapper.controller_flags() & ControllerFlags.HAS_RSTICK and not mapper.controller_flags() & ControllerFlags.IS_DECK and what == RIGHT:
569569
return self.action.whole(mapper, x, y, what)
570570
if mapper.is_touched(what):
571571
if mapper.is_touched(what) and not mapper.was_touched(what):

0 commit comments

Comments
 (0)