Setting up the Xbox 360 DVD remote with OpenELEC

I've recently moved house and so have inherited a new(ish) TV. The TV I was using before had a remote with a set of unused media buttons at the bottom, which I repurposed to control OpenELEC on my Raspberry Pi. Since the new remote doesn't have any buttons to spare, I had to give the Pi one of its very own. I had a look round and eventually settled upon the Xbox 360 DVD remote, which I picked up on eBay for an entirely reasonable three pounds - I expected to get a Chinese clone at that price but was pleasantly surprised to find that it turned out to be genuine! I remember setting up the old remote being fairly involved so I'm making it into a start-to-finish tutorial this time round.

Note: This tutorial was written for openELEC 3.2.4. If you're using a different version, some things might be different (particularly the paths, if you're using raspbmc or stock XBMC instead).

The first step is to get hold of an IR receiver. Follow the steps in the Hardware section here (tl;dr: 3.3V module, connect power to GPIO pin 1, ground to pin 6 and data to pin 12), but you can ignore all the software stuff as support is now built into OpenELEC. I used a TSOP38238 module and picked up some jumper leads to connect it up. Again, eBay is your friend. Enabling support in the kernel is as simple as running the following command over SSH:

echo "modprobe lirc_rpi" >> /storage/.config/autostart.sh

Reboot, and then run the following to add a new remote:

killall lircd
irrecord /storage/.config/lircd.conf

Follow the instructions. For a full list of key names (starting with KEY_), you can run irrecord -list namespace | grep KEY_ | more. There's a few that are a little difficult to work out - for play/pause you want KEY_PAUSE (PLAY and PLAYPAUSE don't seem to work properly), for back you want KEY_EXIT, and for enter you want KEY_OK. You can always use my config if you can't be bothered to set it up yourself and you don't mind my deranged button layout. I also wanted the big Xbox button to rescan the selected programme if I added a new episode - more on that later, but for now we map it to something unused like KEY_VENDOR:

Remote button layout

Some of the buttons are unused because I'd inevitably forget what they did. You can always run the above irrecord command again to add more. You'll want to add the following to /storage/.config/lircd.conf:

begin remote
 name asdf_360remote
 bits 13
 flags RC6|CONST_LENGTH
 eps 30
 aeps 100
 header 2660 890
 one 446 448
 zero 446 448
 pre_data_bits 24
 pre_data 0x1BFF80
 gap 106750
 toggle_bit_mask 0x8000
 rc6_mask 0x100000000
 begin codes
 KEY_MUTE 0x0BD7
 KEY_VENDOR 0x0B9B
 KEY_STOP 0x0BE6
 KEY_PAUSE 0x0BE7
 KEY_REWIND 0x0BEA
 KEY_FASTFORWARD 0x0BEB
 KEY_PAUSE 0x0BE9
 KEY_PREVIOUS 0x0BE4
 KEY_NEXT 0x0BE5
 KEY_SUBTITLE 0x0BAE
 KEY_OK 0x0BDB
 KEY_EXIT 0x0BDC
 KEY_UP 0x0BE1
 KEY_LEFT 0x0BDF
 KEY_OK 0x0BDD
 KEY_RIGHT 0x0BDE
 KEY_DOWN 0x0BE0
 KEY_HOME 0x0BF2
 end codes
end remote

Some remotes have trouble with button presses getting repeated, but this one seems fine. If you do have issues, see here for info on the suppress_repeat option.

Now we want to translate LIRC buttons into XBMC buttons, so we edit /storage/.xbmc/userdata/Lircmap.xml and replace the existing <remote device="devinput"> section. For some reason the name you give in lircd.conf is irrelevant and it'll always use devinput, hence replacing the existing section rather than adding our own. Note that the KEY_VENDOR button we added earlier maps to the xbox XBMC button, which we'll use in a minute.

 <remote device="devinput">
 <left>KEY_LEFT</left>
 <right>KEY_RIGHT</right>
 <up>KEY_UP</up>
 <down>KEY_DOWN</down>
 <select>KEY_OK</select>
 <start>KEY_HOME</start>
 <back>KEY_EXIT</back>
 <play>KEY_PLAY</play>
 <pause>KEY_PAUSE</pause>
 <stop>KEY_STOP</stop>
 <forward>KEY_FASTFORWARD</forward>
 <reverse>KEY_REWIND</reverse>
 <skipplus>KEY_NEXT</skipplus>
 <skipminus>KEY_PREVIOUS</skipminus>
 <subtitle>KEY_SUBTITLE</subtitle>
 <mute>KEY_MUTE</mute>
 <xbox>KEY_VENDOR</xbox>
 </remote>

I left KEY_PLAY in there just in case it came in handy at some point. It probably won't.

Now we need to edit /storage/.xbmc/userdata/keymaps/remote.xml, to map the XBMC buttons to XBMC commands. There's a few things to change here because I swear whoever wrote the damn thing has no concept of usability, or you can just download my finished one here.

  • First things first, we add <xbox>scanitem</xbox> to the <keymap><global><remote> section. This is what powers our comically giant rescanning X button.
  • For some reason the Home button does something different in every single view. If you're playing a video, it'll open the OSD. Sure, why not. You'll want to replace every incidence of <start>prettymuchanythinghere</start> with <start>Home</start>, EXCEPT the one in the <FullscreenVideo> section (usability, right?). For that one you'll want <start>XBMC.ActivateWindow(Home)</start> instead. I have no idea why.
  • If we're home already, it'd be nice if the Home button would return us to the playing video. So in the <Home> section, we add <start>Fullscreen</start>.
  • When playing a video, the Back button will rewind (WHY?!?!). We'd like it to return to the previous menu just like LITERALLY EVERYWHERE ELSE, so in the <FullscreenVideo> section we replace <back>SmallStepBack</back> with <back>Back</back>.
  • Did I say literally everywhere? I lied. Back also does something crazy when you're watching a visualisation, or in the settings menu. So in <Visualisation> and <systeminfo>, we use <back>Back</back> too.

That's it for the remote stuff. Save and reboot and hopefully everything should work as expected! If nothing's happening, run irw and press some buttons. If nothing appears, you've probably gone wrong somewhere around the irrecord bit.

--

This is a bit of an aside, but not worth giving its own post to. XBMC's library view is great, but relies on an internet connection to download info about your media. Without one, you might as well use the Files view instead so you don't need to rescan to see new content. This is easy enough to get to but requires a couple of extra button presses - I wanted to go straight to Files when I clicked Videos (I'd already hidden Movies and TV Shows from the home screen in the theme settings). If you want it to do this, you'll need to make a copy of the Confluence theme first as OpenELEC won't let you edit the original. See my earlier blogpost here for instructions. You'll want to edit 720p/Home.xml and search for <onclick condition="StringCompare(Window.Property(VideosDirectLink),True)">ActivateWindow(Videos)</onclick>. Replace this:

<onclick condition="StringCompare(Window.Property(VideosDirectLink),True)">ActivateWindow(Videos)</onclick>
<onclick condition="!StringCompare(Window.Property(VideosDirectLink),True)">ActivateWindow(Videos,root)</onclick>

with this:

<onclick condition="StringCompare(Window.Property(VideosDirectLink),True)">ActivateWindow(Videos,files)</onclick>
<onclick condition="!StringCompare(Window.Property(VideosDirectLink),True)">ActivateWindow(Videos,files)</onclick>

Save and reboot, and you're all sorted. If you managed to get lost somewhere along the way, leave a comment or shoot me an email at hello at this domain!

1 thought on “Setting up the Xbox 360 DVD remote with OpenELEC

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.