drhelius / Gearsystem

Sega Master System / Game Gear / SG-1000 emulator for macOS, Windows, Linux, BSD and RetroArch.
https://x.com/drhelius
GNU General Public License v3.0
250 stars 45 forks source link

Added a generalised shortcut system so any gui events can have a shortcut key defined in the config.ini #52

Closed samizzo closed 2 years ago

samizzo commented 2 years ago

I've added a way to allow the debug keys to be redefined in the config.ini, because I wanted keys that matched Visual Studio (F10 to step, F5 to run, etc). This system could be generalised even more to allow remapping all gui shortcut keys. For starters I would probably get rid of the double mapping that I've made between gui_shortcut_event_map and config_debug and instead combine them so that there is an array of gui_ShortCutEvents in the config.

Let me know if this is something you're interested in. If so I can do some further work in this PR, or you can take it as-is if you like, or I can make further changes in another PR, or you can even just leave it if you're not interested. No problem either way!

drhelius commented 2 years ago

Awesome, thanks for your effort! Yes, I like it.

It would be great if you can complete the work or extend it to all the gui shortcuts in this same PR before merging, so we can test all the work together.

Also, it looks like you're using some non-portable things like stricmp. This will break some platforms as you can see in GitHub Actions.

But hey, it's a nice work!

samizzo commented 2 years ago

Great! I'll fix those errors and extend it to all the gui shorcuts!

samizzo commented 2 years ago

I've generalised this system now. Hopefully it's fairly straightforward, but the idea is you define new gui events in gui_events.def. This file is included in gui_events.h and gui_events.cpp and used to generate both an enum and a string. The string is used by the config system.

You can construct a string for displaying in the ui using gui_event_get_shortcut_string which will look up the specified shortcut. The keypresses are handled in gui_process_input. It will fire the appropriate event there by looking up the shortcut in the config.

This is an example of the shortcuts as written using the default key configuration:

[Shortcuts]
OpenROM = Ctrl+O
Reset = Ctrl+R
Pause = Ctrl+P
FFWD = Ctrl+F
SaveState = Ctrl+S
LoadState = Ctrl+L
DebugStep = Ctrl+F10
DebugContinue = Ctrl+F5
DebugNextFrame = Ctrl+F6
DebugBreakpoint = Ctrl+F9
DebugRuntocursor = Ctrl+F8
DebugGoBack = Ctrl+Backspace
ShowMainMenu = Ctrl+M
drhelius commented 2 years ago

Amazing work, I had a look through all the changes and it looks great!

Let me test it a bit and will merge it ASAP.

drhelius commented 2 years ago

Sorry for the delay, I’ll be looking into it this weekend, expect a merge before Monday.

samizzo commented 2 years ago

No problem at all!

drhelius commented 2 years ago

Again, sorry for the huge delay. I have been under a lot of pressure in my daily job.

And again, thanks a lot for your contribution!!

I'll try to port this changes in the future to both Gearboy and Gearcoleco emulators, that have a similar structure, if you don't mind.

samizzo commented 2 years ago

No problem at all, same here actually! :D

On 22/10/2021 12:01 am, Ignacio Sanchez Gines wrote:

Again, sorry for the huge delay. I have been under a lot of pressure in my daily job.

And again, thanks a lot for your contribution!!

I'll try to port this changes in the future to both Gearboy and Gearcoleco emulators, that have a similar structure, if you don't mind.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/drhelius/Gearsystem/pull/52#issuecomment-948592029, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANL7UALI4BJ3U54O5QP5ETUIAFJJANCNFSM5DSNMAJQ. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.