{"id":176,"date":"2013-12-01T21:35:06","date_gmt":"2013-12-01T21:35:06","guid":{"rendered":"https:\/\/asdfghjkl.me.uk\/blog\/?p=176"},"modified":"2021-03-28T18:04:39","modified_gmt":"2021-03-28T17:04:39","slug":"xboxremote","status":"publish","type":"post","link":"https:\/\/asdfghjkl.me.uk\/blog\/xboxremote\/","title":{"rendered":"Setting up the Xbox 360 DVD remote with OpenELEC"},"content":{"rendered":"<p>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 <a href=\"http:\/\/openelec.tv\">OpenELEC<\/a> 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.<\/p>\n<p><em>Note:\u00a0This 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).<\/em><\/p>\n<p><em><!--more--><\/em><\/p>\n<p>The first step is to get hold of an IR receiver. Follow the steps in the Hardware section\u00a0<a href=\"http:\/\/aron.ws\/projects\/lirc_rpi\">here<\/a> (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\u00a0TSOP38238 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:<\/p>\n<pre>echo \"modprobe lirc_rpi\" &gt;&gt; \/storage\/.config\/autostart.sh<\/pre>\n<p>Reboot, and then run the following to add a new remote:<\/p>\n<pre>killall lircd\nirrecord \/storage\/.config\/lircd.conf<\/pre>\n<p>Follow the instructions. For a full list of key names (starting with KEY_), you can run\u00a0<em>irrecord -list namespace | grep KEY_ | more<\/em>. 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:<\/p>\n<p><a href=\"https:\/\/asdfghjkl.me.uk\/blog\/wp-content\/uploads\/remotebuttons.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-large wp-image-178\" src=\"https:\/\/asdfghjkl.me.uk\/blog\/wp-content\/uploads\/remotebuttons-562x1024.jpg\" alt=\"Remote button layout\" width=\"562\" height=\"1024\" srcset=\"https:\/\/asdfghjkl.me.uk\/blog\/wp-content\/uploads\/remotebuttons-562x1024.jpg 562w, https:\/\/asdfghjkl.me.uk\/blog\/wp-content\/uploads\/remotebuttons-164x300.jpg 164w, https:\/\/asdfghjkl.me.uk\/blog\/wp-content\/uploads\/remotebuttons-624x1136.jpg 624w, https:\/\/asdfghjkl.me.uk\/blog\/wp-content\/uploads\/remotebuttons.jpg 815w\" sizes=\"(max-width: 562px) 100vw, 562px\" \/><\/a><\/p>\n<p>Some of the buttons are unused because I'd inevitably forget what they did. You can always run the above\u00a0<em>irrecord<\/em> command again to add more. You'll want to add the following to \/storage\/.config\/lircd.conf:<\/p>\n<pre>begin remote\n name asdf_360remote\n bits 13\n flags RC6|CONST_LENGTH\n eps 30\n aeps 100\n header 2660 890\n one 446 448\n zero 446 448\n pre_data_bits 24\n pre_data 0x1BFF80\n gap 106750\n toggle_bit_mask 0x8000\n rc6_mask 0x100000000\n begin codes\n KEY_MUTE 0x0BD7\n KEY_VENDOR 0x0B9B\n KEY_STOP 0x0BE6\n KEY_PAUSE 0x0BE7\n KEY_REWIND 0x0BEA\n KEY_FASTFORWARD 0x0BEB\n KEY_PAUSE 0x0BE9\n KEY_PREVIOUS 0x0BE4\n KEY_NEXT 0x0BE5\n KEY_SUBTITLE 0x0BAE\n KEY_OK 0x0BDB\n KEY_EXIT 0x0BDC\n KEY_UP 0x0BE1\n KEY_LEFT 0x0BDF\n KEY_OK 0x0BDD\n KEY_RIGHT 0x0BDE\n KEY_DOWN 0x0BE0\n KEY_HOME 0x0BF2\n end codes\nend remote<\/pre>\n<p>Some remotes have trouble with button presses getting repeated, but this one seems fine. If you do have issues, see <a href=\"https:\/\/web.archive.org\/web\/20170830004621\/http:\/\/wiki.openelec.tv\/index.php?title=Guide_To_lirc_rpi_GPIO_Receiver\">here<\/a> for info on the suppress_repeat option.<\/p>\n<p>Now we want to translate LIRC buttons into XBMC buttons, so we edit <em>\/storage\/.xbmc\/userdata\/Lircmap.xml<\/em> and replace the existing &lt;remote device=\"devinput\"&gt; section. For some reason the name you give in <em>lircd.conf<\/em> is irrelevant and it'll\u00a0always 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.<\/p>\n<pre> &lt;remote device=\"devinput\"&gt;\n &lt;left&gt;KEY_LEFT&lt;\/left&gt;\n &lt;right&gt;KEY_RIGHT&lt;\/right&gt;\n &lt;up&gt;KEY_UP&lt;\/up&gt;\n &lt;down&gt;KEY_DOWN&lt;\/down&gt;\n &lt;select&gt;KEY_OK&lt;\/select&gt;\n &lt;start&gt;KEY_HOME&lt;\/start&gt;\n &lt;back&gt;KEY_EXIT&lt;\/back&gt;\n &lt;play&gt;KEY_PLAY&lt;\/play&gt;\n &lt;pause&gt;KEY_PAUSE&lt;\/pause&gt;\n &lt;stop&gt;KEY_STOP&lt;\/stop&gt;\n &lt;forward&gt;KEY_FASTFORWARD&lt;\/forward&gt;\n &lt;reverse&gt;KEY_REWIND&lt;\/reverse&gt;\n &lt;skipplus&gt;KEY_NEXT&lt;\/skipplus&gt;\n &lt;skipminus&gt;KEY_PREVIOUS&lt;\/skipminus&gt;\n &lt;subtitle&gt;KEY_SUBTITLE&lt;\/subtitle&gt;\n &lt;mute&gt;KEY_MUTE&lt;\/mute&gt;\n &lt;xbox&gt;KEY_VENDOR&lt;\/xbox&gt;\n &lt;\/remote&gt;<\/pre>\n<p>I left KEY_PLAY in there just in case it came in handy at some point. It probably won't.<\/p>\n<p>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 <a href=\"https:\/\/asdfghjkl.me.uk\/files\/remote.xml\">here<\/a>.<\/p>\n<ul>\n<li>First things first, we add\u00a0&lt;xbox&gt;scanitem&lt;\/xbox&gt; to the &lt;keymap&gt;&lt;global&gt;&lt;remote&gt; section. This is what powers our comically giant rescanning X button.<\/li>\n<li>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 &lt;start&gt;prettymuchanythinghere&lt;\/start&gt; with &lt;start&gt;Home&lt;\/start&gt;, EXCEPT the one in the &lt;FullscreenVideo&gt; section (usability, right?). For that one you'll want &lt;start&gt;XBMC.ActivateWindow(Home)&lt;\/start&gt; instead. I have no idea why.<\/li>\n<li>If we're home already, it'd be nice if the Home button would return us to the playing video. So in the &lt;Home&gt; section, we add &lt;start&gt;Fullscreen&lt;\/start&gt;.<\/li>\n<li>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 &lt;FullscreenVideo&gt; section we replace\u00a0&lt;back&gt;SmallStepBack&lt;\/back&gt; with &lt;back&gt;Back&lt;\/back&gt;.<\/li>\n<li>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 &lt;Visualisation&gt; and &lt;systeminfo&gt;, we use &lt;back&gt;Back&lt;\/back&gt; too.<\/li>\n<\/ul>\n<p>That's it for the remote stuff. Save and reboot and hopefully everything should work as expected! If nothing's happening, run <em>irw<\/em>\u00a0and press some buttons. If nothing appears, you've probably gone wrong somewhere around the <em>irrecord<\/em> bit.<\/p>\n<p>--<\/p>\n<p>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).\u00a0If 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 <a title=\"Airplay is rubbish: better audio streaming to XBMC\" href=\"https:\/\/asdfghjkl.me.uk\/blog\/airplaysucks\/\">here<\/a> for instructions. You'll want to edit <em>720p\/Home.xml<\/em> and search for\u00a0<em>&lt;onclick condition=\"StringCompare(Window.Property(VideosDirectLink),True)\"&gt;ActivateWindow(Videos)&lt;\/onclick&gt;<\/em>. Replace this:<\/p>\n<pre>&lt;onclick condition=\"StringCompare(Window.Property(VideosDirectLink),True)\"&gt;ActivateWindow(Videos)&lt;\/onclick&gt;\n&lt;onclick condition=\"!StringCompare(Window.Property(VideosDirectLink),True)\"&gt;ActivateWindow(Videos,root)&lt;\/onclick&gt;<\/pre>\n<p>with this:<\/p>\n<pre>&lt;onclick condition=\"StringCompare(Window.Property(VideosDirectLink),True)\"&gt;ActivateWindow(Videos,files)&lt;\/onclick&gt;\n&lt;onclick condition=\"!StringCompare(Window.Property(VideosDirectLink),True)\"&gt;ActivateWindow(Videos,files)&lt;\/onclick&gt;<\/pre>\n<p>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!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5,3,4],"tags":[],"_links":{"self":[{"href":"https:\/\/asdfghjkl.me.uk\/blog\/wp-json\/wp\/v2\/posts\/176"}],"collection":[{"href":"https:\/\/asdfghjkl.me.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/asdfghjkl.me.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/asdfghjkl.me.uk\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/asdfghjkl.me.uk\/blog\/wp-json\/wp\/v2\/comments?post=176"}],"version-history":[{"count":17,"href":"https:\/\/asdfghjkl.me.uk\/blog\/wp-json\/wp\/v2\/posts\/176\/revisions"}],"predecessor-version":[{"id":330,"href":"https:\/\/asdfghjkl.me.uk\/blog\/wp-json\/wp\/v2\/posts\/176\/revisions\/330"}],"wp:attachment":[{"href":"https:\/\/asdfghjkl.me.uk\/blog\/wp-json\/wp\/v2\/media?parent=176"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/asdfghjkl.me.uk\/blog\/wp-json\/wp\/v2\/categories?post=176"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/asdfghjkl.me.uk\/blog\/wp-json\/wp\/v2\/tags?post=176"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}