Author Topic: [How-To][Requested] Setup MCE IR remote for use with LIRC (and thus xbmc)  (Read 4958 times)

0 Members and 1 Guest are viewing this topic.

Offline beanarooTopic starter

  • Neuling
  • *
  • Posts: 33
Some context...
My main reason for switching to Arch/Manjaro from Debian/Ubuntu was it's full systemd status. Turns out the entire distro is an amazing platform for hosting an HTPC. Quick, stable, reliable. For the purpose of writing this tutorial, I completely REFORMATTED my machine, installed Manjaro 0.8.3 along with needed video drivers and placed my MCE Remote aside, ready to be plugged in...

Disclaimer: I am new to the community, this is my first tutorial here, feedback is appreciated. I am still a noob in many aspects and my methods may not be the best way or even correct, they are based on the works and experiences of many others. I have no idea if this guide will work universally, with other versions/distros or other devices. I will try to help where I can.

The Hardware...
My Media Center Remote came in a cardboard box, labelled Hauppauge and nothing else, really.
     

After plugging the reciever in, a simple lsusb outputs the following:
Code: [Select]
Bus 006 Device 002: ID 0609:0334 SMK Manufacturing, Inc. eHome Infrared Receiver

The Process...
Just to reiterate, this is a fresh Manjaro 0.8.3 install running Kernel 3.4 we will continue as follows:
Setup ir-keytable -> Sort out Human Interface Devices -> Install & configure LIRC -> Configure XBMC


Step 1 - Making sure ir-keytable recognizes input
ir-keytable is "a swiss-knife tool to handle Remote Controllers" according to its man page. From what I understand, it interprets the scancodes received according to a predefined keytable. By running
Code: [Select]
$ sudo ir-keytable we should get output like:
Code: [Select]
Found /sys/class/rc/rc0/ (/dev/input/event6) with:
Driver mceusb, table rc-rc6-mce
Supported protocols: NEC RC-5 RC-6 JVC SONY SANYO LIRC other
Enabled protocols: RC-6
Repeat delay = 500 ms, repeat period = 125 ms
Take careful note of lines 1 and 2, we will be using the information later on. I am fortunate that the driver and keytable are automatically allocated.

Now we check what is being detected by running
Code: [Select]
$ sudo ir-keytable -t and then we start pressing each button on the remote once:
Code: [Select]
Testing events. Please, press CTRL-C to abort.
1360312866.072243: event MSC: scancode = 800f0405
1360312866.072246: event key down: KEY_NUMERIC_5 (0x0205)
1360312866.072246: event sync
1360312866.320967: event key up: KEY_NUMERIC_5 (0x0205)
1360312866.320968: event sync
1360312867.463239: event MSC: scancode = 800f0416
1360312867.463242: event key down: KEY_PLAY (0x00cf)
1360312867.463243: event sync
1360312867.710971: event key up: KEY_PLAY (0x00cf)
1360312867.710972: event sync
1360312869.210244: event MSC: scancode = 800f0420
1360312869.210247: event key down: KEY_LEFT (0x0069)
1360312869.210248: event sync
^[[D1360312869.457636: event key up: KEY_LEFT (0x0069)
1360312869.457637: event sync
1360312870.744247: event MSC: scancode = 800f0421
1360312870.744250: event key down: KEY_RIGHT (0x006a)
1360312870.744250: event sync
^[[C1360312870.990972: event key up: KEY_RIGHT (0x006a)
1360312870.990973: event sync
As you can see above, I pressed 5, Play, Left, Right. BUT, we have a problem... ^[[D and ^[[C indicate keyboard presses left and right being emulated and I can actually use my remote to move my cursor in a text box. This causes havoc when trying to scroll menus in apps like XBMC so our next step is to tell Xorg to ignore them. -> Step 2.

If you are not getting any output, chances are the wrong protocol is being used. This can be changed by means of "sudo ir-keytable -p nec,rc5,rc6,jvc,sony,sanyo", checking for output on "sudo ir-keytable -t" and then using process of elimination to find out which one your remote uses. We can make this persistent by adding it to the lircd.service file in steps to come.

If for some reason you are getting
Code: [Select]
1360312866.072243: event MSC: scancode = 800f0405
1360312866.072246: event sync
1360312867.463239: event MSC: scancode = 800f0416
1360312867.463243: event sync
1360312869.210244: event MSC: scancode = 800f0420
1360312869.210248: event sync
1360312870.744247: event MSC: scancode = 800f0421
1360312870.744250: event sync
You need to assign a table using "sudo ir-keytable -w /etc/rc_keymaps/xxxxx" where xxxxx is the table file, in my case rc6_mce. (If needed, you can create your own using an existing file as a template) We can make this persistent by adding it to the lircd.service file in steps to come.


Step 2 - Eliminating HID conflicts
This is only necessary if your remote is emulating keyboard presses. To avoid getting double movement when trying to navigate using directional buttons, we need to tell Xorg to ignore the remote and leave the job to ir-keytable.
First we need some info on our device. For this we use
Code: [Select]
$ udevadm info --export-db > ~/Documents/udev.txt
We then open the file in our favourite text editor and search for our device using the driver info from line 2 of ir-keytable. (In my case "mceusb")
We are looking for three or four sections (each being a parent of the next) relating to our device (In my case "input/event6")
Code: [Select]
P: /devices/pci0000:00/0000:00:1a.1/usb6/6-2/6-2:1.0
E: DEVICE=/proc/bus/usb/006/002
E: DEVPATH=/devices/pci0000:00/0000:00:1a.1/usb6/6-2/6-2:1.0
E: DEVTYPE=usb_interface
E: DRIVER=mceusb
E: ID_PRODUCT_FROM_DATABASE=eHome Infrared Receiver
E: ID_VENDOR_FROM_DATABASE=SMK Manufacturing, Inc.
E: INTERFACE=255/255/255
E: MODALIAS=usb:v0609p0334d0100dc00dsc00dp00icFFiscFFipFF
E: PRODUCT=609/334/100
E: SUBSYSTEM=usb
E: TYPE=0/0/0
E: USEC_INITIALIZED=89159

P: /devices/pci0000:00/0000:00:1a.1/usb6/6-2/6-2:1.0/rc/rc0
E: DEVPATH=/devices/pci0000:00/0000:00:1a.1/usb6/6-2/6-2:1.0/rc/rc0
E: DRV_NAME=mceusb
E: NAME=rc-rc6-mce
E: SUBSYSTEM=rc

P: /devices/pci0000:00/0000:00:1a.1/usb6/6-2/6-2:1.0/rc/rc0/input6
E: DEVPATH=/devices/pci0000:00/0000:00:1a.1/usb6/6-2/6-2:1.0/rc/rc0/input6
E: EV=100013
E: ID_BUS=usb
E: ID_FOR_SEAT=input-pci-0000_00_1a_1-usb-0_2_1_0
E: ID_INPUT=1
E: ID_INPUT_KEY=1
E: ID_MODEL=MCE_TRANCEIVR_Emulator_Device_2006
E: ID_MODEL_ENC=MCE\x20TRANCEIVR\x20Emulator\x20Device\x202006
E: ID_MODEL_ID=0334
E: ID_PATH=pci-0000:00:1a.1-usb-0:2:1.0
E: ID_PATH_TAG=pci-0000_00_1a_1-usb-0_2_1_0
E: ID_REVISION=0100
E: ID_SERIAL=SMK_CORPORATION_MCE_TRANCEIVR_Emulator_Device_2006_PA120227171234G
E: ID_SERIAL_SHORT=PA120227171234G
E: ID_TYPE=generic
E: ID_USB_DRIVER=mceusb
E: ID_USB_INTERFACES=:ffffff:
E: ID_USB_INTERFACE_NUM=00
E: ID_VENDOR=SMK_CORPORATION
E: ID_VENDOR_ENC=SMK\x20CORPORATION
E: ID_VENDOR_ID=0609
E: KEY=fff 0 200108fc32e 237605100000000 0 700158000 419200004001 8e968000000000 10000000
E: MODALIAS=input:b0003v0609p0334e0100-e0,1,4,14,k71,72,73,77,80,8E,A1,A4,A7,A8,AE,CF,D0,D2,D4,E0,E1,E2,160,164,166,16D,16E,170,171,172,174,175,179,181,182,183,185,188,189,18E,18F,190,191,192,193,197,19C,1A9,200,201,202,203,204,205,206,207,208,209,20A,20B,ram4,lsfw
E: MSC=10
E: NAME="Media Center Ed. eHome Infrared Remote Transceiver (0609:0334)"
E: PHYS="usb-0000:00:1a.1-2"
E: PRODUCT=3/609/334/100
E: PROP=0
E: SUBSYSTEM=input
E: TAGS=:seat:
E: USEC_INITIALIZED=80140

P: /devices/pci0000:00/0000:00:1a.1/usb6/6-2/6-2:1.0/rc/rc0/input6/event6
N: input/event6
S: input/by-id/usb-SMK_CORPORATION_MCE_TRANCEIVR_Emulator_Device_2006_PA120227171234G-event-if00
S: input/by-path/pci-0000:00:1a.1-usb-0:2:1.0-event
E: DEVLINKS=/dev/input/by-id/usb-SMK_CORPORATION_MCE_TRANCEIVR_Emulator_Device_2006_PA120227171234G-event-if00 /dev/input/by-path/pci-0000:00:1a.1-usb-0:2:1.0-event
E: DEVNAME=/dev/input/event6
E: DEVPATH=/devices/pci0000:00/0000:00:1a.1/usb6/6-2/6-2:1.0/rc/rc0/input6/event6
E: ID_BUS=usb
E: ID_INPUT=1
E: ID_INPUT_KEY=1
E: ID_MODEL=MCE_TRANCEIVR_Emulator_Device_2006
E: ID_MODEL_ENC=MCE\x20TRANCEIVR\x20Emulator\x20Device\x202006
E: ID_MODEL_ID=0334
E: ID_PATH=pci-0000:00:1a.1-usb-0:2:1.0
E: ID_PATH_TAG=pci-0000_00_1a_1-usb-0_2_1_0
E: ID_REVISION=0100
E: ID_SERIAL=SMK_CORPORATION_MCE_TRANCEIVR_Emulator_Device_2006_PA120227171234G
E: ID_SERIAL_SHORT=PA120227171234G
E: ID_TYPE=generic
E: ID_USB_DRIVER=mceusb
E: ID_USB_INTERFACES=:ffffff:
E: ID_USB_INTERFACE_NUM=00
E: ID_VENDOR=SMK_CORPORATION
E: ID_VENDOR_ENC=SMK\x20CORPORATION
E: ID_VENDOR_ID=0609
E: MAJOR=13
E: MINOR=70
E: SUBSYSTEM=input
E: USEC_INITIALIZED=80221

  • In a section containing "E: SUBSYSTEM=usb" we want to write down the "E: DRIVER=" (In my case "mceusb")
  • In a section containing "E: SUBSYSTEM=input" we want to write down the "E: NAME=" (In my case "Media Center Ed. eHome Infrared Remote Transceiver (0609:0334)") This section's P: ends with ..../inputX and NOT .../inputX/eventX

Next we add the rule to /etc/X11/xorg.conf.d/10-quirks.conf
Code: [Select]
Section "InputClass"
        Identifier "MCE USB Keyboard mimic blacklist"
        Driver      "mceusb"
        MatchProduct "Media Center Ed. eHome Infrared Remote Transceiver (0609:0334)"
        Option "Ignore" "on"
EndSection
Where Identifier is a userdefined title, Driver is the info from "E: Driver=..." and MatchProduct is the info from "E: NAME=..."

After reboot, we can no longer use the remote to move the cursor in text fields (such as a browser address bar) nor does "^[[D" or "^[[C" pop up when running "sudo ir-keytable -t"

Step 3 - Install & Configure LIRC
We can now finally install lirc-utils from the repositories
Code: [Select]
$ sudo pacman -S lirc-utils
If I am not mistaken, lirc is a predecessor to ir-keytable and runs on a different level. We will pass the ir-keytable interpretations onto lirc by setting up a virtual remote called "devinput".

First, we need our device id. For this we use:
Code: [Select]
$ ls -l /dev/input/by-id/
We then assign it to the "devinput" in lirc's hardware configuration file: /etc/conf.d/lircd.conf
Code: [Select]
  LIRC_DEVICE="/dev/input/by-id/usb-SMK_CORPORATION_MCE_TRANCEIVR_Emulator_Device_2006_PA120227171234G-event-if00"
 LIRC_DRIVER="devinput"
 LIRC_EXTRAOPS=""
 LIRC_CONFIGFILE="/etc/lirc/lircd.conf"

We need to give "devinput" a keymap, luckily one comes packaged with lirc-utils, all we do is copy it to the right place. (symlink if you like)
Code: [Select]
$ sudo cp /usr/share/lirc/remotes/devinput/lircd.conf.devinput /etc/lirc/lircd.conf
We can't test the setup just yet because lirc isn't configured to run with systemd. We now create a service file for it, namely: /etc/systemd/system/lircd.service
Code: [Select]
[Unit]
Description=LIRC Daemon
After=network.target

[Service]
Type=forking
EnvironmentFile=/etc/conf.d/lircd.conf
PIDFile=/run/lirc/lircd.pid
#ExecStartPre=/usr/bin/ir-keytable -c -w KEYMAP_FILE_USUALLY_/etc/rc_keymaps/xxx -p PROTOCOL -P xx -D xx
ExecStartPre=/bin/mkdir -p /run/lirc
ExecStartPre=/bin/rm -f /dev/lircd
ExecStartPre=/bin/rm -f /run/lirc/lircd
ExecStartPre=/bin/ln -s /run/lirc/lircd /dev/lircd

ExecStart=/usr/sbin/lircd -d $LIRC_DEVICE -P /run/lirc/lircd.pid -H $LIRC_DRIVER $LIRC_CONFIGFILE
ExecStopPost=/bin/rm -f /dev/lircd
ExecStopPost=/bin/rm -fR /run/lirc

[Install]
WantedBy=multi-user.target
NOTE: Line 9 is there for those who need to set ir-keytable protocol, keytable, period & delay on boot for their device to be interpreted.

So now we can start the LIRC Daemon using systemd:
Code: [Select]
$ sudo systemctl start lircd.service
We cross our fingers and run LIRC's test: (using CTRL+C to quit)
Code: [Select]
$ irwand start pressing each button on the remote once. Expected output should resemble:
Code: [Select]
00 KEY_DOWN devinput
00 KEY_LEFT devinput
00 KEY_PLAY devinput
00 KEY_EPG devinput

If all works, we make the service permanent and double-check any other lirc service is disabled:
Code: [Select]
$ sudo systemctl disable lirc.service
$ sudo systemctl enable lircd.service

Step 4 - Configuring XBMC
Reserved

NOTES
Reserved - ir-keytable period & delay relating to scroll speed.

Acknowledgements & Resources
Reserved

It's almost 6 a.m. and I am kaput, will finish off when my brain is recharged :) Feedback is welcome.

Offline ringo32

  • Core Team
  • *****
  • Posts: 6322
  • Dutch People look @ manjaro.be or manjaro.nl :)
    • Manjaro Belgium + forum
  • Kernel: linux310 linux313
  • Desktop: I3-Openbox/xfce
  • Branch: unstable
  • GPU Card: Nvidia Geforce 8600 GT (acer 23inch)
  • GPU driver: non-free
  • Skill: Intermediate
with systemctl start XXX you only start with 1 session

Enable would be don after reboot :)

[irc] www.manjaro.be/irc  #manjaro #manjaro-nl #manjaro-ru #manjaro-es #linuxpark  #manjaro-de #manjaro-fr offtopic #manjaro-talk

Offline beanarooTopic starter

  • Neuling
  • *
  • Posts: 33
with systemctl start XXX you only start with 1 session

Enable would be don after reboot :)

If you read further you'll see that enable is used later.  ;)
Reason is we are making a new .service file and we want to start first, then test to see if it works, if it doesn't we can stop and correct.
When we are sure everything is working, we make things permanent with enable.

Offline ringo32

  • Core Team
  • *****
  • Posts: 6322
  • Dutch People look @ manjaro.be or manjaro.nl :)
    • Manjaro Belgium + forum
  • Kernel: linux310 linux313
  • Desktop: I3-Openbox/xfce
  • Branch: unstable
  • GPU Card: Nvidia Geforce 8600 GT (acer 23inch)
  • GPU driver: non-free
  • Skill: Intermediate
bummer :)
sorry :D

[irc] www.manjaro.be/irc  #manjaro #manjaro-nl #manjaro-ru #manjaro-es #linuxpark  #manjaro-de #manjaro-fr offtopic #manjaro-talk

Offline whoknows

  • Jr. Mitglied
  • **
  • Posts: 50
  • Kernel: Linux313-64
  • Desktop: xfce
  • Branch: Testing
  • GPU Card: Intel
  • GPU driver: Free
  • Skill: Novice
Thanks beanaroo I now have a working remote.

Offline ultima

  • Held Mitglied
  • *****
  • Posts: 1565
Great job in there beanaro, keep posting tutorails .

Offline screaming jet

  • Vollwertiges Mitglied
  • ***
  • Posts: 137
  • Kernel: linux39-x64
  • Desktop: XFCE
  • Branch: Stable
  • GPU Card: Various Nvidia
  • GPU driver: non-free
  • Skill: Novice
Okay I am setting up two machines at the moment and the first has the issue of acting like it is getting double a double keypress. Any thoughts?

And the other one is here:

http://forum.manjaro.org/index.php?topic=3172.msg27143#new

Offline beanarooTopic starter

  • Neuling
  • *
  • Posts: 33
Hi, screaming jet,

Try sudo ir-keytable -t and check if this happens with all buttons or just directional buttons. It could be the remote simulating keyboard arrows at the same time. Look at Step 2

Otherwise, play with the delay and period settings by increasing them.
Code: [Select]
sudo ir-keytable -D 500 -P 200 This means, if a button is held down, wait 500ms before repeating it every 200ms. These settings are not permanent and have to be applied by uncommenting the one line in the .service Step 3 and adjusting the values.

I would really like to ammend the How-To but Manjaro Forum policy is prohibiting me from editing the original post. I will try reach out to a mod again soon.

Offline screaming jet

  • Vollwertiges Mitglied
  • ***
  • Posts: 137
  • Kernel: linux39-x64
  • Desktop: XFCE
  • Branch: Stable
  • GPU Card: Various Nvidia
  • GPU driver: non-free
  • Skill: Novice
Thanks. I did get that part sorted some how I can't remember what I did. I just need to get the other machines remote working but I think I need to blacklist the other module but I suck at blacklisting and am unsure what I need to do to get it blacklisted.

Offline terry_gardener

  • Jr. Mitglied
  • **
  • Posts: 54
  • Kernel: linux310-x64
  • Desktop: gnome 3.10 + gnome-shell & cinnamon 2
  • Branch: stable
  • GPU Card: nvidia GTX460
  • GPU driver: non-free
  • Skill: Novice
i got mine working slightly different way to you.

Code: [Select]
sudo pacman -S lirc-utils
Code: [Select]
sudo systemctl enable lirc.service
then followed the steps on http://www.arch-ed.dk/systemd-lircd-mceusb-xbmc-and-arch-linux/

installed using 0.8.4 net iso.

Offline beanarooTopic starter

  • Neuling
  • *
  • Posts: 33
@terry_gardener

When I tried lirc-utils I had conflicting results. inputlirc was causing issues with ir-keytable and so some buttons were ignored and irw was giving me funny output.

Glad it worked for you!

Offline res0r9lm

  • Neuling
  • *
  • Posts: 3
  • Kernel: Linux-3.10 x86_64
  • Desktop: Xfce
  • Branch: stable
  • GPU Card: Nvidia GeForce GT 240
  • Skill: Advanced
I had tried lirc.service it didn't work for me either but the op with lircd.service worked flawless for the /etc/lirc/lircd.conf instead of copying file over I just created lircd.conf to incude the config.
Code: [Select]
include "/usr/share/lirc/devinput/lircd.conf.devinput"
For XBMC I have ~/.xbmc/userdata/Lircmap.xml
Code: [Select]
<!-- This file contains the mapping of LIRC keys to XBMC keys used in Keymap.xml  -->
<!--                                                                              -->
<!-- How to add remotes                                                           -->
<!-- <remote device="name_Lirc_calls_the_remote">                                 -->
<!--                                                                              -->
<!-- For the commands the layout following layout is used                         -->
<!-- <XBMC_COMMAND>LircButtonName</XBMC_COMMAND>                                  -->
<!--                                                                              -->
<!-- For a list of XBMC_COMMAND's check out the <remote> sections of keymap.xml   -->

<lircmap>


<remote device="SMK_CORPORATION_MCE_TRANCEIVR">
<left>KEY_LEFT</left>
<right>KEY_RIGHT</right>
<up>KEY_UP</up>
<down>KEY_DOWN</down>
<select>KEY_OK</select>
<start>KEY_MEDIA</start>
<back>KEY_EXIT</back>
<record>KEY_RECORD</record>
<play>KEY_PLAY</play>
<pause>KEY_PAUSE</pause>
<stop>KEY_STOP</stop>
<forward>KEY_FASTFORWARD</forward>
<reverse>KEY_REWIND</reverse>
<volumeplus>KEY_VOLUMEUP</volumeplus>
<volumeminus>KEY_VOLUMEDOWN</volumeminus>
<channelplus>KEY_CHANNELUP</channelplus>
<channelminus>KEY_CHANNELDOWN</channelminus>
<skipplus>KEY_NEXT</skipplus>
<info>KEY_INFO</info>
<skipminus>KEY_PREVIOUS</skipminus>
<title>KEY_EPG</title>
<subtitle>KEY_SUBTITLE</subtitle>
<mute>KEY_MUTE</mute>
<menu>KEY_DVD</menu>
<power>KEY_SLEEP</power>
<myvideo>KEY_VIDEO</myvideo>
<mymusic>KEY_AUDIO</mymusic>
<mypictures>KEY_MHP</mypictures>
<mytv>KEY_PVR</mytv>
<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>
<star>KEY_NUMERIC_STAR</star>
<hash>KEY_NUMERIC_POUND</hash>
<red>KEY_RED</red>
<green>KEY_GREEN</green>
<yellow>KEY_YELLOW</yellow>
<blue>KEY_BLUE</blue>
</remote>
</lircmap>