Xpad and LIRC
Posted by Dave Eddy on Jan 31 2011LIRC and xpad with XBMC
When I first started using XBMC on Ubuntu, I read that it is impossible to use LIRC and xpad at the same time, and that in order for the IR receiver to work with LIRC you need to blacklist the xpad module. This is true from a stock install of Ubuntu, but upon examining the source of the modules, I found that they could be edited in such a way to allow both to be used at the same time without stepping on each other.
The problem lies in the way that the two modules look to see if something plugged in is an Xbox accessory. They both use the vendor ID’s, but they both have a default case of accepting the id 0xFFFF which is sometimes used by third-party chinese accessories. Because I knew what IR receiver I was going to be using, I could edit the LIRC module to ignore the vendor ID 0xFFFF, so it could be picked up by xpad. This would allow the LIRC module to only pick up the stock Xbox DVD dongle, and ignore any other Xbox accessory. Then xpad would be able to pick up any accessory that wasn’t matched by LIRC.
Editing lirc_atiusb.c
This is the source code of the kernel module used to scan USB devices to see if they are an IR receiver. I followed the (somewhat outdated) guide here on how to modify the source code, and replace the module with the new source https://help.ubuntu.com/community/LIRC.
During this process i used Ubuntu 10.10, and the current version installed on
my system was 0.8.7~pre3
.
To start off I first installed LIRC with the following command:
sudo aptitude install lirc lirc-modules-source
This will install LIRC with all of the necessary kernel modules needed to allow for IR receivers connected via USB. The next step was to modify the USB kernel module for LIRC to ignore the vendor 0xFFFF.
cd /usr/src/lirc-0.8.7~pre3/drivers/lirc_atiusb
sudo vim lirc_atiusb.c
The modification to this file is very simple, we find the line that looks like this and we add two slashes to the line to comment it out. For me this was found on line 180.
Now I just ran the commands that I found on the guide above to recompile the module. First you remove the current modules by running this command:
sudo dkms remove -m lirc -v 0.8.7~pre3 --all
This might take some time, but when it is finished it is time to compile the new modules and put them into place, you can do that with these commands.
sudo dkms add -m lirc -v 0.8.7~pre3
sudo dkms -m lirc -v 0.8.7~pre3 build
sudo dkms -m lirc -v 0.8.7~pre3 install
Assuming there are no errors here, the next step is to simply remove the current running module and reload it with modprobe.
sudo rmmod lirc_atiusb
sudo depmod -a
sudo modprobe lirc_atiusb
sudo service lirc restart
LIRC playing nice
Now that the kernel module has been edited, LIRC will no longer put a strangle hold onto controllers that are not recognized, or present themselves as 0xFFFF. I’m happily using my Xbox IR Receiver via LIRC, and 4 controllers (including dance mats) via xpad and there is no problems at all!
Force xpad dpad_to_buttons
This is another kernel module that I edited to force the xpad module to treat
the dpad as buttons rather than as axises. This allows the xpad controllers to
be used to control XBMC. This accomplishes effectively what using something
like xboxdrv
does, but this happens directly in the kernel and not in user
space.
Guide for this coming soon..