Ryochan7 / sc-controller

User-mode driver and GTK3 based GUI for Steam Controller
GNU General Public License v2.0
177 stars 23 forks source link

Right analog stick does not work as mouse #75

Open bell07 opened 1 year ago

bell07 commented 1 year ago

Configured the right stick to use as mouse for old game on Steam Deck with Gentoo.

    "rstick": {
        "action": "mouse()"
    }, 

evteston the "SCController Mouse" device returns no mouse input. The mouse is not moved :-(

How I can help to find the reason?

EDIT: Same setting on left stick work as expected. The right stick works fine as "stick" so there is no hardware issue.

Ryochan7 commented 1 year ago

The problem is definitely not uinput related then. Maybe it is a problem with the steamdeck driver in the program? RS mouse works in theory with the DS4 and DualSense but the actual behavior has always been wrong. Still tries to calculate deltas like when using a touchpad as input. I do not use SC Controller other than with the Steam Controller so I did not want to bother trying to correct the behavior.

bell07 commented 1 year ago

Tried the same with my Logitech F710: both sticks are useable as mouse as expected with this pad. So I think the issue root is in steamdeck driver in program.

Ryochan7 commented 1 year ago

I finally changed how the mouse action works with RS. It took some hackery but it feels better to me and it is closer to what I am used to from my other experiments. More of the actual computation is done in the mouse action rather than in the Mouse class (uinput.py).

https://github.com/Ryochan7/sc-controller/commit/fa32bb3b570eadeebef9f96bc3027de3ddd0e56d

bell07 commented 1 year ago

unfortunately the change did not fix my issue. The right stick still not work as mouse

gordon-quad commented 12 months ago

I did a little investigation and it looks like following patch fixes rstick mouse on my deck, however it is a bit ugly.

--- a/scc/actions.py    2023-10-16 19:06:46.387956633 -0000
+++ b/scc/actions.py    2023-10-31 13:43:32.689125560 -0000
@@ -17,7 +17,7 @@
 OUTPUT_360_STICK_MIN, OUTPUT_360_STICK_MAX)
 from scc.constants import STICK_PAD_MAX_HALF, TRIGGER_MIN, TRIGGER_HALF
 from scc.constants import HIPFIRE_NORMAL, HIPFIRE_SENSIBLE, HIPFIRE_EXCLUSIVE
-from scc.constants import LEFT, RIGHT, CPAD, STICK, PITCH, YAW, ROLL
+from scc.constants import LEFT, RIGHT, CPAD, STICK, RSTICK, PITCH, YAW, ROLL
 from scc.constants import PARSER_CONSTANTS, ControllerFlags
 from scc.constants import FE_STICK, FE_TRIGGER, FE_PAD
 from scc.constants import TRIGGER_CLICK, TRIGGER_MAX
@@ -918,7 +918,7 @@
                #       mapper.mouse_move(x * self.speed[0] * 0.01, y * self.speed[1] * 0.01)
                #       mapper.force_event.add(FE_STICK)
                if ((what == STICK) or
-                       (what == RIGHT and mapper.controller_flags() & ControllerFlags.HAS_RSTICK)):
+                       (what == RSTICK and mapper.controller_flags() & (ControllerFlags.HAS_RSTICK | ControllerFlags.IS_DECK))):
                        ratio_x = x / (STICK_PAD_MAX if x > 0 else STICK_PAD_MIN) * copysign(1, x)
                        ratio_y = y / (STICK_PAD_MAX if y > 0 else STICK_PAD_MIN) * copysign(1, y)
                        mouse_dx = ratio_x * (mapper.time_elapsed * BASE_STICK_MOUSE_SPEED) * self.speed[0]
Ryochan7 commented 12 months ago

Not sure why HAS_RSTICK is not set in ControllerFlags for the Deck. Actions should not have to know what device is being mapped if it can be helped.

Ryochan7 commented 11 months ago

Now that I have mapper.py pulled up, I can see why HAS_RSTICK is not set for the Steam Deck module. Both the Right Stick and Right Touchpad use the same mapping id (RIGHT). Such a configuration works fine for the DS4 or DualSense as those controllers only include one touchpad (CPAD). It complicates matters when a device has two sticks and two touchpads like the Steam Deck.

mapper.py uses one workaround to use RSTICK as the mapping id in one portion of code. However, later in mapper.input, the conflict will happen. Some extra code will have to be changed. Also, I need to double check what SC Controller uses in the profiles for the Right Stick id.

bell07 commented 10 months ago

Confirm the "ugly fix" does solve my issue. Thank you!