Sapphire Remote

From Official Kodi Wiki
Jump to: navigation, search

Contents

1 Sapphire Remote

Sapphire remote face.jpg

A very cheap but functional remote for Linux machines.


This remote is described here http://rtr.ca/sapphire_remote/ . It is a very nice and cheap remote. Mark Lord, the author of the above page should take all the credit, his driver is simple and simply brilliant. It requires compiling a driver and editing a couple of files, but don't worry. it's not that hard. This guide sets up the remote on a Ubuntu system, in particular these steps were tested on a new XBMCbuntu 12.0 system.

2 Steps involved

  1. Install the tools required to compile the driver.
  2. Download, compile and install the driver.
  3. Install a keymap suitable for Kodi (the driver comes programmed for mythtv).

2.1 Install the tools required to compile the driver.

Ubuntu has a virtual package called build-essential which installs the compiler tools. NB added 27 April 2013 - on XBMCbuntu you need to install gawk as well - most distros have this but XBMCbuntu is pretty cut down.

  $ sudo apt-get install build-essential
  $ sudo apt-get install gawk

The needed tools will be installed.

2.2 Download, compile and install the driver.

You need to download the latest driver from Mark's site. As at the time I am writing (8 April 2013) the latest is 4.6. Go to his website and get the most recent, and change the numbers in my example if there is a lter version.

   $ cd ~/Downloads
   $ wget http://rtr.ca/sapphire_remote/sapphire-4.6.tar.gz
   $ tar xzvf sapphire-4.6.tar.gz
   $ cd sapphire-4.6
   $ sudo make install

Some distros also need a startup script, I am not sure if ubuntu does, but no harm in doing it. Mark installs the script in /usr/local/bin/sapphire_startup.sh. To make this script run on boot, use your editor to add the command to /etc/rc.local

   $ sudo nano -w /etc/rc.local

Put the command just above the ine that says exit 0, so it will look like this:

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

/usr/local/bin/sapphire_startup.sh

exit 0

Press ^x (ctrl-x) to exit nano, answering yes to whether to save the file.

2.3 Install a keymap suitable for Kodi

Mark's driver comes with a keymap that works very nicely on mythtv, but the button presses for Kodi are different in many places. My keymap for Kodi is as follows:

#
# Default keymap from sapphire.c v3.0.
#
# Edit this as you please, keeping in mind that spaces are NOT permitted
# within each column.
#
# Eg. this is INCORRECT: KEY_F15 | ALT
# whereas this is good: KEY_F15|ALT
#
# Use the provided sapphire_keymap.sh script to install these
# mappings at runtime in place of the driver's built-in mappings.
# Keep your own copy of this file separate from the driver source,
# so that subsequent changes in the driver mappings won't clobber
# your own definitions here.
#
# As in the example above, "KeyCode" values can be combined with
# any mix of these "modifier" keys: SHIFT, ALT, CTRL, and/or META.
#
# Eg. SAPPHIRE_PLAY KEY_P|CTRL NO_REPEAT ## Mythtv Play/Pause function
# Or: SAPPHIRE_PLAY KEY_P|CTRL|ALT NO_REPEAT ## something else
#
# The "SpecialOptions" field is used to indicate the desired auto-repeat rate
# for each button individually. The choices are:
#
# NO_REPEAT - the button will not auto-repeat when held down.
# SLOW_REPEAT - the button will repeat slowly.
# RAMP_REPEAT - the button will repeat slowly at first, but speed up if held down.
# LONGKEY - no auto-repeat: special behaviour described below.
#
# The special value "LONGKEY" can be used in "SpecialOptions"
# insted of an auto-repeat setting. This causes a button on the remote
# to have two separate functions, depending upon how quickly it is released.
#
# A short-press/release gets the regular "KeyCode" value, but if the button
# is held down for one second or longer, then an alternate value can be send instead.
# Just combine the desired alternate keycode with the LONGKEY tag.
#
# Eg. SAPPHIRE_MUTE KEY_F9 LONGKEY|KEY_F15 ## Mute (tap) or Audiosync (hold)
#
# ButtonName KeyCode SpecialOptions ## Comments
#
SAPPHIRE_UP KEY_UP RAMP_REPEAT ## up (CUSTOM)
SAPPHIRE_DOWN KEY_DOWN RAMP_REPEAT ## down (CUSTOM)
SAPPHIRE_RIGHT KEY_RIGHT SLOW_REPEAT ## right
SAPPHIRE_LEFT KEY_LEFT SLOW_REPEAT ## left
SAPPHIRE_ENTEROK KEY_ENTER LONGKEY|KEY_F15 ## Select (tap) or Audiosync (hold)
SAPPHIRE_BACK KEY_ESC SLOW_REPEAT ## Back
SAPPHIRE_PLAY KEY_P|CTRL NO_REPEAT ## Play/Pause
SAPPHIRE_PAUSE KEY_P NO_REPEAT ## Play/Pause
SAPPHIRE_VOLUP KEY_KPPLUS FAST_REPEAT ## Volume Up
SAPPHIRE_VOLDOWN KEY_KPMINUS FAST_REPEAT ## Volume Down
SAPPHIRE_CHUP KEY_PAGEUP SLOW_REPEAT ## channel up (CUSTOM)
SAPPHIRE_CHDOWN KEY_PAGEDOWN SLOW_REPEAT ## channel down (CUSTOM)
SAPPHIRE_MUTE KEY_F8 LONGKEY|KEY_F15 ## Mute (tap) or Audiosync (hold)
SAPPHIRE_RECORD KEY_R NO_REPEAT ## Record/Delete (CUSTOM)
SAPPHIRE_FWD KEY_DOT NO_REPEAT ## FFwd
SAPPHIRE_REW KEY_COMMA NO_REPEAT ## Rewind
SAPPHIRE_ANGLE KEY_W NO_REPEAT ## Adjust Fill
SAPPHIRE_SAP KEY_W|CTRL NO_REPEAT ## Toggle Aspect Ratio
SAPPHIRE_DVDMENU KEY_C NO_REPEAT ## Context Menu
SAPPHIRE_INFOEPG KEY_I NO_REPEAT ## Info
SAPPHIRE_TAB KEY_END SLOW_REPEAT ## Commskip Fwd
SAPPHIRE_BACKTAB KEY_HOME SLOW_REPEAT ## Commskip Rev
SAPPHIRE_RADIO KEY_O NO_REPEAT ## Signal Monitor
SAPPHIRE_LASTCH KEY_H NO_REPEAT ## previous chan
SAPPHIRE_LANGUAGE KEY_L NO_REPEAT ## Next Audio Track
SAPPHIRE_TELETEXTCC KEY_T NO_REPEAT ## Toggle Closed-Caption
SAPPHIRE_HOMEHOUSE KEY_F18 NO_REPEAT ## jump to MainMenu (CUSTOM jumppoint)
SAPPHIRE_BLUEVIDEOS KEY_F14 NO_REPEAT ## MythVideo (CUSTOM jumppoint)
SAPPHIRE_LIVETV KEY_F16 NO_REPEAT ## Program Guide (CUSTOM jumppoint)
SAPPHIRE_REDDVDVCD KEY_F13 LONGKEY|KEY_F13|ALT ## PlayDVD/DVDMenu (CUSTOM jumppoints)
SAPPHIRE_YELLOWPICTURES KEY_F14|ALT NO_REPEAT ## Watch Recordings (CUSTOM jumppoint)
SAPPHIRE_1 KEY_1 SLOW_REPEAT ## 1
SAPPHIRE_2 KEY_2 SLOW_REPEAT ## 2
SAPPHIRE_3 KEY_3 SLOW_REPEAT ## 3
SAPPHIRE_4 KEY_4 SLOW_REPEAT ## 4
SAPPHIRE_5 KEY_5 SLOW_REPEAT ## 5
SAPPHIRE_6 KEY_6 SLOW_REPEAT ## 6
SAPPHIRE_7 KEY_7 SLOW_REPEAT ## 7
SAPPHIRE_8 KEY_8 SLOW_REPEAT ## 8
SAPPHIRE_9 KEY_9 SLOW_REPEAT ## 9
SAPPHIRE_0 KEY_0 SLOW_REPEAT ## 0
SAPPHIRE_STOP KEY_X NO_REPEAT ## Stop current playback
SAPPHIRE_POWER KEY_F2 NO_REPEAT ## start frontend (CUSTOM desktop script)
SAPPHIRE_CLEAR KEY_MACRO_0 NO_REPEAT ## Adjust audiosync by 90msecs (see below)
SAPPHIRE_GREENMUSIC KEY_A NO_REPEAT ## Adjust time stretch

There is quite a bit of stuff from mythtv in there that I haven't been bothered to edit out. You of course can edit it any way you like, but the changes I have made from the mythtv buttons are:

  • Volume Up, Volume Down & Mute to correct Kodi keys
  • DVDMenu Button to "C" - context menu
  • Radio Button to "O" - show codec info (couldn't decide which button to use for that, but Radio wasn't otherwise in use)
  • Language Button to "L" - next audio track
  • Subtitle Button to "T" - toggle subtitles
  • Stop Button to "X" - stop.

Anyway, as I say, you can set them up however you like, and take advantage of long press and the other driver features.

I put the keymap under /etc/sapphire, which you have to create.

  $ sudo mkdir /etc/sapphire
  $ sudo nano -w /etc/sapphire/keymap.xbmc

Copy and paste my keymap from above and then exit nano.

2.3.1 Option 1: Load keymap on boot

Now if all you are doing is runnning Kodi you can install this keymap on boot and it can stay there. So load the keymap on boot via /etc/rc.local as we did to load the driver above. Again using nano edit the /etc/rc.local file and add this line AFTER the line we added earlier.

/usr/local/bin/sapphire_keymap.sh /etc/sapphire/keymap.xbmc

2.3.2 Option 2: Load keymap when starting Kodi

Personally I run mythbuntu and my machine boots to mythfrontend, and I start Kodi when I want it from a muythtv menu item. Therefore I leave the default keymap as it works for mythtv. A script starts Kodi after loading keymap.xbmc, and on exit from Kodi it restores keymap.default. This is the script:

[email protected]:~$ cat /usr/local/bin/startxbmc
#!/bin/sh
/usr/local/bin/sapphire_keymap.sh /etc/sapphire/keymap.xbmc
/usr/bin/xbmc
/usr/local/bin/sapphire_keymap.sh /etc/sapphire/keymap.default

Starting at version 4.6 the following step (making /proc/sapphire world writable) is no longer necessary. It is left here for users of earlier versions.

For this to work you need to change permissions on /proc/sapphire, which I do via a simple line in /etc/rc.local:

/bin/chmod 666 /proc/sapphire

Obviously this line must come after the one that loads the sapphire module.

This page is currently a work in progress. You can see some other info here http://forum.kodi.tv/showthread.php?tid=159433&pid=1368998#pid1368998 and I'll try and create some generic info for the wiki.--Nickr 03:03, 25 March 2013 (EDT)

Personal tools
Namespaces

Variants
Actions
Navigation
Wiki help
Toolbox