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

Add the raw platform specific key code to SDL_Keysym #10057

Merged
merged 7 commits into from
Jun 22, 2024

Conversation

slouken
Copy link
Collaborator

@slouken slouken commented Jun 19, 2024

This allows applications to handle keys that SDL doesn't recognize, in a platform dependent way.

Fixes #6390

@slouken
Copy link
Collaborator Author

slouken commented Jun 19, 2024

@Kontrabant, is there anything meaningful to do for the Wayland platform here?

@Kontrabant
Copy link
Contributor

They keycode passed in the key and focus handlers is defined in the spec as "a platform-specific key code", so passing it through would work.

@slouken
Copy link
Collaborator Author

slouken commented Jun 19, 2024

Like that?

@Kontrabant
Copy link
Contributor

Yep!

@slouken
Copy link
Collaborator Author

slouken commented Jun 19, 2024

Thanks!

@@ -733,8 +733,7 @@ typedef struct SDL_PenButtonEvent
* An event used to drop text or request a file open by the system
* (event.drop.*)
*
* The `data` is owned by SDL and should be copied if the application wants to
* hold onto it beyond the scope of handling this event. Do not free it!
* The `source` and `data` are owned by SDL and should be copied if the application wants to hold onto them beyond the scope of handling this event.
Copy link
Collaborator

Choose a reason for hiding this comment

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

For consistency with other headers (and so there's a link to the full documentation), can these change to:

"The source and data strings follow the SDL_GetStringRule."

char *result = NULL;

if (string) {
size_t len = SDL_strlen(string) + 1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not just:

if (string) {
    return SDL_FreeLater(SDL_strdup(string));
}
return NULL;

Or even just:

return string ? SDL_FreeLater(SDL_strdup(string)) : NULL;

SDL_AllocateEventMemory isn't a mysterious interface we have to route this stuff through. :)

This adds more app editing and audio control keys and removes keys that launch applications

Work in progress on libsdl-org#6390
@slouken slouken force-pushed the keyboard branch 4 times, most recently from a074aa0 to 0d7ef95 Compare June 21, 2024 02:29
@slouken
Copy link
Collaborator Author

slouken commented Jun 21, 2024

@Kontrabant, can you add the Wayland code for querying the full keymap? You can look at the Cocoa and Windows implementations for examples.

This allows applications to handle keys that SDL doesn't recognize, in a platform dependent way.

Fixes libsdl-org#6390
@slouken slouken force-pushed the keyboard branch 4 times, most recently from a883a22 to c535dd1 Compare June 21, 2024 17:04
@Kontrabant
Copy link
Contributor

@Kontrabant, can you add the Wayland code for querying the full keymap? You can look at the Cocoa and Windows implementations for examples.

Sure, I'll take care of it.

@slouken
Copy link
Collaborator Author

slouken commented Jun 21, 2024

@Kontrabant, can you add the Wayland code for querying the full keymap? You can look at the Cocoa and Windows implementations for examples.

Sure, I'll take care of it.

Thanks! I'll leave it as-is for now and you can add a PR once this is merged, or you can push a separate commit to this PR, whichever you prefer.

@slouken slouken force-pushed the keyboard branch 3 times, most recently from f1578c5 to a25daaf Compare June 21, 2024 20:42
@slouken
Copy link
Collaborator Author

slouken commented Jun 22, 2024

@Kontrabant, can you also do the X11 code? I have the place where it needs to be done, I just don't know how to map from modifiers to level, and I suspect it'll be the same as the Wayland code.

@slouken slouken merged commit c9cfa46 into libsdl-org:main Jun 22, 2024
39 checks passed
@slouken slouken deleted the keyboard branch June 22, 2024 05:06
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.

Improved scancode handling
3 participants