drfiemost / Hurrican

A fork of Hurrican, freeware jump and shoot game created by Poke53280, with SDL2 enabled by default, support for libopenmpt and CRT simulation
MIT License
7 stars 2 forks source link

No pause or menu function on gamepad #7

Closed s1eve-mcdichae1 closed 2 years ago

s1eve-mcdichae1 commented 2 years ago

There is no "pause" or "menu" button mapped to the gamepad. Once I begin a game, I cannot exit without pressing [Esc] on the keyboard (*well, I guess I can also wait till I lose all my lives and return to the menu that way. This is not an ideal solution for me.)

Can a pause/menu button be added to the gamepad mappings?

drfiemost commented 2 years ago

Please check if commit be51d30 works for you.

s1eve-mcdichae1 commented 2 years ago

Please check if commit be51d30 works for you.

Sort of. I can get back to the menu and exit the game now, but...can it be configurable? Right now I don't see a way to do that, and it's set on button 2 (the "east" face button, on my controller, which is "shoot" by default.) Ideally it would be on "start" (button 8?) or "menu" (9?) if I can't configure it myself, but not all controllers have a "menu" button.

In any case, it probably shouldn't be the "shoot" button in a shooting game ;)

s1eve-mcdichae1 commented 2 years ago

...I tried to remap "shoot" to the right-trigger as a temporary workaround, but the triggers aren't recognized, probably because they are analog axes? That may not be within the scope of this issue, however.

s1eve-mcdichae1 commented 2 years ago

Sorry I didn't mean to close this, that was an accident.

drfiemost commented 2 years ago

The button is hardcoded right now, need to move to the newer SDL_GameController API so it would be possible to use standard mapped buttons. In the meanwhile I've updated the code with a new function, you might want to change the button number to fit your needs.

s1eve-mcdichae1 commented 2 years ago

Looks like there's an off-by-one somewhere, so "button 8" here in the code is actually "button 9" in the game.

"8(9)" is my Menu/Hotkey button and "7(8)" is my Start which feels more natural to me so I've set it like this locally with PR #12 but since it's going to be different for every gamepad, I don't know if you think it's worth merging.

s1eve-mcdichae1 commented 2 years ago

With that change on my end though, it's working great. Thanks!

drfiemost commented 2 years ago

I've merged the change but it needs a better solution before going into master, so I'll keep the ticket open.

drfiemost commented 2 years ago

I think I've found a shorcut, can you please check 9292ec8 to see if the start button is correctly detected at startup?

s1eve-mcdichae1 commented 2 years ago

I may not have much time with my system over the weekend but I will check it out when I get a chance.

drfiemost commented 2 years ago

Got a chance to test a PS4 controller and it looks good, the SDL_CONTROLLER_BUTTON_START is detected as the button "Options", so I've implemented the mapping for all the required buttons. If the joystick_pause branch works fine for you I'll merge it into master.

s1eve-mcdichae1 commented 2 years ago

If the joystick_pause branch works fine for you I'll merge it into master.

I think so, yeah. I only had a few minutes to test 3d67def but it's a real quick check to see if "start" works, or not.

It did.

To make sure it wasn't just falling back on the hardcoded default button value, I changed it back to "8" (my "menu" button) and recompiled, and it still paused the game on "start," not on "menu."

drfiemost commented 2 years ago

Good! Hope the other buttons are correct too. I'll proceed with the merging, Just open another ticket if there are still issues.