TOPIC: PS3 Remote Controller in Openelec – alternate solutions

PS3 Remote Controller in Openelec – alternate solutions 1 year 3 months ago #1

  • ancalex
  • ancalex's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 314
  • Thank you received: 47
  • Karma: 27
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

File Attachment:

File Name: squashfs-tools.tar.gz
File Size: 37 KB

Generic.i386 and ION.x86_64 addon

File Attachment:

File Name: shell.squashfs-tools.mksquashfs.zip
File Size: 642 KB

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/

File Attachment:

File Name: bluez-tools.tar.gz
File Size: 82 KB

Generic.i386 and ION.x86_64 addon

File Attachment:

File Name: shell.bluez.bluez-tools.zip
File Size: 512 KB

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

File Attachment:

File Name: evrouter.tar.gz
File Size: 18 KB

Generic.i386 and ION.x86_64 addon

File Attachment:

File Name: service.input.evrouter.zip
File Size: 62 KB

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
#DisablePlugins = input
Pack your new SYSTEM file and update.

Pairing the remote
Put remote in discovery mode and
bt-adapter –d
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

File Attachment:

File Name: Lircmap.zip
File Size: 1 KB

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.

File Attachment:

File Name: bluez-4.96-ps3remote.patch.zip
File Size: 5 KB

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
Last Edit: 1 year 3 months ago by ancalex. Reason: link correction
The administrator has disabled public write access.
The following user(s) said Thank You: EKi

Re: PS3 Remote Controller in Openelec – alternate solutions 1 year 3 months ago #2

  • EKi
  • EKi's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 14
  • Karma: 0
It works! Thank you for an awesome guide.

There is one mistake (not sure if it is a mistake), for me lib/udev was in usr/lib/udev. I'm running OpenELEC-Fusion.i386-devel-20120125153223-r9647

Also, what buttons do these correspond with on the PS3 remote?

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

The first six I believe are L1,L2,L3,R1,R2,R3. BTN_START is probably the Start button, but what is BTN_0?
The administrator has disabled public write access.

Re: PS3 Remote Controller in Openelec – alternate solutions 1 year 3 months ago #3

  • ancalex
  • ancalex's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 314
  • Thank you received: 47
  • Karma: 27
Hi EKi
In the development builds udev rules are in /usr/lib/udev in OpenELEC 1.0.2 there are in lib/udev.
Your assumption is correct about the keys, BTN_0 is the key with a cross on it, I'm using it for audio mute.
I'm glad it is working for you.
What mapping method are you using?
Regards
The administrator has disabled public write access.

Re: PS3 Remote Controller in Openelec – alternate solutions 1 year 3 months ago #4

  • EKi
  • EKi's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 14
  • Karma: 0
I used the eventlircd method. I also used the debug feature of xbmc to figure out what button is which. I also cleaned up your Lircmap.xml a bit, it now shows what the not-so-clear buttons are on the PS3 remote.

Lircmap.xml

I don't know enough to help with the timeout and key repeating problems, but maybe this thread has some info.
Last Edit: 1 year 3 months ago by EKi.
The administrator has disabled public write access.

Re: PS3 Remote Controller in Openelec – alternate solutions 1 year 3 months ago #5

  • piotrasd
  • piotrasd's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 16
  • Thank you received: 3
  • Karma: 0
somebody can tell me where on exist version of openelec (with working and paired PS3 remote) map more buttons ?? (this Lircmap.xml dont work :( )

Many dont work like, audio, subtitles, eject, etc.
And LiveTV any button is not assigned to EPG or Channel list :( (Time and clear is good for this)
The administrator has disabled public write access.

Re: PS3 Remote Controller in Openelec – alternate solutions 1 year 3 months ago #6

  • ancalex
  • ancalex's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 314
  • Thank you received: 47
  • Karma: 27
Hi piotrasd
This Lircmap.xml alone will not work for you of course (and is only an example that is working for me).
You must make more changes like I stated in my first post (patching your SYSTEM file).
If you want more personalized button mapping you must make your own Lircmap.xml and also remote.xml,
The administrator has disabled public write access.
Moderators: ericab, turbomettwurst, lrusak

Our Sponsors & Partners

arctic_logo