The lucky recipient of the gift uses an older model Logitech Harmony universal infrared remote control. As the latest revision of the Shield TV ('16GB, 2017') lacks an infrared receiver, a Flirc USB was included. Flirc receives infrared commands and converts them to keypresses given by emulated USB human interface devices, such as keyboards and game controllers.
In Flirc's firmware is a built in Kodi profile that can be used with a Logitech Harmony remote immediately. The profile uses Kodi's keyboard controls. Unfortunately, the keyboard keys used do not match with other Android applications, which prevents a single Logitech Harmony activity from controlling Android TV in its entirety. In addition, the Harmony device configuration profile does not let the Android TV device sleep by default.
In this post all components (Logitech Harmony remote, FLIRC, Android TV and Kodi) are aligned so that they all work comfortably together.
Configuring the Logitech Harmony remote
Add a new device using the following information:
- Device (only needed for Harmony Remote Software): Computer -> Media Center PC
- Manufacturer: Flirc
- Model: Kodi
A Shield TV can be switched on and off using Flirc, and possibly other Android TV devices as well. In the software for the Harmony remote, the new device's power settings can be configured as follows to allow activities to switch the device on and off when necessary:
- "I want to turn off this device when (it's) not in use".
- "A button on the remote for On, and a different button for Off" / "I press two different buttons for on and for off".
- Use command "." (period) as the (only) power on command.
- Use command "PowerOff" as the (only) power off command.
This is all the configuration that is strictly necessary for the Logitech Harmony remote. It is up to the user to configure one or more activities and to map commands to buttons on the remote. An example mapping is given in Appendix A.
Ensure that any built in profiles are disabled to avoid configuration conflicts. The infrared commands in the configuration file and in the Flirc Kodi profile for the Logitech Harmony are exclusively used by Flirc and should therefore not conflict with any other devices.
In Android TV the Escape keyboard key is used for the Back command. In Kodi the Backspace key is used for this command, while Escape is used for other functions. It is possible to swap the functions of these keys in Kodi, which would make the Escape keyboard key's function consistent across both Android TV and Kodi.
Create on the Android TV device a new file,
Android/data/org.xbmc.kodi/files/.kodi/userdata/keyboard.xml. Note that the exact path can differ between devices. The file needs the following content:
<?xml version="1.0" encoding="UTF-8"?> <keymap> <global> <keyboard> <backspace>PreviousMenu</backspace> <escape>Back</escape> <escape mod="longpress"></escape> </keyboard> </global> <FullscreenVideo> <keyboard> <backspace>Fullscreen</backspace> </keyboard> </FullscreenVideo> <VideoMenu> <keyboard> <backspace>Fullscreen</backspace> <escape></escape> </keyboard> </VideoMenu> <PVROSDChannels> <keyboard> <backspace>Close</backspace> <escape></escape> </keyboard> </PVROSDChannels> <PVRSettings> <keyboard> <backspace></backspace> <escape>PreviousMenu</escape> </keyboard> </PVRSettings> </keymap>
Restart Kodi after the file is saved, and the functions of the Escape and Backspace keyboard keys should have been swapped.
Appendix A: Configuration overview
Below is an overview of the configuration between the Harmony remote and the Android TV device.
The first column concerns a reference mapping of the Harmony buttons to Harmony commands in the second column. This configuration is done in the Harmony configuration software. Note that a Harmony One was used for these columns. A different mapping might be more appropriate for other Harmony models.
The third and fourth column contain the Flirc keys mapped to Harmony commands in the second column.
The fifth column shows Android TV and Kodi functions that are available through the Harmony remote and Flirc. After configuration, the first and fifth column can be used as a reference functional mapping of user controls to system functions, hiding the technical details from the second, third and fourth columns. Note that a keyboard configuration change in Kodi is necessary for consistent use of the back key, as described earlier in this post.
|Harmony button||Harmony command||Keyboard key||Media key||Android TV/Kodi function|
|(only used by activity)||PwrOff||wake/suspend||Power off (discrete)|
|(only used by activity)||. (dot/period)||Lshift+Lctrl+Lalt+F15||Power on (discrete)|
|Channel up||PageUp||Page Up||Page up|
|Channel down||PageDown||Page Down||Page down|
|Fast forward||FastForward||Fast forward||Fast forward|
|Skip back||SkipBack||Previous||Skip backward|
|Skip forward||SkipForward||Next||Skip forward|
|LCD - Home||ParentFolder||Backspace||Previous menu / Home screen / Exit full screen|
|LCD - Full screen||FullScreen||Tab||Fullscreen playback|
|LCD - Toggle subtitles||ShowSubtitles||T||Toggle subtitles|
|LCD - Next subtitle||NextSubtitle||L||Next subtitle|
The only key combination that is special in the table is for the power on function. An Nvidia Shield TV (and possible other Android TV devices) uses the wake/suspend media key on a USB keyboard to power off, but not to power on. In fact, every other button can be used to power on the device. This is by design. It allows for discrete power buttons on universal remotes (one button for power off, another button for power on), which prevents an unintended power off when the system should be powered on and vice versa.
For the power on function, a key combination is used that is unlikely to be used for something else. If a system is already powered on, the key combination will not perform an undesired action.