[Linux] HOW-TO MCE Remote WITHOUT LIRC (Natty)

  Thread Rating:
  • 1 Votes - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
wstewart Offline
Senior Member
Posts: 212
Joined: Jan 2009
Reputation: 1
Location: Canada
Post: #1
In this how-to, I will describe how I got an MCE remote to work without using LIRC. As you may know, many of the LIRC drivers have been migrated into the kernel. This how-to is based on a few others:

http://forum.xbmc.org/showthread.php?tid=99042
http://forum.xbmc.org/showthread.php?tid=101151
http://forum.xbmc.org/showthread.php?tid=104541

The IR kernel drivers look like a keyboard to XBMC, so the Lircmap.xml is not used and can not be this approach. All changes to key mapping of the remote must be done through keyboard.xml.

I have made this work on Ubuntu Natty and it will probably work on Maverik, but I am not sure. Definitely will not work on anything earlier due to the kernel version.

I have this working on a PC with a MCE USB receiver (built-in), as well as on a Asrock 330HT using the internal IR receiver with the kernel nuvoton driver.

There are a couple of problems that we must work around. First install the ubuntu ir-keytable package

Code:
apt-get install ir-keytable


Now there is a bug in that version that causes it to ignore key codes greater than 0x80000000. So do the following:

Code:
git clone http://linuxtv.org/git/v4l-utils.git
apt-get install autoconf
apt-get install libjpeg62-dev g++
cd v4l-utils/utils/keytable
make
cp ./ir-keytable /usr/bin

EDIT: Apparently ir-keytable is fixed in oneiric.

If your using an xbmcfreak version, then do the following
Comment echo none +lirc > /sys/class/rc/rc0/protocols in /etc/rc.local

Now we're going to temporarily disable lirc. So

Code:
mv /etc/init.d/lirc /etc/init.d/lirc1

If you feel comfortable, just go ahead and remove LIRC instead.

now reboot, then run ir-keytable, and you should see something like

Quote:Found /sys/class/rc/rc0/ (/dev/input/event2) with:
Driver mceusb, table rc-rc6-mce
Supported protocols: NEC RC-5 RC-6 JVC SONY LIRC
Enabled protocols: RC-5 RC-6
Name: Media Center Ed. eHome Infrared
bus: 3, vendor/product: 0471:0815, version: 0x0000
Repeat delay = 500 ms, repeat period = 33 ms

The important thing is that the MCE receiver is recognized and that RC-6 is enabled. If this doesn't work, grep for mce in dmesg to see if there are errors loading the kernel driver.

Next run ir-keytable -t

press some keys on your remote and you should see things like

Quote:1320643260.849486: event MSC: scancode = 800f041e
1320643260.849498: event key down: KEY_UP (0x0067)
1320643260.849500: event sync
1320643260.968489: event MSC: scancode = 800f041e
1320643261.219926: event key up: KEY_UP (0x0067)
1320643261.219933: event sync
1320643261.682490: event MSC: scancode = 800f0421
1320643261.682502: event key down: KEY_RIGHT (0x006a)
1320643261.682504: event sync
1320643261.788502: event MSC: scancode = 800f0421
1320643262.039923: event key up: KEY_RIGHT (0x006a)
1320643262.039930: event sync

Now the next problem is that the kernel ir drivers generate keyboard scan codes greater than 255 for some keys. Xorg does not recognize these, in fact it ignores them. Until there is an overhaul of Xorg to fix this, we must work around it otherwise XBMC will never get the keys.

Create a new mapping file in /etc/rc_keymaps, call it rc6_mce

Code:
# table rc6_mce, type: RC-6
0x800f0400 KEY_KP0
0x800f0401 KEY_KP1
0x800f0402 KEY_KP2
0x800f0403 KEY_KP3
0x800f0404 KEY_KP4
0x800f0405 KEY_KP5
0x800f0406 KEY_KP6
0x800f0407 KEY_KP7
0x800f0408 KEY_KP8
0x800f0409 KEY_KP9
0x800f040a KEY_DELETE
0x800f040b KEY_ENTER
0x800f040c KEY_KPSLASH                # Power
0x800f040d KEY_C                    # Left Meta, Start
0x800f040e KEY_MUTE
0x800f040f KEY_I                    # Info
0x800f0410 KEY_PAGEUP                # Volume Up
0x800f0411 KEY_PAGEDOWN                # Volume Down
0x800f0412 KEY_CHANNELUP
0x800f0413 KEY_CHANNELDOWN
0x800f0414 KEY_F                    # Fast forward
0x800f0415 KEY_R                    # Rewind
0x800f0416 KEY_PLAY
0x800f0417 KEY_RECORD
0x800f0418 KEY_PAUSE
0x800f046e KEY_PLAYPAUSE
0x800f0419 KEY_STOP
0x800f041a KEY_NEXTSONG                # Skip Next            
0x800f041b KEY_PREVIOUSSONG            # Skip Previous
0x800f041c KEY_NUMERIC_POUND
0x800f041d KEY_NUMERIC_STAR
0x800f041e KEY_UP
0x800f041f KEY_DOWN
0x800f0420 KEY_LEFT
0x800f0421 KEY_RIGHT
0x800f0422 KEY_ENTER                # Ok
0x800f0423 KEY_BACKSPACE            # Back / Exit
0x800f0424 KEY_DVD
0x800f0425 KEY_TUNER
0x800f0426 KEY_EPG
0x800f0427 KEY_ZOOM
0x800f043a KEY_BRIGHTNESSUP
0x800f0446 KEY_TV
0x800f0447 KEY_AUDIO
0x800f0448 KEY_PVR
0x800f0449 KEY_CAMERA
0x800f044a KEY_VIDEO
0x800f044c KEY_LANGUAGE
0x800f044d KEY_TITLE
0x800f044e KEY_PRINT
0x800f0450 KEY_RADIO
0x800f045a KEY_SUBTITLE
0x800f045b KEY_RED
0x800f045c KEY_O                    # Green
0x800f045d KEY_YELLOW
0x800f045e KEY_Z                    # Blue
0x800f0465 KEY_POWER2
0x800f046e KEY_PLAYPAUSE
0x800f046f KEY_MEDIA
0x800f0480 KEY_BRIGHTNESSDOWN
0x800f0481 KEY_PLAYPAUSE

This is largely based on the default file.

Now run ir-keytable like this

Quote:ir-keytable -c -p RC-5,RC-6 -w /etc/rc_keymaps/rc6_mce

Next re-run ir-keytable -t to make sure it still works.

Now we want our new mapping file to be loaded at startup, so create a file xbmc-ir-keytable.conf in /etc/init (note in init NOT init.d) as follows

Code:
#

description     "xbmc-ir-keytable"

start on (filesystem and stopped udevtrigger)

pre-start script

end script

script
        logger "Setting IR Keymap..."
        /usr/bin/ir-keytable -c -p RC-5,RC-6 -w /etc/rc_keymaps/rc6_mce

end script

pre-stop script

end script

Ok, now we need to remap the keys in xbmc to work. Need to add a keyboard.xml to .xbmc/userdata/keymaps. See next post for contents of my keyboard.xml

This is based on the default file and modified to my preferences. Note that there does seem to be an issue with the recent git of xbmc. You use to be able to look for the scancode of unmapped/unknown keys in the log and use something like <key id='65446'>, but the with recent overhauls, this seems to no longer work.

That should be it, it should work. The only thing that's a bit of a pain, is that if you press and hold a key, the repeat frequency seems very, very high. I haven't got around to tuning that yet.
(This post was last modified: 2012-01-07 03:12 by wstewart.)
find quote
wstewart Offline
Senior Member
Posts: 212
Joined: Jan 2009
Reputation: 1
Location: Canada
Post: #2
Ok here is my keyboard.xml

Code:
<keymap>
  <global>
    <keyboard>
      <p>Play</p>
      <q>Queue</q>
      <f>FastForward</f>
      <r>Rewind</r>
      <left>Left</left>
      <right>Right</right>
      <up>Up</up>
      <down>Down</down>
      <left mod="ctrl">analogseekback</left>
      <right mod="ctrl">analogseekforward</right>
      <pageup>PageUp</pageup>
      <pagedown>PageDown</pagedown>
      <return>Select</return>
      <enter>Select</enter>
      <backspace>Back</backspace>
      <key id='65446'>Back</key>
      <m>ActivateWindow(PlayerControls)</m>
      <s>ActivateWindow(shutdownmenu)</s>
      <escape>PreviousMenu</escape>
      <i>Info</i>
      <menu>ContextMenu</menu>
      <c>ContextMenu</c>
      <space>Pause</space>
      <x>Stop</x>
      <period>SkipNext</period>
      <comma>SkipPrevious</comma>
      <tab>FullScreen</tab>
      <printscreen>Screenshot</printscreen>
      <s mod="ctrl">Screenshot</s>
      <minus>VolumeDown</minus>
      <plus>VolumeUp</plus>
      <equals>VolumeUp</equals>
      <zero>Number0</zero>
      <one>Number1</one>
      <two>Number2</two>
      <three>Number3</three>
      <four>Number4</four>
      <five>Number5</five>
      <six>Number6</six>
      <seven>Number7</seven>
      <eight>Number8</eight>
      <nine>Number9</nine>
      <numpadminus>VolumeDown</numpadminus>
      <numpadplus>VolumeUp</numpadplus>
      <numpadzero>Number0</numpadzero>
      <numpadone>Number1</numpadone>
      
      <!-- changed -->
      <numpadtwo>JumpSMS2</numpadtwo>
      <numpadthree>JumpSMS3</numpadthree>
      <numpadfour>JumpSMS4</numpadfour>
      <numpadfive>JumpSMS5</numpadfive>
      <numpadsix>JumpSMS6</numpadsix>
      <numpadseven>JumpSMS7</numpadseven>
      <numpadeight>JumpSMS8</numpadeight>
      <numpadnine>JumpSMS9</numpadnine>
      <numpaddivide>XBMC.ShutDown()</numpaddivide>
      
      <backslash>ToggleFullScreen</backslash>
      <home>FirstPage</home>
      <end>LastPage</end>
      <!-- Multimedia keyboard keys -->
      <browser_back>Back</browser_back>
      <browser_forward/>
      <browser_refresh/>
      <browser_stop/>
      <browser_search/>
      <browser_favorites>ActivateWindow(Favourites)</browser_favorites>
      <browser_home>XBMC.ActivateWindow(Home)</browser_home>
      <volume_mute>Mute</volume_mute>
      <volume_down>VolumeDown</volume_down>
      <volume_up>VolumeUp</volume_up>
      <next_track>SkipNext</next_track>
      <prev_track>SkipPrevious</prev_track>
      <stop>Stop</stop>
      
      <!-- changed -->
      <play_pause>Play</play_pause>
      <pause>Pause</pause>
      
      <launch_mail></launch_mail>
      <launch_media_select>XBMC.ActivateWindow(MyMusic)</launch_media_select>
      <launch_app1_pc_icon>ActivateWindow(MyPrograms)</launch_app1_pc_icon>
      <launch_app2_pc_icon>ActivateWindow(MyPrograms)</launch_app2_pc_icon>
      <launch_file_browser/>
      <launch_media_center/>
      <!-- ****************************************************** -->
      <!-- MS Media Center keyboard shortcuts sent by MCE remotes -->
      <!-- See http://msdn.microsoft.com/en-us/library/bb189249.aspx -->
      <p mod="ctrl,shift">Play</p>        <!-- Play -->
      <s mod="ctrl,shift">Stop</s>        <!-- Stop -->
      <p mod="ctrl">Pause</p>             <!-- Pause -->
      <f mod="ctrl,shift">FastForward</f> <!-- Fwd -->
      <b mod="ctrl,shift">Rewind</b>      <!-- Rew -->
      <f mod="ctrl">SkipNext</f>          <!-- Skip -->
      <b mod="ctrl">SkipPrevious</b>      <!-- Replay -->
      <d mod="ctrl">Info</d>              <!-- MCE Details -->
      <f10>VolumeUp</f10>                 <!-- MCE Vol up -->
      <f9>VolumeDown</f9>                 <!-- MCE Vol down -->
      <f8>Mute</f8>                       <!-- MCE mute -->
      <g mod="ctrl">OSD</g>               <!-- MCE Guide -->
      <m mod="ctrl">ActivateWindow(music)</m>    <!-- MCE My music -->
      <i mod="ctrl">ActivateWindow(pictures)</i> <!-- MCE My pictures -->
      <e mod="ctrl">ActivateWindow(video)</e>    <!-- MCE videos -->
      <m mod="ctrl,shift">PlayerControl(ShowVideoMenu)</m> <!-- MCE DVD menu -->
      <!-- MCE keypresses without an obvious use in XBMC -->
      <o mod="ctrl">Notification(MCEKeypress, Recorded TV, 3)</o>
      <t mod="ctrl">Notification(MCEKeypress, Live TV, 3)</t>
      <t mod="ctrl,shift">Notification(MCEKeypress, My TV, 3)</t>
      <a mod="ctrl">Notification(MCEKeypress, Radio, 3)</a>
      <u mod="ctrl">Notification(MCEKeypress, DVD subtitle, 3)</u>
      <a mod="ctrl,shift">Notification(MCEKeypress, DVD audio, 3)</a>
    </keyboard>
find quote
wstewart Offline
Senior Member
Posts: 212
Joined: Jan 2009
Reputation: 1
Location: Canada
Post: #3
last part of keyboard.xml

Code:
</global>
  <LoginScreen>
    <keyboard>
      <end>XBMC.ShutDown()</end>
    </keyboard>
  </LoginScreen>
  <Home>
    <keyboard>
      <i>XBMC.ActivateWindow(SystemInfo)</i>
    </keyboard>
  </Home>
  <VirtualKeyboard>
    <keyboard>
      <backspace>Backspace</backspace>
    </keyboard>
  </VirtualKeyboard>
  <MyFiles>
    <keyboard>
      <space>Highlight</space>
      <delete>Delete</delete>
      <m>Move</m>
      <r>Rename</r>
    </keyboard>
  </MyFiles>
  <MyMusicPlaylist>
    <keyboard>
      <space>Back</space>
      <delete>Delete</delete>
      <u>MoveItemUp</u>
      <d>MoveItemDown</d>
    </keyboard>
  </MyMusicPlaylist>
  <MyMusicPlaylistEditor>
    <keyboard>
      <u>MoveItemUp</u>
      <d>MoveItemDown</d>
      <delete>Delete</delete>
    </keyboard>
  </MyMusicPlaylistEditor>
  <MyMusicFiles>
    <keyboard>
      <space>Playlist</space>
      <q>Queue</q>
      <delete>Delete</delete>
    </keyboard>
  </MyMusicFiles>
  <MyMusicLibrary>
    <keyboard>
      <space>Playlist</space>
      <q>Queue</q>
    </keyboard>
  </MyMusicLibrary>
  <FullscreenVideo>
    <keyboard>
      <numpadzero>Number0</numpadzero>
      <numpadone>Number1</numpadone>
      <numpadtwo>Number2</numpadtwo>
      <numpadthree>Number3</numpadthree>
      <numpadfour>Number4</numpadfour>
      <numpadfive>Number5</numpadfive>
      <numpadsix>Number6</numpadsix>
      <numpadseven>Number7</numpadseven>
      <numpadeight>Number8</numpadeight>
      <numpadnine>Number9</numpadnine>

      <menu>OSD</menu>
      <c>OSD</c>
      <back>Stop</back>
      <backspace>Stop</backspace>
      <next_track>BigStepForward</next_track>
      <prev_track>BigStepBack</prev_track>
      <delete>ShowSubtitles</delete>
      
      <f>FastForward</f>
      <r>Rewind</r>
      <period>StepForward</period>
      <comma>StepBack</comma>

      <quote>SmallStepBack</quote>
      <opensquarebracket>BigStepForward</opensquarebracket>
      <closesquarebracket>BigStepBack</closesquarebracket>

      <m>OSD</m>
      <i>Info</i>
      <o>CodecInfo</o>
      <z>AspectRatio</z>
      <t>ShowSubtitles</t>
      <t mod="ctrl">SubtitleAlign</t>
      <l>NextSubtitle</l>
      <return>OSD</return>
      <enter>OSD</enter>
      
      <!--
      <backspace>Fullscreen</backspace>
      -->
          
      <left>StepBack</left>
      <right>StepForward</right>
      <up>BigStepForward</up>
      <down>BigStepBack</down>

      
      <a>AudioDelay</a>
      <escape>Fullscreen</escape>
      <v>XBMC.ActivateWindow(Teletext)</v>
      <up mod="ctrl">SubtitleShiftUp</up>
      <down mod="ctrl">SubtitleShiftDown</down>
    </keyboard>
  </FullscreenVideo>
  <VideoTimeSeek>
    <keyboard>
      <return>Select</return>
      <enter>Select</enter>
    </keyboard>
  </VideoTimeSeek>
  <FullscreenInfo>
    <keyboard>
      <f>FastForward</f>
      <r>Rewind</r>
      <period>StepForward</period>
      <o>CodecInfo</o>
      <i>Back</i>
      <d mod="ctrl">Back</d>
      <m>OSD</m>
    </keyboard>
  </FullscreenInfo>
  <PlayerControls>
    <keyboard>
      <m>Back</m>
    </keyboard>
  </PlayerControls>
  <Visualisation>
    <keyboard>
      <f>FastForward</f>
      <r>Rewind</r>
      <period>SkipNext</period>
      <comma>SkipPrevious</comma>
      <return>ActivateWindow(MusicOSD)</return>
      <enter>ActivateWindow(MusicOSD)</enter>
      <m>ActivateWindow(MusicOSD)</m>
      <i>Info</i>
      <p>ActivateWindow(VisualisationPresetList)</p>
      <v>ActivateWindow(VisualisationSettings)</v>
      <n>ActivateWindow(MusicPlaylist)</n>
      <left>SkipPrevious</left>
      <right>SkipNext</right>
      <up>IncreaseRating</up>
      <down>DecreaseRating</down>      <!--<back>NextPreset</back>!-->
      <o>CodecInfo</o>
      <l>LockPreset</l>
      <escape>FullScreen</escape>
    </keyboard>
  </Visualisation>
  <MusicOSD>
    <keyboard>
      <f>FastForward</f>
      <r>Rewind</r>
      <period>SkipNext</period>
      <comma>SkipPrevious</comma>
      <m>Back</m>
      <i>Info</i>
      <o>CodecInfo</o>
      <p>ActivateWindow(VisualisationPresetList)</p>
      <v>ActivateWindow(VisualisationSettings)</v>
      <n>ActivateWindow(MusicPlaylist)</n>
    </keyboard>
  </MusicOSD>
  <VisualisationSettings>
    <keyboard>
      <f>FastForward</f>
      <r>Rewind</r>
      <period>SkipNext</period>
      <comma>SkipPrevious</comma>
      <m>Back</m>
      <i>Info</i>
      <o>CodecInfo</o>
      <p>ActivateWindow(VisualisationPresetList)</p>
      <v>Back</v>
      <n>ActivateWindow(MusicPlaylist)</n>
    </keyboard>
  </VisualisationSettings>
  <VisualisationPresetList>
    <keyboard>
      <f>FastForward</f>
      <r>Rewind</r>
      <period>SkipNext</period>
      <comma>SkipPrevious</comma>
      <m>Back</m>
      <i>Info</i>
      <o>CodecInfo</o>
      <p>Back</p>
      <v>Back</v>
      <n>ActivateWindow(MusicPlaylist)</n>
    </keyboard>
  </VisualisationPresetList>
  <SlideShow>
    <keyboard>
      <zero>ZoomNormal</zero>
      <one>ZoomLevel1</one>
      <two>ZoomLevel2</two>
      <three>ZoomLevel3</three>
      <four>ZoomLevel4</four>
      <five>ZoomLevel5</five>
      <six>ZoomLevel6</six>
      <seven>ZoomLevel7</seven>
      <eight>ZoomLevel8</eight>
      <nine>ZoomLevel9</nine>
      
      <numpadzero>ZoomNormal</numpadzero>
      <numpadone>ZoomLevel1</numpadone>
      <numpadtwo>ZoomLevel2</numpadtwo>
      <numpadthree>ZoomLevel3</numpadthree>
      <numpadfour>ZoomLevel4</numpadfour>
      <numpadfive>ZoomLevel5</numpadfive>
      <numpadsix>ZoomLevel6</numpadsix>
      <numpadseven>ZoomLevel7</numpadseven>
      <numpadeight>ZoomLevel8</numpadeight>
      <numpadnine>ZoomLevel9</numpadnine>
      
      <i>Info</i>
      <o>CodecInfo</o>
      <period>NextPicture</period>
      <comma>PreviousPicture</comma>
      <plus>ZoomIn</plus>
      <minus>ZoomOut</minus>
      <r>Rotate</r>
    </keyboard>
  </SlideShow>
  <ScreenCalibration>
    <keyboard>
      <return>NextCalibration</return>
      <enter>NextCalibration</enter>
      <d>ResetCalibration</d>
      <r>NextResolution</r>
    </keyboard>
  </ScreenCalibration>
  <GUICalibration>
    <keyboard>
      <return>NextCalibration</return>
      <enter>NextCalibration</enter>
      <d>ResetCalibration</d>
    </keyboard>
  </GUICalibration>
  <VideoOSD>
    <keyboard>
      <menu>Back</menu>
      <c>Back</c>
    
      <m>Back</m>
      <g mod="ctrl">Back</g> <!-- MCE Guide button -->
      <i>Info</i>
      <o>CodecInfo</o>
    </keyboard>
  </VideoOSD>
  <VideoMenu>
    <keyboard>
      <numpadzero>Number0</numpadzero>
      <numpadone>Number1</numpadone>
      <numpadtwo>Number2</numpadtwo>
      <numpadthree>Number3</numpadthree>
      <numpadfour>Number4</numpadfour>
      <numpadfive>Number5</numpadfive>
      <numpadsix>Number6</numpadsix>
      <numpadseven>Number7</numpadseven>
      <numpadeight>Number8</numpadeight>
      <numpadnine>Number9</numpadnine>
      
      <menu>OSD</menu>
      <c>OSD</c>
      
      <opensquarebracket>BigStepForward</opensquarebracket>
      <closesquarebracket>BigStepBack</closesquarebracket>
      <m>OSD</m>
      <i>Info</i>
      <o>CodecInfo</o>
      <z>AspectRatio</z>
      <t>ShowSubtitles</t>
      <l>NextSubtitle</l>
      <a>AudioDelay</a>
      <escape>Fullscreen</escape>
      <return>Select</return>
      <enter>Select</enter>      <!-- backspace>Fullscreen</backspace -->
    </keyboard>
  </VideoMenu>
  <OSDVideoSettings>
    <keyboard>
      <i>Info</i>
      <o>CodecInfo</o>
    </keyboard>
  </OSDVideoSettings>
  <OSDAudioSettings>
    <keyboard>
      <i>Info</i>
      <o>CodecInfo</o>
    </keyboard>
  </OSDAudioSettings>
  <VideoBookmarks>
    <keyboard>
      <delete>Delete</delete>
    </keyboard>
  </VideoBookmarks>
  <MyVideoLibrary>
    <keyboard>
      <delete>Delete</delete>
      <space>Playlist</space>
      <w>ToggleWatched</w>
    </keyboard>
  </MyVideoLibrary>
  <MyVideoFiles>
    <keyboard>
      <space>Playlist</space>
      <q>Queue</q>
      <w>ToggleWatched</w>
    </keyboard>
  </MyVideoFiles>
  <MyVideoPlaylist>
    <keyboard>
      <space>Back</space>
      <delete>Delete</delete>
      <u>MoveItemUp</u>
      <d>MoveItemDown</d>
    </keyboard>
  </MyVideoPlaylist>
  <MyPictures>
    <keyboard>
      <delete>Delete</delete>
    </keyboard>
  </MyPictures>
  <ContextMenu>
    <keyboard>
      <c>Back</c>
      <menu>Back</menu>
    </keyboard>
  </ContextMenu>
  <Scripts>
    <keyboard>
      <i>info</i>
    </keyboard>
  </Scripts>
  <MusicInformation>
    <keyboard>
      <i>Back</i>
      <d mod="ctrl">Back</d>
    </keyboard>
  </MusicInformation>
  <MovieInformation>
    <keyboard>
      <i>Back</i>
    </keyboard>
  </MovieInformation>
  <PictureInfo>
    <keyboard>
      <period>NextPicture</period>
      <comma>PreviousPicture</comma>
      <i>Back</i>
      <d mod="ctrl">Back</d>
      <o>Back</o>
      <space>Pause</space>
    </keyboard>
  </PictureInfo>
  <Teletext>
    <keyboard>
      <v>Back</v>
    </keyboard>
  </Teletext>
  <FileBrowser>
    <keyboard>
      <space>Highlight</space>
    </keyboard>
  </FileBrowser>
  <ShutdownMenu>
    <keyboard>
      <s>Back</s>
    </keyboard>
  </ShutdownMenu>
  <AddonInformation>
    <keyboard>
      <i>Back</i>
    </keyboard>
  </AddonInformation>
</keymap>
find quote
illumilore Offline
Junior Member
Posts: 6
Joined: Nov 2011
Reputation: 0
Post: #4
Nice guide.

The version of ir-keytables in oneiric (0.8.5-3ubuntu1) seems to work with my mce remote without need of grabbing the git.

Is there a way to test that keyboard scan codes greater than 255 are working in oneiric since the kernel's mce drivers might have been updated as well?
find quote
wstewart Offline
Senior Member
Posts: 212
Joined: Jan 2009
Reputation: 1
Location: Canada
Post: #5
illumilore Wrote:Is there a way to test that keyboard scan codes greater than 255 are working in oneiric since the kernel's mce drivers might have been updated as well?

Its not the kernel drivers that need an update/overhaul. Its xorg server itself. If you google the subject, you'll see its been in discussion for at least a year and is a fairly major change, so I don't think we'll see it anytime soon. Perhaps in 1.12 or in the newer x11 server in development, Wayland Display Server.

if you use the default rc6_mce file then it will generate keycodes greater then 255. Omit "-w /etc/rc_keymaps/rc6_mce" and it should load the default file, forget exactly where its stored. If you have already run ir-keytables with "-w /etc/rc_keymaps/rc6_mce", then you need to specify -w with the path to the default file (will be somewhere under /usr)

Enable debugging in xbmc and you can see it is detected in the log.
(This post was last modified: 2011-11-09 07:29 by wstewart.)
find quote
parag Offline
Junior Member
Posts: 1
Joined: Nov 2011
Reputation: 0
Post: #6
ir-keytable -c -p RC-5,RC-6 -w /etc/rc_keymaps/rc6_mce
these setting are lost on restart and the remote uses the old setting again.

any input to avoid it?
find quote
wstewart Offline
Senior Member
Posts: 212
Joined: Jan 2009
Reputation: 1
Location: Canada
Post: #7
parag Wrote:ir-keytable -c -p RC-5,RC-6 -w /etc/rc_keymaps/rc6_mce
these setting are lost on restart and the remote uses the old setting again.

any input to avoid it?

That's why you need to create the script in /etc/init that I give above to set things on every boot.
find quote
jet-lee Offline
Junior Member
Posts: 13
Joined: Dec 2011
Reputation: 0
Post: #8
Hi I have followed your guide and read about a million pages relating to mce setup in xbmc.

I hate to sound stupid, but in my mind there is a missing link in this chain, and hopefully you can clarify for me ...

I currently have a hauppauge mce rc-6 remote, which appears to work, I have followed your guide, but am having trouble understanding where the special mapping comes in .. basically I can use ir-keytable -t and my remote outputs perfectly .. specifically the OK key shows as KEY_OK ..

I have looked in my keyboard.xml, but cant for the life of me .. see how KEY_OK maps into the keyboard.xml file .. I have tried <KEY_OK>Select</KEY_OK>, expecting this to miraculously work, but it didnt, and I wouldve expected nothing less .. how would XBMC magically know that <KEY_OK> actually meant a remote button .. as opposed to a magical keyboard combo ?? I feel like Im ranting, but this has taken me 4 days of research, and Im no closer to a solution .. but perhaps you can clarify for me please...

All I want, is to be able to push an MCE remote button, find the code or constant name that it generates or maps to, and edit my keyboard.xml file to select a specific XBMC action to map it to ... what on earth am I missing .. please help.

PS, I am a windows person, but have bumbled my way through an Ubuntu oneiric + Latest XBMC install .. so please be gentle ..
find quote
djk29a Offline
Junior Member
Posts: 11
Joined: Nov 2009
Reputation: 0
Post: #9
The file that is most relevant to your question is the rc6_mce file under /etc/rc_keymaps. The comments to the right are inserted by the original poster.

Using ir-keytable -t, you would find the keycode that's emitted, and because of how IR keycodes work now, you don't map KEY_OK to something anymore (removal of Lircmap.xml is noted in the first couple sentences). Prior to the newer versions of the Linux kernel, we used to modify that to map keycodes to the XBMC command mappings like Select, Escape, and so on.

In your situation, the line that's relevant for you is:
Code:
0x800f0422 KEY_ENTER                            # Ok
Forget about KEY_OK, it doesn't exist on a regular keyboard, right? You don't have an OK key (unless you're on some really esoteric keyboard that won't work with most consumer PCs).

For another example of how things changed, I added another line to my rc6_keymap file like so:

Code:
0x800f0426 KEY_C # menu button
This line used to map to KEY_EPG (the "Menu" button / program guide button), and now XBMC as well as a bunch of other apps will see it as the 'c' key from the keyboard, which according to the keyboard.xml file brings up the context menu.

Code:
<c>ContextMenu</c>

And if you want to set the repeat frequency / delay, modify the command used in the ir-keytable command.
find quote
wstewart Offline
Senior Member
Posts: 212
Joined: Jan 2009
Reputation: 1
Location: Canada
Post: #10
Your getting KEY_OK because you are still using the default rc keymap file from /lib/udev/rc_keymaps/rc6_mce. Only this file has KEY_OK.

XBMC doesn't know what to do with KEY_OK and you can't define arbitrary keys in keyboard.xml.

There could be two reasons why ir-keytable is using the default file instead of the one I defined. Could be something wrong with the init script that its not running. So try this at at the command line

Code:
/usr/bin/ir-keytable -c -p RC-5,RC-6 -w /etc/rc_keymaps/rc6_mce

Now
Code:
ir-keytable -t

Now check if you still get KEY_OK or KEY_ENTER. If you get KEY_ENTER its your init script, if you still get KEY_OK, then there is something wrong with the /etc/rc_keymap file. Perhaps a type, check that it begins with

Code:
# table rc6_mce, type: RC-6

Although that looks like a comment, it is mandatory that it appear exactly that way. ir-keytable uses it.

The other explanation is that perhaps you didn't build and replace ir-keytable correctly.

But I see your using oneric, so it may have been fixed in that ubuntu build anyway. If you replaced the ir-keytable executable according to my instructions, try this to check if the oneric version is ok.

Code:
apt-get remove ir-keytable
rm /usr/bin/ir-keytable
apt-get install ir-keytable

If that still fails, then you probably still need to build ir-keytable according to my instructions and perhaps the first time did not work out for you.

Ps. you don't sound stupid, it took me a lot of time and trouble to figure this out, so its not all that straight forward.
(This post was last modified: 2011-12-03 07:41 by wstewart.)
find quote
jet-lee Offline
Junior Member
Posts: 13
Joined: Dec 2011
Reputation: 0
Post: #11
djk29a Wrote:The file that is most relevant to your question is the rc6_mce file under /etc/rc_keymaps. The comments to the right are inserted by the original poster.

Using ir-keytable -t, you would find the keycode that's emitted, and because of how IR keycodes work now, you don't map KEY_OK to something anymore (removal of Lircmap.xml is noted in the first couple sentences). Prior to the newer versions of the Linux kernel, we used to modify that to map keycodes to the XBMC command mappings like Select, Escape, and so on.

In your situation, the line that's relevant for you is:
Code:
0x800f0422 KEY_ENTER                            # Ok
Forget about KEY_OK, it doesn't exist on a regular keyboard, right? You don't have an OK key (unless you're on some really esoteric keyboard that won't work with most consumer PCs).

For another example of how things changed, I added another line to my rc6_keymap file like so:

Code:
0x800f0426 KEY_C # menu button
This line used to map to KEY_EPG (the "Menu" button / program guide button), and now XBMC as well as a bunch of other apps will see it as the 'c' key from the keyboard, which according to the keyboard.xml file brings up the context menu.

Code:
<c>ContextMenu</c>

And if you want to set the repeat frequency / delay, modify the command used in the ir-keytable command.

Thanks for answering .. please correct me if Im wrong ..

Heres a summary if what im getting from your post, I will try to make changes, but I believe you first understand, then fiddle, otherwise you make it worse ..

So the constant name like "KEY_OK" is not always relevant to XBMC, in my case I have 2 different IR codes in my mce_rc6 file, which means when I select the code for "KEY_OK", it is translated to the button "KEY_OK" before getting accepted by XBMC, and because "KEY_OK" is not a proper key, XBMC has no idea what to do with it ..

But, if I change the mce_rc6 file to have "key_ok code" and "KEY_ENTER" on the same line, XBMC will know exactly what to do with "KEY_ENTER" ...

So my understanding then is : XBMC has a list of "usable" keycode constant names, so I need to map IR codes with valid keycode constant names, and Im golden Confused?
find quote
jet-lee Offline
Junior Member
Posts: 13
Joined: Dec 2011
Reputation: 0
Post: #12
wstewart Wrote:Your getting KEY_OK because you are still using the default rc keymap file from /lib/udev/rc_keymaps/rc6_mce. Only this file has KEY_OK.

XBMC doesn't know what to do with KEY_OK and you can't define arbitrary keys in keyboard.xml.

There could be two reasons why ir-keytable is using the default file instead of the one I defined. Could be something wrong with the init script that its not running. So try this at at the command line

Code:
/usr/bin/ir-keytable -c -p RC-5,RC-6 -w /etc/rc_keymaps/rc6_mce

Now
Code:
ir-keytable -t

Now check if you still get KEY_OK or KEY_ENTER. If you get KEY_ENTER its your init script, if you still get KEY_OK, then there is something wrong with the /etc/rc_keymap file. Perhaps a type, check that it begins with

Code:
# table rc6_mce, type: RC-6

Although that looks like a comment, it is mandatory that it appear exactly that way. ir-keytable uses it.

The other explanation is that perhaps you didn't build and replace ir-keytable correctly.

But I see your using oneric, so it may have been fixed in that ubuntu build anyway. If you replaced the ir-keytable executable according to my instructions, try this to check if the oneric version is ok.

Code:
apt-get remove ir-keytable
rm /usr/bin/ir-keytable
apt-get install ir-keytable

If that still fails, then you probably still need to build ir-keytable according to my instructions and perhaps the first time did not work out for you.

Ps. you don't sound stupid, it took me a lot of time and trouble to figure this out, so its not all that straight forward.

Thanks for this, I will try these steps a little later, and post back my results, hopefully they will help someone else, thx for taking the time to answer
find quote
jet-lee Offline
Junior Member
Posts: 13
Joined: Dec 2011
Reputation: 0
Post: #13
wstewart - you are spot on, checking the mce_rce file showed that it did not indeed have a "KEY_OK" mapping, and running the ir-keytable -c manually then running ir-keytable in test mode, showed that the OK button was indeed then responding as "KEY_ENTER"

Firing up XBMC and testing some buttons then yielded wonderful results, and it behaved exaclty as I had hoped.

So it appears as though my startup script is not persisting, I will follow that up and post back again .. thanks for your help, this is all becoming a lot clearer now.

Regards

Jet
find quote
jet-lee Offline
Junior Member
Posts: 13
Joined: Dec 2011
Reputation: 0
Post: #14
OK

Managed to sort it, beware, I am a complete Linux noob, so this may be very against Linux security standards etc ...

I was looking at the script, and copied the command into terminal window, when the penny dropped, I forgot, that a lot of your commands needed to be run as root, and often Id run a command and I would get a "you need to run this as root" type error .. when I pasted your script, it needed root privileges to run .. so I did some google trawling on how to run startup scripts as root .. and its working perfectly now.

For anyone else looking for a solution I created a file in /etc/init.d/ called "xbmc-ir-keytable"

that looked like this
Code:
#! /bin/bash
/usr/bin/ir-keytable -c -p RC-5,RC-6 -w /etc/rc_keymaps/rc6_mce
exit 0

then ran
Code:
chmod +x xbmc-ir-keytable

Code:
sudo update-rc.d xbmc-ir-keytable defaults

rebooted my machine, then tested "ir-keytable -t" again .. and presto .. my OK button responded with "KEY_ENTER" ..

No More problems

I am sure this is not the most elegant solution, but it worked for me .. please feel free to suggest better alternatives Wink

Regards

Jet
find quote
wstewart Offline
Senior Member
Posts: 212
Joined: Jan 2009
Reputation: 1
Location: Canada
Post: #15
jet-lee, glad you got it working. That is odd that the init script didn't work for you. Perhaps there is something different in oneiric compared to Natty.

I couldn't get the init.d script to work in Natty. My explanation was that with upstart it is difficult if not impossible to control the order in which the init.d scripts run compared to the upstart scripts.
find quote
Post Reply