RPCS3 / rpcs3

PlayStation 3 emulator and debugger
https://rpcs3.net/
GNU General Public License v2.0
15.49k stars 1.92k forks source link

[Linux] Controller support #2678

Closed hcorion closed 7 years ago

hcorion commented 7 years ago

There is controller support on windows, but not on linux.

This is just an issue for users to track and developers to register interest.

refi64 commented 7 years ago

Could I take a shot at this? Been wanting to contribute something, but everything else is waaay over my head...

deepbluev7 commented 7 years ago

@kirbyfan64 I was also interested in doing that, but by all means, have a go at it. I don't know of anyone working on that, but even if someone is working on it, it won't hurt, right?

CoalaJoe commented 7 years ago

Any progress?

deepbluev7 commented 7 years ago

https://github.com/kirbyfan64/rpcs3/commits/linux-joy -> kirbyfan64 is working on it

refi64 commented 7 years ago

Yeah, my graphics driver farted on me and I've been trying to fix it. Sorry...

deepbluev7 commented 7 years ago

Don't worry, everybody's got enough time to wait for you to finish. Although I would be interested in why you chose the joystick API over evdev?

hcorion commented 7 years ago

@kirbyfan64 I would also like to know why, the gamepad API is outdated, and I'd much rather the evdev.

Linux has 2 different input systems for Joysticks. The original 'Joystick' interface and the newer 'evdev' based one.

--https://wiki.archlinux.org/index.php/Gamepad

Also see:

https://meghprkh.github.io/blog/2016/06/03/Handling-joysticks-and-gamepads-in-linux/ It seems to be a pretty good guide on using evdev.

refi64 commented 7 years ago

@MonokelPinguin @hcorion FWIW the reasoning was that IME most command-line tools for joysticks use the /dev/js* API, and I figured the consistency would be helpful. Also, it didn't seem like there would really be much gain from using evdev (though, based on your comments, I'm probably wrong!).

That being said, I'll do evdev instead if you guys prefer it.

hcorion commented 7 years ago

We can do a sort-of poll. Anyone preferring evdev, upvote the above comment with a Hooray emoji 🎉. Anyone preferring the joystick api, upvote the above comment with a heart emoji ❤️.

deepbluev7 commented 7 years ago

While I prefer evdev, because it allows to get much more information about the controller, it is also much more complex to use. Quick unfair comparison

Joystick also maps all axes to the same range, while you have to query the range on evdev. Buttons and axes also aren't exported in a contiguous range. Also you have to check if an event device is a controller on evdev, as all input devices appear as an evdev device. You also have to handle more synchronisation events with evdev and there is no good tool to calibrate controllers for evdev afaik.

On the other hand are axes values exported with the controller native bit range, which may be especially interesting for an emulator. Also force feedback can only be used with evdev.

And joystick isn't really legacy, I think its API is provided on top of evdev.

Still I would prefer evdev, even if it was for force feedback alone.

refi64 commented 7 years ago

Alas, evdev seems to have won this battle. ;)

logos88 commented 7 years ago

2733 DS4 support and XInput rumble

logos88 commented 7 years ago

Has been any progress in this?

kd-11 commented 7 years ago

Seems to have stalled since last commits are a month old. @kirbyfan64 Any plans for the evdev switch?

refi64 commented 7 years ago

Well, yeah, there are plans, but my motherboard is burned ATM, and my efforts to use RPCS3 in a VM on someone else's laptop have not been successful, to say the least... :/

adomo88 commented 7 years ago

@kirbyfan64 will you work on this anytime soon?

refi64 commented 7 years ago

I was able to start work on it again (my dad's letting me use his laptop), and my goal is to have a working version by some time before Sunday (ideally tomorrow).

mirh commented 7 years ago

By the way, I'm not sure my CC got to you, and whether you are into kernel stuff, but we are kind of in-need of a tinkering with evdev itself in the first place.

refi64 commented 7 years ago

Side note: I'm pretty much done with this, but after rebasing onto master and the new Qt GUI, now evdev is dropping all the events. Once I figure out what the heck went wrong, I'll submit the PR.

hcorion commented 7 years ago

Closed by dbd6953 Thanks @kirbyfan64 !

gasinvein commented 7 years ago

Is evdev support ready? Controller selector in keyboard configuration menu is inactive. screenshot_20170727_171559

twdarkeh commented 7 years ago

You cannot currently configure controllers, only the keyboard.

refi64 commented 7 years ago

@gasinvein https://gist.github.com/kirbyfan64/72f5d7223fcba2e24c4286aea9e4ccc1

anoadragon453 commented 7 years ago

On Arch Linux (kernel 4.12.3-1-ARCH) with a SIXAXIS PS3 controller here I can't get RPCS3 to recognize any input.

evtest:

❯ sudo evtest /dev/input/by-id/usb-Sony_PLAYSTATION_R_3_Controller-event-joystick | grep KEY
Event type 1 (EV_KEY)
Event: time 1501815527.164530, type 1 (EV_KEY), code 311 (BTN_TR), value 1
Event: time 1501815527.274516, type 1 (EV_KEY), code 311 (BTN_TR), value 0
Event: time 1501815527.664518, type 1 (EV_KEY), code 311 (BTN_TR), value 1
Event: time 1501815527.824517, type 1 (EV_KEY), code 311 (BTN_TR), value 0
Event: time 1501815528.024504, type 1 (EV_KEY), code 311 (BTN_TR), value 1
Event: time 1501815528.144513, type 1 (EV_KEY), code 311 (BTN_TR), value 0
Event: time 1501815528.284511, type 1 (EV_KEY), code 311 (BTN_TR), value 1
Event: time 1501815528.424508, type 1 (EV_KEY), code 311 (BTN_TR), value 0
Event: time 1501815528.654505, type 1 (EV_KEY), code 313 (BTN_TR2), value 1
Event: time 1501815529.314492, type 1 (EV_KEY), code 313 (BTN_TR2), value 0
Event: time 1501815529.354490, type 1 (EV_KEY), code 313 (BTN_TR2), value 1
Event: time 1501815529.534490, type 1 (EV_KEY), code 313 (BTN_TR2), value 0
Event: time 1501815529.574490, type 1 (EV_KEY), code 313 (BTN_TR2), value 1
Event: time 1501815529.734487, type 1 (EV_KEY), code 313 (BTN_TR2), value 0
Event: time 1501815534.444411, type 1 (EV_KEY), code 312 (BTN_TL2), value 1
Event: time 1501815534.584395, type 1 (EV_KEY), code 312 (BTN_TL2), value 0
Event: time 1501815534.954401, type 1 (EV_KEY), code 314 (BTN_SELECT), value 1
Event: time 1501815535.124397, type 1 (EV_KEY), code 314 (BTN_SELECT), value 0
Event: time 1501815535.264396, type 1 (EV_KEY), code 314 (BTN_SELECT), value 1
Event: time 1501815535.384394, type 1 (EV_KEY), code 314 (BTN_SELECT), value 0
Event: time 1501815535.694378, type 1 (EV_KEY), code 315 (BTN_START), value 1
Event: time 1501815535.944383, type 1 (EV_KEY), code 315 (BTN_START), value 0
Event: time 1501815536.054384, type 1 (EV_KEY), code 315 (BTN_START), value 1
Event: time 1501815536.254380, type 1 (EV_KEY), code 315 (BTN_START), value 0
Event: time 1501815604.464264, type 1 (EV_KEY), code 304 (BTN_SOUTH), value 1
Event: time 1501815604.674262, type 1 (EV_KEY), code 304 (BTN_SOUTH), value 0
Event: time 1501815605.455248, type 1 (EV_KEY), code 307 (BTN_NORTH), value 1
Event: time 1501815605.595236, type 1 (EV_KEY), code 307 (BTN_NORTH), value 0
Event: time 1501815605.775244, type 1 (EV_KEY), code 305 (BTN_EAST), value 1
Event: time 1501815605.895242, type 1 (EV_KEY), code 305 (BTN_EAST), value 0
Event: time 1501815606.015241, type 1 (EV_KEY), code 308 (BTN_WEST), value 1
Event: time 1501815606.135236, type 1 (EV_KEY), code 308 (BTN_WEST), value 0
...

Config file (/home/user/.config/rpcs3/config_linuxjoystick.yml):

  0 Axis scaling: false 
  1 
  2 Select: 314 
  3 Start: 315  
  4                     
  5 Triangle: 307     
  6 Circle: 305               
  7 Cross: 304     
  8 Square: 308 
  9     
 10 Up: 544     
 11 Down: 545   
 12 Left: 546    
 13 Right: 547

(line numbers are part of the text editor, not literally in the file).

RPCS3 seems to not pick up on any of the buttons I press either in games or using the GamePad test tool. Is there something else I should be trying?

Running RPCS3 v0.0.3-5586-02845f546.

mirh commented 7 years ago

4.12 changed quite a lot of things in DS3 handling. And they are still working on it.

gasinvein commented 7 years ago

@kirbyfan64, I'm missing this config file. Should I create it manually? If so, can you please provide a full example? I am using Steam Controller with sc-controller, if that matters.

refi64 commented 7 years ago

@gasinevin I believe it should work out-of-the-box if you set it to emulate an XBox 360 controller.

@anoadragon453 Are you sure you selected the Evdev pad handler in the drop-down menu? What does the log file look like.

anoadragon453 commented 7 years ago

@kirbyfan64 Oooh, didn't know that was a thing. Yep, works now.

Might want to stick that in the gist for future noobs :)

hcorion commented 7 years ago

@gasinvein I haven't been able to get the steam controller to work yet.

anoadragon453 commented 7 years ago

Getting some weird issues now, for instance this is my config file:

Axis scaling: false

Select: 314
Start: 315

Triangle: 307
Circle: 305
Cross: 304
Square: 308

Up: 544
Down: 545
Left: 546
Right: 547

When pressing SELECT with evtest I get the following:

Event: time 1501889283.385347, type 1 (EV_KEY), code 314 (BTN_SELECT), value 1
Event: time 1501889283.525335, type 1 (EV_KEY), code 314 (BTN_SELECT), value 0
Event: time 1501889284.655327, type 1 (EV_KEY), code 314 (BTN_SELECT), value 1
Event: time 1501889284.845298, type 1 (EV_KEY), code 314 (BTN_SELECT), value 0
Event: time 1501889285.045337, type 1 (EV_KEY), code 314 (BTN_SELECT), value 1
Event: time 1501889285.185306, type 1 (EV_KEY), code 314 (BTN_SELECT), value 0
Event: time 1501889285.455306, type 1 (EV_KEY), code 314 (BTN_SELECT), value 1
Event: time 1501889285.595299, type 1 (EV_KEY), code 314 (BTN_SELECT), value 0

However RPCS3 says it's unmapped?

E Joystick #0 sent button event for unmapped button 314 x8

Is there something I'm missing here?

refi64 commented 7 years ago

Sorry, that's bad directions on my part. If you scroll up in the log, you'll see some stuff like:

Joystick #0 has button X as Y

So if you want the button X, you put Y in the file.

e.g. if it says something like:

Joystick #0 has button 314 as 2

you would put 2 in the config file.

anoadragon453 commented 7 years ago

Ok! I get it now, and it's working, thanks!

Instructions are pretty difficult though, should definitely get GUI support going for this :)

Edit: Yeah these actually match directly to what's reported by KDE's joystick settings except that you have to subtract 1 before putting it in the config file. Sounds like that's something on your end?

anoadragon453 commented 7 years ago

Last problem is L3 and R3 seem to trigger R2 and L2 respectively. Using the Z axis triggers: false option did not help.

Full config:

Axis scaling: false

Select: 8
Start: 9

Triangle: 2
Circle: 1
Cross: 0
Square: 3

Up: 13
Down: 14
Left: 15
Right: 16

L3: 11
R3: 12
refi64 commented 7 years ago

The default config already has L2 and R2 bound to 11 and 12, so you need to change those too.

gadzook commented 7 years ago

Steam controller with sc-controller does not seem to work at all on the latest appimage. There are no messages in the log regarding it. i've selected evdev in the controller handling menu, and used evtest to make sure my buttons are all working. I've changed the config file & followed every step in this thread, but none of the buttons work at all.

refi64 commented 7 years ago

@gadzook It's probably because of https://github.com/kozec/sc-controller/issues/227. sc-controller doesn't seem to support evdev well? Regardless, you'll probably have to use something else, like xboxdrv.

gasinvein commented 7 years ago

@kirbyfan64 I also tried xboxdrv on top of sc-controller's device with no success.

kozec commented 7 years ago

It's probably because of kozec/sc-controller#227. sc-controller doesn't seem to support evdev well? Regardless, you'll probably have to use something else, like xboxdrv.

Hi there. I believe problem at hand is caused by this rather unorthodox approach to device enumeration and this innovative way of determining if device is joystick :)

By doing so, not only you are relying on evdev's "persistent input names" option, that's, albeit default on same distros, still very much optional, but you are also ignoring virtual devices, that are not using "bustype-serialnumber-something-event-joystick" naming scheme for obvious reason.

That excludes not only virtual gamepad created by SC-Controller, but should also at least xboxdrv, ds4drv and gamepad emulation in Steam.

hcorion commented 7 years ago

I've got a fix for RPCS3 properly detecting evdev controllers locally, I'll PR it soon, do you mind if I tag you to review it @kozec ?

refi64 commented 7 years ago

Well, in my defense, I'm not alone here. ;)

Now that I look into this again, though, it seems like the proper way to do this would be to use libudev instead, which would also avoid the try-to-open loop.

hcorion commented 7 years ago

And also this guide: https://meghprkh.github.io/blog/2016/06/03/Handling-joysticks-and-gamepads-in-linux/ uses /dev/input/by-path, so it's not just us.