Skip to content

Fix control binding the escape key. - #2896

Merged
IntegratedQuantum merged 8 commits into
PixelGuys:masterfrom
HansAschenloher:2257-fix-escape-during-control-binding-process
May 6, 2026
Merged

IntegratedQuantum merged 8 commits into
PixelGuys:masterfrom
HansAschenloher:2257-fix-escape-during-control-binding-process

Conversation

@HansAschenloher

Copy link
Copy Markdown
Contributor

When pressing the escape key while in a control binding process, then the control should get bound to escape and the settings window should still be open.
This commit disables closing the settings window while binding a key.

fixes: #2257

@Wunka Wunka moved this to Easy to Review in PRs to review Apr 19, 2026

@IntegratedQuantum IntegratedQuantum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same issue applies to all other keybinds that can be pressed while in the settings.
So please apply this fix in a central location where it applies to all keybinds.

@IntegratedQuantum IntegratedQuantum moved this from Easy to Review to In review in PRs to review Apr 19, 2026
When pressing the escape key while in a control binding process,
then the control should get bound to escape and the settings window
should still be open.
This commit disables closing the settings window while binding a key.

fixes: PixelGuys#2257
@HansAschenloher
HansAschenloher force-pushed the 2257-fix-escape-during-control-binding-process branch from dd31fc0 to e721590 Compare April 21, 2026 20:05
Comment thread src/graphics/Window.zig Outdated
}

fn action(self: *Key, typ: enum { press, release, repeat }, isGrabbed: bool, mods: Modifiers, textKeyPressedInTextField: bool) void {
if (hasNextInputListenter()) return;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing this here has a side effect: If I click on a button to bind a gamepad key, without having a controller installed, I'll get stuck unable to interact with anything. I'd suggest to move the check to functions that handle the listeners.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I totally missed this.
While fixing this I discovered another bug.
When clicking a button to bind a gamepad key, without having a controller installed, then it is not possible to bind it to a keyboard key again and you are cannot rebind the key.
I suggest resetting the binding process when toggling from keyboard to gamepad and vise versa.

I included this fix in this pr.
I have no Gamepad so please check if everything works as expected.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should probably also reset the binding process when closing / opening the window. Currently when set to gamepad mode and trying to set a key, but if you then close the window by for example pressing any keyboard key or clicking with the mouse outside the window. The binding process is not reset.

@DellieDelta

Copy link
Copy Markdown
Contributor

Tested the latest commit with a controller, and rebinding keys works. Some keys do close the settings menu though when binding them, these are X and B. And binding the thumbstick scrolls the setting menu. But the same bugs are present on the master version as well :)

@IntegratedQuantum IntegratedQuantum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright then please also fix the issue mentioned in #2896 (comment)

@HansAschenloher

Copy link
Copy Markdown
Contributor Author

Tested the latest commit with a controller, and rebinding keys works. Some keys do close the settings menu though when binding them, these are X and B. And binding the thumbstick scrolls the setting menu. But the same bugs are present on the master version as well :)

Thanke you for testing it :)
Ok I looked over the controller part again, and it seems like the key binding is on-release. So the normal key actions get triggered before the binning event, that will then abort the update function.
I have no controller to test it, I suggest to create a new issue for the controller part.

If someone want to look into it, here is the relevant code

Comment thread src/gui/windows/controls.zig Outdated
}

pub fn onOpen() void {
pub fn initWindow() void {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be private now that you renamed it

Comment thread src/gui/windows/controls.zig Outdated
}

pub fn onClose() void {
pub fn deinitWindow() void {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@IntegratedQuantum
IntegratedQuantum merged commit b16eadf into PixelGuys:master May 6, 2026
1 check passed
@HansAschenloher
HansAschenloher deleted the 2257-fix-escape-during-control-binding-process branch May 6, 2026 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Pressing escape during binding process closes the menu yet still binds it

4 participants