Fix Xbox 360 controller support

  Thread Rating:
  • 4 Votes - 4.75 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
shiretoko212 Offline
Team-Kodi Member
Posts: 156
Joined: Jul 2012
Reputation: 1
Post: #76
Dondi: Chatpad support would be excellent. I think it would act like an actual keyboard though (if you have proper working modded drivers), so neither a new device name nor keymap adjustment would be necessary to support it. Thanks for sharing though. That being said, you can use the onscreen keyboard via a regular xbox 360 controller with relative ease. Don't forget to try all those xbox 360 controllers with the keymap in this thread to see if you can unearth some new device names for us.
(This post was last modified: 2012-12-04 01:13 by shiretoko212.)
find quote
Dondi Offline
Member
Posts: 94
Joined: Dec 2012
Reputation: 0
Post: #77
I will be noodling soon.... setting up my RAID and NAS stuff this week (need a refresher on some XBMC stuff ATM).

I only brought up the ChatPad thing because it looks like the thread about it on here died... I think it would be perfect!!

Not sure that it works as a keyboard as far as Win OS et al are concerned, which is probably why there is a contest to get this thing to work with any HTPC (thats the gist of what I got from the contest thread and the drivers for ChatPad threads)

Thanks!!

Alienware X-51: 3.4GHz, 16GB RAM, 250GB SSD C drive, 12T RAID, Win 8, XBMC 12.1, Nox
MacPro 1,1, 2 x 2.66GHz Dual-Core Xeon, 12GB RAM, 500GB C drive, 1.5T 2nd HD, OS X 10.6.8, XBMC 12.1, Nox
Precision 7500: 2 x 2GHz, 30GB RAM, 500GB C drive, 2TB 2nd HD, Win 8, XBMC 12.1, Confluence
Arcade Cabinet
(This post was last modified: 2012-12-04 01:16 by Dondi.)
find quote
shiretoko212 Offline
Team-Kodi Member
Posts: 156
Joined: Jul 2012
Reputation: 1
Post: #78
(2012-12-04 01:14)Dondi Wrote:  Not sure that it works as a keyboard as far as Win OS et al are concerned, which is probably why there is a contest to get this thing to work with any HTPC (thats the gist of what I got from the contest thread and the drivers for ChatPad threads)
I know it isn't supported natively. Whichever driver they create to support the chatpad will have it behave like a keyboard to the system, rather than as a secondary joystick device that needs a keymap written for xbmc. That's what I meant.
find quote
maboivin Offline
Junior Member
Posts: 3
Joined: Dec 2012
Reputation: 0
Post: #79
Following MastaofDesasta's post about linux and xboxdrv, if I start xboxdrv without any config, xbmc lists my xbox 360 wireless controller as
04:46:06 T:3035742944 INFO: opened device 'Xbox Gamepad (userspace driver)' (file name /dev/input/event0), m_bSkipNonKeyEvents 0

By the way, my controller is listed as Microsoft Xbox 360 Wireless Controller (PC) if I don't change the name and tried to add it as an altname without any effect.

But if I specify a config like the following:
[xboxdrv]
ui-clear=true
extra-devices=false
extra-events=false
deadzone=4000
device-name="Xbox 360 Wireless Receiver"
(...)

I can change the name to match the ones in the /xbmc/system/keymaps/joystick.Microsoft.Xbox.360.Controller.xml and xbmc seems to recognize it correctly in the log:
04:53:28 T:3036242656 INFO: Found input device /dev/input/event0
04:53:28 T:3036242656 INFO: opened device 'Xbox 360 Wireless Receiver' (file name /dev/input/event0), m_bSkipNonKeyEvents 0

The issue is that it doesn't work at all with xbmc, but I receive all the events in the ssh sessions from the controller... Is it supposed to work out of the box? Do I need to povide such xboxdrv config?

Thanks.
(This post was last modified: 2012-12-04 07:07 by maboivin.)
find quote
shiretoko212 Offline
Team-Kodi Member
Posts: 156
Joined: Jul 2012
Reputation: 1
Post: #80
maboivin: xboxdrv does send input to xbmc in my testing. Did you restart xbmc after starting xboxdrv?

I installed Frodo beta 1 from the unstable ppa in a new install of Xubuntu 12.10 x64. The default device name of the built in 360 driver on Linux is called "Microsoft X-Box 360 pad", and the xboxdrv userspace driver is called "Xbox Gamepad (userspace driver)".

XBMC needs a second redesigned keymap file for these two device names (and others as they are discovered), representing fundamentally different numbering and axes. There's no other way to support these drivers on *nix. And yes, in Linux, the Guide button is mapped to a button number, and using the unmodified keymap in this thread, any use of the triggers destroys the whole session, causing future inputs to fail or behave poorly. To have the buttons behave the same way crossplatform, *nix device names need a separate keymap (possible a 3rd for OSX, but I don't have that system to test; so chime in OSX users). If the triggers' buggy behavior can't be fixed by a keymap, it will require either code change or being excluded from the *nix keymap entirely.

If we discover that some device names appear on both Windows and *nix, OS detection will be required to determine which keymap to use. Or a different keymap bundled with each OS version of XBMC would solve that problem.

I'm reverting the parent post back to v1.95, as my keymap is now known to only be capable of supporting Windows accurately. A separate *nix keymap is required.
(This post was last modified: 2012-12-04 13:26 by shiretoko212.)
find quote
natethomas Offline
Team Kodi Community Manager
Posts: 3,737
Joined: Apr 2008
Reputation: 63
Location: Kansas
Post: #81
Now working on checking OSX. I'm using the driver recommended around town and found here:

http://tattiebogle.net/index.php/Project...iver#toc11

Update:
The good news is that the buttons do show up using the Joystick and Gamepad Tester for OSX found here:
http://alphaomega.software.free.fr/joyst...ester.html

The keys displayed there are:
http://pastebin.com/9qHPdZuV

Which of course are marginally different than our keymap. Particularly around the stick button/start+back+guide area. At least ABXY are the same.

The bad news is that the controller doesn't appear to show up at all in the debug log. The only attached devices are:
06:24:01 T:140735106126208 DEBUG: USB Device Attach:IR Receiver, -49217536
06:24:01 T:140735106126208 DEBUG: USB Device Attach:Apple Internal Keyboard / Trackpad, -99483648

I'm attaching my entire debug log, in case I'm looking in the wrong place.
http://pastebin.com/6JD2hWsW

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.

[Image: badge.gif]
(This post was last modified: 2012-12-04 14:48 by natethomas.)
find quote
maboivin Offline
Junior Member
Posts: 3
Joined: Dec 2012
Reputation: 0
Post: #82
shiretoko212: Yes I restarted xbmc after loading the xboxdrv driver. I was able to have a mouse with the right joystick but none of the buttons were working. Will do some more testing tonight.
find quote
shiretoko212 Offline
Team-Kodi Member
Posts: 156
Joined: Jul 2012
Reputation: 1
Post: #83
maboivin: What distro and release are you using? In Ubuntu-based distros, at least in my testing, xboxdrv isn't even required for the xbox 360 controller to work, unless you want advanced functionality.

natethomas: Perhaps contacting the developer of that driver might help, if he's receptive. Looks like he updated the driver 2 months ago, so he's still active. It would be nice to add support for OSX, even though it isn't a built in official driver. Fixing support for Linux is probably higher priority though, since it has built in drivers for 360 controllers (at least in Ubuntu), and XBMC distributes its own version of it.



Jackpot! http://lxr.free-electrons.com/source/dri...ick/xpad.c See lines 120-170 for every xpad device name possible on Linux. Some of the names do overlap with Windows, so the XBMC linux version might need its own specific keymap version. I've updated the list in the parent post with all applicable 360 device names from that list, excluding dance mats and guitars. Since they classify whether it's xbox or 360, the xbox 1 keymap should probably gain some altnames from that list. Now if we could only see the source code for Microsoft's driver for all the device names they have... I wonder if that's asking for too much.
(This post was last modified: 2012-12-04 16:19 by shiretoko212.)
find quote
natethomas Offline
Team Kodi Community Manager
Posts: 3,737
Joined: Apr 2008
Reputation: 63
Location: Kansas
Post: #84
That's a lot of names. I hate to suggest it, but I'm beginning to wonder if we might want to take a deeper look altogether at controller support for Gotham. Dozens of keymap altnames feels awkward. Perhaps it might be better to try to emulate the USB-CEC adapter method, where an application intelligently figures out what controller is connected and adjusts the settings accordingly.

Just a thought for the future.

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.

[Image: badge.gif]
find quote
shiretoko212 Offline
Team-Kodi Member
Posts: 156
Joined: Jul 2012
Reputation: 1
Post: #85
I went through the list, and there are only 8 device names for 360 controllers in xpad (a 9th for a catch all unknown category that 360 controllers sometimes show up as and a 10th for xboxdrv). The size of the list is inflated by dancepads and guitar hero devices that no one would use for controlling xbmc anyway. As far as expanding xbox 1 altname support, I'm sure it isn't more than a dozen more names. I do agree that a better system would be nice in the future, but I think we can make this happen in Frodo using the altname method, right? (If they make a better system in the future, they can always clean up the keymap modifications we make.) Now that we know all 10 linux device names, all we have to do is make a keymap that maps the same way as in Windows for consistency, and since it will be a separate keymap file per platform, the list won't look so long.
(This post was last modified: 2012-12-04 16:50 by shiretoko212.)
find quote
natethomas Offline
Team Kodi Community Manager
Posts: 3,737
Joined: Apr 2008
Reputation: 63
Location: Kansas
Post: #86
Seems right, though I'm not sure how to narrow keymap by platform in the case of name duplication.

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.

[Image: badge.gif]
(This post was last modified: 2012-12-04 18:25 by natethomas.)
find quote
shiretoko212 Offline
Team-Kodi Member
Posts: 156
Joined: Jul 2012
Reputation: 1
Post: #87
natethomas: It may require a code and/or packaging change. However, of the known Windows device names, only Xbox 360 Wireless Receiver overlaps, and I don't know for sure that Xbox 360 Wireless Receiver is a Windows device name.

OK. I spent a few hours working with the keymaps on Xubuntu via both xpad and xboxdrv. xboxdrv is going to require its own keymap, as a few axes are different from xpad. That's okay, because it has a simple unique device name. A few of the button IDs are different for the thumbsticks and back/guide buttons compared to the Windows keymap (especially considering Windows can't use the guide button on the keymap), but both xpad and xboxdrv share everything other than a few axes.

In both xboxdrv and xpad, I can't find a button number for the Start button. I've tried mapping actions to button 0 through 42 and to the tag start, but the start button still does nothing. However, I can see from the xboxdrv output that start does respond to being pressed: "X1: 1086 Y1: -1103 X2: -3310 Y2: -1653 du:0 dd:0 dl:0 dr:0 back:0 guide:0 start:1 TL:0 TR:0 A:0 B:0 X:0 Y:0 LB:0 RB:0 LT: 0 RT: 0" I just can't find out what mapping is being triggered in xbmc when it's pressed. Not the end of the world but needs to be fixed somehow for crossplatform consistency. Button 8 maps to nothing on the controller, which is very strange. That should be where start is mapped, but it does nothing.

Last but not least, the following issue is critical, and until this is fixed, I consider Linux support for 360 controllers to be broken. One thing both xpad and xboxdrv have in common is broken triggers. Even if the triggers aren't mapped, pressing them at all even once causes all axis actions (thumbsticks) to malfunction for the duration of the xbmc session. This doesn't make sense, since xboxdrv reports the pressing of each trigger as a number between 0 and 255, LT and RT respectively. I can make one of them kind of function via axis 6 value -1/+1, but not perfectly (breaks other axes), and it still doesn't fix the malfunctions of the other axes. Something about the way xpad and xboxdrv report xbox 360 trigger actions sends xbmc on the fritz. It might be something requiring a fix on the code level.

Anyhow, here's the beta of each for people to play with on Linux to see if they can fix it. I fixed all the sections in v0.2. Since I populated the device list from the xpad source code (lines 120-170), there shouldn't be any missing 360 device names, at least in the case of Linux.

Edit: See parent post for the keymaps.
(This post was last modified: 2012-12-05 18:49 by shiretoko212.)
find quote
natethomas Offline
Team Kodi Community Manager
Posts: 3,737
Joined: Apr 2008
Reputation: 63
Location: Kansas
Post: #88
Nice work on that Shiretoko. I'm going to try to get the XBMCbuntu and OpenELEC guys to take a look at this thread to see if/what 360 driver is packaged in.

I've emailed the OSX driver writer. No response yet, but I'd probably give him at least a day to respond.

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.

[Image: badge.gif]
find quote
haywire Offline
Junior Member
Posts: 13
Joined: Sep 2010
Reputation: 0
Post: #89
Thanks for your work Shiretoko

Out of curiosity what does your xbmc.xboxdrv file look like?
find quote
shiretoko212 Offline
Team-Kodi Member
Posts: 156
Joined: Jul 2012
Reputation: 1
Post: #90
haywire: I left xboxdrv completely unaltered and default, latest version 0.8.4, installed from the Xubuntu 12.10 x64 repos. If you're looking for the keymap, see the parent post.
(This post was last modified: 2012-12-05 18:50 by shiretoko212.)
find quote
Post Reply