Philippsen's Blog

Everyday findings in my world of .net and related stuff

Posts Tagged ‘flirc’

Using an Apple TV remote with kodi on Raspberry Pi (using Flirc)

Posted by Torben M. Philippsen on March 4, 2017

I have become a big fan of both kodi and Raspberry Pi.

On of the advantages with Kodi is that it works with HDMI cec, wich basically means that You can use Your regular tv remote since all button input signals will be transfered using Your HDMI cable – nice. On most of the tv manufacturers remote controls, the arrow and media buttons are in the bottom region of the remote. For just navigating kodi I started to search for a more simple remote. I wanted a remote of good qaility, nice design and not too expensive. And somehow that lead me into wanting to use an apple tv remote along with kodi. The apple tv remote (3rd gen.) has a simple and very nice aluminum design with just a few simple buttons used to navigate. The price is also very attractive compared to other remotes like Logitech Harmony

samsun_remoteapple-tv-aluminum-remote

Prerquistes:

 

I will not go into details of how to use flirc or kodi – but will focus on the procedure you need to go through. If You need any information about how to configure flirc, please visit their website. If You need to know more about kodi, please visit their wiki.

First step – configure the remote to work with flirc – pairing buttons

One important thing to know about flirc is that it just records keybord commands. Below is how I mapped the Apple tv remote buttons.

Button on apple tv remote Keyboard signal
Left button Left arrow
Right button Right arrow
Up button Up arrow
Down button Down arrow
Center button Enter
Menu button Backspace
Play/Pause button Space

 

Here is a complete list of Kodi keyboard commands

Second step – create kodi keymap

One of the features that makes kodi extremely flexible is that you can create keymaps. This basically means, that You can have a button work one way if you are in one menu and have the same button act in another way in some other menu. Put in another way – one button can act in different ways based on the context in the user interface. Having only seven buttons to configure this is very useful.

So the basic features that I would want to have the apple remote to support?:

  • Navigate left
  • Navigate right
  • Navigate down
  • navigate up
  • Select
  • Play/pause
  • Context menu
  • Navigate back (escaping a menu)

As you migh notice, this is eight commands for seven buttons.

I decided to have the play/pause button work in two different ways.

  1. When wathching movies etc. I want it to play/pause when pressed
  2. When items are highlighted in playlists and in the video submenu I want it to display the context menu for instance for being able to see movie information)

To make a long story short what You basically need to do is to map a keyboard command with a kodi command – and that is what You use the keymap for.

  • Create a remote.xml file
  • Paste this xml snippet

<?xml version="1.0" encoding="UTF-8"?>
<!– This file contains the mapping of keys (gamepad, remote, and keyboard) to actions within XBMC –>
<!– The <global> section is a fall through – they will only be used if the button is not          –>
<!– used in the current window’s section.  Note that there is only handling                       –>
<!– for a single action per button at this stage.                                                 –>
<!– For joystick/gamepad configuration under linux/win32, see below as it differs from xbox       –>
<!– gamepads.                                                                                     –>

<!– The format is:                      –>
<!–    <device>                         –>
<!–      <button>action</button>        –>
<!–    </device>                        –>

<!– To map keys from other remotes using the RCA protocol, you may add <universalremote> blocks –>
<!– In this case, the tags used are <obc#> where # is the original button code (OBC) of the key –>
<!– You set it up by adding a <universalremote> block to the window or <global> section:       –>
<!–    <universalremote>             –>
<!–       <obc45>Stop</obc45>         –>
<!–    </universalremote>            –>

<!– Note that the action can be a built-in function.                 –>
<!–  eg <B>ActivateWindow(MyMusic)</B>                         –>
<!– would automatically go to My Music on the press of the B button. –>

<!– Joysticks / Gamepads:                                                                    –>
<!–   See the sample PS3 controller configuration below for the format.                      –>
<!–                                                                                          –>
<!–  Joystick Name:                                                                          –>
<!–   Do ‘cat /proc/bus/input/devices’ or see your xbmc log file  to find the names of       –>
<!–   detected joysticks. The name used in the configuration should match the detected name. –>
<!–                                                                                          –>
<!–  Button Ids:                                                                             –>
<!–   ‘id’ is the button ID used by SDL. Joystick button ids of connected joysticks appear   –>
<!–   in xbmc.log when they are pressed. Use your log to map custom buttons to actions.      –>
<!–                                                                                          –>
<!–  Axis Ids / Analog Controls                                                              –>
<!–   Coming soon.                                                                           –>
<keymap>
    <Videos>
        <keyboard>
            <key id="VK_SPACE">ContextMenu</key>
            <space>ContextMenu</space>
        </keyboard>
    </Videos>
    <VideoPlaylist>
        <keyboard>
            <key id="VK_SPACE">ContextMenu</key>
            <space>ContextMenu</space>
        </keyboard>
    </VideoPlaylist>
</keymap>

VK_space is the keyboard command that kodi receives. See List of keynames that can be used in keymap for more information

  • upload the remote.xml file to your Raspberry Pi/Kodi – path: /storage/.kodi/userdata/keymaps/
  • Put flirc usb device in usb port on Raspberry Pi
  • Reboot kodi

That’s it.

 

References:

Advertisements

Posted in Books and reading stuff | Tagged: , , , | Comments Off on Using an Apple TV remote with kodi on Raspberry Pi (using Flirc)

 
%d bloggers like this: