[LINUX] HOW-TO set up Lirc with USB HID remote controls (Hama, Auvisio)

  Thread Rating:
  • 1 Votes - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
keny Offline
Junior Member
Posts: 3
Joined: Dec 2009
Reputation: 0
Post: #1
This guide is a step-by-step manual how to make work remote controls with USB HID profile such as remote control from Hama or Auvisio. Although these remote controls work out of the box even with mouse functionality not all buttons can be used to control XBMC. That's why I am using Lirc to get as maximum as possible from this remote.

This guide follows Lirc configuration on Ubuntu, but the approach can be generalized to other Linux distribution, where hardware.conf and init script is not used.

1) Install Lirc

If Lirc is not installed, please do so with following:

Code:
sudo apt-get install lirc

2) Prepare lircd.conf

USB HID remotes don't behave as Infra devices. Each button is identified as a key press. So in order to recognize the keys by Lirc, save this file http://linux.bytesex.org/v4l2/linux-inpu...lircd.conf under /etc/lirc/lircd.conf.

3) Find Phys address of your remote

Almost all guides for Lirc configure remote devices as a path /dev/input/eventX, where X can stand for any number. But I had a problem that event number changed after the restart of the computer and my remote stopped working. So we will use a different approach - Phys address. Defining Phys address will force Lirc to go through all input devices and find the correct one with matching Phys field.

Please note that USB HID remotes are using two input devices (keyboard, mouse).

Run this command and find your two USB HID devices (generally field NAME should contain HID and some numbers while other has some clever names assigned):

Quote:cat /proc/bus/input/devices

I: Bus=0003 Vendor=05a4 Product=9881 Version=0110
N: Name="HID 05a4:9881"
P: Phys=usb-0000:00:04.0-4/input0
S: Sysfs=/devices/pci0000:00/0000:00:04.0/usb2/2-4/2-4:1.0/input/input3
U: Uniq=
H: Handlers=kbd event3
B: EV=120013
B: KEY=e080ffdf 1cfffff ffffffff fffffffe
B: MSC=10
B: LED=7

I: Bus=0003 Vendor=05a4 Product=9881 Version=0110
N: Name="HID 05a4:9881"
P: Phys=usb-0000:00:04.0-4/input1
S: Sysfs=/devices/pci0000:00/0000:00:04.0/usb2/2-4/2-4:1.1/input/input4
U: Uniq=
H: Handlers=kbd mouse1 event4
B: EV=17
B: KEY=1f0000 0 2020000 3878 d801d001 1e0000 0 0 0
B: REL=103
B: MSC=10

What will we need is the Phys address: usb-0000:00:04.0-4/input0, usb-0000:00:04.0-4/input1.

4) Configure Hardware.conf
If you are running on Ubuntu and you have installed the standard Lirc package, you should have hardware.conf in /etc/lirc. All you need to do is to put the Phys address for both devices to REMOTE_DEVICE and TRANSMITTER_DEVICE. Keep the quotes as in the example below. Also configure fields TRANSMITTER_LIRCD_CONF and REMOTE_LIRCD_CONF to /etc/lirc/lircd.conf where you stored the downloaded mapping file.

Hardware.conf should look like this:
Quote:# /etc/lirc/hardware.conf
#
#Chosen Remote Control
REMOTE="None"
REMOTE_MODULES=""
REMOTE_DRIVER="devinput"
REMOTE_DEVICE="phys="usb-0000:00:04.0-4/input0""
REMOTE_LIRCD_CONF="/etc/lirc/lircd.conf"
REMOTE_LIRCD_ARGS=""

#Chosen IR Transmitter
TRANSMITTER="None"
TRANSMITTER_MODULES=""
TRANSMITTER_DRIVER="devinput"
TRANSMITTER_DEVICE="phys="usb-0000:00:04.0-4/input1""
TRANSMITTER_LIRCD_CONF="/etc/lirc/lircd.conf"
TRANSMITTER_LIRCD_ARGS=""

#Enable lircd
START_LIRCD="true"

#Don't start lircmd even if there seems to be a good config file
#START_LIRCMD="false"

#Try to load appropriate kernel modules
LOAD_MODULES="true"

# Default configuration files for your hardware if any
LIRCMD_CONF=""

#Forcing noninteractive reconfiguration
#If lirc is to be reconfigured by an external application
#that doesn't have a debconf frontend available, the noninteractive
#frontend can be invoked and set to parse REMOTE and TRANSMITTER
#It will then populate all other variables without any user input
#If you would like to configure lirc via standard methods, be sure
#to leave this set to "false"
FORCE_NONINTERACTIVE_RECONFIGURATION="false"
START_LIRCMD=""

5) Join two devices to one Lirc device

The problem is that XBMC by defaults listen on /dev/lircd for Lirc commands. But using two input device will create also another lirc device. So we have to join them together to one Lirc device. This is a simple task if you are starting the lirc daemon manually from the terminal, but that's not a usual way. Ubuntu starts Lirc automatically by script /etc/init.d/lirc. The easiest way I found so far is to modify two lines in the script to join both input devices. The disadvantage is that after Lirc package update the init script might be modified again.

Modify /etc/init.d/lirc at line 66 to
Quote:REMOTE_ARGS="$REMOTE_ARGS --output=/dev/lircd --listen"

and at line 88 to
Quote:TRANSMITTER_ARGS="$TRANSMITTER_ARGS --output=/dev/lircd --connect=localhost:8765 --pidfile=/var/run/lircd1.pid"

6) Restart Lirc and verify the functionality
Restart Lirc by executing this command:
Quote:sudo /etc/init.d/lirc restart

Then you can verify the functionality by running:
Quote:irw
And you should see the assigned names when you press a button on the remote control.

7) Configure Lircmap.xml for XBMC

Now you can map the names of the keys from 'irw' to XBMC as you like. For completeness sake I present my current configuration of Lircmap.xml:

Quote:<lircmap>
<remote device="linux-input-layer">
<power>SLEEP</power>
<start>HOMEPAGE</start>
<myTV>T</myTV>
<mymusic>M</mymusic>
<mypictures>I</mypictures>
<myvideo>E</myvideo>
<pause>PLAYPAUSE</pause>
<stop>STOPCD</stop>
<reverse>B</reverse>
<forward>F</forward>
<skipplus>NEXTSONG</skipplus>
<skipminus>PREVIOUSSONG</skipminus>
<record>R</record>
<back>BACKSPACE</back>
<info>BTN_RIGHT</info>
<left>LEFT</left>
<right>RIGHT</right>
<up>UP</up>
<down>DOWN</down>
<select>ENTER</select>
<title>BTN_MOUSE</title>
<volumeplus>VOLUMEUP</volumeplus>
<volumeminus>VOLUMEDOWN</volumeminus>
<mute>MUTE</mute>
<pageplus>PAGEUP</pageplus>
<pageminus>PAGEDOWN</pageminus>
<one>KP1</one>
<two>KP2</two>
<three>KP3</three>
<four>KP4</four>
<five>KP5</five>
<six>KP6</six>
<seven>KP7</seven>
<eight>KP8</eight>
<nine>KP9</nine>
<zero>KP0</zero>
<display>KPASTERISK</display>
<clear>ESC</clear>
</remote>
</lircmap>

Hopefully now you can enjoy controlling your HTPC with XBMC remotely from your couch.
find quote
mighty_bombero Offline
Member
Posts: 76
Joined: May 2007
Reputation: 0
Post: #2
Hi,

thanks for the guide. Used it with Karmic XBMC Live and a hama 52451 remote. Had to move to /dev/input/eventX for remote_device and and transmitter_device but otherwise it was very helpful.

mighty_bombero
find quote
Tito Offline
Junior Member
Posts: 14
Joined: Dec 2009
Reputation: 0
Post: #3
It doesnt work here, when i change /etc/init.d/lirc the rulenumbers dont match.
When i change the lines i think the needed, i get when is restart lirc and want to try with irw, connection refused.

Mighty, how did you change your /etc/init.d/lirc ?
thx
find quote
jbernardo Offline
Member
Posts: 81
Joined: Mar 2009
Reputation: 0
Post: #4
Hi Tito,
For the latest versions of lirc in ubuntu, don't change /etc/init.d/lirc, instead change /etc/lirc/hardware.conf, and both for the "REMOTE_SOCKET" and "TRANSMITTER_SOCKET" put /dev/lircd between the "", this is what I put in mine:
Code:
# /etc/lirc/hardware.conf
#
#Chosen Remote Control
REMOTE="Linux input layer (/dev/input/eventX)"
REMOTE_MODULES=""
REMOTE_DRIVER="devinput"
REMOTE_DEVICE="/dev/input/by-id/usb-073a_2230-event-mouse"
REMOTE_SOCKET="/dev/lircd"
REMOTE_LIRCD_CONF="devinput/lircd.conf.devinput"
REMOTE_LIRCD_ARGS=""

#Chosen IR Transmitter
TRANSMITTER="Custom"
TRANSMITTER_MODULES=""
TRANSMITTER_DRIVER="devinput"
TRANSMITTER_DEVICE="/dev/input/by-id/usb-073a_2230-mouse"
TRANSMITTER_SOCKET="/dev/lircd"
TRANSMITTER_LIRCD_CONF="devinput/lircd.conf.devinput"
TRANSMITTER_LIRCD_ARGS=""

This seems to work, but I am still unable to get anything out of the "mouse" wheel with irw. Everything else seems to work now.
find quote
Tito Offline
Junior Member
Posts: 14
Joined: Dec 2009
Reputation: 0
Post: #5
i get connection refused
Code:
# /etc/lirc/hardware.conf
#
#Chosen Remote Control
REMOTE="Linux input layer (/dev/input/eventX)"
REMOTE_MODULES=""
REMOTE_DRIVER="devinput"
REMOTE_DEVICE="/dev/input/by-path/pci-0000:00:04.0-usb-0:5:1.0-event-kbd"
REMOTE_SOCKET="/dev/lircd"
REMOTE_LIRCD_CONF="devinput/lircd.conf.devinput"
REMOTE_LIRCD_ARGS=""

#Chosen IR Transmitter
TRANSMITTER="Custom"
TRANSMITTER_MODULES=""
TRANSMITTER_DRIVER="devinput"
TRANSMITTER_DEVICE="/dev/input/by-path/pci-0000:00:04.0-usb-0:5:1.1-event-mouse
TRANSMITTER_SOCKET="/dev/lircd"
TRANSMITTER_LIRCD_CONF="devinput/lircd.conf.devinput"
TRANSMITTER_LIRCD_ARGS=""

#Enable lircd
START_LIRCD="true"

Code:
irw
connect: Connection refused

Its get wrong when i put, /dev/lircd in the config.
find quote
thajacabela Offline
Junior Member
Posts: 3
Joined: Dec 2009
Reputation: 0
Post: #6
you can try

Code:
irw /dev/lircd

It works for me, but also there is no code for some remote keys like the mouse buttons, or the power one, or the next/previous chapter.
find quote
jbernardo Offline
Member
Posts: 81
Joined: Mar 2009
Reputation: 0
Post: #7
Well, "irw /dev/lircd" works, but as thejacabela wrote, the mouse and the power button don't return anything.
My problem now is that even though irw shows it is working, XBMC ignores the remote. I tried changing the name of the device from "linux-input-layer" to "devinput" in Lircmap.xml, but it still isn't working. Lircmap.xml is supposed to be in ~/.xbmc/userdata, right?
find quote
thajacabela Offline
Junior Member
Posts: 3
Joined: Dec 2009
Reputation: 0
Post: #8
I think problem is /etc/init.d/lirc
because it add "1" to the TRANSMITTER_SOCKET,
then there is not the same device and some buttons don´t work in the /dev/lircd (TRANSMITTER_SOCKET will be /dev/lircd1 )

Solution could be change /etc/init.d/lirc, what I've done:

Line 83 (more or less), it said:

Code:
#Now, if we ALSO have a remote defined, add some args
#To make the second lircd connect
if [ ! -z "$REMOTE_DEVICE" ] || [ ! -z "$REMOTE_DRIVER" ]; then                        
         TRANSMITTER_SOCKET="${TRANSMITTER_SOCKET}1"
         #TRANSMITTER_ARGS="$TRANSMITTER_ARGS --connect=localhost:8765 --pidfile=/var/run/lirc/lircd1.pid"
fi

change with
Code:
#Now, if we ALSO have a remote defined, add some args
#To make the second lircd connect
if [ ! -z "$REMOTE_DEVICE" ] || [ ! -z "$REMOTE_DRIVER" ]; then
    TRANSMITTER_SOCKET="${TRANSMITTER_SOCKET}"
    #TRANSMITTER_SOCKET="${TRANSMITTER_SOCKET}1"
    #TRANSMITTER_ARGS="$TRANSMITTER_ARGS --connect=localhost:8765 --pidfile=/var/run/lirc/lir    cd1.pid"
fi


Line 157 (more or less), it said
Code:
#now if we additionally have a transmitter defined, it is secondary process
if [ ! -z "$TRANSMITTER_LIRCD_ARGS" ]; then
    /usr/sbin/lircd $TRANSMITTER_LIRCD_ARGS < /dev/null
    if [ -S "$TRANSMITTER_SOCKET" ]; then
        rm -f ${OLD_SOCKET}1 && ln -s $TRANSMITTER_SOCKET ${OLD_SOCKET}1
    fi
fi

change with
Code:
#now if we additionally have a transmitter defined, it is secondary process
if [ ! -z "$TRANSMITTER_LIRCD_ARGS" ]; then
    /usr/sbin/lircd $TRANSMITTER_LIRCD_ARGS < /dev/null
    if [ -S "$TRANSMITTER_SOCKET" ]; then
        rm -f ${OLD_SOCKET} && ln -s $TRANSMITTER_SOCKET ${OLD_SOCKET}
        #rm -f ${OLD_SOCKET}1 && ln -s $TRANSMITTER_SOCKET ${OLD_SOCKET}1
    fi
fi


Line 203 (more or less), it said
Code:
        if [ "$START_LIRCD" = "true" ]; then
        log_daemon_msg "Stopping remote control daemon(s): LIRC"
        start-stop-daemon --stop --quiet --exec /usr/sbin/lircd
        log_end_msg $?
        [ -h "$OLD_SOCKET" ] && rm -f $OLD_SOCKET                        
        [ -h "${OLD_SOCKET}1" ] && rm -f ${OLD_SOCKET}1
fi

change with
Code:
if [ "$START_LIRCD" = "true" ]; then
        log_daemon_msg "Stopping remote control daemon(s): LIRC"
        start-stop-daemon --stop --quiet --exec /usr/sbin/lircd
        log_end_msg $?
        [ -h "$OLD_SOCKET" ] && rm -f $OLD_SOCKET
        [ -h "${OLD_SOCKET}" ] && rm -f ${OLD_SOCKET}
        #[ -h "${OLD_SOCKET}1" ] && rm -f ${OLD_SOCKET}1
fi


I haven´t test it yet but I think it must work, I will test later if I've time.

In the other hand, Keny solution (thanks a lot, Keny) must work "as is" without changing hardware.conf

PD-sorry my english
find quote
thajacabela Offline
Junior Member
Posts: 3
Joined: Dec 2009
Reputation: 0
Post: #9
I've tested and doesn´t work.

But I've solved, in your /etc/init.d/lirc :

Line 83 (more or less), it said:
Code:
#Now, if we ALSO have a remote defined, add some args
#To make the second lircd connect
if [ ! -z "$REMOTE_DEVICE" ] || [ ! -z "$REMOTE_DRIVER" ]; then                        
         TRANSMITTER_SOCKET="${TRANSMITTER_SOCKET}1"
         #TRANSMITTER_ARGS="$TRANSMITTER_ARGS --connect=localhost:8765 --pidfile=/var/run/lirc/lircd1.pid"
fi

change with
Code:
#Now, if we ALSO have a remote defined, add some args
#To make the second lircd connect
if [ ! -z "$REMOTE_DEVICE" ] || [ ! -z "$REMOTE_DRIVER" ]; then
    TRANSMITTER_SOCKET="${TRANSMITTER_SOCKET}"
    #TRANSMITTER_SOCKET="${TRANSMITTER_SOCKET}1"
    #TRANSMITTER_ARGS="$TRANSMITTER_ARGS --connect=localhost:8765 --pidfile=/var/run/lirc/lir    cd1.pid"
fi

And don't change any more in the file.

Restart lirc "/etc/init.d/lirc restart" (or reboot the machine)

and try
Code:
irw /dev/lircd

I can see codes for all remote buttons
find quote
jbernardo Offline
Member
Posts: 81
Joined: Mar 2009
Reputation: 0
Post: #10
For me it still doesn't work. If I change line 83 and 84 in /etc/lircd, commenting them both, then the lirc instance for the "transmitter" won't start:
Code:
$ sudo /etc/init.d/lirc restart                                                                                                  
* Stopping remote control daemon(s): LIRC                                                                                                [ OK ]
* Loading LIRC modules                                                                                                                   [ OK ]
* Starting remote control daemon(s) : LIRC                                                                                               [ OK ]
lircd: there seems to already be a lircd process with pid 11060                                                                                  
lircd: otherwise delete stale lockfile /var/run/lirc/lircd.pid

If I only remove the "1" at the end of line 83, lirc will restart, but "irw /dev/lircd" won't show any keypresses for the mouse or the power button.

Also, the remote gets ignored by XBMC, seems like it doesn't see the Lircmap.xml in .xbmc/userdata.
EDIT: My Lircmap was corrupted. Now all I need to do is fix the detection of mouse and power button
(This post was last modified: 2009-12-17 09:14 by jbernardo.)
find quote
Tito Offline
Junior Member
Posts: 14
Joined: Dec 2009
Reputation: 0
Post: #11
The way i did is:
change hardware.conf to this
Quote:REMOTE="Linux input layer (/dev/input/eventX)"
REMOTE_MODULES=""
REMOTE_DRIVER="devinput"
REMOTE_DEVICE="/dev/input/by-path/pci-0000:00:04.0-usb-0:5:1.0-event-kbd"
REMOTE_SOCKET=""
REMOTE_LIRCD_CONF="devinput/lircd.conf.devinput"
REMOTE_LIRCD_ARGS=""
TRANSMITTER="Custom"
TRANSMITTER_MODULES=""
TRANSMITTER_DRIVER="devinput"
TRANSMITTER_DEVICE="/dev/input/by-path/pci-0000:00:04.0-usb-0:5:1.1-event-mouse"
TRANSMITTER_SOCKET=""
TRANSMITTER_LIRCD_CONF="devinput/lircd.conf.devinput"
TRANSMITTER_LIRCD_ARGS=""
START_LIRCD="true"
START_LIRCMD=""
LOAD_MODULES=""
LIRCMD_CONF=""
FORCE_NONINTERACTIVE_RECONFIGURATION="false"

and change rule 158 of /etc/init.d/lirc to:
Quote:rm -f ${OLD_SOCKET} && ln -s ${TRANSMITTER_SOCKET}1 ${OLD_SOCKET}

this will create a symlink from /var/run/lirc/lircd1 to /dev/lircd where xbmc reads from.
find quote
jbernardo Offline
Member
Posts: 81
Joined: Mar 2009
Reputation: 0
Post: #12
I don't have a separate event for mouse and keyboard. I have a event and a mouse entry in /dev/input, and that is all. My problem is that I just can't get the mouse and power buttons to do anything meaningfull. If I try to record with irrecord, I get the same values for all mouse buttons.
find quote
mighty_bombero Offline
Member
Posts: 76
Joined: May 2007
Reputation: 0
Post: #13
Tito Wrote:It doesnt work here, when i change /etc/init.d/lirc the rulenumbers dont match.
When i change the lines i think the needed, i get when is restart lirc and want to try with irw, connection refused.

Mighty, how did you change your /etc/init.d/lirc ?
thx

Hm, I changed the lines starting with REMOTE_ARGS and TRANSMITTER_ARGS as in the original tutorial (though line numbers differ on Karmic). Hope this still helps.
find quote
wonko Offline
Donor
Posts: 45
Joined: Nov 2007
Reputation: 0
Location: Germany
Post: #14
Hi,

thanks for this guide. Helped me a lot along the way. The problem I have
is that a push of a button on the remote triggers the designated command
multiple times. This happens when using the original remote as well as with my
Logitech Harmony remote.I experimented with various delay settings in the
Logitech software to no avail. Is there a way to fix this ?


Regards,

Matthias.
find quote
Redsandro Offline
Skilled Python Coder
Posts: 133
Joined: Jul 2008
Reputation: 0
Location: Netherlands
Post: #15
jbernardo Wrote:
Code:
REMOTE_DEVICE="/dev/input/by-id/usb-073a_2230-event-mouse"
Looks like we have the exact same remote (PCremote), so I copied your variation of lircd.conf.

But no matter what, I keep getting this:
Code:
$ irw
connect: Connection refused

lircd is not running after /etc/init.d/lirc is started. It doesn't give any error either.
I tried apt-get purge lirc and install it again.

Try Xubuntu. It's the new Ubuntu.
(This post was last modified: 2010-03-19 19:37 by Redsandro.)
find quote
Post Reply