Using an MCE remote and Archive:Gyration USB remote in Ubuntu for XBMC using Lirc: Difference between pages

From Official Kodi Wiki
(Difference between pages)
Jump to navigation Jump to search
>Jhsrennie
(New page: Note: this article refers to build 26407 and later. Earlier versions of XBMC did not have all the features described in this and related articles. The first offical release of XBMC with th...)
 
>Gsgleason
No edit summary
 
Line 1: Line 1:
Note: this article refers to build 26407 and later. Earlier versions
This is a configuration for using a Gyration USB media remote reviewed at [http://reviews.cnet.com/keyboards/gyration-media-center-pc/4505-3134_7-32331445.html]
of XBMC did not have all the features described in this and related
This method uses two instances of lircd that are manually configured to start using /etc/rc.local. The files that are affected are:
articles. The first offical release of XBMC with this remote support
/etc/lirc/lircd.conf
will be v10.05.
/etc/rc.local
~usernamerunningxbmc/.xbmc/userdata/Keymap.xml
~usernamerunningxbmc/.xbmc/userdata/Lircmap.xml


If you have one of the many cheap MCE remote controllers then just
Credit goes to the random anonymous bits and pieces I've found on the Interwebs along with my own experimentation using hexcump -C to look at the character device files while pressing buttons.
connect it to your PC and there's a fair chance it will just work. If
you have the official Microsoft MCE remote controller or a full
compatible then you may need a small amount of extra effort to get it
working: details below.


If you're in a hurry to get your remote working jump straight
First, install the lirc package.
to:
<source lang="bash">sudo apt-get install lirc</source>


<ul>
We do not want to use Ubuntu's init scripts and config files, therefore we need to tell it not to start up automatically.  Here is the command which changes the symbolic link in /etc/rc2.d/:
  <li>Using the official MS remote with XBMC on Windows</li>
<source lang="bash">sudo update-rc.d lirc disable 2</source>
  <li>Using non-MS remotes with XBMC on Windows</li>
  <li>Using remote controllers with XBMC on Linux</li>
</ul>


However if you have the spare five minutes it will take to read this
Back up your old files that we are about to overwrite:
article I recommend that you take the time to do it. Once you've read
<source lang="bash">mkdir ~/backupfiles
this article the articles above will make more sense.
for a in /etc/rc.local /etc/lirc/lircd.conf  ~/.xbmc/userdata/Lircmap.xml ~/.xbmc/userdata/Keymap.xml ; do cp $a ~/backupfiles/; done</source>


Media Center remotes are obviously designed to work with Microsoft
Put these lines in /etc/rc.local:
Windows Media Center Edition (hence the "MCE" acronym) so this article
<source lang="bash">/usr/sbin/lircd --driver=devinput --device=/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-mouse --output=/dev/lircd1 --pidfile=/var/run/lircd1.pid --listen
concentrates on Windows. However the same remotes will usually work
/usr/sbin/lircd --driver=devinput --device=/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-kbd --output=/dev/lircd --pidfile=/var/run/lircd.pid --connect=localhost:8765</source>
with Linux and possibly OSX, and much of this discussion applies to all
platforms.


On Linux there is a standard method for supporting remote
Here is /etc/lirc/lircd.conf
controllers using software called Lirc. Assuming there is a Linux
<source lang="bash">#This configuration has been automatically generated via
driver for your remote controller you can configure Lirc to use it with
#the Ubuntu LIRC package maintainer scripts.
XBMC. Details are in the Linux article above. Note that XBMCLive is
#
already configured to work with the official MS remote. Sadly, on
#It includes the default configuration for the remote and/or
Windows the situation is a lot more confused.
#transmitter that you have selected during package installation.
#
#Feel free to add any custom remotes to the configuration
#via additional include directives or below the existing
#Ubuntu include directives from your selected remote and/or
#transmitter.


#
# lircd.conf
#    for Gyration MCE remote(s).  Could almost certainly be expanded to work for their keyboard as well.
#
# Composed by Marc Randolph based upon
#    initial lircd.conf by Modulok (https://bugs.launchpad.net/mythbuntu/+bug/156494/comments/6)
#    with help from the Linux MCE wiki (http://wiki.linuxmce.org/index.php/Gyration-GYR3101US-codes)
#
# Notes:
#    Star and Hash keys produce two key sequences: 0x002A followed by either 8 for star, or 3 for hash
#
# Revision history
#    2.3 - Marc Randolph - Renamed camera to pictures and video to videos.  Added alternative mappings
#    2.2 - Marc Randolph - Added untested DVDMenu entry
#    2.1 - Marc Randolph - StarHash comment was wrong
#    2.0 - Marc Randolph - Special codes should be correct, or at least, very close to correct
#    1.0 - Marc Randolph - added missing codes and changed names to match up the mceusb remote
#                        -    Some of the more special codes have not been verified (Pictures, LiveTV,  etc)
#    0.1 - Modulok      - Initial revision
#
#
begin remote


== Why there is a problem (on Windows) ... ==
name    gyration
bits          16
eps            30
aeps          100


The problem with using MCE remotes is that there is no such thing as
one            0    0
a standard MCE remote. There is the official Microsoft remote of
zero            0    0
course, and some remotes are genuinely fully compatible with the MS
pre_data_bits  16
remote. Unfortunately the majority of MCE remote controllers,
pre_data      0x8001
especially the cheap ones, work in different ways. There are four
gap          135997
different ways a remote can work on Windows.
toggle_bit_mask 0x0


<ol>
      begin codes
  <li>The remote can send an IR code like the Microsoft remote. To use
        Home                    0x0066 # AKA "Windows button"
  the remote an application has to link to the IR driver.<br>&nbsp;</li>
        Up                      0x0067
        Left                    0x0069
        Right                    0x006A
        Down                    0x006C
        Mute                    0x0071
        VolDown                  0x0072
        VolUp                    0x0073
        Power                    0x008e
        Pause                    0x0077
        More                    0x0082  # AKA "Info" or Help
        Back                    0x009E
        Skip                    0x00A3
        Replay                  0x00A5
        Stop                    0x00A6
        RecTV                    0x00A7  #Not "recorded TV", but "record current show on TV"
        Rewind                  0x00A8
        Play                    0x00CF
        Forward                  0x00D0
        Pictures                0x00D4  # not on Dell remote
        RecordedTV              0x00E2  # aka KEY_MEDIA
        Guide                    0x016A
        LiveTV                  0x016E  # aka KEY_PVR
        DVD                      0x0185
        Music                    0x0187  # not on Dell remote # aka KEY_MP3
        Videos                  0x0189  # not on Dell remote
        ChanUp                  0x0192
        ChanDown                0x0193
        DVDMenu                  0x019A  # untested. not on Dell remote
        Clear                    0x0001
        One                      0x0002
        Two                      0x0003
        Three                    0x0004
        Four                    0x0005
        Five                    0x0006
        Six                      0x0007
        Seven                    0x0008
        Eight                    0x0009
        Nine                    0x000A
        Zero                    0x000B
        Enter                    0x001C
        StarHash                0x002A  # Star=0x2a and 0x08; Hash = 0x2a and 0x03
        a                      0x001E
    end codes


  <li>The remote can send the Windows message WM_APPCOMMAND. This
end remote
  message is used to send a multimedia application messages like "Play",
# Alternative mappings to try if some of the above don't work
  "Pause", "Stop" etc. To use this type of remote an application has to
# (please report any findings back to http://www.mythtv.org/wiki/Gyration-based_MCE_Remotes)
  process the WM_APPCOMMAND messages.<br>&nbsp;</li>
#            Up  0x0062
 
#          Left  0x0064
  <li>The remote can simulate multimedia keypresses when you press a
#        Right  0x0066
  button. Multimedia keys were introduced with the Microsoft multimedia
#          Down  0x0068
  keyboard, which has extra keys for multimedia functions like "Play"
#        Pause  0x0075
  etc. To use this type of remote an application has to process the
#        Power  0x008E
  multimedia keypresses.<br>&nbsp;</li>
#          Halt  0x019C
 
#        Lights  0x0111
  <li>Finally the remote can simulate the standard MS Media Center
#        Clear  0x0016
  keyboard shortcuts. When Microsoft introduced Media Center the
#        Enter  0x0024
  specified a set of standard keyboard shortcuts to operate it. For
#      DVDMenu  0x0029
  example control-shift-P means "Play". Many cheap MCE remotes simulate
</source>
  these keyboard shortcuts e.g. when you press the Play button they
  simulate the keypress control-shift-P. To use this type of remote an
  application has to process the Media Center keypresses.<br>&nbsp;</li>
</ol>
 
 
== ... and how to solve it ==
 
The good news is that from build 26407 onwards XBMC has support
built in for remote controllers of types 2, 3 and 4. This includes the
vast majority of the cheap MCE remotes, so the basic functions like
"Play" etc will work without any messing around. A lot of MCE remotes
include extra keys not on the official MS remote, and to get these to do
anything you will need some manual configuration. All this is covered in
the article on using non-MS remotes.
 
Ironically the official MS remote will not work with XBMC out of the
box. This is because it uses IR codes i.e. type 1 in the list above,
and XBMC does not support this. The good news is that the MS remote is
easily reconfigured to work as a type 4 remote instead. This is covered
in the article on using the MS remote.
 
 
== A note on Linux ==
 
to be completed
 
 
== How it works ==
 
Actually supporting the type 2 and 3 remotes is quite easy, and
version 9.11 (Camelot) of XBMC already includes partial support for
these types. The only changes in the post 26407 builds just extend the
WM_APPCOMMAMD processing a bit. It's handling the type 4 remotes that
is hard. This is because type 4 remotes send combinations of keypresses
with modifier keys like Control and Shift. The key handler in XBMC
v9.11 and earlier cannot process the key modifiers so it can't process
the simulated keypresses sent by the type 4 remotes. The later builds
include support for key modifiers and add the Media Center keyboard
shortcuts to the key mapping file.
 
 
== If you can't wait for v10.05 ==
 
The remote controller support described above will be included
in XBMC version 10.05. If you can't wait that long you'll need to
build the latest version of XBMC yourself. If you don't have the
development tools (or skills) to compile XBMC yourself there are
several people around who provide development builds. See
<a href="http://forum.xbmc.org/showthread.php?t=62109">
http://forum.xbmc.org/showthread.php?t=62109</a> for example.
Alternatively there is an unofficial Windows build of v9.11
with key modifier support retro-fitted at
<a href="http://xbmcmce.sourceforge.net/">xbmcmce.sourceforge.net</a>.
 
 
== Configuring the keyboard ==
 
You're into nerd (OK, "enthusiast") territory now. This section
described how to manually edit the key mappings in XBMC. You will only
need to do this if your remote sends non-standard keypresses, or if you
want to use non-standard buttons on the remote. If you are going to do
this make sure you read the article on using non-MS remotes first.
 
The mapping of keypresses like <i>P</i> to XBMC actions like
<i>Play</i> is configured in a file called keyboard.xml. There is a
copy of keyboard.xml in C:\Program Files\XBMC\system\keymaps, and the
settings in this file apply to all users. In general you shouldn't edit
or replace this file because any mistakes you make can be hard to undo.
At the very least make a backup copy of the file before you change
anything.
 
If you want to change the key mapping you can create a second
keyboard.xml file in your userdata/keymaps folder (see below for where
this folder is). XBMC combines the system keyboard.xml with your
userdata keyboard.xml so you only need to add any extra keys; you don't
need to duplicate all the key definitions already in the system
keyboard.xml. You can also override any key definitions in the
system keyboard.xml by putting the new definition in your userdata
keyboard.xml.
 
If you use Linux then your userdata folder is $home/.xbmc/userdata
so the full path to your keyboard.xml file is
$home/.xbmc/userdata/keymaps/keyboard.xml.
 
If you use Windows the situation is a bit more complicated because
it depends on whether you installed XBMC in default mode or portable
mode. In portable mode the path to the file is
C:\Program&nbsp;Files\XBMC\userdata\keymaps\keyboard.xml. In default
mode the file is in your profile, in
%APPDATA%\XBMC\userdata\keymaps\keyboard.xml, where APPDATA is an
environment variable. In both default and portable mode, if the
keymaps folder doesn't exist in your userdata folder just create
it.
 
A side note: if you are using the 64 bit versions of Windows replace
C:\Program&nbsp;Files\ by C:\Program&nbsp;Files&nbsp;(x86)\. If you
didn't install XBMC into the Program&nbsp;Files folder then replace
C:\Program&nbsp;Files\XBMC\ by whatever directory you chose at
installation.
 
== Modifying keyboard.xml ==
 
The keyboard.xml file is just a text file and can be edited in any
text editor like Notepad in Windows or gedit in Linux. One day there
will be a nice GUI app for editing keyboard.xml, but for now you need to
do it by hand.
 
The first step is to create the keyboard.xml file in
userdata\keymaps. If there isn't a keymaps folder in userdata then
create one now. To get you started there is a sample keyboard.xml
<a href="keyboard.xml">here</a> with key mappings for the standard
Media Center keyboard shortcuts. In many cases just copying this
file into userdata\keymaps will be enough to get your remote
working.
 
If you make a mistake in the keyboard.xml XBMC will probably just
ignore it and none of your extra keymappings will work. If you think
this has happened look in the xbmc.log file for an error like:
 
<pre>ERROR: Error loading keymap: special://masterprofile/keymaps/keyboard.xml, Line 16
      Error reading end tag.
ERROR: Error loading keymap: special://profile/keymaps/keyboard.xml, Line 16
      Error reading end tag.</pre>

Revision as of 01:25, 8 June 2010

This is a configuration for using a Gyration USB media remote reviewed at [1] This method uses two instances of lircd that are manually configured to start using /etc/rc.local. The files that are affected are: /etc/lirc/lircd.conf /etc/rc.local ~usernamerunningxbmc/.xbmc/userdata/Keymap.xml ~usernamerunningxbmc/.xbmc/userdata/Lircmap.xml

Credit goes to the random anonymous bits and pieces I've found on the Interwebs along with my own experimentation using hexcump -C to look at the character device files while pressing buttons.

First, install the lirc package.

sudo apt-get install lirc

We do not want to use Ubuntu's init scripts and config files, therefore we need to tell it not to start up automatically. Here is the command which changes the symbolic link in /etc/rc2.d/:

sudo update-rc.d lirc disable 2

Back up your old files that we are about to overwrite:

mkdir ~/backupfiles
for a in /etc/rc.local /etc/lirc/lircd.conf  ~/.xbmc/userdata/Lircmap.xml ~/.xbmc/userdata/Keymap.xml ; do cp $a ~/backupfiles/; done

Put these lines in /etc/rc.local:

/usr/sbin/lircd --driver=devinput --device=/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-mouse --output=/dev/lircd1 --pidfile=/var/run/lircd1.pid --listen
/usr/sbin/lircd --driver=devinput --device=/dev/input/by-id/usb-Gyration_Gyration_RF_Technology_Receiver-event-kbd --output=/dev/lircd --pidfile=/var/run/lircd.pid --connect=localhost:8765

Here is /etc/lirc/lircd.conf

#This configuration has been automatically generated via
#the Ubuntu LIRC package maintainer scripts.
#
#It includes the default configuration for the remote and/or
#transmitter that you have selected during package installation.
#
#Feel free to add any custom remotes to the configuration
#via additional include directives or below the existing
#Ubuntu include directives from your selected remote and/or
#transmitter.

#
# lircd.conf
#    for Gyration MCE remote(s).  Could almost certainly be expanded to work for their keyboard as well.
#
# Composed by Marc Randolph based upon
#    initial lircd.conf by Modulok (https://bugs.launchpad.net/mythbuntu/+bug/156494/comments/6)
#    with help from the Linux MCE wiki (http://wiki.linuxmce.org/index.php/Gyration-GYR3101US-codes)
#
# Notes:
#    Star and Hash keys produce two key sequences: 0x002A followed by either 8 for star, or 3 for hash
#
# Revision history
#    2.3 - Marc Randolph - Renamed camera to pictures and video to videos.  Added alternative mappings
#    2.2 - Marc Randolph - Added untested DVDMenu entry
#    2.1 - Marc Randolph - StarHash comment was wrong
#    2.0 - Marc Randolph - Special codes should be correct, or at least, very close to correct
#    1.0 - Marc Randolph - added missing codes and changed names to match up the mceusb remote
#                        -    Some of the more special codes have not been verified (Pictures, LiveTV,  etc)
#    0.1 - Modulok       - Initial revision
#
#
begin remote

 name     gyration
 bits           16
 eps            30
 aeps          100

 one             0     0
 zero            0     0
 pre_data_bits   16
 pre_data       0x8001
 gap          135997
 toggle_bit_mask 0x0

      begin codes
         Home                     0x0066 # AKA "Windows button"
         Up                       0x0067
         Left                     0x0069
         Right                    0x006A
         Down                     0x006C
         Mute                     0x0071
         VolDown                  0x0072
         VolUp                    0x0073
         Power                    0x008e
         Pause                    0x0077
         More                     0x0082  # AKA "Info" or Help
         Back                     0x009E
         Skip                     0x00A3
         Replay                   0x00A5
         Stop                     0x00A6
         RecTV                    0x00A7  #Not "recorded TV", but "record current show on TV"
         Rewind                   0x00A8
         Play                     0x00CF
         Forward                  0x00D0
         Pictures                 0x00D4  # not on Dell remote
         RecordedTV               0x00E2  # aka KEY_MEDIA
         Guide                    0x016A
         LiveTV                   0x016E  # aka KEY_PVR
         DVD                      0x0185
         Music                    0x0187  # not on Dell remote  # aka KEY_MP3
         Videos                   0x0189  # not on Dell remote
         ChanUp                   0x0192
         ChanDown                 0x0193
         DVDMenu                  0x019A  # untested.  not on Dell remote
         Clear                    0x0001
         One                      0x0002
         Two                      0x0003
         Three                    0x0004
         Four                     0x0005
         Five                     0x0006
         Six                      0x0007
         Seven                    0x0008
         Eight                    0x0009
         Nine                     0x000A
         Zero                     0x000B
         Enter                    0x001C
         StarHash                 0x002A  # Star=0x2a and 0x08; Hash = 0x2a and 0x03
        a                       0x001E
     end codes

end remote
# Alternative mappings to try if some of the above don't work
# (please report any findings back to http://www.mythtv.org/wiki/Gyration-based_MCE_Remotes)
#            Up  0x0062
#          Left  0x0064
#         Right  0x0066
#          Down  0x0068
#         Pause  0x0075
#         Power  0x008E
#          Halt  0x019C
#        Lights  0x0111
#         Clear  0x0016
#         Enter  0x0024
#       DVDMenu  0x0029