PDA

View Full Version : PlayStation3 (PS3) bluetooth remote and LIRC?


brandonj
2007-09-25, 23:45
Hello,
I have been following the progress of XBMC Linux since day one, and I have to say, you are all doing great!

I am not a cpp programmer by any means, so I will help where I can. At the moment, I am attempting to get the PS3 BD Remote to work with XBMC. (This is a bluetooth remote) Although a lot of the work I am doing is not with XBMC directly, I would like to post my progress, and hopefully there are others interested and could give some input.

So far, I have been able to pair the remote, decode all the button presses, get battery life info, and map the buttons to keyboard button presses (which is how I control XBMC), using a program called xte, which interfaces with the xtest library. Everything I have written is written in python.

The problems I have run in to that is XBMC related is mostly with the Virtual Keyboard in XBMC. The keyboard doesn't have any commands to move the cursor-type thing around the letters on the virtual keyboard (i assume, because you don't need a virtual keyboard, if you have a physical one).

To solve this problem, there are a number of things that can be done:
-Fix the virtual keyboard to work with keyboard buttons
-Make a driver to interface the sony remote with LIRC.
-Make a driver to treat the remote as a joystick


The first option is probably the quickest and easiest to do, and will solve the problem just fine, but the second option is probably the most complete solution, with the third being "if all else fails".

Another problem I am having, is I have to pair the remote every time the script is run. I don't know enough about bluetooth to make it remember the connection so I don't have to pair it every time.

The following two posts will include everything I know about the remote commands that are sent, as well as a sample python script that I use to map button presses to keyboard presses.

If you are interested in helping with this project, I will gladly accept any code or even simple guidance on how to progress with this.

Thanks,

Brandon

brandonj
2007-09-26, 00:00
The commands received by the remote look like this:
a1 01 00 00 00 03 ff ff ff ff ff 01 02

The following is an explanation of what I know so far about each number:

The 1st octet always stays the same at A1. It's purpose is unknown.

The 2nd octet always stays the same at 01. It's purpose is unknown.

The 3rd 4th and 5th octets are for multiple button presses with the controller keys. When multiple buttons are pressed, it's values are added together to form the key combination.

The 6th octet is the actual button that is being pressed. if the result is FF, then it is a special command (for key releases and multiple button presses)

the 7th - 11th octets always stay the same at FF. It's purpose is unknown.

the 12th octet is used when the 6th octet is FF. If 6th is FF, and 12th is 00, then all the keys are released. If the 6th is FF and 12th is 01, then it is a multi key combination. If 6th is NOT FF, then 12th is always 01.

The 13th octet is the current battery life of the remote. 5 is full, 0 is empty.


Key Maps (6th octet)
--------

ff --Key Released
16 --EJECT
64 --AUDIO
65 --ANGLE
63 --SUBTITLE
0f --CLEAR
28 --TIME
00 --1
01 --2
02 --3
03 --4
04 --5
05 --6
06 --7
07 --8
08 --9
09 --0
81 --RED
82 --GREEN
80 --BLUE
83 --YELLOW
70 --DISPLAY
1a --TOP MENU
40 --POP UP/MENU
0e --RETURN
5c --OPTIONS/TRIANGLE
5d --BACK/CIRCLE
5e --X
5f --VIEW/SQUARE
54 --UP
55 --RIGHT
56 --DOWN
57 --LEFT
0b --ENTER
5a --L1
58 --L2
51 --L3
5b --R1
59 --R2
52 --R3
43 --PLAYSTATION
50 --SELECT
53 --START
33 -- <-SCAN
34 -- SCAN->
30 --PREV
31 --NEXT
60 -- <-SLOW/STEP
61 -- SLOW/STEP->
32 --PLAY
38 --STOP
39 --PAUSE




Keys that support multiple key combinations
--------------------------------------------

UP
RIGHT
DOWN
LEFT

SELECT
L3
R3
START

OPTIONS/TRIANGLE
BACK/CIRCLE
X
VIEW/SQUARE

L2
R2
L1
R1

brandonj
2007-09-26, 00:07
This is the script I have written so far:

import bluetooth
import os

loop_forever = True
while loop_forever is True:

target_name = "BD Remote Control"
target_address = None
remote = bluetooth.BluetoothSocket(bluetooth.L2CAP)


target_connected = False
while target_connected is False:
print "Searching for BD Remote Control"
print "(Press Start + Enter on remote to make discoverable)"
nearby_devices = bluetooth.discover_devices()

for bdaddr in nearby_devices:
if target_name == bluetooth.lookup_name( bdaddr ):
target_address = bdaddr
break

if target_address is not None:
print "Found BD Remote Control with address ", target_address
print "Attempting to pair with remote"

try:
remote.connect((target_address,19))
target_connected = True
print "Remote Paired.\a"
except:
print "ERROR - Could Not Connect. Trying again..."

else:
print "Could not find BD Remote Control. Trying again..."


done = False
while not done:
datalen = 0
try:
data = remote.recv(1024)
datalen = len(data)
except:
done = True

if datalen == 13:
keycode = data.encode("hex")[10:12]

if keycode == "ff":
print "Key Released or Multiple keys pressed"

elif keycode == "16": #EJECT
print "Eject"
os.system("xte 'key s'")

elif keycode == "64": #AUDIO
print "Audio"
os.system("xte 'key w'")

elif keycode == "65": #ANGLE
print "Angle"
os.system("xte 'key z'")

elif keycode == "63": #SUBTITLE
print "Subtitle"
os.system("xte 'key n'")

elif keycode == "0f": #CLEAR
print "Clear"
os.system("xte 'key d'")

elif keycode == "28": #TIME
print "Time"
os.system("xte 'key t'")

elif keycode == "00": #1
print "1"
os.system("xte 'key 1'")

elif keycode == "01": #2
print "2"
os.system("xte 'key 2'")

elif keycode == "02": #3
print "3"
os.system("xte 'key 3'")

elif keycode == "03": #4
print "4"
os.system("xte 'key 4'")

elif keycode == "04": #5
print "5"
os.system("xte 'key 5'")

elif keycode == "05": #6
print "6"
os.system("xte 'key 6'")

elif keycode == "06": #7
print "7"
os.system("xte 'key 7'")

elif keycode == "07": #8
print "8"
os.system("xte 'key 8'")

elif keycode == "08": #9
print "9"
os.system("xte 'key 9'")

elif keycode == "09": #0
print "0"
os.system("xte 'key 0'")

elif keycode == "81": #RED
print "Red"

elif keycode == "82": #GREEN
print "Green"

elif keycode == "80": #BLUE
print "Blue"

elif keycode == "83": #YELLOW
print "Yellow"

elif keycode == "70": #DISPLAY
print "Display"
os.system("xte 'key i'")

elif keycode == "1a": #TOP MENU
print "Top Menu"

elif keycode == "40": #POP UP/MENU
print "Pop Up/Menu"

elif keycode == "0e": #RETURN
print "Return"
os.system("xte 'key BackSpace'")

elif keycode == "5c": #OPTIONS/TRIANGLE
print "Options/Triangle"
os.system("xte 'key s'")

elif keycode == "5d": #BACK/CIRCLE
print "Back/Circle"
os.system("xte 'key Escape'")

elif keycode == "5e": #X
print "X"
os.system("xte 'key x'")

elif keycode == "5f": #VIEW/SQUARE
print "View/Square"
os.system("xte 'key v'")

elif keycode == "54": #UP
print "Up"
os.system("xte 'key Up'")

elif keycode == "55": #RIGHT
print "Right"
os.system("xte 'key Right'")

elif keycode == "56": #DOWN
print "Down"
os.system("xte 'key Down'")

elif keycode == "57": #LEFT
print "Left"
os.system("xte 'key Left'")

elif keycode == "0b": #ENTER
print "Enter"
os.system("xte 'key Return'")

elif keycode == "5a": #L1
print "L1"
os.system("xte 'key +'")

elif keycode == "58": #L2
print "L2"
os.system("xte 'key -'")

elif keycode == "51": #L3
print "L3"

elif keycode == "5b": #R1
print "R1"
os.system("xte 'key Page_Up'")

elif keycode == "59": #R2
print "R2"
os.system("xte 'key Page_Down'")

elif keycode == "52": #R3
print "R3"

elif keycode == "43": #PLAYSTATION
print "Playstation"

elif keycode == "50": #SELECT
print "Select"
os.system("xte 'key ['")

elif keycode == "53": #START
print "Start"
os.system("xte 'key]'")

elif keycode == "33": #<-SCAN
print "<-Scan"
os.system("xte 'key r'")

elif keycode == "34": # SCAN->
print "Scan->"
os.system("xte 'key f'")

elif keycode == "30": #PREV
print "Prev"
os.system("xte 'key ,'")

elif keycode == "31": #NEXT
print "Next"
os.system("xte 'key .'")

elif keycode == "60": #<-SLOW/STEP
print "<-Slow/Step"

elif keycode == "61": # SLOW/STEP->
print "Slow/Step->"

elif keycode == "32": #PLAY
print "Play"
os.system("xte 'key p'")

elif keycode == "38": #STOP
print "Stop"
os.system("xte 'key x'")

elif keycode == "39": #PAUSE
print "Pause"
os.system("xte 'key Space'")

else:
print "Unknown or garbage data"
else:
print "Unknown or garbage data"

print "Disconnected."
try:
remote.close()
except:
print "Can not close. Oh well."

print "Program Ended."

mace
2007-09-26, 20:35
I would say that option two is the best. It would be a more robust solution against changes in XBMC and it would benefit the entire lirc comunity. Unfortunally I'm not a programmer so for this I'm no good

brandonj
2007-09-26, 21:14
I agree.

Looking through the LIRC source code, there is a daemon for a Sony Ericsson cellphone, which communicates via bluetooth. This could probably be modified to produce the results desired. I need to take a closer look at this.

-Brandon

Gamester17
2007-12-10, 15:05
Any updates on this?

That Sony PlayStation 3 Remote Control (http://www.amazon.com/Sony-PlayStation-Blu-ray-Disc-Remote/dp/B000M17AVO) would make a really cheap RF (Radio Frequency) remote if someone could get it working with LIRC (http://www.lirc.org).

...and the LIRC website does state that it works with "Bluetooth mobile phones" so maybe it would be possible to do what brandonj suggest and modify that to get the Sony PlayStation 3 Remote Control (http://www.amazon.com/Sony-PlayStation-Blu-ray-Disc-Remote/dp/B000M17AVO) working via bluetooth, as it would be much nicer to have it working nativly than to have to go through a python or other script. By the way, some guys did manage to get it working via a python like brandonj suggested by making as virtual keyboard interface:
http://www.youtube.com/watch?v=0C8QN3Hux4g

Now back top discussion about a native implementation; I wonder which bluetooth profile(s) the remote uses, there are a few possibilites;

AVRCP (Audio/Video Remote Control Profile)
This profile is designed to provide a standard interface to control TVs, Hi-fi equipment, etc. to allow a single remote control (or other device) to control all of the A/V equipment to which a user has access. It may be used in concert with A2DP or HID (see bellow). It has the possibility for vendor-dependent extensions. Additionally, with the version 1.3 release of the specification, there is now capability to transmit information on the status of the music source, including information on the track itself (artist, track name, etc).
http://en.wikipedia.org/wiki/Bluetooth_profile

SPP (Serial Port Profile)
This profile is based on the ETSI TS 07.10 specification and uses the RFCOMM protocol. It emulates a serial cable to provide a simply implemented wireless replacement for existing RS-232 based serial communications applications, including familiar control signals. It provides the basis for DUN, FAX, HSP and AVRCP profiles.
http://en.wikipedia.org/wiki/Bluetooth_profile

HID (Human Interface Device Profile)
Provides support for devices such as mice, joysticks, keyboards, as well as sometimes providing support for simple buttons and indicators on other types of devices. It is designed to provide a low latency link, with low power requirements. Bluetooth HID is a lightweight wrapper of the Human Interface Device protocol defined for USB. The use of the HID protocol simplifies host implementation (ex: support by Operating Systems) by enabling the re-use of some of the existing support for USB HID to also support Bluetooth HID. Popular devices that feature support for this profile include: Logitech diNovo Media Desktop 2.0, Microsoft Optical Desktop Elite for Bluetooth. PlayStation 3 controllers and Wii Remotes also use BT HID.
http://en.wikipedia.org/wiki/Bluetooth_profile

brandonj
2007-12-10, 20:23
There have been no major updates with me on the PS3 remote, although I have been using it exclusively in XBMC-Linux using python scripts. I will post what I'm using in the next post - it's an "out-of-the-box" solution, so you don't have to modify XBMC at all to use it. You do have to pair it every time the script is run though. I don't know how to get around this. I am pretty new to bluetooth.

Unfortunately, the virtual keyboard does not play nicely when using the real keyboard (the script I modified just sends keyboard events via uinput), so adding sources and stuff like that requires a real keyboard to type everything out.

I think that LIRC would be the best way to go, just to have a common interface. I don't have enough coding experience to write one myself, so I'm pretty much depending on someone else to implement this. I am willing to help in any way I can, however.

The PS3 remote uses HID to communicate, as far as I have been able to tell - when you pair it in windows, it shows up as a HID device. If you look at my previous posts, you can see that it just sends a single line of hex to show the button states, battery life, etc.

brandonj
2007-12-11, 02:41
This shell script came from the azureus wiki to pretty much make any console a daemon. I modified it to call the python script that maps button presses to keyboard events

ps3remote.py
#! /bin/sh

#The user that will run Azureus
BD_USER=root

#Name of the screen-session
NAME=remotecontrol_screen

#executable files in the following paths that are perhaps needed by the script
PATH=/bin:/usr/bin:/sbin:/usr/sbin

#your path to the azureus directory, where Azureus2.jar is located
DIR=/usr/bin

#Description
DESC="Remote Control screen daemon"

case "$1" in
start)
if [[ `su $BD_USER -c "screen -ls |grep $NAME"` ]]
then
echo "Remote Daemon is already running!"
else
echo "Starting $DESC: $NAME"
su $BD_USER -c "cd $DIR; screen -dmS $NAME python cakemote.py"
fi
;;
stop)
if [[ `su $BD_USER -c "screen -ls |grep $NAME"` ]]
then
echo -n "Stopping $DESC: $NAME"
su $BD_USER -c "screen -X quit"
echo " ... done."
else
echo "Coulnd't find a running $DESC"
fi
;;
restart)
if [[ `su $BD_USER -c "screen -ls |grep $NAME"` ]]
then
echo -n "Stopping $DESC: $NAME"
su $BD_USER -c "screen -X quit"
echo " ... done."
else
echo "Coulnd't find a running $DESC"
fi
echo "Starting $DESC: $NAME"
su $BD_USER -c "cd $DIR; screen -dmS $NAME python cakemote.py"
echo " ... done."
;;
status)
if [[ `su $BD_USER -c "screen -ls |grep $NAME"` ]]
then
echo "Remote Daemon is RUNNING"
else
echo "Remote Daemon is DOWN"
fi
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
exit 1
;;
esac

exit 0

brandonj
2007-12-11, 03:11
The following is the script I am currently using to interface with the PS3 remote:

cakemote.py modified for my needs:

http://cl1p.net/cakemote/

topfs2
2008-01-24, 19:48
Well from what I can tell this remote uses the L2CAP protocol and if that script takes care of ALL the buttons on the remote? this script shouldn't be all that hard to "port" to C/C++ and implement natively into XBMC.

Here's some read
http://people.csail.mit.edu/albert/bluez-intro/x95.html#l2cap-and-udp

Compare (C code)
http://people.csail.mit.edu/albert/bluez-intro/x559.html
to (Python code)
http://people.csail.mit.edu/albert/bluez-intro/x264.html

I'd even suggest looking at my Wiiremote implementation as a reference on what needs to be changed in order for this to work
http://sourceforge.net/tracker/index.php?func=detail&aid=1876587&group_id=87054&atid=581840
Granted, my code doesn't use many bluez calls as the wiiremote have it's lib and my code is emulation mouse behavior but this should be possible depending on how well the python calls you've created works?

d4rk
2008-03-15, 15:41
brandonj, thanks for your script. I've updated it to use the new event server that is now part of XBMC and committed (http://xbmc.svn.sourceforge.net/viewvc/xbmc/branches/linuxport/XBMC/tools/EventClients/ps3_remote.py?view=markup) it to SVN. It works quite well, here are some shots of it:

http://xbmc.org/forum/attachment.php?attachmentid=19&stc=1&d=1205584572

http://xbmc.org/forum/attachment.php?attachmentid=20&stc=1&d=1205584584

http://xbmc.org/forum/attachment.php?attachmentid=21&stc=1&d=1205584599

brandonj
2008-03-16, 09:56
d4rk: very impressive! I have been trying to accomplish this using the libcwiid code that topfs wrote to implement the wiimote, but was having a terrible time doing so (i blame my terrible C++ skills). You made it so I don't have to finish it :).

Your implementation looks great! I am glad that some of my script was useful for you. Keep it up, and if I come up with any enhancements, I will definately let you know.

-Brandon

stepir
2008-03-18, 22:49
this might be a little offtopic but... I've seen some remote for PS3 that are given with USB IR adapter. I've never purchased one but was thinking of using it to replace the PS3 remote with a standard logitech harmony remote.

Off course I was waiting to see some progress with XBMC on PS3 before looking better at the remote replacement :)

So big question, from your topic I guess you are using Linux XBMC on PS3 :)
would you provide any feedback about it? how it works? performances with DIVx playback without hw acceleration support? have you tried divx playback at lower res (720, 480, etc)?

brandonj
2008-03-18, 23:11
So big question, from your topic I guess you are using Linux XBMC on PS3 :)

Actually, it is XBMC on a PC. I simply use the PS3 remote with a bluetooth adapter, and wrote a python script to map button presses from the remote to keyboard presses, which in turn was modified by d4rk to run on XBMC's event server (which is awesome, BTW).

So, no, it does not run on the PS3. But they day it does (and runs well) will also be the day I buy a PS3 :)

-Brandon

Gamester17
2008-03-18, 23:31
So big question, from your topic I guess you are using Linux XBMC on PS3 :)No, you have totally missunderstod, there is no XBMC for PS3. This topic is only about using the PS3 bluetooth remote with XBMC for Linux on a normal x86-computer (not the PS3), with a bluetooth dongle on the x86-computer.

If you would like to discuss (the non-existing) XBMC for PS3 please see this other topic-thread => http://xbmc.org/forum/showthread.php?t=21849

stepir
2008-03-18, 23:53
Thanks and sorry for the OT!

zAo_OSX
2008-05-21, 18:17
Wow, great job d4rk!

Can you give us some little instructions on how to install/configure this?

topfs2
2008-05-21, 21:11
Look here: http://xbmc.org/wiki/?title=EventServer

It's all the EventClients including the PS3 Remote.

/Topfs2

Crocodile
2008-06-11, 13:05
I use http://antst.mine.nu/linuxdriverforsonybdremote and then use lirc. This is better as I do not have to pair the remote all the time and I can use the remote in any program supporting lirc :)

brandonj
2008-06-11, 17:39
Awesome. I will have to try this out.

-Brandon

danillll
2009-02-12, 05:22
I thought I would revive and use this thread to get a complete solution for using the PS3 BD Remote, especially that if you go now to a nearby Liquidating Circuit City, you can get this remote for 17$! dirt cheap.

As already known, the ps3_remote.py works perfectly, however you need to pair it every time you reboot and this is the only issue that needs to be solved.

I tried the tool described in comment #19 but couldn't make it to work, I wonder if anybody has a documented steps for how to use the bdremotedb.

For now I am using the ps3remote.py and reduced the pain of ssh to the box and run the script everytime I did the following.

- create a a file call it <whateveryoucallit>.sh
- add the following lines

#!/bin/bash

sleep 10
cd /home/xbmc/XBMC-FILES/SOURCE-CODE/XBMC/tools/EventClients/Clients/PS3\ BD\ Remote/
./ps3_remote.py 127.0.0.1 9777 &> /dev/null

-save it under /etc/init.d
-execute
%sudo update-rc.d <whateveryoucallit>.sh defaults

- now everytime you reboot it will automatically prompts you to pair your remote, if you missed it, it will prompt you again....


This is a temporary solution, so I wonder if the author of the ps3_remote.py can shed some light on what are the implementation obstacles he faced that prevented him from getting the pairing issue solved and if there is any work in progress.

Gonna start looking at the script in details and see if I can figure out something.

If somebody has another solution please go ahead and post it.

brandonj
2009-02-12, 06:02
Back in the day, before the script was modified to use the eventclient, i just had the script loop forever - if it wasn't connected, then try to pair until it connects. It worked for me, but it was far from ideal. At this point, it pretty much works the way you are using it. It needs some work, but i think the bluetooth tools in linux need some help first.

In the mean time, it might help you to note that the key events (outlined somewhere in the forums - probably in this thread, i can't remember) sent by the remote are received by the computer even if the remote isn't paired. Someone out there wrote a script that reads BD data, and if it finds one coming from the remote, it sends a command to LIRC. This method lets you use the remote in an unpaired state, but i don't know if battery life is affected using this method or not. You can find it here: http://antst.mine.nu/linuxdriverforsonybdremote

Good luck

danillll
2009-02-12, 07:10
Back in the day, before the script was modified to use the eventclient, i just had the script loop forever - if it wasn't connected, then try to pair until it connects. It worked for me, but it was far from ideal. At this point, it pretty much works the way you are using it. It needs some work, but i think the bluetooth tools in linux need some help first.

In the mean time, it might help you to note that the key events (outlined somewhere in the forums - probably in this thread, i can't remember) sent by the remote are received by the computer even if the remote isn't paired. Someone out there wrote a script that reads BD data, and if it finds one coming from the remote, it sends a command to LIRC. This method lets you use the remote in an unpaired state, but i don't know if battery life is affected using this method or not. You can find it here: http://antst.mine.nu/linuxdriverforsonybdremote

Good luck


right, this was the tool that I mentioned, but I wasn't able to make it work, I compiled it, ran it but I couldn't get any data when running irw.
Have you tried it? di it work for you?

d4rk
2009-02-13, 21:42
Currently, you need to use ps3d.py (http://www.xbmc.org/trac/browser/branches/linuxport/XBMC/tools/EventClients/Clients/PS3 Sixaxis Controller/ps3d.py) (executed as root) to have it autoconnect after initial pairing. I haven't tested using the BD Remote with it in a few months.

The reason it needs to run as root is that it needs to listen on certain privileged Bluetooth sockets, specifically L2CAP PSMs 17 and 19.

danillll
2009-02-21, 17:06
Currently, you need to use ps3d.py (http://www.xbmc.org/trac/browser/branches/linuxport/XBMC/tools/EventClients/Clients/PS3 Sixaxis Controller/ps3d.py) (executed as root) to have it autoconnect after initial pairing. I haven't tested using the BD Remote with it in a few months.

The reason it needs to run as root is that it needs to listen on certain privileged Bluetooth sockets, specifically L2CAP PSMs 17 and 19.

I tried and I can't make it work it is stuck in the while loop

def start_hidd(bdaddr=None, ipaddr="127.0.0.1"):
devices = [ 'PLAYSTATION(R)3 Controller',
'BD Remote Control' ]
hid = HID(bdaddr)
while True:
if hid.listen():
(csock, addr) = hid.get_control_socket()
device_name = bt_lookup_name(addr[0])
if device_name == devices[0]:


I ran it like this

sudo ./ps3d.py 00:19:C1:5A:31:D1 127.0.0.1
Connecting to Bluetooth device: 00:19:C1:5A:31:D1
Connecting to IP: 127.0.0.1
Starting HID daemon



did it work for you?

danillll
2009-02-22, 00:06
Currently, you need to use ps3d.py (http://www.xbmc.org/trac/browser/branches/linuxport/XBMC/tools/EventClients/Clients/PS3 Sixaxis Controller/ps3d.py) (executed as root) to have it autoconnect after initial pairing.

when you mentioned "initial pairing", can you elaborate please, do I need to do other steps from just running ps3d.py ? do I need to pair it with linux directely?
If yes, how would I do it from a command line? I am using the live version.

Thanks

d4rk
2009-02-24, 23:43
when you mentioned "initial pairing", can you elaborate please, do I need to do other steps from just running ps3d.py ? do I need to pair it with linux directely?
If yes, how would I do it from a command line? I am using the live version.

Thanks

By initial pairing, I mean pairing it once using the ps3_remote.py program. When you run that program, it will prompt you to press start + enter, which will initiate pairing.

pilophae
2009-03-22, 14:10
I just recently began using XBMC, which is awesome by the way, and bought a PS3 BD Remote for use with XBMC. I use xmbc-linuxport r18760 in Ubuntu 8.10.

The remote works well with ps3_remote.py, but I can't use it at all with bdremoted and ps3d.py doesn't seem to have any effect on operation. However, sporadically the remote times out and won't reconnect even if pressing Enter + Start and/or running ps3d.py concurrently with ps3_remote.py. It doesn't even show up on Bluetooth inquiries until I "reboot" it by replacing the batteries.

Has anyone else experienced this?

I have also read that the remote is supposed to send its keypresses even when not paired, but hcidump does not show any unsolicited traffic.

freezy
2009-03-30, 15:44
Folks,

I still have a little problem understanding the relation between ps3d.py and ps3_remote.py. From the README.txt:
The remote needs to be paired initially with the 'ps3_remote.py'
program in this directory which you can continue using if you do not
want to run 'ps3d.py' as root.
By "initially" I guess that means on every reboot? I don't mind running ps3d.py as root since it's only the HTPC box, so does this mean I don't need ps3_remote.py?
The disadvantage of using
'ps3_remote.py' is that pairing is required on every run. Once initial
pairing is done, 'ps3d.py', when run as root, will automatically
detect incoming connections from both the PS3 remote and the Sixaxis
controller.Is the "disadvantage" a fact, or does it only apply in the case where I don't want to run ps3d.py as root? Though you talk about running ps3d.py as root and pairing with ps3_remote.py, so I assume that you have to use it in any case? Again, "every run" means every system startup?

So is it correct that the only automatic solution (aka: "boot, start xbmc and the remote works") would be to put ps3_remote.py into a startup script as danilll (http://xbmc.org/forum/showpost.php?p=282842&postcount=21) suggests? But then why does it call it every 10 seconds, why not just once? As far as I understand, ps3_remote.py loops until the remote is paired.

As you may noticed, I'm pretty confused. ;) It would be great if someone could roughly describe what each of the two scripts is designed for, and what scenarios of usage there are for a remote control.

Cheers,

-freezy.

freezy
2009-03-30, 15:47
Oh and don't get me wrong: At the moment, running ps3_remote.py on the shell, it works great. Just looking for an automatic solution and a global understanding of this EventClient implementation.

pilophae
2009-03-31, 20:17
My problem was apparently that the batteries drain due to that the remote keeps being connected unless you disconnect it with the PS-button. However, the ps3remote.py script does not recognize that the remote has shut down, and the only way to recover is to restart ps3remote.py.

I gather that ps3d.py is supposed to remedy this, but it doesn't even register the remote, paired or not.

I see now that the remote does indeed generate BT events when not paired. :o

freezy
2009-04-09, 01:06
Is there anyone having the BD remote working correctly? Meaning:

Remote control needs to be paired at most once after (re)boot
Remote's batteries aren't drowned when not used
Remote doesn't "crash" so I have to remove the batteries

I tried bdremoted, but nothing. Starts up, LIRCd connects to it, irw displays nothing. Also tried to stop bluetoothd before, with and without hidd enabled and some more stuff I found at the Ubuntu forums.

Using EventClient from XBMC with ps3_remote.py gets it going but it's very unstable. It disconnects after 3-10 minutes (while using it), where I can only reactivate it by removing a battery and pairing it again (same issue as pilophae). Sometimes it lasts longer but in any case, the next day I have to pair again, which is pretty painful (pressing Start+OK for FIVE seconds, WTH!).

And I had no success with ps3d.py either. I'm still not really sure what it's supposed to do though (see my last post).

pilophae, do you have it working now? Does anyone else have similar experiences? I love the reaction time and the smoothness even when wandering around, but like this it's not very satisfactory. Any hints appreciated!

Cheers,
-freezy.

pilophae
2009-04-09, 10:38
freezy: It works for as long as the batteries last, and I don't disconnect it with the PS button. I am using ps3_remote.py.

Since ps3d.py listens to the unpaired traffic generated by the remote, it should work in theory, but it doesn't seem to register any traffic at all for me.

bluey
2009-04-26, 16:41
Do you use an usb dongle to connect with your remote? Maybe you are affacted by the new btusb driver which replaced hci_usb since 2.6.27. Please check dmesg while you connect to your remote.

https://bugs.launchpad.net/ubuntu/+source/linux/+bug/268502?comments=all

pakojones
2009-05-10, 12:44
Hi,

If you are interested, I have made a guide to setup the PS3 remote using LIRC without need to pair it every reboot

http://xbmc.org/forum/showthread.php?t=50717

J.

pilophae
2009-05-10, 17:27
@pakojones: I don't have an issue with pairing (anymore), it's the power saving feature of the remote that does not work with the Event Server script.

Also, do you have to run the applet to have Blueman automatically pair your remote, or is there some kind of shell alternative?

@bluey: I'm not affected by that bug.

Zapa
2009-06-16, 01:05
Have the same thing here, runnign XBMC Live 9.04.1

Running this works, I can pair the remote and everything
python /home/xbmc/EventClients/Clients/PS3\ BD\ Remote/ps3_remote.py localhost &> /etc/init.d/start_remote.log

Then I press ctrl-c and run this (as root):
python /home/xbmc/EventClients/Clients/PS3\ Sixaxis\ Controller/ps3d.py 00:21:4F:B1:1A:80 localhost &> /etc/init.d/start_remote.log
Nothing happens

After pressing ctrl-c the log file looks like this:
Connecting to Bluetooth device: 00:21:4F:B1:1A:80
Connecting to : localhost
Starting HID daemon
Traceback (most recent call last):
File "/home/xbmc/EventClients/Clients/PS3 Sixaxis Controller/ps3d.py", line 420, in <module>
main()
File "/home/xbmc/EventClients/Clients/PS3 Sixaxis Controller/ps3d.py", line 416, in main
start_hidd(bdaddr, ipaddr)
File "/home/xbmc/EventClients/Clients/PS3 Sixaxis Controller/ps3d.py", line 357, in start_hidd
if hid.listen():
File "/var/lib/python-support/python2.6/xbmc/bt/hid.py", line 32, in listen
(self.client_csock, self.caddress) = self.csock.accept()
File "/usr/lib/python2.6/dist-packages/bluetooth/bluez.py", line 129, in accept
client, addr = self._sock.accept ()
KeyboardInterrupt


am I doing somehting wrong here?

pilophae
2009-06-16, 09:14
@Zapa: What are you trying to do? Without knowing what you expect to be right, we can't answer you about what is wrong.

Also, do NOT write program output to any file in /etc, EVER. /var/log or /tmp are more suitable locations for logging.

Zapa
2009-06-16, 09:34
Im trying to use the PS3 remote without pairing after reboot, thats how I understood using ps3d.py would work.

I can pair the remote using ps3_remote, and control XBMC, then I press ctrl-c to exit the ps3_remote thread and run ps3d.
Then I would expect the ps3d script to work just like the ps3_remote (without having to pair again)

When this works, I will put the ps3d into the .sh file (like danillll wrote in post 21) so, the remote is usable without pairing or manuel start after reboot.

Will move the logs to /tmp, being newish to these kind of linux operations, /etc seemed as good as any other place :) thats where the .sh file was placed, so the log was easy to open there

Hope that explains it abit better and thanks for responding :)

pilophae
2009-06-16, 09:46
I don't think we have any testimonies of a working ps3d.py for the remote. Closing the ps3_remote.py script will definitely disconnect the remote from the Bluetooth stack, so it seems meaningless to start it and stop it before ps3d.py since it does not change the hardware status.

If your batteries last your entire session, I find that pressing Start + Enter every once in a while isn't such a hassle.

Zapa
2009-06-16, 10:29
Yes, it's not that bad to pair after starting, I just haven't given up on the automatic solution yet :)

The readme (http://xbmc.svn.sourceforge.net/viewvc/xbmc/branches/linuxport/XBMC/tools/EventClients/README.txt) mentions that you have to disable existing HID servers, not sure what that is though, I haven't disabled anything...

It also mentions, that for the ps3 controller, you have to use sixaxis.c for pairing, after that ps3d.py should work here aswell, think I will test that when I get home

Zapa
2009-06-16, 10:44
There are also signs of life when looking in the repository (http://xbmc.svn.sourceforge.net/viewvc/xbmc/branches/linuxport/XBMC/tools/EventClients/Clients/PS3%20Sixaxis%20Controller/ps3d.py?view=log) ps3d.py was updated a month ago, with comments about "PS3 BluRay
remote"

TREX6662k5
2009-06-23, 20:12
This is with the original bluetooth init.d script disabled to start bdremote before hcid and lircd. hcid modprobes rfcomm for you.

log_daemon_msg "Starting Bluetooth Remote HID"
start-stop-daemon --start --quiet --exec /usr/local/sbin/bdremoted -- -p 8888 -a 00:19:C1:5A:F1:3F -t 3
start-stop-daemon --start --quiet --exec /usr/sbin/hcid -- -x -s
start-stop-daemon --start --quiet --exec /usr/sbin/lircd -- -H null --connect 127.0.0.1:8888

Edit /etc/bluetooth/hcid.conf to your liking (eg, disable iscan, pscan enabled, change pin etc)

Remember to pair it once
hidd --connect 00:19:C1:5A:F1:3F

If needed add this to /etc/modprobe.d/options
options hci_usb reset=1

menno
2009-07-01, 14:54
I am about to buy this remote, but there seem to be these two very
imporant issues still standing.
As in

- reboot = need to re-"pair"
- battery drain = cause of no time-out

is it fixable?

Zapa
2009-07-01, 14:57
well, I gave up, and got myself a MCE remote instead which worked out of the box

TREX6662k5
2009-07-01, 19:47
Meno if you use BDremote you only need to pair it once and it supports timeout. There is a little delay as the connection is re-established.

The hard part is getting it to work. Works for me, your millage may vary.

LAGMonkey
2009-07-03, 21:46
well i cant get the blooming program to work.

bdremote-0.2 just dosnt do squat and ive followed all the guides i can fine (even ones in NORWEGIAN! i cant read norwegian)

im running full fat ubuntu jaunty 9.04.
Bluetooth dongle is a Microsoft Trans. v3. (orignally from wireless presenter mouse 8000 then using MS software to change the dongle to "hardware mode" although i still see the mouse in proc/bus/input/devices)

to get the dongle to even start i had to run;
hciconfig hci0 reset

in /etc/ro.local

now i have libbluetooth-dev installed but when i go to make bdremote-0.2 it gives me...
bdremoted.c: In function ‘main’:
bdremoted.c:138: warning: ignoring return value of ‘nice’, declared with attribute warn_unused_result

and i cant get any output from irw. i even tried pakojones's way (http://www.xbmc.org/forum/showthread.php?t=50717) and i can get the remote to connect but then it wont output to cat /proc/bus/input/devices

the only way i can get a device in cat /proc/bus/input/devices i have to manually connect via hidd --connect.

then i dont get
H: Handlers=kbd event8

but
H: Handlers=event8

TREX6662k5
2009-07-16, 16:33
Haven't experienced your make problems before, though I think I read somewhere that newer ubuntu's or libbluetooth-dev maybe incompatible. I'm running on Hardy.

In post #43 is part of a init.d script to get it working. Remember to pair it once.