RPCS3 / rpcs3

PS3 emulator/debugger
https://rpcs3.net/
GNU General Public License v2.0
15.13k stars 1.89k forks source link

[Feature Request] Rebindable motion input controls to mouse/keyboard/other controllers #13883

Open ElTioRata opened 1 year ago

ElTioRata commented 1 year ago

Quick summary

Bakugan (and other games) requires you to have a PS3 controller with motion input because various game mechanics are tied to it. Unfortunately, at least for the case of Bakugan, the game doesn't provide a "non-motion" controller option, so the game is unplayable on PC controls and standard controllers. A workaround for this issue could be making the motion input fully rebindable, a good example of this feature is Dolphin with its Wiimote.

AIGLE25 commented 12 months ago

yeah sure ! i am stuck on sly cooper too

KonstantinosK77 commented 7 months ago

I thin it's necessary!! A lot of us we have Xinput game controllers and we can't play games with motion control!!

madman-asunder commented 5 months ago

I would like this as well! I wanna play Thieves in Time :)

Valtekken commented 5 months ago

+1 on this, Killzone 2 is unplayable otherwise and my DS3 is borked so I don't even have the option

JimScript commented 5 months ago

I wonder how this could be implemented, Sixaxis seems to actually be determined by 4 values(or at least that's what RPCS3 reads for a Dualsense):

The range of values seem to be centered around 512 with +/- ~112 at rest and the numbers going wildly if you shake the controller. For all those tilting mini-games, you could map the X and Z to a stick, but I'm not sure if emulating the Y axis would be necessary to add. For all those shaking inputs, bouncing the G axis around might be enough to trigger it, but every developer could read "shake" a different way(unless there's a hidden system call that just tells the game a controller is shaking).

madman-asunder commented 5 months ago

Yeah I think the 4 values means you would need to either A target common use cases or B allow a bit of mapping and custom functionality. I think mapping x and y to the stick would serve a vast percentage of use cases.

gsergeantGTHB commented 3 months ago

+1

luphoria commented 2 months ago

I've made a post to the RPCS3 forums regarding this feature: https://forums.rpcs3.net/showthread.php?tid=208083 The forum post still needs to be manually approved.

I'm interested in perhaps tackling this issue but I've never contributed to RPCS3 before.

From my post:

In my searching for answers, I also came across this repo: https://github.com/ZeptoBST/DualShock4-emulator/ -- which appears able to emulate SIXAXIS from xbox and keyboard controller inputs, very much like what I want. I don't know if the tool actually features rebindable keys for this or a joystick option, though, because/and it's Windows-only, and I'm on Linux. If there is some kind of solution for this that's cross-platform and works on generally any gamepad, that would suit my needs. It seems like under the hood there is already SIXAXIS emulation to some degree, because I was able to get gyro working from my Switch Pro controller without any hiccups. This implies that there is likely some way I can plug in other inputs wherever the sdl gyro is being translated to ds3 sixaxis. If it's possible for me to implement this feature myself, I would love to be able to contribute upstream as well. But I don't really know how to get started in the rpcs3 repository.

luphoria commented 2 months ago

https://github.com/RPCS3/rpcs3/blob/71524271e948316d57515422bd0da0159a55d24d/rpcs3/Input/sdl_pad_handler.cpp#L709-L727

It should be pretty simple to take the gyro -> sixaxis approach like this to stick -> sixaxis. Still kind of wandering in my understanding the codebase here, but it shouldn't be too difficult. Should just be math with existing numbers to convert the current stick position to DS3 resolution format for yaw.

luphoria commented 2 months ago

https://github.com/RPCS3/rpcs3/assets/60309933/9494e7f7-e279-4c59-afb6-0a38586f3946

I've got gyro emulation on left stick evdev working! As you can see in the video, it's very jank. I don't know what normal values look like (other than that they are between 0 and 1024) and I'm not a mathematician so I just did a very basic conversion from the joystick range to the gyro range.

I added the following lines after rpcs3/Input/evdev_joystick_handler.cpp:L1221:

pad->m_sensors[0].m_value = Clamp0To1023(512 + (lx - 127.5f) * 4.016f);
pad->m_sensors[1].m_value = Clamp0To1023(512 + (ly - 127.5f) * 4.016f); 

Just looking at it, my equation for what i'm doing is overcomplicated lol. But regardless it's just a successful test. I'm gonna rrefine the conversion so it's smoother. If you are feeling spicy, you could even use the right stick for Z and W values.

If there's interest, I would be happy to try making this an actual feature instead of a hacky thing.

luphoria commented 2 months ago

Not a solution to good equation, but this code makes the input feel pretty natural (at least for the game I'm playing):


    // apply deadzone (is the configured deadzone accessible here?)
    if (abs(lx - 127) < 30)
        lx = 127.5f;
    if (abs(ly - 127) < 30)
        ly = 127.5f;

    pad->m_sensors[0].m_value = Clamp0To1023(512 + (lx - 127.5f));
    pad->m_sensors[1].m_value = Clamp0To1023(399 + (ly - 127.5f)); 
luphoria commented 2 months ago

Moved the logic to rpcs3/Input/pad_thread.cpp after line 538:


        for (u32 i = 0; i < connected_devices; i++)
        {
            const auto& pad = m_pads[i];
            pad->m_sensors[0].m_value = (512 + (pad->m_sticks[0].m_value - 127.5f));
            pad->m_sensors[1].m_value = (399 + (pad->m_sticks[1].m_value - 127.5f) * 2);
        }

This should bind gyro X and Y to the left joystick for all input types.

luphoria commented 2 months ago

Branch with this change: https://github.com/luphoria/rpcs3/tree/joystick-rebind I don't know if I plan on ever making this upstream-ready, but I do intend to flesh out the feature.