Archive:Set up Streamzap PC Remote for Linux

From Official Kodi Wiki
Jump to navigation Jump to search

Introduction

This page is all about getting the Streamzap PC Remote to work completely with XBMC. Currently it includes only information on how to configure Streamzap on Linux.

There are two ways you can set up Streamzap to work with XBMC on Linux.

  • lircd
  • inputlirc

LIRCD and Inputlirc Conflict

If you run LIRCD and Inputlirc they will conflict with each since when it comes to ownership /dev/lircd. That is service that runs last gets control of it (and on Ubuntu that services always seems to be inputlirc). You can check it out for yourself by restarting either service and the doing ls -la /dev/lircd.

So please make sure only one is running at one time.

Disclaimer

The setups described below worked for me without damaging anything at the time. However, I make no guarantees that it won't blow up your computer or run away with your significant other.

Linux Distros, XBMC and LIRC Implementation and Versions Tested

LIRCD:

  • Gentoo and XBMC 9.11 (Camelot) and official app-misc/lirc-0.8.7 from portage
  • Ubuntu 10.04 and XBMC 9.11 (Camelot)
  • Ubuntu 10.10 and XBMC 10.0 (Dharma RC1) [buggy, but has workaround, see below]

Inputlirc:

  • Ubuntu 10.10 and XBMC 10.0 (Dharma RC1) [buggy, no workaround yet, see below]

Drivers

Streamzap PC Remote is well supported in linux. However, I have seen drivers named differently. Here are the variations I've run into:

  • lirc_streamzap
  • streamzap (new ir_core implementation?)
  • rc_streamzap (new ir_core implementation?)

The configuration of LIRCD I've used in the past combine streamzap with lirc_dev.

Ubuntu 10.10 Bugs and Workarounds

In Ubuntu 10.10, pressing any button on the remote will send the event twice to the system. The cause is not completely clear to me but it seems it due to the fact that both the new and the old drivers currently compiled into the kernel are sending events to the input system.

Bug has been filed and fix is still pending: https://bugs.launchpad.net/ubuntu/+source/lirc/+bug/663651
There is also a forum thread on this: http://ubuntuforums.org/showthread.php?s=68f4cf4da940af13a8e70457b034938d&t=1595018

Workarounds:

There is a workaround if you are using a LIRCD setup using a socket (not uevents), which works by disabling the Streamzap XInput Keyboard device so the events from the remote are not sent to X. However, for some reason disabling XInput device does not work when using Inputlirc since it uses the same input system.

LIRCD

Introduction

LIRC is a package that allows you to decode and send infra-red signals of many (but not all) commonly used remote controls. The most important part of LIRC is the lircd daemon that will decode IR signals received by the device drivers and provide the information to the system.

LIRCD is versatile and can be configured to received from either a simple device node like /dev/lirc0 or from any device in /dev/input/ layer and to write either to a socket or to generate Linux input events. This tutorial currently only covers the default setup of reading from /dev/lirc0 device node and writing to socket /dev/lircd socket.

Installation and Configuration

Starting with LIRC 0.7.1 streamzap configuration has been included in the base package.

Ubuntu

During the install when prompted to select the IR Receiver, scrolldown and select "Streamzap PC Remote.

sudo apt-get install lirc

It is very likely that lirc is already installed on your system. In that case, run the following to configure it.
When prompted to select the IR Receiver, scrolldown and select "Streamzap PC Remote.

sudo dpkg-reconfigure lirc

The configuration will setup the following files like so:

/etc/lirc/hardware.conf

REMOTE="Streamzap PC Remote"
REMOTE_MODULES="lirc_dev streamzap"
REMOTE_DRIVER=""
REMOTE_DEVICE="/dev/lirc0"
REMOTE_SOCKET=""
REMOTE_LIRCD_CONF="streamzap/lircd.conf.streamzap"
REMOTE_LIRCD_ARGS=""

...

START_LIRCD="true"


/etc/lirc/lircd.conf

...

#Configuration for the Streamzap PC Remote remote:
include "/usr/share/lirc/remotes/streamzap/lircd.conf.streamzap"

Fixing Ubuntu 10.10: Duplicate Keypresses Issue

In Ubuntu 10.10, pressing any button on the remote will send the event twice to the system (see details here: #Ubuntu 10.10 Bugs and Workarounds). Since the new Xorg server used in Ubuntu 10.10 adds Streamzap as a keyboard, which then cause XBMC to react a key press twice, once to LIRCD.

Gentoo

Add streamzap to LIRC_DEVICES in /etc/make.conf

...

LIRC_DEVICES="${LIRC_DEVICES} streamzap"

Install app-misc/lirc, add it to boot, and run it.

emerge -av app-misc/lirc
rc-update add lircd default
/etc/init.d/lircd start


It works out of the box. However if you need to edit the either lircd or remote configuration, use the following files:

LIRCD config: /etc/conf.d/lircd
Remote config: /etc/lirc/lircd.conf

Configuring XBMC

The last thing you need to do is let XBMC know to what buttons to respond. This is done by editing a LIRC Map for XBMC.

nano -w ~/.xbmc/userdata/Lircmap.xml

and put the following content in:

<lircmap>
  <remote device="Streamzap_PC_Remote">
    <play>PLAY</play>
    <pause>PAUSE</pause>
    <stop>STOP</stop>
    <forward>>></forward>
    <reverse><<</reverse>
    <left>LEFT</left>
    <right>RIGHT</right>
    <up>UP</up>
    <down>DOWN</down>
    <pageplus>CH_UP</pageplus>
    <pageminus>CH_DOWN</pageminus>
    <select>OK</select>
    <back>EXIT</back>
    <menu>MENU</menu>
    <title>RED</title>
    <info>GREEN</info>
    <skipplus>>>|</skipplus>
    <skipminus>|<<</skipminus>
    <display>YELLOW</display>
    <record>RECORD</record>
    <volumeplus>VOL_UP</volumeplus>
    <volumeminus>VOL_DOWN</volumeminus>
    <mute>MUTE</mute>
    <record>RECORD</record>
    <power>POWER</power>
    <blue>BLUE</blue>
    <one>1</one>
    <two>2</two>
    <three>3</three>
    <four>4</four>
    <five>5</five>
    <six>6</six>
    <seven>7</seven>
    <eight>8</eight>
    <nine>9</nine>
    <zero>0</zero>
  </remote>
</lircmap>

Here I took liberties to map specific XBMC command to Streamzaps extra keys:

  • Display Command: YELLOW button
  • Title Command: RED
  • Info Command: GREEN Button

Inputlirc

Inputlirc is "a daemon to utilize /dev/input/event*".

Attention Ubuntu 10.10 users. There is currently a bug with using inputlirc with no workaround.See #Ubuntu 10.10 Bugs and Workarounds for more details.


UDEV Setup

First you have to create an own udev rule to ensure, that your device nodes are always the same.

We get the physical address from /proc/bus/input/devices:

cat /proc/bus/input/devices

the output is something like this:

...
I: Bus=0000 Vendor=0000 Product=0000 Version=0000
N: Name="Streamzap PC Remote Infrared Receiver (0e9c:0000)"
P: Phys=usb-0000:00:06.0-1/input0
S: Sysfs=/devices/virtual/rc/rc0/input4
U: Uniq=
H: Handlers=kbd event4 
B: EV=100003
B: KEY=3ff 0 0 0 fc000 1 0 0 0 0 18000 4180 c0000801 9e1680 0 0 0

...

What we need are the values behind Phys=. In my case usb-0000:00:06.0-1/input0

Now we write a new rules file for udev:

sudo nano /etc/udev/rules.d/10-irremote.rules

and put the following content in:

SUBSYSTEM=="input",ATTRS{phys}=="usb-0000:00:06.0-1/input0",SYMLINK="input/irremote0"

Now restart udev and trigger a new discovery:

sudo restart udev
sudo udevadm trigger

Under /dev/input should now be a symlink call irremote0:

ls /dev/input

Inputlirc Installation and Configuraiton

First you have to install inputlirc and lirc:
Please note that here we only need the lirc package because it contains "irw" and other utils. Please do not configure it for the Streamzap Remote

sudo apt-get update
sudo apt-get install inputlirc lirc

Then you need to configure it properly:

sudo nano /etc/default/inputlirc

and put the following content in:

EVENTS="/dev/input/irremote0"
OPTIONS="-c -g -m 0"

The entries under EVENTS are the devices we created via udev. The OPTION entries mean the following:

-g Grabs the input from the devices, specified under EVENTS, so that no other application interferes with it.
-m 0 By default, all keycodes below 88 are filtered out. This setting ensures, that all keycodes are captured
-c Because some of the keys on the remote are mapped to keys with modifiers, this option maps this codes to single events.


Now restart inputlirc

sudo /etc/init.d/inputlirc restart

You can now test the remote via 'irw':

irw /dev/lircd

This is some sample output from irw when pressing buttons:

6a 0 KEY_RIGHT irremote0
6c 0 KEY_DOWN irremote0
160 0 KEY_OK irremote0
8b 0 KEY_MENU irremote0
ae 0 KEY_EXIT irremote0
191 0 KEY_BLUE irremote0
18e 0 KEY_RED irremote0

Configuring XBMC

The last thing you need to do is let XBMC know to what buttons to respond. This is done by editing a LIRC Map for XBMC.

nano -w ~/.xbmc/userdata/Lircmap.xml

and put the following content in:

<lircmap>
  <remote device="irremote0">
    <play>KEY_PLAY</play>
    <pause>KEY_PAUSE</pause>
    <stop>KEY_STOP</stop>
    <forward>KEY_FASTFORWARD</forward>
    <reverse>KEY_REWIND</reverse>
    <left>KEY_LEFT</left>
    <right>KEY_RIGHT</right>
    <up>KEY_UP</up>
    <down>KEY_DOWN</down>
    <pageplus>KEY_CHANNELUP</pageplus>
    <pageminus>KEY_CHANNELDOWN</pageminus>
    <select>KEY_OK</select>
    <back>KEY_EXIT</back>
    <menu>KEY_MENU</menu>
    <title>KEY_RED</title>
    <info>KEY_GREEN</info>
    <skipplus>KEY_FORWARD</skipplus>
    <skipminus>KEY_BACK</skipminus>
    <display>KEY_YELLOW</display>
    <record>KEY_RECORD</record>
    <volumeplus>KEY_VOLUMEUP</volumeplus>
    <volumeminus>KEY_VOLUMEDOWN</volumeminus>
    <mute>KEY_MUTE</mute>
    <record>KEY_RECORD</record>
    <power>KEY_POWER</power>
    <blue>KEY_BLUE</blue>
    <one>KEY_NUMERIC_1</one>
    <two>KEY_NUMERIC_2</two>
    <three>KEY_NUMERIC_3</three>
    <four>KEY_NUMERIC_4</four>
    <five>KEY_NUMERIC_5</five>
    <six>KEY_NUMERIC_6</six>
    <seven>KEY_NUMERIC_7</seven>
    <eight>KEY_NUMERIC_8</eight>
    <nine>KEY_NUMERIC_9</nine>
    <zero>KEY_NUMERIC_0</zero>
  </remote>
</lircmap>

Here I took liberties to map specific XBMC command to Streamzaps extra keys:

  • Display Command: YELLOW button
  • Title Command: RED
  • Info Command: GREEN Button