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

  Thread Rating:
  • 6 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
kitlaan Offline
Member
Posts: 74
Joined: Nov 2009
Reputation: 5
Location: Massachusetts
Post: #481
Zerogoki Wrote:how do I re-pair the remote when I stopped the bluetooth service?

So either with the bluetooth service stopped and running "sudo bluetoothd -nd", OR just run the bluetooth service. Running manually is useful as it gives more debugging information. Then once you're happy, just ctrl-c out of bluetoothd, and re-start the bluetooth service.

(You may want to run the ps3_unpair script, if list-devices shows your remote.)

Then, in another console, run the ps3_pair script, and follow the instructions. There should be some indication of stuff going on in the bluetoothd output...

If it looks good, ctrl-c out of bluetoothd, and run it again. This time just hit buttons on the remote (no pairing), and it should detect...
find quote
Zerogoki Offline
Junior Member
Posts: 19
Joined: May 2010
Reputation: 0
Post: #482
Thanks again for the replay Kitlaan. I think we are getting close to the root of the problem.

So I did what you said and 1) unpaired my remote. 2) stopped the bluetooth service. 3) I started "sudo bluetoothd -nd" and in another terminal ran the pairing script. When I went back to the bluetoothd terminal screen I saw nothing when I was mashing buttons. then after about 30 sec to a min later of still mashing I saw a bunch of Got Key commands flying up the screen. so far so good (kind of, see below). I tried the "hold PS button" to disconnect and after about 20 seconds i got the following message:
Code:
bluetoothd[xxxx]: Got Key: 108 [0]
bluetoothd[xxxx]: Hangup or error on ps3remote server socket

(bluetoothd:xxxx) Glib-CRITICAL **: g_source_remove: assertion 'tag > 0' failed

I wasnt sure what this meant but after pressing a button it looked like my remote reconnected because I saw this:
Code:
bluetoothd[xxxx]: adapter_get_device(00:26:43:BA:B6:57)
bluetoothd[xxxx]: Incoming connection on PSM 17
bluetoothd[xxxx]: Incoming connection on PSM 19
bluetoothd[xxxx]: Processing PS3 device: 00:26:43:BA:B6:57
bluetoothd[xxxx]: Got Key: 108 [1]
bluetoothd[xxxx]: Got Key: 108 [0]

so disregarding the error I continued on. At this point I got the remote commands coming in through bluetooth and looks good. So next I terminated the bluetoothd and restarted it. Now when I go to press buttons, nothing. I kept pressing for like 5 mins and still nothing.



So it seems i am closer but my main problem is when I stop/start the bluetooth service my remote stops working completely. This is probably explains why when I reboot my system the remote doesnt work ( I verified uniput and the bluetooth service starts up on reboot).

My second problem (well question) is what might be the cause of the delay in my initial connection? I mean after I re-pair the remote I would think it would already be connected and sending commands immediately but it takes like I said about 30 sec to a full min before I see the remote commands coming out.

Third, that funky error message when my remote disconnected. I also flipped my off switch and saw the error (see my comment in this thread here on how to add a switch to the BD remote Big Grin). but again both times when I turned my remote back on and pressed a button, I saw the Got Key commands again.
find quote
vonb3ta Offline
Junior Member
Posts: 10
Joined: Jun 2010
Reputation: 0
Location: Switzerland
Post: #483
Hi guys I have basically been following the EXACT steps Zerogoki has been following, but am also getting the exact same responses, here is what I have done:

First I entered the commands:
Code:
sudo nano /etc/apt/sources.list

Then added:
Code:
deb http://ppa.launchpad.net/kitlaan/ppa/ubuntu jaunty main
deb-src http://ppa.launchpad.net/kitlaan/ppa/ubuntu jaunty main

At the top, then Ctrl+X, saved and exited. Followed by these commands:
Code:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 6F7177CC
sudo apt-get update

After this I followed Zerogoki's footsteps:

Zerogoki Wrote:here are the commands I run:
Code:
sudo apt-get update
sudo apt-get install bluez
sudo apt-get install bluez-utils
sudo apt-get install build-essential
sudo apt-get install libbluetooth-dev

next I get the ps3pair files and link it

Code:
wget http://kitlaan.twinaxis.com/holdingcell/ps3pair.tar.gz
tar xvfz ps3pair.tar.gz
cd ~/ps3pair
sudo python ps3_pair.py

after it is done I start the uinput module. now I am not sure if order matters but I just keep playing with these to get the remote to "sort of" work.

so from what I gathered this starts the module
Code:
sudo modprobe uinput

these commands let me know when it is working
Code:
lsmod | grep uinput
/usr/share/doc/bluez/examples/list-devices
cat /proc/bus/input/devices | grep emot


once I got it connected the directional buttons work (ie. up and down cycle through my previous commands and enter well is enter).

I also go into the /etc/modules and add iunput to the file at the end.

Code:
sudo nano /etc/modules

in the file i add uinput to the end and so it looks like this:
Code:
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.

loop
lp
uinput

save it.

next I edit the config file by doing this command:
Code:
sudo nano /etc/bluetooth/input.conf
in here I add my remotes address and add a few key commands as noted in the wiki howto guide: http://wiki.xbmc.org/index.php?title=HOW..._BD_Remote

so I figure at this point I should be good to go. well when I restart and load XBMC none of my remote buttons work (not even the up and down keys like it did in the terminal mode). So I am not sure what I am doing wrong. I even try holding start and enter to let the remote go into pairing mode but still nothing after mashing buttons like crazy.

At this point every time I enter:
Code:
sudo python ps3_pair.py
It says the remote is already paired, I have tried to Un-Pair it and re-Pair it but nothing.

When typing
Code:
/usr/share/doc/bluez/examples/list-devices
It shows the PS3 remote, but:
Paired 0
Connected 0
Trusted 1

====> Laugh THE BREAKTHROUGH

After reading the other threads, I tried:
Code:
hciconfig hdi0 lm ACCEPT,MASTER
Suddenly the remote arrows and enter started working again, Ctrl+Alt+F1 back to XBMC and the remote worked.

I am going to try to add hciconfig hdi0 lm ACCEPT,MASTER to rc.local and see if I can get this to load every startup.

Zerogoki, you might want to try and put in the terminal
Code:
hciconfig hdi0 lm ACCEPT,MASTER
Then try and play around with the remote to see if you can get it working as well.

If and when I get this working I will write up a Tutorial for XBMClive users, or I will try to write a script as well
find quote
Zerogoki Offline
Junior Member
Posts: 19
Joined: May 2010
Reputation: 0
Post: #484
Hey vonb3ta,

Thanks for the info. Actually I have got the remote working (with and without setting the hci0 to MASTER) and have seen it work in XBMC (for me is Ctrl+Alt+F7) when I go back to that screen (see my previous comment above). The problem I am having is after I get the remote working and stop and start the bluetooth service, the remote doesnt reconnect automatically. I have to run the unpair and then the pair script again to get it to work again. Does yours work if you stop/start the bluetooth service ("sudo /etc/init.d/bluetooth stop" then "sudo /etc/init.d/bluetooth start") or if you restart the system?

I did as you suggested and tried setting the hci0 from SLAVE to MASTER after I re-started the bluetooth service (since if I do it before I start the bluetooth service it defaults back to SLAVE) when the remote was working but still the remote never connects again. If I unpair and pair the remote it works again (after about 30 sec of waiting I see my commands).


I ran the "/usr/share/doc/bluez/examples/list-devices" and here is what it says when the remote is working:

Code:
[/org/bluez/xxxx/hci0 ]
    Name = Broadcom BCM2035
    Powered = 1
    Devices = dev_00_26_43_BA_B6_57
    DiscoverableTimeout = 0
    PairableTimeout = 0
    Discoverable = 0
    Address = 00:18:F8:89:8B:8D
    Discovering = 0
    Pairable = 1
    Class = 4849664
    UUIDs = 0x1115 0x1117 0x1116 0x1112 0x111f 0x110a 0x110c 0x110e
    [ /org/bluez/xxxx/hci0/dev_00_26_43_BA_B6_57 ]
        Name = BD Remote Control
        Paired = 0
        Adapter = /org/bluez/xxxx/hci0
        Alias = BD Remote Control
        Connected = 1
        UUIDs = 0x1124 0x1200
        Address = 00:26:43:BA:B6:57
        Class = 0x00250c
        Trusted = 1

Now the only part that has me concerned is the Paired = 0. Maybe this is why it doesnt work between bluetooth sessions.
find quote
Zerogoki Offline
Junior Member
Posts: 19
Joined: May 2010
Reputation: 0
Post: #485
GOOD News!! (for the most part), I some how got my remote to auto connect when I stop/start the bluetooth service. I also got it to work across reboots (yay).

here's what I did. I was reading through faxo comments in post #395 and for some reason I started playing with the "sudo hcitool" commands. I stop and started the bluetooth service (so my remote wasnt working_ and I did an "sudo hcitool cc 00:26:43:BA:B6:57 " which posted some error

Code:
[   490.976695] hci_cmd_task: hci0 command tx timeout
but after that the remote worked!! not sure what i did but to make sure I wasnt going crazy I tried it again, and IT WORKED as soon as the error message popped up. Just for kicks I did a restart, hit "Ctrl+Alt+F1" logged in and typed in my "sudo hcitool cc 00:26:43:BA:B6:57" again. remote worked!!

I kept playing around with this procedure and after looking at other commands it seems that sudo hcitool <almost anything> 00:26:43:BA:B6:57 " makes the remote work (like running that tool does or sets something up that makes everything fall into place).

So I went into the /etc/rc.local and just added my command (I added "sudo hcitool name 00:26:43:BA:B6:57") just above the "exit 0" and saved it. did a restart and poof! remote works as soon as I am in XBMC.

Well thats one for the books..

I did however download h00s' ps3bdremote file and played with it before getting this to work but I really dont think it did anything for me. So I am going to do a clean install of XBMC live and create a list of commands/steps I did and if I get it working ill post it and have a nice cold beer. Thanks to everyone that helped in getting me this far, if all goes well phase 2 will be getting the buttons setup as I want. but one step at a time.

p.s. I also tested doing "/etc/init.d/bluetooth stop" then "sudo bluetoothd -nd" to see the commands (I had to go into another screen and do my magical "sudo hcitool name 00:26:43:BA:B6:57" command and when I went back to the bluetoothd debug screen I saw my command. I also verified that the time out works too (still getting that weird GLib-CRITICAL" error I posted above but at this point I dont care).
(This post was last modified: 2010-06-10 21:55 by Zerogoki.)
find quote
Zerogoki Offline
Junior Member
Posts: 19
Joined: May 2010
Reputation: 0
Thumbs Up  XBMC Live 9.11 with PS3 BD Remote , Yes it really works!
Post: #486
So.... I did everything from scratch and bibbity bobbity boo, wam bam thank you mam, the remote works in XBMC live!

Here are the step by step instructions I took to get this working. I pretty much did this on my machine while typing this up so I shouldnt be missing anything.


Install XBMC live to a harddrive or USB drive.

After you boot into XBMC for the first time just hit "Ctrl+Alt+F1" to get to the first screen's terminal. Log in using the username password you setup when installing XBMC.

Now the first then we are going to do is an update and install all the software we need for this.

Code:
sudo apt-get update
Note it will ask for your password again. just re-enter it.


Code:
sudo apt-get install python-software-properties
this is to use the automated repository downloading command on next line. say "yes" when it asks you are you sure on the download.

Code:
sudo add-apt-repository ppa:kitlaan/ppa
here you should see some long executing text and then a imported: 1 (RSA: 1) at the end. If this doesnt work you might have to manually add the repository.

Code:
sudo apt-get update
I do this to refresh the list again.

Code:
sudo apt-get install bluez python-bluez python-dbus
This will install the Bluez packages as well as other packages we will need. Again, say "yes" to the downloads.




Next we will setup the "uniput" module which is what sends the remote commands into the kernel.

Code:
sudo modprobe uinput
this starts just the uinput module in the current session.

Code:
sudo nano /etc/modules
when the file opens, add "uinput" (without quotes)at the bottom just after "lp" so the uinput module starts up automatically on reboots from now on. save it by doing ("Ctrl+X" then "Y" and "enter")

At this point bluetooth should be installed and running. you can confirm by doing: "sudo /etc/init.d/bluetooth status". It should say bluetooth is running.





Next let start the pairing process.

Code:
wget http://kitlaan.twinaxis.com/holdingcell/ps3pair.tar.gz
This will download kitlaan's pairing script.

Code:
tar xvfz ps3pair.tar.gz
will extract it.

Code:
sudo python ps3pair/ps3_pair.py
This command will being the pairing.

Just to note normally before I run this I like to start holding down the start+enter keys on the remote for a few seconds before I press enter. If it finds something it will post the address with the name (note sometimes the remote's name at first comes up as [unknown]. If only 1 thing comes up just type 1 and enter. It should register the device followed by a "done".

Now if you press the up button on the remote and nothing happens after like a minute (it should cycle through your commands send so far); try this:

Code:
sudo hcitool name xx:xx:xx:xx:xx
where the xx's are your remote's address (you should see it when the pairing script ran, you might want to make a note of the address somewhere). After entering that, pressing the up and down buttons should now work.



Next we will update the bluetooth input file.

Code:
sudo nano /etc/bluetooth/input.conf

Here you want to see the remote's config info. what we want to do is replace where it has [11:22:33:44:55] with your remote's address. dont forget to uncomment the line (remote the # just before it) so it runs when the script runs. If you wnat the remote to time out after lets say 30 seconds, uncomment the line just below that says IdleTimeout=30 (note you can change this to anything you want).


For now lets just skip the editing of the buttons. lets make sure everything is working so far.

Before we restart there is one last thing we should add that I need to get it working 100% . We will open the rc.local file add add the hcitool command to this file.

Code:
sudo nano /etc/rc.local

In the file go just above the last line ("exit 0"), add the command "sudo hcitool name xx:xx:xx:xx:xx" where again the xx's are your remote's address". save it (Ctrl+X, Y, and enter) and now we should be ready for the restart. You should be able to also go back to the XBMC screen (Ctrl+Alt+F7) and see the remote work.

When you restart XBMC the remote should respond to simple commands like up, down, enter, play, and stop, etc. We will need to customize the input.conf and/or key mappings xml file to fully use all the keys.



I just wanted to add that I noticed that when I run the pairing script the very first think I saw after my command was that "[ xxx.xxxxxxx] hci_cmd_task: hci0 command tx timeout" message which is what I get when I run the hcitool command. I am figuring this error is what I needed to have happen when the bluetooth service starts or I reboot to get the remote to work.

Again I wanted to say thanks to Kitlaan for his code and everyone else that commented in this thread on getting this working in XBMC Live. Now where is my beer!?
find quote
vonb3ta Offline
Junior Member
Posts: 10
Joined: Jun 2010
Reputation: 0
Location: Switzerland
Post: #487
thanks Zerogoki Laugh, your technique worked for me
I changed the
Code:
sudo hcitool name xx:xx:xx:xx:xx
to
Code:
hciconfig hdi0 lm ACCEPT,MASTER

Which works as well, thus no need for the Bluetooth address Nerd

Anyway I am working on a Shell Script to do all of this in an automated system as well as install any of the Aeon Skins
find quote
logistiker Offline
Junior Member
Posts: 20
Joined: Aug 2009
Reputation: 0
Post: #488
Ruff: I'm trying to apply your patch to bluez 4.66. It applies but it does not build. It builds on 4.65 correctly. Here's the error it stops on when running make:

Code:
libtool: link: x86_64-pc-linux-gnu-gcc -shared  audio/.libs/audio_libasound_module_pcm_bluetooth_la-pcm_bluetooth.o audio/.libs/audio_libasound_module_pcm_bluetooth_la-ipc.o  -Wl,--whole-archive sbc/.libs/libsbc.a -Wl,--no-whole-archive  -Wl,-rpath -Wl,/var/tmp/portage/net-wireless/bluez-4.66-r2/work/bluez-4.66/lib/.libs lib/.libs/libbluetooth.so /usr/lib64/libasound.so -lm -ldl -lpthread -lrt  -march=amdfam10 -Wl,-O1   -Wl,-soname -Wl,libasound_module_pcm_bluetooth.so -o audio/.libs/libasound_module_pcm_bluetooth.so                                                                                                                  
input/manager.o: In function `input_manager_init':                                                                                                            
manager.c:(.text+0x487): undefined reference to `debug'                                                                                                        
collect2: ld returned 1 exit status                                                                                                                            
make[1]: *** [src/bluetoothd] Error 1                                                                                                                          
make[1]: *** Waiting for unfinished jobs....                                                                                                                  
libtool: link: ( cd "audio/.libs" && rm -f "libasound_module_pcm_bluetooth.la" && ln -s "../libasound_module_pcm_bluetooth.la" "libasound_module_pcm_bluetooth.la" )                                                                                                                                                          
libtool: link: x86_64-pc-linux-gnu-gcc -shared  audio/.libs/audio_libgstbluetooth_la-gstbluetooth.o audio/.libs/audio_libgstbluetooth_la-gstsbcenc.o audio/.libs/audio_libgstbluetooth_la-gstsbcdec.o audio/.libs/audio_libgstbluetooth_la-gstsbcparse.o audio/.libs/audio_libgstbluetooth_la-gstavdtpsink.o audio/.libs/audio_libgstbluetooth_la-gsta2dpsink.o audio/.libs/audio_libgstbluetooth_la-gstsbcutil.o audio/.libs/audio_libgstbluetooth_la-gstrtpsbcpay.o audio/.libs/audio_libgstbluetooth_la-ipc.o  -Wl,--whole-archive sbc/.libs/libsbc.a -Wl,--no-whole-archive  -Wl,-rpath -Wl,/var/tmp/portage/net-wireless/bluez-4.66-r2/work/bluez-4.66/lib/.libs lib/.libs/libbluetooth.so /usr/lib64/libgstaudio-0.10.so -L/usr/lib64 /usr/lib64/libgstinterfaces-0.10.so /usr/lib64/libgstrtp-0.10.so /usr/lib64/libgstbase-0.10.so /usr/lib64/libgstreamer-0.10.so /usr/lib64/libgobject-2.0.so /usr/lib64/libgmodule-2.0.so /usr/lib64/libgthread-2.0.so -lpthread -lrt /usr/lib64/libxml2.so -ldl -lz -lm /usr/lib64/libglib-2.0.so  -pthread -march=amdfam10 -Wl,-O1 -pthread   -pthread -Wl,-soname -Wl,libgstbluetooth.so -o audio/.libs/libgstbluetooth.so                                                                                                                                                
libtool: link: ( cd "audio/.libs" && rm -f "libgstbluetooth.la" && ln -s "../libgstbluetooth.la" "libgstbluetooth.la" )                                        
make: *** [all] Error 2
(This post was last modified: 2010-06-21 21:33 by logistiker.)
find quote
vonb3ta Offline
Junior Member
Posts: 10
Joined: Jun 2010
Reputation: 0
Location: Switzerland
Post: #489
perhaps my script can help, just use the "install Ps3 remote part" as well as the pair part of the script.

http://forum.xbmc.org/showthread.php?tid=76094
find quote
kitlaan Offline
Member
Posts: 74
Joined: Nov 2009
Reputation: 5
Location: Massachusetts
Post: #490
logistiker Wrote:Ruff: I'm trying to apply your patch to bluez 4.66. It applies but it does not build. It builds on 4.65 correctly.

My latest patch now handles 4.66. The bluez code changed how debug prints worked in the last release. In addition, a bug was fixed where a crash could happen during idle disconnect (thanks Kristian!).

bluez-4.66 packages for lucid and karmic are in the build queue for my PPA. They have NOT been tested, as of this post, so user beware.
find quote
xbmc-ps3 Offline
Junior Member
Posts: 3
Joined: Jul 2010
Reputation: 0
Post: #491
Zerogoki Wrote:
Code:
sudo python ps3pair/ps3_pair.py
This command will being the pairing.

Just to note normally before I run this I like to start holding down the start+enter keys on the remote for a few seconds before I press enter. If it finds something it will post the address with the name (note sometimes the remote's name at first comes up as [unknown]. If only 1 thing comes up just type 1 and enter. It should register the device followed by a "done".

Now if you press the up button on the remote and nothing happens after like a minute (it should cycle through your commands send so far); try this:

Code:
sudo hcitool name xx:xx:xx:xx:xx
where the xx's are your remote's address (you should see it when the pairing script ran, you might want to make a note of the address somewhere). After entering that, pressing the up and down buttons should now work.


Unfortunately for me when running this it doesn't appear to pair properly, and neither running the suggested hcitool etc. or hciconfig etc. seem to fix this.

When I run /usr/share/doc/bluez/examples/list-devices immediately after the pairing command it shows (amongst other info);
Trusted=1
Connected=1
Paired=0

If I then run the /usr/share/doc/bluez/examples/list-devices command immediately after it shows;
Trusted=1
Connected=0
Paired=0

I did try to pair the dongle and remote in Windows a few times to see if this would help at all(and it does pair fine) but after doing this I have the same problems.

Anyone have any ideas that could help me out?
(This post was last modified: 2010-07-06 23:42 by xbmc-ps3.)
find quote
zagon Offline
Junior Member
Posts: 4
Joined: Jun 2010
Reputation: 0
Location: Starship Enterprise
Post: #492
xbmc-ps3 Wrote:Unfortunately for me when running this it doesn't appear to pair properly, and neither running the suggested hcitool etc. or hciconfig etc. seem to fix this.

When I run /usr/share/doc/bluez/examples/list-devices immediately after the pairing command it shows (amongst other info);
Trusted=1
Connected=1
Paired=0

If I then run the /usr/share/doc/bluez/examples/list-devices command immediately after it shows;
Trusted=1
Connected=0
Paired=0

I did try to pair the dongle and remote in Windows a few times to see if this would help at all(and it does pair fine) but after doing this I have the same problems.

Anyone have any ideas that could help me out?

Stuck on this as well, got it pair once (after a hell of a lot of tries) w/ ps3_pair. Listed in /usr/share/doc/bluez/examples/list-devices . No dice getting it to work, or unpair/pair again etc.
find quote
LAGMonkey Offline
Member
Posts: 51
Joined: Nov 2008
Reputation: 0
Post: #493
for my bluetooth dongle to work at all, i have a command issued in my /etc/rc.local file

code Wrote:hciconfig hci0 reset

Now the hci0 bit might change for you but, as i said, if i dont issue that command my Bluetooth dongle just wont work as its looking for the microsoft mouse that it came with to connect to it.
find quote
kitlaan Offline
Member
Posts: 74
Joined: Nov 2009
Reputation: 5
Location: Massachusetts
Post: #494
Yeah, I'm still confused why pairing/connection doesn't work for some people. Either there's bluetooth dongles that aren't quite right, or the bluez pair/connection logic has a hole in it that I haven't run across yet. No rhyme or reason for it that I can tell, so far.

I'm working on a bluez 4.69 patch. I also moved the patch location to a more permanent place.
find quote
xbmc-ps3 Offline
Junior Member
Posts: 3
Joined: Jul 2010
Reputation: 0
Post: #495
kitlaan Wrote:Yeah, I'm still confused why pairing/connection doesn't work for some people. Either there's bluetooth dongles that aren't quite right, or the bluez pair/connection logic has a hole in it that I haven't run across yet. No rhyme or reason for it that I can tell, so far.

I'm working on a bluez 4.69 patch. I also moved the patch location to a more permanent place.

Is there any info that we could collate that would be of use?
find quote
Post Reply