开发者

Keyboard Code IDs

开发者 https://www.devze.com 2023-01-14 02:42 出处:网络
Upon discovering that SDL and X11 use the same keyboard key IDs (I think they\'re called keysyms), I wanted to use these codes. However, I don\'t know them and I don\'t want to just use their defines

Upon discovering that SDL and X11 use the same keyboard key IDs (I think they're called keysyms), I wanted to use these codes. However, I don't know them and I don't want to just use their defines as I don't want to include stuff as I'm writing a library and don't want to rely on either X11 or SDL as I may just be using X11 or just SDL. Is there a list of keyboard codes like 0x200 or something?

Let me try to explain a bit better, I'm using SDL and X11 as libraries to make input, but I want my application to have its own key开发者_Go百科 defines to abstract SDL, X11 and Win32 keys.


It is not wise to use the codes directly because these might change anytime (unlike their defines). And exploiting the fact that SDL uses the same codes as X11 doesn't sound well. Better approach would be to create bridge headers for both X11 and SDL that would look like this:

#define MYLIB_SOME_KEY0 SDL_SOME_KEY0
#define MYLIB_SOME_KEY1 SDL_SOME_KEY1

Then just conditionally include the corresponding header.

In case I didn't convince you, you can find the corresponding defines in SDL.h header.


If I understand well, then I think it is impossible. It is the OS that handles the keyboard signals and convert them to the corresponding keyboard layout (eg: azerty or qwerty). And send that to the application.

May I guess what you are trying? Making a keyboard handler to make it also possible to walk with
A S D W on an azerty keyboard?

If so, then it is possible to change the 'a' with the 'q' and the 'z' with the 'w' manually.

0

精彩评论

暂无评论...
验证码 换一张
取 消