Advertisement
Guest User

Untitled

a guest
Mar 10th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.38 KB | None | 0 0
  1. Mouse, Keyboard & Joypad working with WHDLoad on RetroPie
  2. please note: this is a rough and ready post, written quickly - I think it covers all steps, but if I’ve missed anything I’ll update it.
  3. Also note: If you copy and paste, double check that facebook hasn't added curly quotations etc.
  4. I spent a whole weekend determined to get Keyboard & Mouse free gaming working on UAE4Arm and I am pleased to say, I managed it before my head exploded.
  5. Firstly, before you try this - I managed to get this working following a lot of different tutorials, failing, then learning a hell of a lot as I went along. And through sheer persistence and some problem solving I managed to get it working.
  6. I cannot offer support - this works by magic, I mixed up some other magicians’ spells and luckily I didn’t blow myself up, I just know this is working for me (back up your image before you try this)
  7. Second, it requires the additional controller configuration (dropdown) of the latest UAE4Arm - I know some people have been having problems with it. I don’t know what those problems are, so I can’t offer solutions for those either. Again, this works for me.
  8. I did this with a NES30 Pro from 8bitdo, this brought with it more problems as 8bitdo controllers don’t supply linux with a controller ID.
  9. I’ll give you a little of the theory behind the method before I go into the tutorial.
  10. The theory:
  11. I had heard it was possible to map keyboard and mouse to a controller (with analog sticks) and dug into some tutorials (mediamogul’s Advanced controller configuration on the RetroPie Wiki was very helpful) before trying it out using ScummVM.
  12. The method works by creating a virtual xbox controller and using xboxdrv to map your controller to it. xboxdrv is very configurable and it allows you to map buttons/axis on your controller to mouse, keyboard etc.
  13. Once I had that successfully working, I wondered if it would work for Amiga too.
  14. I’d already configured UAE4Arm to work with the WHDLoad project, so I was using Olly’s version - the same settings actually worked perfectly for mouse and keyboard mapping, but, Joystick wouldn’t work at all.
  15. I had a theory this was due to UAE looking through the joypads available to linux and using the first one it found.
  16. To test this, I installed the newer version of UAE4Arm, manually selected the virtual controller from dropdown on the input screen and it worked :)
  17. I fixed the problems upgrading caused (it overwrites the changes you made to: /opt/retropie/configs/amiga/emulators.cfg) then I changed a setting in each of my WHDLoad pack .uae files to use the virtual joypad, and presto - WHD gaming with joystick, mouse and keyboard all from one joypad, (and I can also launch ADF games from the menu using just the control pad).
  18. This method gives you the following benefits.
  19. - Open GUI with Select+X, then quit using Select+Start
  20. - Switch between mouse and joystick in game (for ADFs that don’t have WHD support)
  21. - Create your own mapping (eg. map joystick to analog stick and use a modifier to switch between mouse and joystick)
  22. - Use shoulder buttons and DPAD as common keys you might require in games (Q to quit etc)
  23. - And more, I’m sure you’ll think of some.
  24. So here’s the how to…
  25.  
  26. Step 1: [Back Up]
  27.  
  28. Back up your SD card so you can revert back to it if:
  29.  
  30. a) This messes something up for you or
  31. b) You don’t like it
  32.  
  33.  
  34.  
  35. Step 2: [Map your controller to be read as a standard Xbox360 controller]
  36.  
  37. Follow step 1 of this guide on the RetroPie WIKI:
  38.  
  39. https://github.com/RetroPie/RetroPie-Setup/wiki/Universal-Controller-Calibration-&-Mapping-Using-xboxdrv
  40.  
  41. Stop when you get to the end of the paragraph that begins with “Now that we have all the event codes from the controller… “ because we’re not going to be adding the mapping to rc.local (we’ll be adding it somewhere else).
  42.  
  43. Write your button codes etc on paper (you will need them later)
  44. You’ll also need either: the controller name or the event number.
  45.  
  46. You get this by typing: cat /proc/bus/input/devices (to get the event number - it’s next to H: Handlers = ), ls /dev/input/by-id/ (if your device is listed, write down its name - including spaces etc… it’s case sensitive too)
  47.  
  48.  
  49.  
  50. Step 3: [Let’s make the mouse part work for testing]
  51.  
  52. By this stage, we’ve installed xboxdrv and written down our controller name (or event number)
  53.  
  54. We’re going to test the mouse works before upgrading UAE4Arm.
  55.  
  56. By default, xboxdrv can only be run as root, we need it to work at user level…
  57.  
  58. From the command line:
  59.  
  60. sudo nano /etc/udev/rules.d/55-permissions-uinput.rules
  61.  
  62. Add this line:
  63.  
  64. KERNEL=="uinput", MODE="0660", GROUP="users"
  65.  
  66. Then CTRL+X, Y, Enter (quit, save, confirm)
  67.  
  68. Then we need to add some code to ‘runcommand-onstart.sh’ which will execute when launching UAE4Arm
  69.  
  70. I got this technique from the Wiki here:
  71.  
  72. https://github.com/RetroPie/RetroPie-Setup/wiki/Universal-Controller-Calibration-&-Mapping-Using-xboxdrv
  73.  
  74. Scroll down to (3B) Expanding Launch Capabilities and follow the instructions… stop when you get to this line:
  75.  
  76. For some emulators we could face some problem.
  77.  
  78. Next, we’ll make some specific edits to ‘runcommand-onstart.sh’ as some of the code on the Wiki is not relevant to us:
  79.  
  80. From the command line:
  81.  
  82. sudo nano /opt/retropie/configs/all/runcommand-onstart.sh
  83.  
  84. Delete the following:
  85.  
  86. mame-libretro)
  87. ;;
  88.  
  89. fba)
  90. case $rom in
  91. "amidar.zip"|"atetris.zip"|"puckman.zip") # Configuration used only for these ROMs
  92. $xboxkill
  93. joycommand="$basicPS3 $fourway &"
  94. eval $joycommand
  95. ;;
  96. *) # Configuration for every other ROMs on this emulator
  97. $xboxkill
  98. joycommand="$basicPS3 &"
  99. eval $joycommand
  100. ;;
  101. esac
  102. ;;
  103.  
  104. daphne)
  105. ;;
  106.  
  107. scummvm)
  108. $xboxkill
  109. joycommand="$basicPS3 $scummVM &"
  110. eval $joycommand
  111. ;;
  112.  
  113. (they’re not needed for this)
  114.  
  115. We also need to make some changes to the controls…
  116.  
  117. Replace this:
  118.  
  119. amiga="--axismap -Y1=Y1,-Y2=Y2 \
  120. --ui-axismap x2=REL_X:1,y2=REL_Y:1 \
  121. --ui-axismap x1=KEY_LEFT:KEY_RIGHT,y1=KEY_DOWN:KEY_UP \
  122. --ui-buttonmap du=KEY_UP,dd=KEY_DOWN,dl=KEY_LEFT,dr=KEY_RIGHT \
  123. --ui-buttonmap lt=BTN_LEFT,rt=BTN_RIGHT,start=KEY_ESC,back=KEY_LEFTCTRL,y=KEY_SPACE,a=KEY_LEFTCTRL,b=KEY_LEFTALT,x=KEY_LEFTSHIFT \
  124. --ui-buttonmap guide=void,tl=void,lt=void,rt=void,back=void \
  125. --ui-axismap x2=void"
  126.  
  127. With this:
  128.  
  129. amiga="--axismap -Y1=Y1,-Y2=Y2 \
  130. --buttonmap tl^toggle=tl \
  131. --buttonmap tr^toggle=tr \
  132. --ui-axismap tl+x1=REL_X:5,tl+y1=REL_Y:5 \
  133. --ui-buttonmap tl+b=BTN_LEFT,tl+a=BTN_RIGHT \
  134. --ui-buttonmap rt+a=KEY_ENTER,rt+b=KEY_ESC,rt+x=KEY_SPACE,rt+y=KEY_P,rt+du=KEY_UP,rt+dd=KEY_DOWN,rt+dl=KEY_LEFT,rt+dr=KEY_RIGHT \
  135. --ui-buttonmap back+x=KEY_F12,back+start=KEY_Q \
  136. --ui-buttonmap guide=void \
  137. --ui-axismap x2=void"
  138.  
  139. (this does the following: L3 toggles mouse - Left analog becomes mouse, b becomes left mouse, a becomes right mouse, press L3 again to revert back… also, hold right trigger to make Dpad into cursor keys… finally, select-x opens UAE4Arm GUI, select-start to quit to emulationstation from GUI… you can make your own mapping etc)
  140.  
  141. Replace this:
  142.  
  143. basicPS3="/opt/retropie/supplementary/xboxdrv/bin/xboxdrv >/dev/null \
  144. --evdev /dev/input/event2 \
  145. --silent \
  146. --detach-kernel-driver \
  147. --force-feedback \
  148. --mimic-xpad \
  149. --dpad-as-button \
  150. --trigger-as-button \
  151. --evdev-absmap ABS_X=x1,ABS_Y=y1,ABS_Z=x2,ABS_RX=y2 \
  152. --evdev-keymap KEY_#302=a,KEY_#301=b,BTN_DEAD=x,KEY_#300=y,BTN_THUMB=tl,BTN_THUMB2=tr,BTN_BASE5=lb,BTN_BASE6=rb,BTN_BASE3=lt,BTN_BASE4=rt,BTN_TRIGGER=back,BTN_TOP=start,BTN_SOUTH=guide,BTN_TOP2=du,BTN_PINKIE=dr,BTN_BASE=dd,BTN_BASE2=dl
  153. --calibration x1=-32767:0:32767,y1=-32767:0:32767,x2=-32767:0:32767,y2=-32767:0:32767"
  154.  
  155. With this:
  156.  
  157. basicPS3="/opt/retropie/supplementary/xboxdrv/bin/xboxdrv > /dev/null \
  158. --evdev /dev/input/event2 \
  159. --silent \
  160. --detach-kernel-driver \
  161. --deadzone=4000 \
  162. --deadzone-trigger 15% \
  163. --force-feedback \
  164. --mimic-xpad \
  165. --trigger-as-button \
  166. --evdev-absmap ABS_X=x1,ABS_Y=y1,ABS_Z=x2,ABS_RZ=y2,ABS_HAT0X=dpad_x,ABS_HAT0Y=dpad_y \
  167. --evdev-keymap BTN_SOUTH=a,BTN_EAST=b,BTN_NORTH=x,BTN_WEST=y,BTN_TL=lb,BTN_TR=rb,BTN_TL2=lt,BTN_TR2=rt,BTN_THUMBL=tl,BTN_THUMBR=tr,BTN_SELECT=back,BTN_START=start \
  168. --calibration x1=-32767:0:32767,y1=-32767:0:32767,x2=-32767:0:32767,y2=-32767:0:32767"
  169.  
  170. You’ll need to map your own controller at this point…
  171.  
  172. In step 2 you wrote down your event number, input id (if your controller had one) and button events.
  173.  
  174. Edit this line:
  175. --evdev /dev/input/event2 \
  176.  
  177. If you have an input id, this line becomes:
  178. --evdev /dev/input/by-id/[your controller’s input id] \
  179.  
  180. If not, replace event2, with your own event (might still be event2), for example:
  181. --evdev /dev/input/event3 \
  182.  
  183. Then, replace these, with the button events for your controller:
  184. --evdev-absmap ABS_X=x1,ABS_Y=y1,ABS_Z=x2,ABS_RZ=y2,ABS_HAT0X=dpad_x,ABS_HAT0Y=dpad_y \
  185. --evdev-keymap BTN_SOUTH=a,BTN_EAST=b,BTN_NORTH=x,BTN_WEST=y,BTN_TL=lb,BTN_TR=rb,BTN_TL2=lt,BTN_TR2=rt,BTN_THUMBL=tl,BTN_THUMBR=tr,BTN_SELECT=back,BTN_START=start \
  186.  
  187. (for each pairing YOUR button event comes first, its’ xbox equivalent comes after the equals sign, pairs are separated by commas)
  188. (if your dpad gives you BTN_ events, and not ABS_ events, add —dpad-as-button)
  189. (if your left & right trigger give you ABS_ events, delete --trigger as button)
  190. (make sure the \ stays in place for each line - if not, xboxdrv will fail)
  191.  
  192. Save your changes and exit nano.
  193.  
  194. You’ll also need to kill xboxdrv on exit (this comes from the wiki)
  195. we do this with the onend script
  196.  
  197. From terminal:
  198.  
  199. sudo nano /opt/retropie/configs/all/runcommand-onend.sh
  200.  
  201. #!/bin/sh
  202. sudo killall >/dev/null xboxdrv
  203.  
  204. Save and quit
  205.  
  206. Make it executable
  207.  
  208. sudo chmod +x /opt/retropie/configs/all/runcommand-onend.sh
  209.  
  210. If everything you’ve done so far has been successful, you should be able to return to emulation station and launch UAE4Arm.
  211.  
  212. When (if) it launches, click L3 (push your left analog stick in, then release) and try your analog stick. If it moves the mouse cursor smoothly, push select & start (keyboard Q) to quit the GUI and return to emulation station.
  213.  
  214. If you’re not happy with the mapping, or you’ve mapped buttons wrongly - you can edit those lines again.
  215.  
  216. If there are problems, something doesn’t launch you can:
  217. sudo nano /dev/shm/runcommand.log
  218.  
  219. And possibly debug from there (I had to do this from terminal a lot while experimenting, but I learned a lot from it - the changes we’ve made so far are all easy to comment out or revert back)
  220.  
  221.  
  222.  
  223. Step 4: [Update UAE4Arm (overwriting Olly’s version) and fix it for WHDLoad]
  224.  
  225. Sorry guys, this is a necessary step - I spent a whole day trying to figure out why everything else was working, but UAE wasn’t recognising the joystick parts of the mapping even though I could play Syndicate with the controller (it happily accepted the mouse and keyboard). It seems the older version of UAE4Arm was grabbing the first joypad if found on the list and using it (event2 in my case).
  226.  
  227. I’ll assume you know how to update your emulators, you just need to update UAE4Arm from the retropie setup script.
  228.  
  229. Once you’ve done that, launch UAE4Arm to access the GUI.
  230.  
  231. Check your (joypad) mouse works (L3, then use the analog stick - alternatively hold RT and try the DPAD). If it does, select INPUT and in the dropdown, change from your original controller to the xbox one listed.
  232.  
  233. Save the configuration as “Default” (if you’ve updated your default config before, you can save it as something else)
  234.  
  235. Exit UAE4Arm.
  236.  
  237. Press F4 (or ssh into your pi).
  238.  
  239. The only thing that should have been overwritten by the update is: /opt/retropie/configs/amiga/emulators.cfg
  240.  
  241. So you just need to:
  242.  
  243. - Open emulators.cfg for editing;
  244.  
  245. sudo nano /opt/retropie/configs/amiga/emulators.cfg
  246.  
  247. - Change the line reading 'uae4arm' to the following;
  248.  
  249. uae4arm="pushd /opt/retropie/emulators/uae4arm/; ./uae4arm -config=%ROM%"
  250.  
  251. To make WHDLoad work again.
  252.  
  253. Step 5: [Update a .uae file then launch a game to test]
  254.  
  255. We just need to make one change to our .uae files (we can automate this later)
  256.  
  257. If you edited your default config file in the previous step…
  258.  
  259. First backup your config file:
  260.  
  261. cp /opt/retropie/emulators/uae4arm/conf/uaeconfig.uae /opt/retropie/emulators/uae4arm/conf/uaeconfig.old
  262.  
  263. (this is all on one line with a space in between)
  264.  
  265. Then:
  266.  
  267. sudo nano /opt/retropie/emulators/uae4arm/conf/uaeconfig.uae
  268.  
  269. If you used a different config file, open that one instead.
  270.  
  271. Scroll down using your cursor til you find a two lines that look like this:
  272. input.1.joystick.2.friendlyname=Microsoft X-Box 360 pad
  273. input.1.joystick.2.name=JOY2
  274.  
  275. Scroll back up to find the line that looks like this
  276.  
  277. Find this line: joyport1=joy2
  278.  
  279. If joy(x) is different to the number represented by the Microsoft X-Box 360 pad (our mapped virtual joypad), change the number to match.
  280.  
  281. (We want UAE4Arm to use the virtual joypad we mapped.)
  282.  
  283. Make sure you remember the joy(x) number, we need it when editing one more .uae file.
  284.  
  285. Locate your amiga roms folder…
  286.  
  287. e.g.:
  288.  
  289. cd ~/RetroPie/roms/amiga/
  290.  
  291. Then edit one of your .uae files (choose one you know uses joystick for testing)
  292.  
  293. e.g.:
  294.  
  295. sudo nano “Magic Pockets.uae”
  296.  
  297. We need to add this line to the config:
  298.  
  299. joyport1=joy2
  300.  
  301. (Ensure your joy(x) represents your own Xbox virtual joypad I added mine just below: sound_auto=yes)
  302.  
  303. Save and quit.
  304.  
  305. Launch your game from EmulationStation.
  306.  
  307. If it worked, the following should happen:
  308.  
  309. 1) You can play as normal (using your joypad)
  310. 2) Select & X should open the GUI
  311. 3) L3 should then give you mouse control over the GUI with the left analog stick
  312. 4) If it does, use select & start to quit to EmulationStation
  313.  
  314. If it all worked as it should, from this point you now need to update all your .uae files as we did for that game.
  315.  
  316. I wasn’t excited about that prospect so I figured I’d cheat (see next step)
  317.  
  318. Once they all have the joyport1=joy2 line, you’ll be able to switch between mouse and joypad at will, and exit to GUI then exit to emulation station using just the joypad.
  319.  
  320. Step 5: [Update your .uae files automatically]
  321.  
  322. If you haven’t already added Dom Cresswell’s _Config Maker, do it now - you’ll need it (see his downloads post for instructions)
  323.  
  324. Next, edit the config maker’s template file
  325.  
  326. From command line:
  327.  
  328. sudo nano ~/RetroPie/roms/amiga/"_Config Maker"/uaeconfig.uaetemp
  329.  
  330. Add:
  331.  
  332. joyport1=joy2
  333.  
  334. If joy(x) is different to the number represented by the Microsoft X-Box 360 pad (our mapped virtual joypad), change the number to match.
  335.  
  336. Save and exit.
  337.  
  338. Return to emulation station and run the config maker.
  339.  
  340. It will scan your amiga roms folder for games, check if a .uae file exists for it and then ask if you want to overwrite the existing file.
  341.  
  342. Type: Y (for yes, you will need your keyboard for this)
  343.  
  344. Once it completes, quit to GUI, then quit to emulation station (your joypad shortcuts should work for this)
  345.  
  346. And, that SHOULD be it.
  347.  
  348. If you change controllers, don’t like the new setup or something breaks, you can revert back by removing the line from uaeconfig.uaetemp and rerunning the config maker. Then remove the stuff you added to runcommand-onstart.sh
  349.  
  350. Alternatively re-image your SD card from the backup you made in step 1.
  351.  
  352. I’m pretty sure I covered everything I did, and found, in this post. I can’t go into specific “what if” scenarios and I don’t know enough about xboxdrv to help with those - however, I did find the retropie wiki and forum to be invaluable. (Mediamogul’s posts are very helpful)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement