A Fix for lr-mupen64plus-next N64 Controller Input Issues
-
This is an addition to the solution 'badviper' made for fixing controller mapping issues for N64 on the lr-mupen64plus-next emulator.
Setup:
Pi Model 3B+ with Canakit power supply
RetroPie 4.7.1 Buster
Image pre-made from RetroPie website, with some personal tweaks
Controller used: Retrolink N64 USB Controller
Emulator: lr-mupen64plus-nextScenario:
- Testing Super Mario 64 and StarFox 64 on lr-mupen64plus-next using default video settings
- Controller mapped in ES using recommended mappings
Issue
- Controller buttons work fine and act as they should in ES, and jstest,
- In the emulator, the physical B button acts as the logical A button, and the physical A button doesn't work for the logical B button (can't back out of menus, etc.)
- Controller works perfectly fine in other N64 emulators like mupen64plus-GLideN64, mupen64plus-gles2n64, and mupen64plus-gles2rice.
- Compared the button mappings in:
/opt/retropie/configs/all/retroarch/autoconfig/Generic USB Joystick .cfg
and
/opt/retropie/configs/all/retroarch-joypads/Generic USB Joystick .cfg
and
/opt/retropie/configs/N64/mupen64plus.cfg
and
/opt/retropie/configs/N64/InputAutoCfg.ini
and
/opt/retropie/configs/all/emulationstation/es_input.cfg
I discovered that, just like 'badviper', I could not get the button mapping to work correctly in lr-mupen64plus-next despite it working perfectly fine in emulation station.
See his post about this issue and his solution:
Re: lr-mupen64plus-next and N64 controller input issuesHe reconfigure his controller in emulation station using the configuration shown here:
link text
As you can see here, and as discussed in his post, mapping the controller like this does make it work in the games, but then navigating menus in the RGUI and emulation station becomes difficult because your physical 'A' button is now 'B', your physical 'B' button is now 'Y', and your physical C-down button is 'A'. I was not entirely ok with this and wanted the controller to still be usable while in emulation station so that I didn't have to rewire the synapses in my brain.Solution
-
I reconfigured my controller in emulation station by using this mapping:
Basically it's the standard layout, except the L-shoulder (or L-Trigger) and Z-trigger have swapped places (I'll get to why in a minute). Also, I set my Hotkey as the physical Left Shoulder button. -
Since I didn't map an 'X' button, I have no way of getting into the RGUI (without a keyboard), but I found this post on reddit about a great idea:
link text
The idea being to navigate to /opt/retropie/configs/n64/retroarch.cfg and open this with Notepad++ and add an input to this config file:
input_menu_toggle_btn = "button(0)"
# Settings made here will only override settings in the global retroarch.cfg if placed above the #include line input_remapping_directory = "/opt/retropie/configs/n64/" input_menu_toggle_btn = "button(0)" input_player1_joypad_index = "0" input_player2_joypad_index = "1" # input_player3_joypad_index = "2" # input_player4_joypad_index = "3" #include "/opt/retropie/configs/all/retroarch.cfg"
"Button 0" is the physical C-Up button on the controller. Save this config and reboot emulation station (probably not necessary, but just in case)
-
Launch a game and use Hotkey (L-Shoulder ) + C-Up to access the RGUI quick menu. Scroll down to "Controls". Then down to "Port 1 Controls". Now change the button mappings. The buttons with the highlighted red dots are the only ones I had to change, which are the buttons for A, B, Z, and L Shoulder:
We had to swap the Z-Trigger and the L-Shoulder buttons in emulation station, but now we have to swap them back here so that they function correctly in the game. I know...it's messed up. -
Go back a menu and "Save Core Remap File".
-
Use Hotkey + C-Up to exit.
You can now play N64 games on the Retrolink N64 USB Controller! You can also still navigate Emulation Station menus with the controller. The only caveat of having swapped the Z-Trigger and the L-Shoulder buttons is that you can no longer 'page-up' quickly through game lists in Emulation Station like the L-shoulder button used to do. The Z button will bring up the 'Options' menu so you can 'Jump to...' a game letter section though.
You can also fix other N64 emulators that run on retroarch that have wonky buttons (which they will because we reconfigured them in emulation station) by going into the RGUI (the same L-shoulder+C-up combo still works) and into the Controls menu, and selecting 'Load Remap File'. Choose the 'Mupen64Plus-Next' remap file and now those same button mappings will be applied to this emulator too.
One final note:
I used to prefer having the physical Z button as the Hotkey, but when I set it up that way for this emulator the Z action wouldn't function 100% correctly. It would work, but only act as if I tapped the button. If I was trying to hold the button down, it would still only behave like I tapped the button once. Again, someone on reddit figured it out:
link text
You can't have the hotkey bound to the Z-trigger. In any other emulator pressing the Hotkey does nothing until you pair it with another button. In this emulator, it thinks the Z button and the hotkey are separate and being pressed at the same time, so it partially cancels out the action command...I think...I'm not really sure, but setting your Hotkey as the physical L-Shoulder button solved that problem. I'm sure that the emulator is still performing the action incorrectly when you push the L-Shoulder button while in-game, but it's often not really an important button for gameplay so it doesn't really matter. Z-button on the other hand...you need that for Mario to do a butt stomp, or in the case of StarFox, you need to hold that so you can bank left.Final, Final, note; Here's what my controller config files end up looking like (and their locations) for reference:
/opt/retropie/configs/all/retroarch/autoconfig/Generic USB Joystick .cfg
input_device = "Generic USB Joystick "
input_driver = "udev"
input_enable_hotkey_btn = "4"
input_r_y_minus_btn = "0"
input_l_btn = "7"
input_load_state_btn = "7"
input_r_y_plus_btn = "2"
input_up_btn = "h0up"
input_up_btn_label = "D-Pad Up"
input_left_btn = "h0left"
input_left_btn_label = "D-Pad Left"
input_state_slot_decrease_btn = "h0left"
input_r_x_minus_btn = "3"
input_l_y_plus_axis = "+1"
input_l_y_plus_axis_label = "Left Stick Down"
input_l_x_plus_axis = "+0"
input_l_x_plus_axis_label = "Left Stick Right"
input_right_btn = "h0right"
input_right_btn_label = "D-Pad Right"
input_state_slot_increase_btn = "h0right"
input_l2_btn = "4"
input_l_x_minus_axis = "-0"
input_l_x_minus_axis_label = "Left Stick Left"
input_r_x_plus_btn = "1"
input_r_btn = "5"
input_r_btn_label = "RB"
input_save_state_btn = "5"
input_l_y_minus_axis = "-1"
input_l_y_minus_axis_label = "Left Stick Up"
input_down_btn = "h0down"
input_down_btn_label = "D-Pad Down"
input_start_btn = "9"
input_start_btn_label = "Start"
input_exit_emulator_btn = "9"
input_b_btn = "8"
input_reset_btn = "8"
input_a_btn = "6"/opt/retropie/configs/all/emulationstation/es_input.cfg
<inputConfig type="joystick" deviceName="Generic USB Joystick " deviceGUID="03000000790000000600000010010000">
<input name="pageup" type="button" id="7" value="1"/>
<input name="start" type="button" id="9" value="1"/>
<input name="up" type="hat" id="0" value="1"/>
<input name="a" type="button" id="6" value="1"/>
<input name="b" type="button" id="8" value="1"/>
<input name="down" type="hat" id="0" value="4"/>
<input name="pagedown" type="button" id="5" value="1"/>
<input name="right" type="hat" id="0" value="2"/>
<input name="left" type="hat" id="0" value="8"/>
<input name="rightanalogup" type="button" id="0" value="1"/>
<input name="rightanalogdown" type="button" id="2" value="1"/>
<input name="select" type="button" id="7" value="1"/>
<input name="leftanalogdown" type="axis" id="1" value="1"/>
<input name="leftanalogright" type="axis" id="0" value="1"/>
<input name="leftanalogleft" type="axis" id="0" value="-1"/>
<input name="leftanalogup" type="axis" id="1" value="-1"/>
<input name="rightanalogleft" type="button" id="3" value="1"/>
<input name="rightanalogright" type="button" id="1" value="1"/>/opt/retropie/configs/N64/mupen64plus.cfg
DPad R = "hat(0 Right)"
DPad L = "hat(0 Left)"
DPad D = "hat(0 Down)"
DPad U = "hat(0 Up)"
Start = "button(9)"
Z Trig = "button(7)"
B Button = "button(8)"
A Button = "button(6)"
C Button R = "button(1)"
C Button L = "button(3)"
C Button D = "button(2)"
C Button U = "button(0)"
R Trig = "button(5)"
L Trig = "button(4)"
Mempak switch = ""
Rumblepak switch = ""
Analog axis configuration mappings
X Axis = "axis(0-,0+)"
Y Axis = "axis(1-,1+)" -
@adamg thanks for sharing this. I just updated to Buster and my old fix for mapping the generic n64 didn't work. Mapping a hotkey for the menu did the trick. Weird though, I only had to map my A and Z buttons, everything worked fine.
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.