rpcs3 icon indicating copy to clipboard operation
rpcs3 copied to clipboard

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

Open ElTioRata opened this issue 1 year ago • 14 comments

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.

ElTioRata avatar May 18 '23 16:05 ElTioRata

yeah sure ! i am stuck on sly cooper too

AIGLE25 avatar Sep 11 '23 15:09 AIGLE25

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

KonstantinosK77 avatar Feb 06 '24 19:02 KonstantinosK77

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

madman-asunder avatar Mar 18 '24 23:03 madman-asunder

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

Valtekken avatar Mar 19 '24 01:03 Valtekken

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 X Axis: how it tilts left(-) or right(+)
  • The Y Axis: how right-side-up(-) or upside-down(+) it is
  • The Z Axis: how it tilts forward(-) or backward(+)
  • The G Axis: how fast it is moving counterclockwise(-) or clockwise(+)

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).

JimScript avatar Mar 21 '24 14:03 JimScript

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.

madman-asunder avatar Mar 25 '24 15:03 madman-asunder

+1

gsergeantGTHB avatar May 26 '24 17:05 gsergeantGTHB

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 avatar Jun 28 '24 03:06 luphoria

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 avatar Jun 28 '24 18:06 luphoria

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 avatar Jun 29 '24 03:06 luphoria

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 avatar Jun 29 '24 04:06 luphoria

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 avatar Jun 29 '24 18:06 luphoria

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.

luphoria avatar Jun 29 '24 21:06 luphoria