Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebindable keyboard controls #1891

Merged
merged 1 commit into from
Jan 11, 2022
Merged

Rebindable keyboard controls #1891

merged 1 commit into from
Jan 11, 2022

Conversation

epozzobon
Copy link
Contributor

@epozzobon epozzobon commented Sep 20, 2021

This pull request makes it possible to rebind the keyboard controls in the xenia config file. This fixes #1333.
It supports switching layers using caps lock (as the current default key bindings) and multiple keys for the same gamepad input.

I acknowledge that the syntax is a bit awkward, and I would be happy to get some feedback on how I can improve it while maintaining compatibility with xenia's current key bindings.

As it stands, the syntax works like this:
keybind_a = "0xBA" # binds key code 0xBA to the A button
keybind_b = "'X'" # binds the X key to the B button. Chars are indicated by ' as per C convention.
keybind_a = "0xBA" # binds key code 0xBA to the A button
keybind_right_trigger = "'E' 'O'" # binds both keys E and O to the right trigger. Space is used as a separator.

Bind the S key to dpad down when caps lock or shift are enabled, and to left thumb down otherwise: (notice ^ and _ preceding the char/keycode)

keybind_dpad_down = "^'S'" 
keybind_left_thumb_down = "_'S'"

Copy link
Member

@gibbed gibbed left a comment

Choose a reason for hiding this comment

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

In general, I like what you've done with the token stuff.

I don't really like the single quotes for character key definitions, but I haven't really thought of a better format yet. I'll think on it.

src/xenia/hid/winkey/winkey_input_driver.cc Outdated Show resolved Hide resolved
src/xenia/hid/winkey/winkey_input_driver.cc Outdated Show resolved Hide resolved
src/xenia/hid/winkey/winkey_input_driver.cc Outdated Show resolved Hide resolved
src/xenia/hid/winkey/winkey_input_driver.cc Outdated Show resolved Hide resolved
src/xenia/hid/winkey/winkey_input_driver.cc Outdated Show resolved Hide resolved
src/xenia/hid/winkey/winkey_input_driver.cc Outdated Show resolved Hide resolved
src/xenia/hid/winkey/winkey_input_driver.cc Outdated Show resolved Hide resolved
src/xenia/hid/winkey/winkey_input_driver.cc Outdated Show resolved Hide resolved
@gibbed
Copy link
Member

gibbed commented Sep 21, 2021

Additionally, I will look at implementing support for TOML arrays in our config reader/writer so we can have that without having a custom thing just for keybinds.

@epozzobon
Copy link
Contributor Author

epozzobon commented Sep 22, 2021

All the issues you pointed out should now be fixed.
I also thought about a better syntax for the bindings: single quotations could be removed entirely, and instead all bindings are considered ascii by default except when they start with 0x.

I think it would make them look quite natural:
keybind_a = "0xBA" # binds key code 0xBA (VK_OEM_1) to the A button
keybind_b = "X" # binds the X key to the B button.
keybind_right_trigger = "E O" # binds both keys E and O to the right trigger. Space is used as a separator.

Bind the S key to dpad down when caps lock or shift are enabled, and to left thumb down otherwise: (notice ^ and _ preceding the char/keycode)

keybind_dpad_down = "^S" 
keybind_left_thumb_down = "_S"

@epozzobon
Copy link
Contributor Author

(xb format makes a mess out of DEFINE_string statements so I'm not able to fix the continuous integration check.)

@gibbed
Copy link
Member

gibbed commented Sep 22, 2021

You can selectively toggle off and on clang-format.

Surround it with:

// clang-format off

// clang-format on

@epozzobon
Copy link
Contributor Author

I must be doing something wrong, but even with those lines, xb format tries to tab the entire namespace

@epozzobon
Copy link
Contributor Author

Can this get merged or is any other change necessary?

src/xenia/hid/winkey/winkey_input_driver.cc Outdated Show resolved Hide resolved
src/xenia/hid/winkey/winkey_input_driver.cc Outdated Show resolved Hide resolved
src/xenia/hid/winkey/winkey_input_driver.cc Outdated Show resolved Hide resolved
@gibbed gibbed merged commit 5e31429 into xenia-project:master Jan 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom Controls Support
2 participants