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

ui: Support changing controller/keyboard mappings #1516

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

antangelo
Copy link
Contributor

@antangelo antangelo commented Aug 7, 2023

Adds a configuration scheme and UI for remapping keyboard/gamepad inputs to the emulated controller. I tried to keep it as modular as possible so that #1478 can extend this system with other devices and the other devices can be mapped independently.

Resolves #136 and supersedes #1301

Leaving in draft initially as this requires some genconfig PRs to be merged-- the genconfig submodule is currently pointed to my fork. I've formatted the PR using clang-format, which is why it differs at points from neighboring code. I am leaving it as-is because formatting code I haven't touched will make this already large change harder to review, but can do so if needed.

image

@UserGit-2021
Copy link

UserGit-2021 commented Aug 7, 2023

Hello! Good job! Will there be mouse support?

@antangelo
Copy link
Contributor Author

Hello! Good job! Will there be mouse support?

Mouse support is out of scope for this PR

@antangelo antangelo marked this pull request as ready for review August 21, 2023 00:07
ui/xui/main-menu.cc Outdated Show resolved Hide resolved
ui/xui/main-menu.cc Outdated Show resolved Hide resolved
ui/xui/main-menu.cc Outdated Show resolved Hide resolved
ui/xemu-controllers.cc Outdated Show resolved Hide resolved
const char *base_path = get_binding_path();

assert(strlen(guid) > 0);
char *binding_path = g_strdup_printf("%s/%s.toml", base_path, guid);
Copy link
Member

Choose a reason for hiding this comment

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

I assume storing non-keyboard mappings in separate files was done to work around genconfig limitations. From a user perspective, it seems weird to have them in separate spots. Should we try to move these input mappings into xemu.toml or do you think it's better to have them separated like this

Copy link
Contributor Author

@antangelo antangelo Oct 18, 2023

Choose a reason for hiding this comment

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

I didn't want to overly clutter xemu.toml, as there are many entries for the various mappings and if a user has multiple controllers then the file can fill up quickly (especially with the addition of more devices later on, or if we support setting mappings per title).

There were genconfig limitations either way (which I resolved separately to allow for multiple configs in the same program), but those required to support maps with string keys would be more involved as well.

Copy link
Member

Choose a reason for hiding this comment

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

I expect most people have at most a handful of devices they intend to use, so I don't think storing button mappings in xemu.toml would add much clutter in the typical case. Would you consider looking into migrating device input mapping into the main config?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have a solution that stores the bindings in an array in the main config. It depends on mborgerson/genconfig#10

I also looked into adding support for tables with arbitrary string keys to genconfig but there's some added complexity there with serialization and efficiently adding nodes to the map without invalidating pointers to the previous nodes within the serialized struct. I don't personally think this complexity is worthwhile if there won't usually be many controllers in the array, as you say, but can finish this approach if you think it's better.

@mborgerson mborgerson self-assigned this Oct 17, 2023
@antangelo antangelo force-pushed the ui/rebinding branch 2 times, most recently from 2df6c52 to d9a01b2 Compare October 18, 2023 17:28
@AkihitoZero5454
Copy link

Can we also have an option to switch the controller image to Controller S?

@ElTioRata
Copy link

It is planned to add mapping profiles? That way they can be assigned per-game.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement gamepad button/axis remapping
5 participants