punesemu / puNES

Qt-based Nintendo Entertaiment System emulator and NSF/NSF2/NSFe Music Player (Linux, FreeBSD, OpenBSD and Windows)
GNU General Public License v2.0
656 stars 42 forks source link

map shortcuts via command line #368

Closed bmsuseluda closed 9 months ago

bmsuseluda commented 9 months ago

hello fabio,

thanks for this great emulator. Right now i can configure a lot via the command line, but what is missing are the input controlls and shortcuts.

Would it be possible to add them as well?

Thanks in regards bmsuseluda

punesemu commented 9 months ago

Hi bmsuseluda, thank you for your frontend :+1: . Right now I'm implementing NSF2 format support and rewriting the NSF player, but when I finish I can take a look at your request. I still have no idea how I could implement it but I'm open to suggestions.

bmsuseluda commented 9 months ago

Based on your input.cfg file i would suggest --shortcut-video-fullscreen Alt+Return,NULL for video fullscreen. I think with this it would be relatively simple to have a similar structure to your config files.

Another approach could be what other emulators are doing:

ares

https://ares-emu.net/news/ares-v133-released

--setting Hotkey/ToggleFullscreen=0x1/0/2

dolphin

https://wiki.dolphin-emu.org/index.php?title=Help:Contents#Command_Line_Options

--config Dolphin.Display.Fullscreen=True

mednafen

-ss.input.port1 3dpad

duckstation

https://github.com/stenzek/duckstation/wiki/Command-Line-Arguments

DuckStation is a bit limited, but supports a command -settings /path/to/custom/config to load a custom config.

Sadly tho there is no standard, so do what suits you best :) I hope this helps and do not feel in a hurry. Do your things in your order and your time and it will be great 👍️

punesemu commented 9 months ago

OK, many thanks for the suggestions, I will keep you updated.

punesemu commented 9 months ago

I implemented it (275865a), I could only do the tests with keyboard commands because my two gamepads don't work. If you can do some tests I would be grateful. For shortcuts you need to use the syntax "--shortcut.hard_reset=F11" for the NES pad "--input.p1k_left=Left". The descriptions of the shortcuts can be found in the puNES.cfg file (you must replace the spaces with the underscore) while the descriptions of the NES pad commands can be found in the input.cfg file.

bmsuseluda commented 9 months ago

of course i will do 🙂

i tried to test with the appImage, but unfortunatly the app does not start. I get the following log statements:

ALSA lib dlmisc.c:339:(snd_dlobj_cache_get0) Cannot open shared library libasound_module_pcm_pulse.so (/usr/lib/libsndfile.so.1: undefined symbol: mpg123_info2)
▶ playback open : No such device or address

I do not know if the problem relates with the appImage in general, because i used the flatpak in the past only.

Is it released as a flatpak already?

punesemu commented 9 months ago
ALSA lib dlmisc.c:339:(snd_dlobj_cache_get0) Cannot open shared library libasound_module_pcm_pulse.so (/usr/lib/libsndfile.so.1: undefined symbol: mpg123_info2)
▶ playback open : No such device or address

Which Linux distribution are you using?

bmsuseluda commented 9 months ago

manjaro (arch)

punesemu commented 9 months ago

I want to try creating a VM with your distro but I need to know what version of Manjaro you use.

bmsuseluda commented 9 months ago

Since Manjaro is a rolling release distro, you can just grab the latest one.

punesemu commented 9 months ago

Can you try with the latest appimage? I should have solved it with commit d753cbc.

bmsuseluda commented 9 months ago

now it runs. thanks for this fast fix.

I was able to set a shortcut to a gamepad key via command line. This is great.

What i could not get to work is to set a gamepad key to the nes pad. I tried "--input.p1j_start=BTN07" as an example.

punesemu commented 9 months ago

Sorry there was a bug that I fixed, get the latest WIP. I have also made other changes that make management clearer, to configure keyboard shortcuts you now have to use the --shortcut.k parameter while for joystick shortcuts --shortcut.j : e.g. --shortcut.k.open=Alt+O or --shortcut.j.hard_reset=BTN05. In a similar way you can also manage the configuration of the NES gamepad : --input.p1k.up=Up or -input.p1j.up=BTN05. You can find the explanation in the -h of the emulator.

bmsuseluda commented 9 months ago

i like the new way to configure the keys. It is much simpler. Sadly i do not get the input settings for gamepads to work.

punesemu commented 9 months ago

I should have solved it with be0c260.

bmsuseluda commented 9 months ago

it works 🎉👍️🙂

punesemu commented 9 months ago

Great, thanks so much for the tests.