We received an update from Brett R regarding his work on the BD Remote for Linux, you can read how to pair it in his previous submission.
Here is Brett's message:
I made some *very* good progress with the remote. I have a python script that can read all the button presses from the ps3-remote that works great on my laptop, but I think there's a bug or something with the version of python available for my PS3 (Ubuntu Edgy). I'm trying to work it out, I'm so close to getting it up on my PS3 it's painful. Many thanks go out to Will W. for a script that I was able to use to read the input to add the key identification part, which can be made to run just about anything instead of just printing the key identification.
I would appreciate it if you could give it a test on your system, or if you don't have the remote see if somebody you know can.
You may need the following modules installed:
libbluetooth2
libbluetooth2-dev
python-bluez
bluez-utils
(available from bluez.org)
You'll have to get your bluetooth address using the hcitool scan method, just replace my remote's address in the script. Just go to line #245, very near the bottom and swap it out.
Run the script by typing:
python remote-version0.1.py
I've posted the video of it in operation on youtube:
Hopefully that should get a little more attention and help.
- Brett
Here is remote-version0.1.py, which reads the commands from the BD Remote.
Soon we can decode the PS3 Blu-ray Disc Remote and use it's full capability in Linux. If anyone would like to help with the project please let us know and we can get you in touch with Brett.





24 comments:
some misc info, hope this helps.
seems we need some utility/drivers to map keys on the remote to some keyboard keys ... but I'm not capable of writing such driver under Windows/Linux. :p
I've notified these infos to authors of GlovePIE and RMX Automation, but so far they haven't replied my mail yet.
http://sbt.idv.tw/temp/bdremote-miscinfo.txt
http://sbt.idv.tw/temp/bdremote-capture.txt
http://sbt.idv.tw/temp/bdremote-keycode.txt
I haven't had much luck getting contact with anyone else either, which is my main reason for asking for help through KvR's blog. I'm trying to rip out the uinput interfacing code from the WMD code to plug in in place of the "xxx Key pressed" that the script currently does.
I know that the guys who put together the Wiimote drivers could do this in their sleep, as they've got a lot of stuff just to deal with the pointer, sending info to LEDs, vibrate, internal speaker and such that's not necessary for our purposes.
As I'm not a python-guru by any definition of the term, I'm having to voodoo-program this thing by cutting out everything that looks irrelevant and crossing my fingers and running the script.
http://svn.navi.cx/misc/trunk/python/uinput_test.py
looks like a great little example that I can cannibalize for some uinput interfacing capabilities.
I'll give it a try this weekend.
http://svn.navi.cx/misc/trunk/python/uinput_test.py
With some help from Matthias Blasing, who did a remote control using your java+bluetooth cellphone program, I now have the remote able to control the mouse (crudely) and press any key on the keyboard. I'm going to try and clean up the code to make it more user-friendly and put a much better video showing how smooth this is.
This makes it a great $25 remote for your media center, as you don't need line of sight (hide that LinuxMCE box!), and you've got 51 unique keys, at least 10 of which can be used together to create a unique code, consequently allowing for a unique action.
If only they put IR on this baby for universal remote control... I suppose a USB IR transmitter plugged into the PS3 could do that... but that's way too complicated for me ;)
Brett,
What can I do to help? I have no python or uinput experience, but I'm eager to get this working, and voodoo canibalization I can doo
Hi,
First, tanks a lot for this script !
I have update it to control mythtv via its telnet interface.
Just enable network control interface in your frondend config (need to restart it).
Don't forget to replace the bluetooth address in the script by your own, and run it.
You can find it here : http://xaelis.free.fr/remote-version0.2.py
Thank you for this script man. I successfully ran it on gentoo on my PS3 and it works great. I'm really looking forward for a driver that allows to get those events from /dev/input/event# or /dev/uinput.
I tried this but it returns with an error:
fcntl.ioctl(fd,uinput.UI_SET_EVBIT, uinput.EV_KEY)
IOError: [Errno 22] Invalid argument
Any ideas about?
Tried this in Python for win32, getting errors about module fcntl being nonexistant. what do I do to fix this>
Thanks for the great script. Do you know if it is possible to automatically make connection without pressing Start+Enter before start using the remote?
Hello, I have been working on PS3 remote support for linux as well. I hope this information is useful. I would like to speak with anyone that is also working on this to compare notes.
-Brandon (brandonj at xmission dot com)
First Explaination of each octet
--------------------------------
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 and 4th 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 5th Octet is always 00, except when the ENTER key is pressed, it's value is 08, and when
the PLAYSTATION button is pressed, it's value is 01. It's purpose is unknown.
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 tends to change for unknown reasons. Values seen on my remote are 03 and 02
(usually 03 when i first pair, and 02 after a couple minutes). I have seen others with a
value of 05.
Key Maps
--------
a1 01 00 00 00 ff ff ff ff ff ff 00 02 --Key Released
a1 01 00 00 00 16 ff ff ff ff ff 01 02 --EJECT
a1 01 00 00 00 64 ff ff ff ff ff 01 02 --AUDIO
a1 01 00 00 00 65 ff ff ff ff ff 01 02 --ANGLE
a1 01 00 00 00 63 ff ff ff ff ff 01 02 --SUBTITLE
a1 01 00 00 00 0f ff ff ff ff ff 01 02 --CLEAR
a1 01 00 00 00 28 ff ff ff ff ff 01 02 --TIME
a1 01 00 00 00 00 ff ff ff ff ff 01 02 --1
a1 01 00 00 00 01 ff ff ff ff ff 01 02 --2
a1 01 00 00 00 02 ff ff ff ff ff 01 02 --3
a1 01 00 00 00 03 ff ff ff ff ff 01 02 --4
a1 01 00 00 00 04 ff ff ff ff ff 01 02 --5
a1 01 00 00 00 05 ff ff ff ff ff 01 02 --6
a1 01 00 00 00 06 ff ff ff ff ff 01 02 --7
a1 01 00 00 00 07 ff ff ff ff ff 01 02 --8
a1 01 00 00 00 08 ff ff ff ff ff 01 02 --9
a1 01 00 00 00 09 ff ff ff ff ff 01 02 --0
a1 01 00 00 00 81 ff ff ff ff ff 01 02 --RED
a1 01 00 00 00 82 ff ff ff ff ff 01 02 --GREEN
a1 01 00 00 00 80 ff ff ff ff ff 01 02 --BLUE
a1 01 00 00 00 83 ff ff ff ff ff 01 02 --YELLOW
a1 01 00 00 00 70 ff ff ff ff ff 01 02 --DISPLAY
a1 01 00 00 00 1a ff ff ff ff ff 01 02 --TOP MENU
a1 01 00 00 00 40 ff ff ff ff ff 01 02 --POP UP/MENU
a1 01 00 00 00 0e ff ff ff ff ff 01 02 --RETURN
a1 01 00 10 00 5c ff ff ff ff ff 01 02 --OPTIONS/TRIANGLE
a1 01 00 20 00 5d ff ff ff ff ff 01 02 --BACK/CIRCLE
a1 01 00 40 00 5e ff ff ff ff ff 01 02 --X
a1 01 00 80 00 5f ff ff ff ff ff 01 02 --VIEW/SQUARE
a1 01 10 00 00 54 ff ff ff ff ff 01 02 --UP
a1 01 20 00 00 55 ff ff ff ff ff 01 02 --RIGHT
a1 01 40 00 00 56 ff ff ff ff ff 01 02 --DOWN
a1 01 80 00 00 57 ff ff ff ff ff 01 02 --LEFT
a1 01 00 00 08 0b ff ff ff ff ff 01 02 --ENTER
a1 01 00 04 00 5a ff ff ff ff ff 01 02 --L1
a1 01 00 01 00 58 ff ff ff ff ff 01 02 --L2
a1 01 02 00 00 51 ff ff ff ff ff 01 02 --L3
a1 01 00 08 00 5b ff ff ff ff ff 01 02 --R1
a1 01 00 02 00 59 ff ff ff ff ff 01 02 --R2
a1 01 04 00 00 52 ff ff ff ff ff 01 02 --R3
a1 01 00 00 01 43 ff ff ff ff ff 01 02 --PLAYSTATION
a1 01 01 00 00 50 ff ff ff ff ff 01 02 --SELECT
a1 01 08 00 00 53 ff ff ff ff ff 01 02 --START
a1 01 00 00 00 33 ff ff ff ff ff 01 02 -- <-SCAN
a1 01 00 00 00 34 ff ff ff ff ff 01 02 -- SCAN->
a1 01 00 00 00 30 ff ff ff ff ff 01 02 --PREV
a1 01 00 00 00 31 ff ff ff ff ff 01 02 --NEXT
a1 01 00 00 00 60 ff ff ff ff ff 01 02 -- <-SLOW/STEP
a1 01 00 00 00 61 ff ff ff ff ff 01 02 -- SLOW/STEP->
a1 01 00 00 00 32 ff ff ff ff ff 01 02 --PLAY
a1 01 00 00 00 38 ff ff ff ff ff 01 02 --STOP
a1 01 00 00 00 39 ff ff ff ff ff 01 02 --PAUSE
Keys that support multiple key combinations
--------------------------------------------
a1 01 10 00 00 54 ff ff ff ff ff 01 02 --UP
a1 01 20 00 00 55 ff ff ff ff ff 01 02 --RIGHT
a1 01 40 00 00 56 ff ff ff ff ff 01 02 --DOWN
a1 01 80 00 00 57 ff ff ff ff ff 01 02 --LEFT
a1 01 01 00 00 50 ff ff ff ff ff 01 02 --SELECT
a1 01 02 00 00 51 ff ff ff ff ff 01 02 --L3
a1 01 04 00 00 52 ff ff ff ff ff 01 02 --R3
a1 01 08 00 00 53 ff ff ff ff ff 01 02 --START
a1 01 00 10 00 5c ff ff ff ff ff 01 02 --OPTIONS/TRIANGLE
a1 01 00 20 00 5d ff ff ff ff ff 01 02 --BACK/CIRCLE
a1 01 00 40 00 5e ff ff ff ff ff 01 02 --X
a1 01 00 80 00 5f ff ff ff ff ff 01 02 --VIEW/SQUARE
a1 01 00 01 00 58 ff ff ff ff ff 01 02 --L2
a1 01 00 02 00 59 ff ff ff ff ff 01 02 --R2
a1 01 00 04 00 5a ff ff ff ff ff 01 02 --L1
a1 01 00 08 00 5b ff ff ff ff ff 01 02 --R1
UPDATE: It looks like the last octet -MIGHT- Be related to battery power (The higher the number, the more battery power). I need to do some more testing to be sure.
-Brandon
I was right, the last octet is the battery status of the remote. The highest is 5, and the lowest (empty) is 0.
http://www2.apebox.org/wordpress/wp-content/uploads/2007/09/cakemote.py
That's my latest work on the above script - uses UInput to simulate keyboard presses on BD remote presses.
The biggest lingering problem is making the binding process permanent (i.e. not needing to hold start & enter every time the script runs)
i got discovery working.
here is some code to do it.
just replace from if __name__ == '__main__':
with the following:
print "Press Start+Enter to make your remote discoverable."
name = "BD Remote Control"
address = None
nearby_devices = bluetooth.discover_devices()
for bdaddr in nearby_devices:
if name == bluetooth.lookup_name( bdaddr ):
address = bdaddr
break
if address is not None:
print "Found remote at address %s" % address
w=BDremote(address)
w.connect()
else:
print "Could not find target bluetooth device nearby"
sys.exit(1)
try:
last=time.time()
while not w.done:
w._getpacket()
finally:
w.disconnect()
Hi....
I am also trying to get this thing to work. But my major goal is to make it usable with vdr.
Until now I made some technology reviews. But am still not sure how to support it exactly. To get it working as hid device would be cool. But on the other hand a vdr plugin with simple capture would be cool enough for me.
A little note: I found out that a button press will send data as well as a key release. I also tested some presses and found similarities even unsynced.
If this turns out to be true hcidump is a good example how to capture the signals. A sync would be unnecessary in this case - of cause only if you are the only one using it in your surrounding.
A valid example keydump can be found here: http://www.xqone.de/
You may contact me for development purposes at >> bdlinux at xqone .de <<.
$ diff -urN cakemote.py cakemote.local.py
--- cakemote.py 2008-01-06 17:38:50.000000000 +0200
+++ cakemote.local.py 2008-01-06 17:57:20.000000000 +0200
@@ -529,23 +529,27 @@
#### MANUAL PS3-MOTE ADDRESS GOES BELOW!!!
####
#### Type 'hcitool scan' at a terminal prompt to get the address.
-
- # Manual Input of PS3 Remote address required for now.
- w=Ps3mote("00:19:C1:4E:DA:53",0)
-
- w.connect()
-print "Connection to remote established."
-
-print "Initializing uinput device."
-fd = init_uinput(uinput_dev)
-
-print "Press any key on the remote to test, or the circle key to exit."
+name = "BD Remote Control"
+address = None
+nearby_devices = bluetooth.discover_devices()
+
+for bdaddr in nearby_devices:
+ if name == bluetooth.lookup_name( bdaddr ):
+ address = bdaddr
+ break
+
+if address is not None:
+ print "Found remote at address %s" % address
+ w=Ps3mote(address)
+ w.connect()
+else:
+ print "Could not find target bluetooth device nearby"
+ sys.exit(1)
try:
- last=time.time()
- while not w.done:
- w._getpacket()
-
+ last=time.time()
+ while not w.done:
+ w._getpacket()
finally:
w.disconnect()
destroy_uinput(fd)
I replaced the discovery functionality to cakemote.py, but the pairing fails as follows:
$ ./cakemote.local.py
Found uinput dev at /dev/input/uinput
Scanning for PS3 remote.
Press Start+Enter to make your remote discoverable.
Found remote at address XX:XX:XX:XX:XX:XX
Attempting to pair with remote XX:XX:XX:XX:XX:XX
Traceback (most recent call last):
File "./cakemote.local.py", line 544, in module
w.connect()
File "./cakemote.local.py", line 423, in connect
self.rx.connect((self.addr,19))
File "string", line 5, in connect
bluetooth.BluetoothError: (111, 'Connection refused')
Hcidump reveals that:
> ACL data: handle 43 flags 0x02 dlen 16
L2CAP(s): Connect rsp: dcid 0x0000 scid 0x0040 result 2 status 0
Connection refused - PSM not supported
Any ideas how to fix this?
I wrote helper daemon for this remote to use it with lirc.
It works without pairing every time when you need to use it.
You can grab it here: http://tinyurl.com/282jlv
In archive you can find instructions.
Anton.
the obvious extensions would be to be able to pass the remote address and the listening port in as parameters on the command line.
will test your code this evening when i get home.
thanks for the code.
Actually, this is noted in TODO file which I added to the archive :)
command-line options and options from file.
Keep in mind, I started to write stuff yesterday and i never wrote before neither lirc-related stuff nor BT-related :)))
In principal. I wanted to add driver to the LIRC, this snapshot is kind of first iteration. Though I don't know now, is it really have sense ti integrate it to the lirc or not.
From my point of view, the most demanding is to add ability to track long key-presses and emulate multiple lirc events. Even more, I'd like to have acceleration of repeating keyevents. Like it is in Apple's frontrow.
Small update.
You have to run my lirc with command:
lircd -H null --connect 127.0.0.1:8888
BTW, I have new version, which simulates multiple keypress events , when you keep key pressed.
I'll add to it reading of file with options and command-line args and will upload.
I stablished small web-page about my implementation of BD remote driver.
You can find it at: http://antst.mine.nu/linuxdriverforsonybdremote
you have a nice site. thanks for sharing this valuable resources. keep it up. anyway, various kinds of ebooks are available here
http://feboook.blogspot.com
Post a Comment