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

Function for adding/removing inputs rather than just replacing them #871

Closed
PaulTarsusRips opened this issue Jun 14, 2024 · 1 comment
Closed

Comments

@PaulTarsusRips
Copy link

Is your feature request related to a problem?
Current Input code allows you to switch an input with a combination of input_binding_scan_start and input_binding_set_safe. But there isn't currently an easy way to add/subtract from the list, instead of merely replacing an input on the list.

Describe the solution you'd like
It would be cool if that was already a predefined function; something like input_binding_add_safe (and input_binding_subtract_safe). It would go a long way towards accessibility! The complete process would look something like:

if keyboard_check_pressed(ord("Q")) { input_binding_scan_start(function(_binding) { input_binding_add_safe("up", _binding); }); }

...which would scan for the next pressed key, then add to the list of the current "up" inputs by replacing the first one that returns as "undefined" (aka empty).

Describe alternatives you've considered
By adding for loops and utilizing alternatives left undefined, you can force it to add/subtract from the list, instead of switching. For adding inputs, this would be a for loop that checks for the first undefined alternative, then replaces it with the input_binding_scan_start key. But this is difficult and could be automated.

Additional context
I am a novice-at-best programmer so the solution is my best guess rather than an expert opinion. But I'm sure this is possible!

@offalynne
Copy link
Owner

offalynne commented Jun 14, 2024

This is possible using the existing API and I don't believe Input should be insulating you from learning to use loops. Iterating through alternates and using binding_set_safe, binding_get_verbs, and binding_remove are the tools you need to achieve the behaviour you've described.

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

No branches or pull requests

2 participants