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

Emscripten input callbacks #10292

Closed
HDAKFD opened this issue Jul 16, 2024 · 4 comments
Closed

Emscripten input callbacks #10292

HDAKFD opened this issue Jul 16, 2024 · 4 comments
Assignees
Milestone

Comments

@HDAKFD
Copy link

HDAKFD commented Jul 16, 2024

Could there be an option to disable these emscripten input callbacks from getting registered. They're causing a lot of issues when trying to mess with html elements.

emscripten_set_keydown_callback,
emscripten_set_keyup_callback,
emscripten_set_keypress_callback

These are the main part of my issue since they just make emscripten to call event.preventDefault() for every html element with input.

@slouken slouken added this to the 3.2.0 milestone Jul 16, 2024
@slouken
Copy link
Collaborator

slouken commented Jul 16, 2024

We can definitely add a hint for this.

@icculus icculus added the icculus-priority Things @icculus is looking at within a larger milestone. label Jan 8, 2025
@icculus
Copy link
Collaborator

icculus commented Jan 12, 2025

You should be able to use an existing hint. Just call...

SDL_SetHint(SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT, "some-element-id-that-doesnt-exist-on-the-page");

...any time before SDL_CreateWindow, and it won't register an input callback at all.

@icculus icculus removed the icculus-priority Things @icculus is looking at within a larger milestone. label Jan 12, 2025
@icculus
Copy link
Collaborator

icculus commented Jan 18, 2025

Okay, I've updated it so setting SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT to "" will stop SDL from setting those input callbacks at all, so no weird hacks with bogus element names.

slouken added a commit that referenced this issue Jan 18, 2025
This is used to say "don't even try to listen for keypresses," for apps that
are managing this outside of SDL.

Fixes #10292.
@slouken
Copy link
Collaborator

slouken commented Jan 18, 2025

I switched it to "#none". We use "" everywhere else as synonymous with NULL.

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

3 participants