2010-07-27, 07:19
This was a project to turn an NES into a XBMC box. I did so with judicious use of a dremel, and it ended up being awesome. That aside, one of my goals (the other one may involve hiring a skin artist of some sort) was to make sure the controller ports work. I bought two USB retroports, installed them into the case (again with the help of a dremel) and got to work on a keyfile. The gods of linux decided not to let me off that easy, but with the help of the forums, I eventually worked it out and it works beautifully.
Step 1 - the keyfile:
This one is based on the apple remote keymap. It seems to work well, and it works about how I think a NES controller should work in XBMC. Feel free to modify, and post your modifications.
I removed the disclaimer text to make it all fit in one post. If you want it, you can borrow it from another keymap. I also commented out certain functions by tagging them as button 5 which doesn't exist. I may reassign them later.
Step 2 - jhat:
Download this: http://hans.fugal.net/blog/2007/06/02/jo...-in-linux/
Compile it. Remember where you put the executable.
Step 3 - figure out where your nes pads show up in the dev directory:
Mine showed up as /dev/input/js0 and /dev/input/js1 - you can work this out through dmesg or through xbmc log. These may change as you add and remove joysticks.
Step 4 - modify runXBMC:
Modify /usr/bin/runXBMC to add two lines that start the jhat daemon in the background of X before you start xbmc. My modifications are included in the following - you'll have to modify yours with the proper paths to jhat and the paths to your retropads:
This will have bugs if I restart XBMC without rebooting - I think. I may improve it later, but I don't think they're critical bugs for my purposes as I don't tend to restart XBMC without rebooting.
Step 5 - Fixup the direction pad for virtual keyboard:
Go to Settings - system - input devices and turn on Remote conntrol sends keyboard presses.
That's it.
I'll submit this for inclusion once I no longer have to do all the jhat stuff. I'll probably edit later to include anything that I forgot.
Step 1 - the keyfile:
This one is based on the apple remote keymap. It seems to work well, and it works about how I think a NES controller should work in XBMC. Feel free to modify, and post your modifications.
I removed the disclaimer text to make it all fit in one post. If you want it, you can borrow it from another keymap. I also commented out certain functions by tagging them as button 5 which doesn't exist. I may reassign them later.
Code:
<keymap>
<global>
<joystick name="RetroUSB.com RetroPad">
<!-- B --> <button id="1">PreviousMenu</button>
<!-- A --> <button id="2">Select</button>
<!-- Select --> <button id="3">Fullscreen</button>
<!-- Start --> <button id="4">ContextMenu</button>
</joystick>
</global>
<Home>
<joystick name="RetroUSB.com RetroPad">
<button id="5">XBMC.ActivateWindow(Favourites)</button>
<button id="4">ActivateWindow(shutdownmenu)</button>
</joystick>
</Home>
<Favourites>
<joystick name="RetroUSB.com RetroPad">
<button id="1">Close</button>
</joystick>
</Favourites>
<MyPictures>
<joystick name="RetroUSB.com RetroPad">
<button id="1">ParentDir</button>
</joystick>
</MyPictures>
<MyMusicPlaylist>
<joystick name="RetroUSB.com RetroPad">
<button id="5">Playlist</button>
</joystick>
</MyMusicPlaylist>
<MyMusicPlaylistEditor>
<joystick name="RetroUSB.com RetroPad">
<button id="1">ParentDir</button>
</joystick>
</MyMusicPlaylistEditor>
<MyMusicFiles>
<joystick name="RetroUSB.com RetroPad">
<button id="1">ParentDir</button>
</joystick>
</MyMusicFiles>
<MyMusicLibrary>
<joystick name="RetroUSB.com RetroPad">
<button id="1">ParentDir</button>
</joystick>
</MyMusicLibrary>
<FullscreenVideo>
<joystick name="RetroUSB.com RetroPad">
<button id="2">Pause</button>
<button id="1">Stop</button>
<button id="4">OSD</button>
<button id="3">Fullscreen</button>
</joystick>
</FullscreenVideo>
<FullscreenInfo>
<joystick name="RetroUSB.com RetroPad">
<button id="1">Close</button>
</joystick>
</FullscreenInfo>
<PlayerControls>
<joystick name="RetroUSB.com RetroPad">
<button id="1">Close</button>
</joystick>
</PlayerControls>
<Visualisation>
<joystick name="RetroUSB.com RetroPad">
<button id="2">Pause</button>
<button id="3">Fullscreen</button>
<button id="4">XBMC.ActivateWindow(MusicOSD)</button>
<button id="1">Stop</button>
</joystick>
</Visualisation>
<MusicOSD>
<joystick name="RetroUSB.com RetroPad">
<button id="1">Close</button>
</joystick>
</MusicOSD>
<VisualisationSettings>
<joystick name="RetroUSB.com RetroPad">
<button id="1">Close</button>
</joystick>
</VisualisationSettings>
<VisualisationPresetList>
<joystick name="RetroUSB.com RetroPad">
<button id="1">Close</button>
</joystick>
</VisualisationPresetList>
<SlideShow>
<joystick name="RetroUSB.com RetroPad">
<button id="1">Stop</button>
<button id="3">Info</button>
<button id="4">Rotate</button>
</joystick>
</SlideShow>
<ScreenCalibration>
<joystick name="RetroUSB.com RetroPad">
<button id="2">NextCalibration</button>
</joystick>
</ScreenCalibration>
<SelectDialog>
<joystick name="RetroUSB.com RetroPad">
<button id="1">Close</button>
</joystick>
</SelectDialog>
<VideoOSD>
<joystick name="RetroUSB.com RetroPad">
<button id="1">Close</button>
<button id="4">Close</button>
</joystick>
</VideoOSD>
<VideoMenu>
<joystick name="RetroUSB.com RetroPad">
<button id="2">Select</button>
<button id="1">Stop</button>
<button id="5">OSD</button>
<button id="4">ContextMenu</button>
</joystick>
</VideoMenu>
<OSDVideoSettings>
<joystick name="RetroUSB.com RetroPad">
<button id="1">Close</button>
</joystick>
</OSDVideoSettings>
<OSDAudioSettings>
<joystick name="RetroUSB.com RetroPad">
<button id="1">Close</button>
</joystick>
</OSDAudioSettings>
<VideoBookmarks>
<joystick name="RetroUSB.com RetroPad">
<button id="1">Close</button>
</joystick>
</VideoBookmarks>
<MyVideoLibrary>
<joystick name="RetroUSB.com RetroPad">
<button id="1">ParentDir</button>
</joystick>
</MyVideoLibrary>
<MyVideoFiles>
<joystick name="RetroUSB.com RetroPad">
<button id="1">ParentDir</button>
</joystick>
</MyVideoFiles>
<MyVideoPlaylist>
<joystick name="RetroUSB.com RetroPad">
<button id="1">Playlist</button>
</joystick>
</MyVideoPlaylist>
<VirtualKeyboard>
<keyboard>
<left>Left</left>
<right>Right</right>
<up>Up</up>
<down>Down</down>
</keyboard>
<joystick name="RetroUSB.com RetroPad">
<button id="1">Close</button>
</joystick>
</VirtualKeyboard>
<ContextMenu>
<joystick name="RetroUSB.com RetroPad">
<button id="1">Close</button>
</joystick>
</ContextMenu>
<FileStackingDialog>
<joystick name="RetroUSB.com RetroPad">
<button id="1">Close</button>
</joystick>
</FileStackingDialog>
<MusicInformation>
<joystick name="RetroUSB.com RetroPad">
<button id="1">Close</button>
</joystick>
</MusicInformation>
<MovieInformation>
<joystick name="RetroUSB.com RetroPad">
<button id="1">Close</button>
</joystick>
</MovieInformation>
<PictureInfo>
<joystick name="RetroUSB.com RetroPad">
<button id="1">Left</button>
<button id="2">Right</button>
<button id="4">Close</button>
</joystick>
</PictureInfo>
<AddonBrowser>
<joystick name="RetroUSB.com RetroPad">
<button id="1">ParentDir</button>
</joystick>
</AddonBrowser>
</keymap>
Step 2 - jhat:
Download this: http://hans.fugal.net/blog/2007/06/02/jo...-in-linux/
Compile it. Remember where you put the executable.
Step 3 - figure out where your nes pads show up in the dev directory:
Mine showed up as /dev/input/js0 and /dev/input/js1 - you can work this out through dmesg or through xbmc log. These may change as you add and remove joysticks.
Step 4 - modify runXBMC:
Modify /usr/bin/runXBMC to add two lines that start the jhat daemon in the background of X before you start xbmc. My modifications are included in the following - you'll have to modify yours with the proper paths to jhat and the paths to your retropads:
Code:
echo "#!/bin/bash" > /home/$xbmcUser/.xsession
echo "ulimit -c 0" >> /home/$xbmcUser/.xsession
echo "/home/bmfrosty/jhat/jhat /dev/input/js0 0 1 &" >> /home/$xbmcUser/.xsession
echo "/home/bmfrosty/jhat/jhat /dev/input/js1 0 1 &" >> /home/$xbmcUser/.xsession
echo "/usr/bin/xbmc --standalone" >> /home/$xbmcUser/.xsession
This will have bugs if I restart XBMC without rebooting - I think. I may improve it later, but I don't think they're critical bugs for my purposes as I don't tend to restart XBMC without rebooting.
Step 5 - Fixup the direction pad for virtual keyboard:
Go to Settings - system - input devices and turn on Remote conntrol sends keyboard presses.
That's it.
I'll submit this for inclusion once I no longer have to do all the jhat stuff. I'll probably edit later to include anything that I forgot.