Kodi Community Forum
[LINUX] Sony PlayStation 3 Blu-ray Disc Remote (PS3 BD) + LIRC + XBMC = SUCCESS - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: General Support (https://forum.kodi.tv/forumdisplay.php?fid=111)
+---- Forum: Linux (https://forum.kodi.tv/forumdisplay.php?fid=52)
+---- Thread: [LINUX] Sony PlayStation 3 Blu-ray Disc Remote (PS3 BD) + LIRC + XBMC = SUCCESS (/showthread.php?tid=50717)



RE: [LINUX] Sony PlayStation 3 Blu-ray Disc Remote (PS3 BD) + LIRC + XBMC = SUCCESS - OS/2 - 2014-07-21

The tarball is compressed using gzip as the driver compression programme.
Hint: Install gzip.

Good Luck Newb.


RE: [LINUX] Sony PlayStation 3 Blu-ray Disc Remote (PS3 BD) + LIRC + XBMC = SUCCESS - panksxbmc - 2014-07-24

Thank you for your HINT.

will try to gzip it and finally go to the next step and report here.. hopefully you will guide me then if I get stuck..


RE: [LINUX] Sony PlayStation 3 Blu-ray Disc Remote (PS3 BD) + LIRC + XBMC = SUCCESS - 12Darius12 - 2014-08-09

Hi,
I recently updated my media PC so now I'm running Ubuntu 14.04.1 and I am trying to get my PS3 remote working again.

I used PS3Pair (I had a copy at http://www.dons.net.au/~darius/ps3_pair.tar.gz if anyone else needs a copy) and fiddled around and got the remote connecting. It mostly works, however I find that not all the buttons work.

Previously I had /etc/bluetooth/input.conf which remapped a few buttons but it doesn't seem to work properly anymore.

I am trying to work out how to debug it but haven't had much luck Sad

I am not using Lirc (and wasn't previously) - just the Bluez input plugin.

Some observations..
- I see events for all buttons appear in the input node (e.g. hexdump -Cv /dev/input/eventXX shows things) for ALL buttons - not just the ones which work
- xev shows events for buttons which work but not for ones which don't
- the bluez docs are basically non existent Sad

Any help appreciated Smile


RE: [LINUX] Sony PlayStation 3 Blu-ray Disc Remote (PS3 BD) + LIRC + XBMC = SUCCESS - panksxbmc - 2014-08-15

(2014-08-09, 13:06)12Darius12 Wrote: Hi,
I recently updated my media PC so now I'm running Ubuntu 14.04.1 and I am trying to get my PS3 remote working again.

I used PS3Pair (I had a copy at http://www.dons.net.au/~darius/ps3_pair.tar.gz if anyone else needs a copy) and fiddled around and got the remote connecting. It mostly works, however I find that not all the buttons work.

Previously I had /etc/bluetooth/input.conf which remapped a few buttons but it doesn't seem to work properly anymore.

I am trying to work out how to debug it but haven't had much luck Sad

I am not using Lirc (and wasn't previously) - just the Bluez input plugin.

Some observations..
- I see events for all buttons appear in the input node (e.g. hexdump -Cv /dev/input/eventXX shows things) for ALL buttons - not just the ones which work
- xev shows events for buttons which work but not for ones which don't
- the bluez docs are basically non existent Sad

Any help appreciated Smile

I want to do the same thing with ubuntu 12.xx .. could you guide me or direct me to the guide that you used to connect the ps3 to my desktop.. Need some infor for the same.
Guide the newbie..


RE: [LINUX] Sony PlayStation 3 Blu-ray Disc Remote (PS3 BD) + LIRC + XBMC = SUCCESS - 12Darius12 - 2014-08-15

(2014-08-15, 04:28)panksxbmc Wrote:
(2014-08-09, 13:06)12Darius12 Wrote: Some observations..
- I see events for all buttons appear in the input node (e.g. hexdump -Cv /dev/input/eventXX shows things) for ALL buttons - not just the ones which work
- xev shows events for buttons which work but not for ones which don't
- the bluez docs are basically non existent Sad

Any help appreciated Smile

I want to do the same thing with ubuntu 12.xx .. could you guide me or direct me to the guide that you used to connect the ps3 to my desktop.. Need some infor for the same.
Guide the newbie..

I discovered the problem - changes to the bluetooth stack mean that you can no longer remap events that way so events go into the kernel with key codes above 255.

X can't handle such codes and ignores them, unfortunately there is no full solution (yet) because it's a limitation in the X protocol.

There is however a patched version of the evdev X11 input driver at http://www.thenautilus.net/SW/xf86-input-evdev/

I use this to remap the keys I want to ones below 255 so X can see them. Kinda tedious but unfortunately there is no other way currently (AFAIK).

I tried using LIRC as a re-mapper - it worked, however it did not generate repeated key press events for the remote which made it even less useful.

(2014-08-15, 04:28)panksxbmc Wrote:
(2014-08-09, 13:06)12Darius12 Wrote: Some observations..
- I see events for all buttons appear in the input node (e.g. hexdump -Cv /dev/input/eventXX shows things) for ALL buttons - not just the ones which work
- xev shows events for buttons which work but not for ones which don't
- the bluez docs are basically non existent Sad

I want to do the same thing with ubuntu 12.xx .. could you guide me or direct me to the guide that you used to connect the ps3 to my desktop.. Need some infor for the same.
Guide the newbie..

Actually, if you just want to connect then the XBMC wiki has a how to on it - I am not sure if Ubuntu 12 supports the bluetooth input mapping, or if you need the evdev patches I posted above.


RE: [LINUX] Sony PlayStation 3 Blu-ray Disc Remote (PS3 BD) + LIRC + XBMC = SUCCESS - jamesbe - 2014-08-15

(2014-08-15, 04:41)12Darius12 Wrote:
(2014-08-15, 04:28)panksxbmc Wrote:
(2014-08-09, 13:06)12Darius12 Wrote: Some observations..
- I see events for all buttons appear in the input node (e.g. hexdump -Cv /dev/input/eventXX shows things) for ALL buttons - not just the ones which work
- xev shows events for buttons which work but not for ones which don't
- the bluez docs are basically non existent Sad

Any help appreciated Smile

I want to do the same thing with ubuntu 12.xx .. could you guide me or direct me to the guide that you used to connect the ps3 to my desktop.. Need some infor for the same.
Guide the newbie..

I discovered the problem - changes to the bluetooth stack mean that you can no longer remap events that way so events go into the kernel with key codes above 255.

X can't handle such codes and ignores them, unfortunately there is no full solution (yet) because it's a limitation in the X protocol.

There is however a patched version of the evdev X11 input driver at http://www.thenautilus.net/SW/xf86-input-evdev/

I use this to remap the keys I want to ones below 255 so X can see them. Kinda tedious but unfortunately there is no other way currently (AFAIK).

I tried using LIRC as a re-mapper - it worked, however it did not generate repeated key press events for the remote which made it even less useful.

(2014-08-15, 04:28)panksxbmc Wrote:
(2014-08-09, 13:06)12Darius12 Wrote: Some observations..
- I see events for all buttons appear in the input node (e.g. hexdump -Cv /dev/input/eventXX shows things) for ALL buttons - not just the ones which work
- xev shows events for buttons which work but not for ones which don't
- the bluez docs are basically non existent Sad

I want to do the same thing with ubuntu 12.xx .. could you guide me or direct me to the guide that you used to connect the ps3 to my desktop.. Need some infor for the same.
Guide the newbie..

Actually, if you just want to connect then the XBMC wiki has a how to on it - I am not sure if Ubuntu 12 supports the bluetooth input mapping, or if you need the evdev patches I posted above.

Could you please post more details on this? I'm trying to get mythtv to work with my PS3 remote and it currently only works with the D-pad and the number keys. XBMC seems to work a little better, play / stop work as well and the PS button but not much else.

I would really like to just remap all the keys to normal keyboard buttons and then I'll do a remap with my harmony remote so it makes sense to the family when using the remote. I just installed 14.04 and this is yet another stumbling block it seems. I've had nothing but problems with the IR remotes ARGH.


RE: [LINUX] Sony PlayStation 3 Blu-ray Disc Remote (PS3 BD) + LIRC + XBMC = SUCCESS - jamesbe - 2014-08-15

EDIT: I got that code to compile, got it installed and now am trying to decipher how the heck to use it....

Keeping track of things I installed in case anyone else reads this:
sudo apt-get install bluez-tools
sudo apt-get install autoconf
sudo apt-get install xutils-dev
sudo apt-get install libtool
sudo apt-get install xserver-xorg-dev
sudo apt-get install libusb-1.0-0-dev
sudo apt-get install libudev-dev


cat /proc/bus/input/devices

I: Bus=0005 Vendor=046d Product=0306 Version=0101
N: Name="BD Remote Control"
P: Phys=00:15:83:15:a3:10
S: Sysfs=/devices/pci0000:00/0000:00:14.0/usb3/3-8/3-8:1.0/bluetooth/hci0/hci0:1/input25
U: Uniq=00:1f:20:40:3a:42
H: Handlers=kbd event17
B: PROP=0
B: EV=200013
B: KEY=7000001083c100 8c00ea00000000 6bc0000000000001 8000 1102c0000801 80168000000000 10000ffe
B: MSC=10
B: FF=107030000 0

use "showkey" in a terminal to get all the keycodes from your remote.


EDIT: work in progress....


RE: [LINUX] Sony PlayStation 3 Blu-ray Disc Remote (PS3 BD) + LIRC + XBMC = SUCCESS - Tripplesixty - 2014-08-28

(2014-08-15, 22:55)jamesbe Wrote: Could you please post more details on this? I'm trying to get mythtv to work with my PS3 remote and it currently only works with the D-pad and the number keys. XBMC seems to work a little better, play / stop work as well and the PS button but not much else.

I would really like to just remap all the keys to normal keyboard buttons and then I'll do a remap with my harmony remote so it makes sense to the family when using the remote. I just installed 14.04 and this is yet another stumbling block it seems. I've had nothing but problems with the IR remotes ARGH.

Im also want to get full key mapping working, however none of the keys in the conf file seem to be taking when testing input with showkey on the command line. Like stated above I'm getting the D pad, number keys, stop and enter working, however none of my custom mapping are working. Is there any way to debug this to make sure that the conf file is properly being loaded?


RE: [LINUX] Sony PlayStation 3 Blu-ray Disc Remote (PS3 BD) + LIRC + XBMC = SUCCESS - 12Darius12 - 2014-08-29

(2014-08-15, 22:55)jamesbe Wrote: Could you please post more details on this? I'm trying to get mythtv to work with my PS3 remote and it currently only works with the D-pad and the number keys. XBMC seems to work a little better, play / stop work as well and the PS button but not much else.

I would really like to just remap all the keys to normal keyboard buttons and then I'll do a remap with my harmony remote so it makes sense to the family when using the remote. I just installed 14.04 and this is yet another stumbling block it seems. I've had nothing but problems with the IR remotes ARGH.

You need to do (approximately) the following..

Install the necessary packages to checkout, build etc..
Code:
sudo apt-get install git automake autoconf pkg-config xcb-proto xutils-dev libtool xserver-xorg-dev libudev-dev evtest

Clone the xf86-input-evdev repo and pull in the changes
Code:
git clone git://www.thenautilus.net/xf86-input-evdev
cd xf86-input-evdev
git pull git://www.thenautilus.net/xf86-input-evdev code-remap-2.8.2

Compile the evdev driver
Code:
./autogen.sh
make

Move the old file out of the way and copy the new one in
Code:
sudo mv /usr/lib/xorg/modules/input/evdev_drv.so /usr/lib/xorg/modules/input/evdev_drv.so.orig
sudo cp ./src/.libs/evdev_drv.so /usr/lib/xorg/modules/input/evdev_drv.so

Then create a config file to use the new option - /usr/share/X11/xorg.conf.d/99-evdev.conf containing
Code:
Section “InputClass"
        Identifier "evdev keyboard catchall"
        MatchIsKeyboard "on"
        MatchDevicePath "/dev/input/event*”
        MatchProduct "PS3 Remote Controller"
        Driver "evdev"
        # Remap list
        # R1/2/3 (311/313/318) to F8/F9/F10 => vol up/down/mute
        # Option (353) to c => context
        # Clear (355) to w => toggle watched
        # Display/Info (358) to i => info
        # Start (315) to s => shutdown menu
        Option "event_key_remap" "311=76 313=75 318=74 353=23 357=54 353=23 355=77 358=31 315=39"
EndSection

You can find which codes to map FROM (i.e. what the PS3 remote generates) by looking for it in the output of 'cat /proc/bus/input/devices'
eg..
Code:
I: Bus=0005 Vendor=054c Product=0306 Version=0000
N: Name="PS3 Remote Controller"
P: Phys=
S: Sysfs=/devices/virtual/input/input71
U: Uniq=
H: Handlers=kbd event22
B: PROP=0
B: EV=3
B: KEY=8000000000000000 7000001083c100 8c00ea00000000 6bc0000000000001 8000 1102c0000801 80168000000000 10000ffe
Note the 'H:' line and event22

Now run 'sudo evtest /dev/input/event22' and press a button on the remote and you will see something like..
Code:
Event: time 1409268216.091763, type 1 (EV_KEY), code 315 (BTN_START), value 1
Event: time 1409268216.091763, -------------- SYN_REPORT ------------
Event: time 1409268216.439260, type 1 (EV_KEY), code 315 (BTN_START), value 0
Event: time 1409268216.439260, -------------- SYN_REPORT ------------

So the code for the 'start' button is 315 (which is above 255 so X11 won't grok it)

You can look up the X11 codes in /usr/share/X11/xkb/keycodes/evdev or just run 'rev' and move the mouse over the xev window and press a key. You will see output like so..
Code:
KeyRelease event, serial 32, synthetic NO, window 0xc00001,
    root 0x273, subw 0xc00002, time 88910611, (43,45), root:(43,84),
    state 0x0, keycode 39 (keysym 0x73, s), same_screen YES,
    XLookupString gives 1 bytes: (73) "s"
    XFilterEvent returns: False

So the key code for 's' is 39, hence we have '315=39' in the X config.

You need to restart X to test changes and so far as I know there is no dynamic way to adjust the table so I suggest working out a list of mappings, generating all the numbers, and editing the file in one big hit.


RE: [LINUX] Sony PlayStation 3 Blu-ray Disc Remote (PS3 BD) + LIRC + XBMC = SUCCESS - chriswhat21 - 2014-09-09

Thank you Darius. That was a bit of a pain, but it worked. One quick note that kept my X from starting though. In your /usr/share/X11/xorg.conf.d/99-evdev.conf, the first “ in this line
Code:
Section “InputClass"
and the last “ in this line
Code:
MatchDevicePath "/dev/input/event*”
need to be replaced with ". " was probably autoformatted to “ somewhere.

Also, the IdleTimeout from the old input.conf doesn't seem to do anything, so my batteries died. I've added "/usr/bin/bt-device --disconnect 00:21:4F:A6:3A:30" to a cron job every 10 minutes. Is there a better way to do this? A way to run a script that will sleep 600 then disconnect after the remote connects?


RE: [LINUX] Sony PlayStation 3 Blu-ray Disc Remote (PS3 BD) + LIRC + XBMC = SUCCESS - 12Darius12 - 2014-09-10

(2014-09-09, 17:02)chriswhat21 Wrote: Thank you Darius. That was a bit of a pain, but it worked. One quick note that kept my X from starting though. In your /usr/share/X11/xorg.conf.d/99-evdev.conf, the first “ in this line
Code:
Section “InputClass"
and the last “ in this line
Code:
MatchDevicePath "/dev/input/event*”
need to be replaced with ". " was probably autoformatted to “ somewhere.

Also, the IdleTimeout from the old input.conf doesn't seem to do anything, so my batteries died. I've added "/usr/bin/bt-device --disconnect 00:21:4F:A6:3A:30" to a cron job every 10 minutes. Is there a better way to do this? A way to run a script that will sleep 600 then disconnect after the remote connects?

Ah nice catch thanks, I think Evernote "helped" the formatting..

WRT BT power off - I have this..

Disconnect on shutdown - /etc/rc.d/K99bt
Code:
#!/bin/sh

exec /home/myth/bin/bt-disconnect-all.py

Disconnect on sleep/hibernate - /etc/pm/sleep.d/01_bt
Code:
#!/bin/sh
case $1 in
hibernate|suspend)
     /home/mythtv/bin/bt-disconnect-all.py
     ;;
thaw|resume)
     ;;
*)
     ;;
esac

Actual script to disconnect BT /home/myth/bin/bt-disconnect-all.py - copied from http://blog.asiantuntijakaveri.fi/2012/12/setting-up-xbmcbuntu-12-based-htpc-part_8278.html

Code:
#!/usr/bin/python

import sys, re
import dbus
from optparse import OptionParser

parser = OptionParser()
parser.add_option("-i", "--device", action="store", type="string", dest="dev_id")

(options, args) = parser.parse_args()

bus = dbus.SystemBus()
manager = dbus.Interface(bus.get_object("org.bluez", "/"), "org.bluez.Manager")

if options.dev_id:
    adapter_path = manager.FindAdapter(options.dev_id)
else:
    adapter_path = manager.DefaultAdapter()

adapter = dbus.Interface(bus.get_object("org.bluez", adapter_path), "org.bluez.Adapter")

for path in adapter.ListDevices():
    device = dbus.Interface(bus.get_object("org.bluez", path), "org.bluez.Device")
    properties = device.GetProperties()
    if properties['Connected']:
        print "Disconnecting %s [%s]..." % (properties['Address'], properties['Name']),
        try:
            device.Disconnect()
            print "done"
        except Exception, e:
            print "error (%s)" % str(e)



RE: [LINUX] Sony PlayStation 3 Blu-ray Disc Remote (PS3 BD) + LIRC + XBMC = SUCCESS - chunkymonkey - 2014-09-10

Thanks Darius!

I followed your instructions and I've got keys other than the basic keys recognised.
I have a small problem though, the X button refuses to be remapped for some reason.
It seems that it behaves as though it is the left mouse button as it shows a pointer on screen.

Thanks chriswhat for catching the " it had me stumped for a while.

Re: Bluetooth timeout
Darius, those scripts seem to only disconnect bluetooth when my htpc shutdown/suspends?

Thanks for the clear instructions guys. Big Grin


RE: [LINUX] Sony PlayStation 3 Blu-ray Disc Remote (PS3 BD) + LIRC + XBMC = SUCCESS - 12Darius12 - 2014-09-11

I think the X button appears as joystick button 0 (no idea why..)

I think the only way to remap it would be to use XBMCs configuration.


RE: [LINUX] Sony PlayStation 3 Blu-ray Disc Remote (PS3 BD) + LIRC + XBMC = SUCCESS - chunkymonkey - 2014-09-11

I've tried messing around and this is what I've found out so far.

evtest reports a keycode of 256
xev reports that it is button 1

In 99-PSRemote.conf
I have remapped 256=53

I have also modified keyboard.xml to include
Code:
<global>
  <mouse>
    <leftclick>x</leftclick>
  </mouse>
</global>

Following the instructions from here, trying to use xbindkeys and xte to remap the Cross (X) button.

http://blog.hanschen.org/2009/10/13/mouse-shortcuts-with-xbindkeys/

Basically, install xbindkeys and xautomation (for xte).

create ~/.xbindkeysrc
Code:
#Remap PS3 X key which is seen as mousebutton
  "xte 'key X'"
    b:1 + release

It worked once but didn't stick after a reboot. I've now tried all possible combinations of the three variables but haven't been able to replicate the key being remapped.

In the meantime, I've just turned off mouse support in System -> Input Devices -> Enable Mouse and Touch Screen support.

I don't have the use of the (X) button but at least if I hit it by accident, the mouse cursor doesn't show up.

I'll continue experimenting to see if I can get it to behave again.


RE: [LINUX] Sony PlayStation 3 Blu-ray Disc Remote (PS3 BD) + LIRC + XBMC = SUCCESS - chunkymonkey - 2014-09-12

Ok, so I figured it out. The reason it stopped working after a reboot was that somehow my keyboard.xml file got saved in a DOS format, which meant that XBMC didn't load it properly.

You only need to change keyboard.xml to remap left click.

Code:
<global>
  <mouse>
    <leftclick>Stop</leftclick>
  </mouse>
</global>

That's all. No need to remap 256 in 99-PSRemote.conf and no need to mess around with xbindkeys.

Only need to figure out a better way to do a bluetooth timeout due to inactivity. I'm currently using chriswhat21 suggested cron job but changed it to every 3 minutes.

Thanks for all the help!

PS. In case anyone else was following along, remember to turn on Mouse and Touch Screen support in System -> Input Devices.
PPS. Doing this also means that if you use a mouse or touchpad as well as the PS3 remote, your mouse/touchpad will behave very weirdly, if at all.