Linux - MCE Keyboard

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
Jbravo Offline
Member
Posts: 57
Joined: Jun 2012
Reputation: 0
Location: Sweden
Post: #1
I normally run XBMC under Win 7, but I decided to take XBMCbuntu out for spin.

The MCE Remote works out of the box, but the MCE Keyboard was stone dead (well the remote keys worked, but not all the other keys...).

After some intense googling I found a solution;

XBMCbuntu is based on Ubuntu11.10, and the kernel in 11.10 does not include the required support for the MCE keyboard. (Included in 12.04 and later).

So first install the MCE keyboard support:
Code:
apt-add-repository ppa:jon-hedgerows/lirc-mod-mce
apt-get update
apt-get install ir-mce-kbd-decoder-dkms # this will fail due to a bug in the postinst script
dkms add -m ir-mce_kbd-decoder -v 3.1
dkms install -m ir-mce_kbd-decoder -v 3.1

Now you should se an entry in dmesg (after reboot) similar to this.
Code:
[    9.425749] input: MCE IR Keyboard/Mouse (mceusb) as /devices/virtual/input/input8

However the MCE keyboard is still not working.

Install ir-keytable (apt-get install ir-keytable) and do:
Code:
ir-keytable

Note that LIRC is the only enabled protocol, to have the MCE keyboard working RC-6 needs to be enabled as well.

Enable RC-6, and keep LIRC since the MCE Remote is using lirc.
Code:
ir-keytable -c -p LIRC,RC-6

The "-c" is added to clear already added keymappings (done from /lib/udev/rules.d/40-ir-keytable.rules). Having both LIRC and keymapping via ir-keytable would result in double key presses.

The MCE keyboard should now work!

Now to the tricky part. To persist the above change during reboots I decided to add a udev rule.

Add the following to /etc/udev/rules.d/90-mce-ir.rules:
Code:
ACTION=="add|change", SUBSYSTEM=="rc", RUN+="/usr/bin/ir-keytable -s $name -c -p LIRC,RC-6"

However, after a restart the only enabled protocol was still LIRC :-(

After hours of trouble shooting a came to the conlclusion that the udev rule was correct but the protocol is reset to LIRC by the init script for lircd. The init script is called from
/lib/udev/rules.d/85-lirc.rules, which is run before my script. The init script is also called from somewhere else, which I can't find (if someone know, please post).

EDIT: The udev rule stops and restarts lirc. The lirc init script then does something that triggers the udev rule yet again. Lirc is also started as normal via init. Seems to be a mess...

So the solution was a hack in /etc/init.d/lirc, change the in_kernel_support method to the following:
Code:
in_kernel_support() {
        if [ -d /sys/class/rc ]; then
                for file in `find /sys/class/rc/*/ -name protocols`; do
                        if [ "$1" = "disable" ]; then
                                echo "+lirc" > $file
                        fi
                done
        fi
}

The init script will now only add LIRC to the enabled protocols when started.

Now the MCE keyboard should finally work after a reboot as well, and if you disconnect/connect the ir-receiver.

Note in this setup we use both ir-keytable and lirc. There is really no use to keep lirc, but it requires that all remote keys are mapped with ir-keytable instead. There are lot of information about this on the forum.

References:
http://www.foosel.org/linux/htpc
https://launchpad.net/~jon-hedgerows/+ar...rc-mod-mce
http://forum.xbmc.org/showthread.php?tid=101151

and README files for udev and ir-keytable
(This post was last modified: 2012-10-07 10:58 by Jbravo.)
find quote
Jbravo Offline
Member
Posts: 57
Joined: Jun 2012
Reputation: 0
Location: Sweden
Post: #2
Update for Ubuntu 12.04/12.10.

The ir-mce-kbd-decoder is now present in the kernel by default, so no need to dynamically load ir-mce-kbd-decoder modules.

However, it seems that a new protocol (mce_kbd) is added to the rc device, unfortunately ir-keytable and lird doesn't play nice with the protocols... Without ir-keytable and lirc installed all supported protocols are enabled by default, check with;
Code:
cat /sys/class/rc/rc0/protocols

and default keymappings are applied.

However, if lirc or ir-keytable is installed the mce_kbd protocol (along with other non required protocols) is for some reason disabled by -ir-keytable and lirc. The problem is then that ir-keytable doesn't recognize the new mce_kbd protocol and thus can't enable it again.

The mce_kbd protocol can instead be enabled by doing (sudo su);
Code:
echo mce_kbd > /sys/class/rc/rc0/protocols

Also make sure RC-6 is enabled, and also LIRC if you use the "old way".

The easy fix is yet again to change this directly in /etc/init.d/lirc:
Code:
in_kernel_support() {
        if [ -d /sys/class/rc ]; then
                for file in `find /sys/class/rc/*/ -name protocols`; do
                        if [ "$1" = "disable" ]; then
                                echo "lirc" > $file
                                echo "+RC-6" > $file
                                echo "+mce_kbd" > $file
                        else
                                echo "none" > $file
                                for protocol in `cat $file`; do
                                        echo "+${protocol}" > $file
                                done
                        fi
                done
        fi
}

The '+' adds to the list of protocols.

I'm still using Lirc (now via Linux devinput), since the key repeat rate when using ir-keytable directly is hysterical, press a key a fraction of a second and you end up with a ton of key presses in XBMC.

Btw, the "*/'"key doesn't work!?

/j
(This post was last modified: 2012-10-07 10:59 by Jbravo.)
find quote
skunkworks Offline
Junior Member
Posts: 3
Joined: Nov 2012
Reputation: 0
Post: #3
Hello -

I have a smk brand remote that came with my hauppauge card. It is black. I am trying to make it work with 12.04.

this is what I get in dmesg when I plug it in.
[ 3098.232207] usb 2-1.3: new full-speed USB device number 8 using ehci_hcd
[ 3098.304279] usb 2-1.3: device descriptor read/64, error -32
[ 3098.505375] Registered IR keymap rc-rc6-mce
[ 3098.505608] input: Media Center Ed. eHome Infrared Remote Transceiver (0609:0334) as /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/rc/rc2/input17
[ 3098.505768] rc2: Media Center Ed. eHome Infrared Remote Transceiver (0609:0334) as /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/rc/rc2
[ 3098.505985] input: MCE IR Keyboard/Mouse (mceusb) as /devices/virtual/input/input18
[ 3098.506325] rc rc2: lirc_dev: driver ir-lirc-codec (mceusb) registered at minor = 1
[ 3098.699703] mceusb 2-1.3:1.0: Registered SMK CORPORATION MCE TRANCEIVR Emulator Device 2006 with mce emulator interface version 1
[ 3098.699707] mceusb 2-1.3:1.0: 2 tx ports (0x0 cabled) and 2 rx sensors (0x0 active)
skunkwork

It sort of works (arrow keys and a few others work without lirc installed). With lirc installed I get nothing. I just tried your directions from post 2 and still get nothing. Any help in a direction to look?

wait - now it seems to work as it did. (arrow keys seem to work but numbers don't or the ok key)

thanks
sam
find quote
skunkworks Offline
Junior Member
Posts: 3
Joined: Nov 2012
Reputation: 0
Post: #4
ok - to clarify.. I can run

skunkworks@skunkworks-Studio-XPS-1645:~$ sudo /usr/sbin/lircd -H dev/input -d /dev/input/event12 -n
[sudo] password for skunkworks:
lircd-0.9.0[2939]: lircd(devinput) ready, using /var/run/lirc/lircd
lircd-0.9.0[2939]: accepted new client on /var/run/lirc/lircd
lircd-0.9.0[2939]: initializing '/dev/input/event12'

The last 2 lines happen when I do irw

When I push keys I get

skunkworks@skunkworks-Studio-XPS-1645:~$ irw
^[[A^[[B

But only the arrow keys and enter seem to work or output anything to irw.

thanks again
sam
find quote
skunkworks Offline
Junior Member
Posts: 3
Joined: Nov 2012
Reputation: 0
Post: #5
Go it working!!

The directions in post 2 worked wonderfully. My issue is the laptop I was testing on had an internal IR receiver. So the usb one was /dev/lirc1. IRW started returning sane results.

Now I need to figure out how to get it working with mythtv.. I would think that someone would have made a .lircrc file for the /usr/share/lirc/remotes/mceusb/lircd.conf.mceusb lircd.conf file..

Thanks again!
sam
find quote
decayingcorpse Offline
Junior Member
Posts: 1
Joined: Feb 2013
Reputation: 0
Post: #6
sorry to renew old post...

i'm attempting to migrate from 10.04 to 12.04 and regardless of what I do, I can't get the MCE keyboard running in 12.04.
anyone got any thoughts/tricks to gettting this f***ing working?
find quote
evylrat Offline
Junior Member
Posts: 13
Joined: Feb 2010
Reputation: 0
Thumbs Up  RE: MCE Keyboard
Post: #7
I got this to work using the details in Post #2.
BUT, i just added the following to /etc/init.d/lirc
Code:
echo "lirc" > $file
echo "+mce_kbd" > $file
i did NOT include +RC-6

the MCE keyboard and remote appear to be working, no side effects. I found that adding commands to /etc/rc.local did not work after a reboot, but adding to lirc stays after a reboot.
find quote