Skip to content

Conversation

@Aceeri
Copy link
Contributor

@Aceeri Aceeri commented Dec 30, 2025

#2678

Looking for thoughts on this, maybe it makes more sense to have a KeyboardLayout struct that you can query, but the main usecase I (and other game devs) have for this is giving correct mappings in games.

  • Tested on all platforms changed
  • Added an entry to the changelog module if knowledge of this change could be valuable to users
  • Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior
  • Created or updated an example program if it would help users understand this functionality

@Aceeri Aceeri changed the title Add keycode_to_key method for getting logical keys from physical win32: Add keycode_to_key method for getting logical keys from physical Dec 30, 2025
@kchibisov
Copy link
Member

The problem is that on platforms like linux we'd need to have a running event loop. I'm also not sure if the function is MT safe, so implementing via global state like that won't generally work, and the function should be a method on a theoretical Keymap struct.

@Aceeri
Copy link
Contributor Author

Aceeri commented Dec 30, 2025

The problem is that on platforms like linux we'd need to have a running event loop. I'm also not sure if the function is MT safe, so implementing via global state like that won't generally work, and the function should be a method on a theoretical Keymap struct.

Gotcha, makes sense. Is the LayoutCache still usable if we were able to move this into the event loop + copy mappings over to a separate Keymap struct (stored on the Window?)? I'm not super familiar with how the main thread safeness works here tbh.

Also do you know if that applies to the appkit/macos version too (#4455)? Just trying to figure out which parts to try to salvage if I try to get this into the event loop.

@kchibisov
Copy link
Member

Can not speak for windows here, for linux caching is useless.

@Aceeri
Copy link
Contributor Author

Aceeri commented Dec 30, 2025

Can not speak for windows here, for linux caching is useless.

As in you can't cache across frames at all? I'll take a bit of a look into the linux code, I haven't really touched it before so I'm pretty blind.

@kchibisov
Copy link
Member

In a sense that there's no point to cache anything, you have access to the entire keymap and thus you get things from it. It could have cache internally...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants