Add initial FnixLib development implementation
This commit is contained in:
commit
84742ae38e
33 files changed
+3340
No files matched your search
@@ -0,0 +1,44 @@
|
||||
#include "platform/linux/x11_keys.h"
|
||||
|
||||
#include <X11/keysym.h>
|
||||
|
||||
/* La traducción de rangos depende de que estos grupos sean contiguos. */
|
||||
_Static_assert(FNIX_KEY_Z - FNIX_KEY_A == 25, "las letras deben ser contiguas");
|
||||
_Static_assert(FNIX_KEY_9 - FNIX_KEY_0 == 9, "los dígitos deben ser contiguos");
|
||||
_Static_assert(FNIX_KEY_F12 - FNIX_KEY_F1 == 11, "F1..F12 deben ser contiguas");
|
||||
|
||||
FnixKey fnix_x11_translate_key(KeySym keysym)
|
||||
{
|
||||
if (keysym >= XK_a && keysym <= XK_z) {
|
||||
return (FnixKey)(FNIX_KEY_A + (int)(keysym - XK_a));
|
||||
}
|
||||
if (keysym >= XK_A && keysym <= XK_Z) {
|
||||
return (FnixKey)(FNIX_KEY_A + (int)(keysym - XK_A));
|
||||
}
|
||||
if (keysym >= XK_0 && keysym <= XK_9) {
|
||||
return (FnixKey)(FNIX_KEY_0 + (int)(keysym - XK_0));
|
||||
}
|
||||
if (keysym >= XK_F1 && keysym <= XK_F12) {
|
||||
return (FnixKey)(FNIX_KEY_F1 + (int)(keysym - XK_F1));
|
||||
}
|
||||
|
||||
switch (keysym) {
|
||||
case XK_space: return FNIX_KEY_SPACE;
|
||||
case XK_Return: return FNIX_KEY_ENTER;
|
||||
case XK_KP_Enter: return FNIX_KEY_ENTER;
|
||||
case XK_Escape: return FNIX_KEY_ESCAPE;
|
||||
case XK_Tab: return FNIX_KEY_TAB;
|
||||
case XK_BackSpace: return FNIX_KEY_BACKSPACE;
|
||||
case XK_Left: return FNIX_KEY_LEFT;
|
||||
case XK_Right: return FNIX_KEY_RIGHT;
|
||||
case XK_Up: return FNIX_KEY_UP;
|
||||
case XK_Down: return FNIX_KEY_DOWN;
|
||||
case XK_Shift_L: return FNIX_KEY_LEFT_SHIFT;
|
||||
case XK_Shift_R: return FNIX_KEY_RIGHT_SHIFT;
|
||||
case XK_Control_L: return FNIX_KEY_LEFT_CTRL;
|
||||
case XK_Control_R: return FNIX_KEY_RIGHT_CTRL;
|
||||
case XK_Alt_L: return FNIX_KEY_LEFT_ALT;
|
||||
case XK_Alt_R: return FNIX_KEY_RIGHT_ALT;
|
||||
default: return FNIX_KEY_UNKNOWN;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user