Sony PS3 BD Remote

From MythTV Official Wiki
Revision as of 20:11, 31 March 2010 by Richard.e.morton (talk | contribs) (uinput kernel module method)

Jump to: navigation, search
Merge-arrows.gif
It has been suggested that this article or section be merged with PS3_Remote. (Discuss)
An angled view of the Sony PS3 Bluetooth remote control.

Sony uses Bluetooth for wireless controllers including the BD Remote (Blueray Disc). The makes for a decent remote option

Here are the advantages

  • Inexpensive ($25 USD)
  • Reasonable layout (51 buttons with separate arrows/seeking controls)
  • Radio Frequency operation (better range, non-line-of-sight)
  • Bluetooth pairing - multiple remotes don't interfere, no picking channels to use


Linux

Cakemote - Python script that reads key presses

bdremote - Daemon that directs bdremote data to LIRC (a cakemote successor)

myth-btremote - Daemon that supports the bd remote with mythtv's network remote infrastructure

cakemote-mythtv.py - Cakemote script tweak for myth .22 keybindings and multikey press functions removed.

ps3_pair.py and ps3_unpair.py - Python script to pair and unpair your BD Remote (requires dbus-python and pygobject python modules)

uinput kernel module method

xbmc_forum_ps3_remote - Great instructions for getting this going addresses battery issues (page 3)

HOW-TO_Setup_PS3_BD_Remote - A wiki based on the above xbmc.org forum thread. I strongly recommend that you use this method. The only XBMC specific stuff in these instructions is the sample input.conf. You will need to customize this for mythtv. Other than that, it is easier and more up to date than the instructions in the rest of this wiki entry.

The XBMC method uses an input.conf to map remote buttons to keyboard button presses. A suggested input.conf follows - remember to read the mappings and to change the MAC address


# input.conf - kitlaan custom
# Configuration file for the input service
#
# This section contains options which are not specific to any
# particular interface
[General]
#
# Set idle timeout (in minutes) before the connection will
# be disconnect (defaults to 0 for no timeout)
#IdleTimeout=30 
#
#
#
# This section contains options that are specific to a device
#
# change this MAC address to that of your paired device
# use "hcitool con" to list active bluetooth connections
[00:24:33:94:E5:4B]
#
# Set a custom idle timeout (in minutes) for this device
IdleTimeout=1   
#
# This section is the PS3 Remote keymap.  It is loaded when bluez starts.
# Use 'uinput.h' from bluez sources or '/usr/include/linux/input.h' for
# a list of possible KEY_* values.
#
[PS3 Remote Map]
# When the 'OverlayBuiltin' option is TRUE (the default), the keymap uses
# the built-in keymap as a starting point.  When FALSE, an empty keymap is
# the starting point.
#OverlayBuiltin = TRUE
#buttoncode = keypress    # Button label = action with default key mappings
0x16 = KEY_ESC            # EJECT = exit
0x64 = KEY_MINUS          # AUDIO = cycle audio tracks
0x65 = KEY_W              # ANGLE = cycle zoom mode
0x63 = KEY_T              # SUBTITLE = toggle subtitles
0x0f = KEY_DELETE         # CLEAR = delete key
0x28 = KEY_F8             # TIMER = toggle through sleep
0x00 = KEY_1              # NUM-1
0x01 = KEY_2              # NUM-2
0x02 = KEY_3              # NUM-3
0x03 = KEY_4              # NUM-4
0x04 = KEY_5              # NUM-5
0x05 = KEY_6              # NUM-6
0x06 = KEY_7              # NUM-7
0x07 = KEY_8              # NUM-8
0x08 = KEY_9              # NUM-9
0x09 = KEY_0              # NUM-0
0x81 = KEY_F2             # RED = red
0x82 = KEY_F3             # GREEN = green
0x80 = KEY_F4             # BLUE = blue
0x83 = KEY_F5             # YELLOW = yellow
0x70 = KEY_I              # DISPLAY = show information
0x1a = KEY_S              # TOP MENU = show guide 
0x40 = KEY_M              # POP UP/MENU = menu 
0x0e = KEY_ESC            # RETURN = back/escape/cancel
0x5c = KEY_R              # TRIANGLE/OPTIONS = cycle through recording options
0x5d = KEY_ESC            # CIRCLE/BACK = back/escape/cancel
0x5f = KEY_A              # SQUARE/VIEW = Adjust Playback timestretch 
0x5e = KEY_ENTER          # CROSS = select
0x54 = KEY_UP             # UP = Up/Skip forward 10 minutes
0x56 = KEY_DOWN           # DOWN = Down/Skip back 10 minutes
0x57 = KEY_LEFT           # LEFT = Left/Skip back 5 seconds
0x55 = KEY_RIGHT          # RIGHT = Right/Skip forward 30 seconds
0x0b = KEY_ENTER          # ENTER = select
0x5a = KEY_F10            # L1 = volume down
# 0x58 = KEY_F2             # L2
# 0x51 = KEY_F3             # L3
0x5b = KEY_F11            # R1 = volume up
0x59 = KEY_PAGEUP         # R2 = move up one page in watch recordings/EPG
0x52 = KEY_PAGEDOWN       # R3 = move down one page in watch recordings/EPG
0x43 = KEY_F9             # PS button = mute
0x50 = KEY_M              # SELECT = menu (as per PS convention)
0x53 = KEY_ENTER          # START = select / Enter (matches terminology in mythwelcome) 
0x33 = KEY_COMMA          # SCAN BACK =  decrease scan forward speed / play backwards; playback speed; 3x, 5, 10, 20, 30, 60, 120, 180
0x32 = KEY_P              # PLAY = play/pause
0x34 = KEY_DOT            # SCAN FORWARD decrease scan backard speed / increase playback speed; 3x, 5, 10, 20, 30, 60, 120, 180
0x30 = KEY_HOME           # PREVIOUS = commercial skip previous
0x38 = KEY_ESC            # STOP = back/escape/cancel
0x31 = KEY_END            # NEXT = commercial skip next
# 0x60 = KEY_COMMA          # SLOW/STEP BACK = jump back (default 10 minutes)
0x39 = KEY_P          	  # PAUSE = play/pause
# 0x61 = KEY_DOT            # SLOW/STEP FORWARD = jump forward (default 10 minutes)
0xff = KEY_MAX

A reboot is required to load the uinput kernel modules.

Build

At the time of this writing, bdremote is not accessible, and some might call it obsolete. Please see the Alternative Methods section above

Get latest source (0.2 at this writing), unpack, and make

cp -p bdremoted /usr/local/sbin/bdremoted

Bluetooth Address of Remote

Hold 'Start' and 'Enter' buttons on the remote

 # hcitool scan
 Scanning ...
           00:19:C1:4F:BE:64       BD Remote Control
 #

bdremote Configuration

/etc/bdremote.conf

# Port number for incoming LIRCD connections
# Default is 8888
BDREMOTE_PORT=
# Disconect timeout for remote in minutes
# Default is 60
BDREMOTE_TIMEOUT=
# Bluetooth address of remote
# Set to address obtained from 'hcitool scan'
# Leave empty to disable
BDREMOTE_ADDR=
# Key repeat rate in repeats per second
# Default is 10
BDREMOTE_RATE=
# Debug level
# Default is 0
BDREMOTE_DEBUG=

bdremote Startup script /etc/init.d/bdremote

#!/bin/sh
#
#

BDREMOTED=/usr/local/sbin/bdremoted
BDREMOTE_CONF=/etc/bdremote.conf 

test -f "$BDREMOTED" || exit 0

if [ -f "$BDREMOTE_CONF" ]; then
    . "$BDREMOTE_CONF"
fi


case "$1" in
    start)
        echo -n "Starting bdremote daemon: "
        BDREMOTE_ARGS="$BDREMOTE_ARGS ${BDREMOTE_PORT:+-p $BDREMOTE_PORT}"
        BDREMOTE_ARGS="$BDREMOTE_ARGS ${BDREMOTE_TIMEOUT:+-t $BDREMOTE_TIMEOUT}"
        BDREMOTE_ARGS="$BDREMOTE_ARGS ${BDREMOTE_ADDR:+-a $BDREMOTE_ADDR}"
        BDREMOTE_ARGS="$BDREMOTE_ARGS ${BDREMOTE_RATE:+-r $BDREMOTE_RATE}"
        BDREMOTE_ARGS="$BDREMOTE_ARGS ${BDREMOTE_DEBUG:+-d $BDREMOTE_DEBUG}"

        if [ -z "$BDREMOTE_ADDR" ]; then
           echo -n "none configured"
        else
            start-stop-daemon --start --quiet --exec "$BDREMOTED" -- $BDREMOTE_ARGS
        fi
        echo
        ;;
    stop)
        echo -n "Stopping bdremote daemon: "
        start-stop-daemon --stop --quiet --exec "$BDREMOTED"
        echo
        ;;
    restart)
        $0 stop
        $0 start
        ;;
    *)
        echo "Usage: /etc/init.d/bdremote {start|stop|restart}"
        exit 1
esac

exit 0

Configure lircd

Modify /etc/lirc/hardware.conf

# Arguments which will be used when launching lircd
LIRCD_ARGS="-H null --connect 127.0.0.1:8888"

Configure bluetooth

hidd doesn't seem to get along with bdremoted. The distribution default seems ok.

/etc/default/bluetooth

BLUETOOTH_ENABLED=1
HIDD_ENABLED=0

Enable startup scripts

# Turn on bdremote before lirc
for runlevel in 2 3 4 5; do
    ln -s ../init.d/bdremote /etc/rc${runlevel}.d/S18bdremote
done
for runlevel in 0 1 6; do
    ln -s ../init.d/bdremote /etc/rc${runlevel}.d/K82bdremote
done

Test Connectivity

Once you have bluetooth, lircd, and bdremoted up and running, it is a good idea to test that lirc is receiving signals from the remote. Simply run

# irw

and press some keys on the remote. You should see some output like:

0043 00 ps SonyBDRemote
0043 01 ps SonyBDRemote

If you don't see any output, it is likely that your BD remote has not properly paired with your computer. Some people say that

# hidd --search

while holding down start+enter on the remote will pair the remote. However, that did not work for me. Instead, I downloaded cakemote.py, edited it and entered my remote's hardware address, run it and hold start+enter on the remote. This has successfully paired the remote every time for me. irw should now print output when you press keys on the remote.

Some people may need to pair the remote each time the computer boots.

According to this bluez mailing list post, bluez-gnome can be used to permanently pair the device with your computer.

Configure Applications

# ln -s ~/.lircrc ~mythtv/.mythtv/lircrc

~mythtv/.lircrc

include ~/.lirc/mythtv

Mythtv

Some editing of mythtv key bindings required for the lircrc below through Utilities/Setup → Edit Keys
Context 	Action 	Original Setting 	New Setting 	Note
Global 	EJECT 	<none> 	Ctrl+4 	Eject Removable Media
JumpPoints 	Main Menu 	<none> 	Ctrl+1 	Main Menu
JumpPoints 	Program Guide 	<none> 	Ctrl+2 	Program Guide
JumpPoints 	TV Recording Playback 	<none> 	Ctrl+3 	TV Recording Playback
TV Playback 	SPEEDDEC 	J 	Ctrl+J 	Decrease the playback speed (match with SPEEDINC)
TV Playback 	SPEEDINC 	U 	Ctrl+U 	Increase the playback speed (avoid miskey for TV Frontend→DETAILS)
TV Playback 	STRETCHDEC 	<none> 	Ctrl+9 	Decrease time stretch speed
TV Playback 	STRETCHINC 	<none> 	Ctrl+0 	Increase time stretch speed
TV Playback 	TOGGLECC608 	<none> 	Ctrl+8 	Toggle VBI CC


~mythtv/.lirc/mythtv

##########
# LIRC mappings for mythtv

# Need to edit key for Global->EJECT
begin
    prog   = mythtv
    remote = SonyBDRemote
    button = eject
    config = Ctrl+4
end

begin
    prog   = mythtv
    remote = SonyBDRemote
    button = audio
    config = +
end

begin
    prog   = mythtv
    remote = SonyBDRemote
    button = angle
    config = W
end

# Need to edit key for desired captioning behavior, e.g.,
# TV Playback->TOGGLECC608      Toggle VBI CC
# TV Playback->TOGGLECC708      Toggle ATSC CC
# TV Playback->NEXTCC           Next of any captions
begin
    prog   = mythtv
    remote = SonyBDRemote
    button = subtitle
    config = Ctrl+8
end

begin
    prog   = mythtv
    remote = SonyBDRemote
    button = clear
    config = Backspace
end

begin
    prog   = mythtv
    remote = SonyBDRemote
    button = time
    config = F8
end

begin
    prog   = mythtv
    remote = SonyBDRemote
    button = num1
    config = 1
end

begin
    prog   = mythtv
    remote = SonyBDRemote
    button = num2
    config = 2
end

begin
    prog   = mythtv
    remote = SonyBDRemote
    button = num3
    config = 3
end

begin
    prog   = mythtv
    remote = SonyBDRemote
    button = num4
    config = 4
end

begin
    prog   = mythtv
    remote = SonyBDRemote
    button = num5
    config = 5
end

begin
    prog   = mythtv
    remote = SonyBDRemote
    button = num6
    config = 6
end

begin
    prog   = mythtv
    remote = SonyBDRemote
    button = num7
    config = 7
end

begin
    prog   = mythtv
    remote = SonyBDRemote
    button = num8
    config = 8
end

begin
    prog   = mythtv
    remote = SonyBDRemote
    button = num9
    config = 9
end

begin
    prog   = mythtv
    remote = SonyBDRemote
    button = num0
    config = 0
end

#begin
#    prog   = mythtv
#    remote = SonyBDRemote
#    button = red
#    config = XXX
#end

#begin
#    prog   = mythtv
#    remote = SonyBDRemote
#    button = green
#    config = XXX
#end

#begin
#    prog   = mythtv
#    remote = SonyBDRemote
#    button = blue
#    config = XXX
#end

#begin
#    prog   = mythtv
#    remote = SonyBDRemote
#    button = yellow
#    config = XXX
#end

# Need to edit key for TV Frontend->DETAILS
begin
    prog   = mythtv
    remote = SonyBDRemote
    button = display
    config = U
end

# Need to edit key for JumpPoints->Main Menu
begin
    prog   = mythtv
    remote = SonyBDRemote
    button = topmenu
    config = Ctrl+1
end

begin
    prog   = mythtv
    remote = SonyBDRemote
    button = popup
    config = M
end

begin
    prog   = mythtv
    remote = SonyBDRemote
    button = return
    config = Esc
end

##########

# Need to edit key for JumpPoints->TV Recording Playback
begin
    prog   = mythtv
    remote = SonyBDRemote
    button = ps
    config = Ctrl+3
end

begin
    prog   = mythtv
    remote = SonyBDRemote
    button = select
    config = Return
end

begin
    prog   = mythtv
    remote = SonyBDRemote
    button = start
    config = Space
end

begin
    prog   = mythtv
    remote = SonyBDRemote
    button = triangle
    config = M
end

begin
    prog   = mythtv
    remote = SonyBDRemote
    button = circle
    config = Esc
end

# Need to edit key for JumpPoints->Program Guide
begin
    prog   = mythtv
    remote = SonyBDRemote
    button = square
    config = Ctrl+2
end

begin
    prog   = mythtv
    remote = SonyBDRemote
    button = cross
    config = I
end

begin
    prog   = mythtv
    remote = SonyBDRemote
    button = up
    repeat = 1
    delay  = 4
    config = Up
end

begin
    prog   = mythtv
    remote = SonyBDRemote
    button = down
    repeat = 1
    delay  = 4
    config = Down
end

begin
    prog   = mythtv
    remote = SonyBDRemote
    button = left
    config = Left
end

begin
    prog   = mythtv
    remote = SonyBDRemote
    button = right
    config = Right
end

begin
    prog   = mythtv
    remote = SonyBDRemote
    button = enter
    config = Return
end

begin
    prog   = mythtv
    remote = SonyBDRemote
    button = l1
    config = Home
end

begin
    prog   = mythtv
    remote = SonyBDRemote
    button = r1
    config = End
end

# Need to edit key for TV Playback->STRETCHDEC
begin
    prog   = mythtv
    remote = SonyBDRemote
    button = l2
    config = Ctrl+9
end

# Need to edit key for TV Playback->STRETCHINC
begin
    prog   = mythtv
    remote = SonyBDRemote
    button = r2
    config = Ctrl+0
end

begin
    prog   = mythtv
    remote = SonyBDRemote
    button = l3
    config = [
end

begin
    prog   = mythtv
    remote = SonyBDRemote
    button = r3
    config = ]
end

##########

begin
    prog   = mythtv
    remote = SonyBDRemote
    button = play
    config = Space
end

begin
    prog   = mythtv
    remote = SonyBDRemote
    button = stop
    config = Esc
end

begin
    prog   = mythtv
    remote = SonyBDRemote
    button = pause
    config = P
end

begin
    prog   = mythtv
    remote = SonyBDRemote
    button = scanrev
    config = <
end

begin
    prog   = mythtv
    remote = SonyBDRemote
    button = scanfwd
    config = >
end

begin
    prog   = mythtv
    remote = SonyBDRemote
    button = prev
    config = Q
end

begin
    prog   = mythtv
    remote = SonyBDRemote
    button = next
    config = Z
end

begin
    prog   = mythtv
    remote = SonyBDRemote
    button = steprev
    config = Left
end

begin
    prog   = mythtv
    remote = SonyBDRemote
    button = stepfwd
    config = Right
end

Linux MythTV Networked Bluetooth Remote

This module follows the work of MythControl on source forge and Antion Starikov's work for the PS3 BD remote driver. The two code bases are combined into a single element.

The file can be downloaded at: myth-btremote

The setup is the same as the standard LIRC interface, apart from the LIRC configuration, except that within the archive is a file for compiling/installing the driver, and also a set of files that are listed above, i.e. /etc/myth_btremote.conf, /etc/init.d/myth-btremoted which are useful for registering the daemon as a service.

The configuration file for the remote looks like :

#enter 
#ps 
#select 
#l3 
#r3 
#start 
#up 
#right 
#down 
#left 
#l2 
#r2 
#l1 
#r1 
#triangle 
#circle 
#cross 
#square 
num1 key 1
num2 key 2
num3 key 3
num4 key 4
num5 key 5
num6 key 6
num7 key 7
num8 key 8
num9 key 9
num0 key 0
return key escape 
#clear 
#eject 
#topmenu 
#time 
#prev 
#next 
#play 
#scanrev 
#scanfwd 
#stop 
#pause 
#popup 
#steprev 
#stepfwd 
#subtitle 
#audio 
#angle 
#display 
#blue 
#red  
#green 
#yellow 


All that is needed is to uncomment a line as you decide which key you want to use, and you just assign an action that is supported by the network interface List of supported commands

Mac OS X

Not so much for free support yet

Remote Buddy

Features virtual keyboard; support for keyspan, ps3bd, wiimote; ~$20/single license, less for more

Remote Buddy - Product Page

WiiLi - GNU Linux Port to Wii: Remote Buddy


DarwiinRemote

Cocoa app to receive/data Nintendo Wii Remote

SourceForge - Source

Hiro Blog - Announcing DarwiinRemote

WiiLi - GNU Linux Port to Wii: DarwiinRemote