Patch for Joypad Hotkeys for Mupen64plus 2.5

260 views
Skip to first unread message

Simon Lang

unread,
Jul 24, 2015, 7:06:38 PM7/24/15
to mupen64plus
Hi there!

I've implemented a new little feature for Mupen64plus (version 2.5) regarding hotkeys.

I usually use Retroarch for most emulators, but I found the mupen64plus core to be a little slow (especially on older machines). Some of you probably know the setup that is common if you use Retroarch on a machine without keyboard and mouse attached to it: You want to to be able to save/load the state, reset and quit the emulator using hotkeys on the joypad. And since you don't have that many keys on ordinary controllers, combinations like "Select + R" or "Select + Start" come in handy (Modifier plus hotkey).

M64plus already supports hotkeys on joypads, but without the modifier option. I added some code to support it the same way that Retroarch does.

Here's a little overview of my changes:
  • In mupen64plus.cfg, if "Joy Mapping Hotkey Modifier" is set to any button, the hotkey modifier is active and hotkeys will only be registered while it is pressed.
    Example 1:
    Joy Mapping Stop = "J0B6"              # Hotkey Modifier (HMod) + Back/Select stops the emulator
    Joy Mapping Save State = "J0B5"        # HMod + R saves the emulator state
    Joy Mapping Hotkey Modifier = "J0B8"   # Hotkeys are only active while Home (Xbox / PS) button is held
    Example 2:
    Joy Mapping Stop = "J0B6"              # Back/Select stops the emulator
    Joy Mapping Save State = "J0B5"        # R saves the emulator state
    Joy Mapping Hotkey Modifier = ""       # Hotkey Modifier is disabled
  • I've also added support for multiple mappings
    Example 1:
    Joy Mapping Stop = "J0B6,J0B7,J1B6,J2B6" # J0 Back, J0 Start, J1 Back and J2 Back each stop the emulator
    Example 2:

    Joy Mapping Stop = "J0B6,J0B7,J1B6,J2B6"       # J0 HMod + J0 Back, J0 HMod + J0 Start, J1 HMod + J1 Back, and J2 HMod + J2 Back each stop the emulator
    Joy Mapping Hotkey Modifier = "J0B8,J1B8,J2B8" # Hotkey Modifier (HMod) is set to Home button on joypads 0, 1 and 2
    Note that each joypad's hotkey modifier state only affects the same joypad, i.e., pressing J0's hotkey modifier and J1's stop button will not stop the emulator.
    (This also means that if a hotkey modifier is set up for J0, but not for J1, then J1 won't be able to use hotkeys. I might fix that.)
  • An easy way to define the same mapping for all joypads is also available now:
    Joy Mapping Stop = "J0B6"              # only J0 can stop the emulator (with HMod + Back)
    Joy Mapping Save State = J*B5          # any joypad can save the state (with their HMod + R)
    Joy Mapping Hotkey Modifier = "J*B8"   # sets up the hotkey modifier for every joypad (Home button)

To apply my patch, download mupen64plus-core-2.5 (or the bundle) and navigate to the directory mupen64plus-core(-2.5) which contains all the files and the src directory. Move the patch there and run

patch -p0 < hotkey.patch

Important: This patch might not work with the current Git version due to changes in eventloop.c. If there's any interest, I'll adjust it.


Drawbacks: The same input used for the hotkeys is still registered by the input plugin, e.g., pressing HMod + A triggers the according hotkey function (if any) and passes the 'A' input to the input plugin (that's how it always used to be, anyway). I haven't found any clean way to prevent this, and it's probably not a big deal.


To the M64 team:

Thanks for the awesome emulator, the great command line interface, and the nice code. It was fairly easy to implement the features without knowing the code. So far I haven't encountered any bugs with my additions, I hope I didn't forget anything and I tried to make it as clean as possible. If you'd like to include the feature and there's something missing, let me know and I'll work on it.

hotkey.patch

Richard Goedeken

unread,
Oct 4, 2015, 7:36:52 PM10/4/15
to mupen...@googlegroups.com
Hi Simon,

Thank you very much for this contribution. Sorry it took so long to respond.
I looked over your code and thought about these new features and while I think
that they are good to have, I wasn't that happy about the way that you
implemented the "hotkey modifier" feature; I thought it was overly complex. I
finally took the time and wrote up a different implementation which is more
flexible and requires fewer code changes. I've committed this to the GitHub
repository here:

https://github.com/mupen64plus/mupen64plus-core/commit/14bf40b236af1d5a5e7b86cd15a6cb628b4153fd

And the updated wiki documentation is here:

http://mupen64plus.org/wiki/index.php?title=Mupen64Plus_Core_Parameters

It is a great feature and I'm sure that it will be useful to lots of people.
Thanks for the suggestion and the code. I tested my implementation here and
all the new features worked for me, but I would appreciate testing from others
as well, because it is a fairly major change.

Thanks,
Richard

simon....@gmail.com

unread,
Nov 17, 2015, 11:20:42 PM11/17/15
to mupen64plus, Ric...@fascinationsoftware.com
Hi Richard,

sorry for the late reply (I forgot to check back), but thanks a lot for your feedback. I've looked over your implementation and prefer it over mine, thanks for taking the time. I'm gonna use the new code from now on and do some testing with it.

Simon
Reply all
Reply to author
Forward
0 new messages