Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USB controller devices don't hotplug #70

Open
mdeguzis opened this issue Jul 25, 2014 · 16 comments
Open

USB controller devices don't hotplug #70

mdeguzis opened this issue Jul 25, 2014 · 16 comments

Comments

@mdeguzis
Copy link
Owner

@beaumanvienna , JC, at some point I want to see if we can implement similar hotplugging like the PS3 bluetooth controller. Should be easy enough to scan /proc for ps3/x360 usb devices and restart rescan/related services.

@mdeguzis mdeguzis changed the title USB device don't hotplug USB controller devices don't hotplug Jul 25, 2014
@beaumanvienna
Copy link
Contributor

Yes, sure, lsusb | grep PlayStation will also work, I did a quick check.

Our current file
https://github.com/ProfessorKaos64/RetroRig/blob/beta/XBMC-cfgs/extra/gp_autodetect_xbmc.sh

would look something like this: http://slexy.org/view/s21lD6XxSq

@mdeguzis
Copy link
Owner Author

Ok I can make those changes tonight. I'm confident enough with that code there I can do that and fell like i'm smart :) hahaha. I will write in the code for x360 usb. I have to make a change or two to prevent the "double profile" occuring with PS3/USB, since the sony kernal module interferes a bit on reconnection. I'm sure I can fix that.

@mdeguzis
Copy link
Owner Author

I got this working for the "wireless" xbox 360 device that uses a usb/wireless hub. If I disconnect the hub after shutting for the x360 controller, I can now reconnect the hub, power on the controller and continue on.

However, true wired devices for Sony / Xbox controllers, I am still having a lot of trouble with. The least of these is the sony_hid module for wired PS3 controllers. If I reconnect the controller, the hid_sony module takes over, and xboxdrv just sits there in jstest. Removing the sony module, and restart xboxdrv doesn't work among other things. I am not sure how on bootup, xboxdrv loads without issue, and I hit the PS buttin in RetroRig, and it's fine. However, in the OS, I can't seem to replicate this bootup action set. I likely need a helping hand to get that one working.

As for Xbox 360 wired, it's a similar issue, but instead of the sony module, its the xpad module (although I load xpad just to get the USB connection). In the end, what I really need, is a module, or the ability to load the USB connection cleanly, so that xboxdrv can then take over. Again, this process works fine on bootup of Ubuntu.

Current work:
http://paste.ubuntu.com/7870362/

@beaumanvienna
Copy link
Contributor

Looks very good! Did you try to blacklist the distracting kernel modules?

@beaumanvienna
Copy link
Contributor

But wait, on a second glance I'm not so sure if this works. You should either determine the controller type from the RetroRig settings or check for all of them in parallel with different actual/old variables. Your script checks during start-up for the type, that's when possibly no controller is online.

@beaumanvienna
Copy link
Contributor

Yeah, this version looks better: http://slexy.org/view/s2RzZftJtV

@mdeguzis
Copy link
Owner Author

You should either determine the controller type from the RetroRig settings

I like this option. I could actively re-copy down gp_autodetect_xbmc.sh and do a sed replace of the "controller type" rather than check for it on startup. For now, I am just trying to get it all working. At least I got the wireless x360 one working (using the wireless hub). Just need ps3/x360 wired. I think this is low to medium priority, since almost all users will plug in controllers at bootup, but it would be useful for when folks add more controllers for additional players.

@beaumanvienna
Copy link
Contributor

I could actively re-copy down gp_autodetect_xbmc.sh and do a sed replace of the "controller type" rather than check for it on startup.

Good idea!

@mdeguzis
Copy link
Owner Author

For now, I have renamed the "testing" versiong of gp_autodetect_xbmc.sh to gp_autodetect_xbmc.sh.testing. I have reverted xboxdrv to what it was in the master branch too (which effectively had some code to accurately kill all xboxdrv processes". I got the PS3 USB Controller to "hot plug" outside RetroRig with:

sudo /usr/sbin/service xboxdrv stop
sudo modprobe -r hid_sony
sudo /usr/sbin/service xboxdrv restart

But translating that to a looped script function is harder than I thought. What entails a manual "hotplug" is this.

  1. computer boots up controller is connected and usable with PS button press using xboxdrv
  2. Unplug controller
  3. Plug in controller
  4. hid_sony kernel module takes over, controller is usable by pressing PS button
  5. sudo modprobe -r hid_sony to unload the son module
  6. Ensure no xboxdrv processes exist, kill all of them if need be
  7. sudo service xboxdrv restart

Maybe I shouldn't worry so much about USB hot plugging, but it would be nice for the future. I will pretty intend on holding this work until 0.9.5 is out and has passed. It would be nice for 1.0, but will take some work to get it properly working. The problem really lies I believe in properly handling all the stages of disconnect/PS button press/unloading/reloading modules. Complicated haha.

@beaumanvienna
Copy link
Contributor

Yes, indeed, complicated. You are really tenacious for this issue, I like that!

@mdeguzis
Copy link
Owner Author

That's how I work on things I am really interested in, especially if it's Linux to begin with hahah. Now hopefully someone sees this work ethic, determination, and love for that area someday, and I get the job I've always wanted. I have incredible drive for attacking issues that make my mind "wake up" and make me happy. Maybe with the next release we both can attack this issue. For the most part, users shouldn't have a huge issue with rebooting if they connect USB controllers I think, but it would be nice to fix this for them at some point. For now, it's a line item in future development features on the wiki.

@mdeguzis
Copy link
Owner Author

mdeguzis commented Aug 1, 2014

I found out why PS3 USB doesn't hotplug right. This is the right way to go about it. Check out the current:

/etc/default/xboxdrv
/etc/init.d/xboxdrv

What isn't happening is the kernel driver being properly detached. If you run xboxdrv --detach-kernel-driver on the command line after unplugging and plugging back in the controller (which the process of doing so, you will see the sony kernel module take over) it works just fine, but not using the xboxdrv service.

You can reference this issue I put in under the retropie project, since that is what I am modeling this after

@beaumanvienna
Copy link
Contributor

I made hotplug support for PS3 / USB basically work tonight, see here: https://github.com/beaumanvienna/RetroRig/blob/beta/XBMC-cfgs/extra/gp_autodetect_xbmc.sh

Two oddities I haven't figured out though. First thing is, it only works for the second time after being plugged in. For all further connects or if directly booted with a connected controller hotplugging is fine. And secondly, sometimes after unplugging the controller it connects via BT...

@beaumanvienna
Copy link
Contributor

Works now 100%. To be observed.

@mdeguzis
Copy link
Owner Author

mdeguzis commented Nov 1, 2014

Wooo!!! Thank you for your help JC

On Sat, Nov 1, 2014 at 6:15 AM, Jens-Christian [email protected]
wrote:

Works now 100%. To be observed.


Reply to this email directly or view it on GitHub
#70 (comment)
.

Michael DeGuzis
Email: [email protected]
Website: http://www.libregeek.org
Linked In Resume/Profile
http://www.linkedin.com/profile/view?id=124915388&trk=nav_responsive_tab_profile

@mdeguzis
Copy link
Owner Author

mdeguzis commented Nov 3, 2014

I will close this once I analyze the Xbox 360 controller side of things.

@mdeguzis mdeguzis modified the milestone: Version 1.0 Dec 1, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants