Skip to content
This repository has been archived by the owner on Jul 6, 2023. It is now read-only.

No pause or menu function on gamepad #7

Closed
s1eve-mcdichae1 opened this issue Dec 8, 2021 · 13 comments · Fixed by #14
Closed

No pause or menu function on gamepad #7

s1eve-mcdichae1 opened this issue Dec 8, 2021 · 13 comments · Fixed by #14
Assignees

Comments

@s1eve-mcdichae1
Copy link

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
Copy link
Owner

Please check if commit be51d30 works for you.

@s1eve-mcdichae1
Copy link
Author

s1eve-mcdichae1 commented Dec 8, 2021

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
Copy link
Author

...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
Copy link
Author

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

@drfiemost
Copy link
Owner

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
Copy link
Author

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
Copy link
Author

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

@drfiemost
Copy link
Owner

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

@drfiemost
Copy link
Owner

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
Copy link
Author

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

@drfiemost
Copy link
Owner

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
Copy link
Author

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
Copy link
Owner

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

drfiemost added a commit that referenced this issue Dec 12, 2021
Allow exiting the game with joystick button and detect button mapping at runtime (issue #7)

Co-authored-by: s1eve-mcdichae1 <92833764+s1eve-mcdichae1@users.noreply.github.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants