In Linux for solving one problem there are always many solutions. It also applies when we want to use a ps3 remote with OpenELEC. There is already an official addon for the ps3 remote but it seems that some users have difficulties to use it, I tried also (and I will try again later) myself this addon but I had no success to “pair” the ps3 remote and began to search for some alternate solution. I also have another big problem with this addon: it needs the input service disabled in bluez, so I can not use my mini bluetooth keyboard with OpenELEC (and no other bluetooth input devices).
Another problem is that this addon does not work with OpenELEC stable 1.0.2 only with the nightly builds because it needs some python libraries. So my goal was to find something that works in stable 1.0.2 and that does not need input service disabled.
Some things written bellow were already posted before by me but it is better to be in one place to be found easily.
TOOLS (not official addons)
mksquashfs addon
For quickly patch OpenELEC’s read-only file system you can use this addon. Also contain two helper scripts : copy_SYSTEM and pack_SYSTEM, the first script will create an editable copy of SYSTEM in system_new directory in /storage, the second will squash this directory to a new SYSTEM file that will be copies to /storage/update for update of course your system.
Please be careful with this, you can easily end up with an unusable system if you make mistakes, you should better backup your original SYSTEM and KERNEL file and also your data from storage directory.
OE package
Generic.i386 and ION.x86_64 addon
bluez-tools addon
A set of command line utilities for bluez on the top of dbus. I patched the source code to solve some issues:
- bt-adapter segfaulting when discovering PS3 remote
- added new option -e --create=<mac> for creating device (ps3 does not pair like standard bluetooth devices, it is added to bluez devices)
- added new option -p --pin=<pin> to set pin value (for used in the future maybe in a gui)
OE package - copy readline to /package/devel/
Generic.i386 and ION.x86_64 addon
evrouter addon
Good old evrouter (event-router), I used it with some cheap chinese remotes with XBMC years ago, it is working also now with OpenELEC, not to much to say, if you want more info go to evrouter’s homepage.
OE package
Generic.i386 and ION.x86_64 addon
Patching SYSTEM
To use bluez in OpenELEC stable 1.0.2 you must make this changes in SYSTEM (remember using copy_SYSTEM script you will have an editable copy of read-only file system in /storage/system_new directory, edit then use pack_SYSTEM and update).
in /etc/init.d/02_make-directorys - add to the end of the file
mkdir –p $HOME/.cache/bluetooth
ln –sf $HOME/.cache/bluetooth /var/lib/bluetooth
edit lib/udev/rules.d/60-persistent-input.rules
third line
SUBSYSTEMS=="bluetooth", GOTO="persistent_input_end"
must be moved after forth line
ENV{ID_INPUT}=="", IMPORT{program}="input_id %p"So after editing the beginning of the file will be
# do not edit this file, it will be overwritten on update
ACTION=="remove", GOTO="persistent_input_end"
SUBSYSTEM!="input", GOTO="persistent_input_end"
ENV{ID_INPUT}=="", IMPORT{program}="input_id %p"
SUBSYSTEMS=="bluetooth", GOTO="persistent_input_end"
SUBSYSTEMS=="usb", ENV{ID_BUS}=="", IMPORT{program}="usb_id --export %p"
In latest nightly builds the single modification is to enable input service in
/etc/bluetooth/main.conf file
Pack your new SYSTEM file and update.
Pairing the remote
Put remote in discovery mode and
find your remote address XX:XX:XX:XX:XX:XX then
bt-device –e XX:XX:XX:XX:XX:XX
then
bt-device --set XX:XX:XX:XX:XX:XX Trusted 1
and finally
bt-input -c XX:XX:XX:XX:XX:XX
alternate method -
here
Now you will have a remote with some keys working
Mapping remote’s keys
I.
eventlircd method
in /lib/udev/rules.d/98-eventlircd.rules add a rule for ps3 remote after bdremoteng rule like this
ATTRS{name}=="bdremoteng", \
ENV{eventlircd_enable}="true", \
ENV{eventlircd_evmap}="bdremoteng.evmap"
ATTRS{name}=="PS3 Remote Controller", \
ENV{eventlircd_enable}="true", \
ENV{eventlircd_evmap}="ps3remote.evmap"add a new evmap file in /etc/ eventlircd.d ps3remote.evmap with this content
BTN_TL = KEY_F1
BTN_TL2 = KEY_F2
BTN_THUMBL = KEY_F3
BTN_TR = KEY_F4
BTN_TR2 = KEY_F5
BTN_THUMBR = KEY_F6
BTN_0 = KEY_F7
BTN_START = KEY_ENTER
Pack your new SYSTEM file and update
Finally add a Lircmap.xml in /storage/.xbmc/userdata with this content
Of course you can use other mapping of your choice
Reboot and try.
II.
evrouter method
install evrouter addon
reboot
place a new file in /lib/udev/rules.d/98-evrouter.rules with this content
# Restart evrouter every time a new input device appears or disappears
ACTION=="add", KERNEL=="event[0-9]*", "SUBSYSTEM=="input", RUN+="/storage/.xbmc/addons/service.input.evrouter/bin/evrouter.restart"
ACTION=="remove", KERNEL=="event[0-9]*", "SUBSYSTEM=="input", RUN+="/storage/.xbmc/addons/service.input.evrouter/bin/evrouter.restart"
(two continuous lines)
Pack your new SYSTEM file and update.
In /storage/.xbmc/addons/service.input.evrouter/config/ you have evrouter.conf file, you can edit for your convenience.
Caveats:
- with eventlircd method I don’t have key repeating
- remote does not time out (with eventlircd method I do not remapped the PS key, if I push the key at least 8 seconds the remote disconnect itself; with evrouter method I remapped eject key to deconnect the remote – some sort of solution)
III.
patching bluez
This is the method that I’m using now. It gives me all that I want from ps3 remote: key repeating, remote timeout, not using eventlircd and easy mapping for all keys. This patch also needs an appropriate input.conf. (files bellow)
The patch I’ve made is based on ruff (rufferson) patch from this xbmc thread (also mentioned by EKi) and here is the link to
ruff’s page on launchpad.
There is also an alternative patch from kitlaan from the same xbmc thread that offers the same benefits for ps3 remote –
kitlaan page on launchpad.
Many thanks to ruff and kitlaan for their efforts.
input.conf
# Configuration file for the input service
# This section contains options which are not specific to any
# particular interface
[General]
# Set idle timeout (in seconds) before the connection will
# be disconnect (defaults to 0 for no timeout)
IdleTimeout=30
##
# Section for options, specific to Sony PS3 BD Remote driver
[PS3 Remote]
# Set keymap to generic keycodes/scancodes, in order
# to be compatible with old XInput driver.
Compat=1
For building patched bluez make in OpenELEC source code a patches directory in packages/network/bluez and copy the patch file then for Generic build issue this command
PROJECT=Generic ARCH=i386 ./scripts/build bluez
After building copy all files from the bluez build directory (build.OpenELEC-Generic.i386-devel/bluez-4.96) to system.new directory (if you use mksquashfs addon), look at install script in packages/network/bluez for what files must be copied. Also copy the new input conf to
system.new/etc/bluetooth and this keyboard.xml(to /storage/.xbmc/userdata/keymaps).
keyboard.xml
<keymap>
<global>
<keyboard>
<f1>XBMC.ActivateWindow(MyVideos)</f1>
<f2>XBMC.ActivateWindow(MyMusic)</f2>
<f3>XBMC.ActivateWindow(MyPictures)</f3>
<f4>XBMC.ActivateWindow(VideoLibrary,TvShows)</f4>
</keyboard>
</global>
</keymap>Pack your new SYSTEM, reboot, update, try.
For the remote to work with virtual keyboard you must check the “remote send key presses” in xbmc system config,
The idea is that I am waiting for comments and opinions. I put a lot of effort in this, time consuming searching for information and also I have to say that I am not a specialist. I would want to see comments saying not only if you have problems but also if it works to improve this work.
Regards