1
0
mirror of https://github.com/XProger/OpenLara.git synced 2025-01-17 21:09:00 +01:00

move linux keyboard input to keysym

This commit is contained in:
xproger 2020-06-08 04:36:16 +03:00
parent 8f1b9a0334
commit c3bf394e29
4 changed files with 49 additions and 16 deletions

View File

@ -191,7 +191,7 @@ enum InputKey { ikNone,
ikN, ikO, ikP, ikQ, ikR, ikS, ikT, ikU, ikV, ikW, ikX, ikY, ikZ, ikN, ikO, ikP, ikQ, ikR, ikS, ikT, ikU, ikV, ikW, ikX, ikY, ikZ,
ikN0, ikN1, ikN2, ikN3, ikN4, ikN5, ikN6, ikN7, ikN8, ikN9, ikNAdd, ikNSub, ikNMul, ikNDiv, ikNDot, ikN0, ikN1, ikN2, ikN3, ikN4, ikN5, ikN6, ikN7, ikN8, ikN9, ikNAdd, ikNSub, ikNMul, ikNDiv, ikNDot,
ikF1, ikF2, ikF3, ikF4, ikF5, ikF6, ikF7, ikF8, ikF9, ikF10, ikF11, ikF12, ikF1, ikF2, ikF3, ikF4, ikF5, ikF6, ikF7, ikF8, ikF9, ikF10, ikF11, ikF12,
ikMinus, ikPlus, ikLSB, ikRSB, ikSlash, ikBSlash, ikComa, ikDot, ikTilda, ikColon, ikApos, ikPrev, ikNext, ikHome, ikEnd, ikDel, ikIns, ikBack, ikMinus, ikPlus, ikLSB, ikRSB, ikSlash, ikBSlash, ikComma, ikDot, ikTilda, ikColon, ikApos, ikPrev, ikNext, ikHome, ikEnd, ikDel, ikIns, ikBack,
// mouse // mouse
ikMouseL, ikMouseR, ikMouseM, ikMouseL, ikMouseR, ikMouseM,
// touch // touch

View File

@ -0,0 +1,15 @@
{
"folders": [
{
"path": ".."
},
{
"path": "../../.."
}
],
"settings": {
"files.associations": {
"typeinfo": "cpp"
}
}
}

View File

@ -0,0 +1,16 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/clang",
"cStandard": "c11",
"cppStandard": "c++11",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}

View File

@ -2,6 +2,7 @@
#include <sys/time.h> #include <sys/time.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <linux/input.h> #include <linux/input.h>
#include <X11/Xutil.h>
#include <linux/joystick.h> #include <linux/joystick.h>
#include <dirent.h> #include <dirent.h>
#include <fcntl.h> #include <fcntl.h>
@ -77,20 +78,21 @@ void sndFree() {
} }
// Input // Input
InputKey keyToInputKey(int code) { InputKey keyToInputKey(XKeyEvent event) {
int codes[] = { KeySym code = XLookupKeysym(&event, 0);
#ifdef ELBRUS
200, 201, 198, 204, if (code == XK_Shift_R) code = XK_Shift_L;
#else if (code == XK_Control_R) code = XK_Control_L;
113, 114, 111, 116, if (code == XK_Alt_R) code = XK_Alt_L;
#endif
65, 23, 36, 9, 50, 37, 64, KeySym codes[] = {
19, 10, 11, 12, 13, 14, 15, 16, 17, 18, XK_Left, XK_Right, XK_Up, XK_Down, XK_space, XK_Tab, XK_Return, XK_Escape, XK_Shift_L, XK_Control_L, XK_Alt_L,
38, 56, 54, 40, 26, 41, 42, 43, 31, 44, 45, 46, 58, XK_0, XK_1, XK_2, XK_3, XK_4, XK_5, XK_6, XK_7, XK_8, XK_9,
57, 32, 33, 24, 27, 39, 28, 30, 55, 25, 53, 29, 52, XK_a, XK_b, XK_c, XK_d, XK_e, XK_f, XK_g, XK_h, XK_i, XK_j, XK_k, XK_l, XK_m,
0x5A, 0x57, 0x58, 0x59, 0x53, 0x54, 0x55, 0x4F, 0x50, 0x51, 0x56, 0x52, 0x3F, 0x6A, 0x5B, XK_n, XK_o, XK_p, XK_q, XK_r, XK_s, XK_t, XK_u, XK_v, XK_w, XK_x, XK_y, XK_z,
0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x5F, 0x60, XK_KP_0, XK_KP_1, XK_KP_2, XK_KP_3, XK_KP_4, XK_KP_5, XK_KP_6, XK_KP_7, XK_KP_8, XK_KP_9, XK_KP_Add, XK_KP_Subtract, XK_KP_Multiply, XK_KP_Divide, XK_KP_Separator,
0x14, 0x15, 0x22, 0x23, 0x3D, 0x33, 0x3B, 0x3C, 0x31, 0x2F, 0x30, 0x70, 0x75, 0x6E, 0x73, 0x77, 0x76, 0x16 XK_F1, XK_F2, XK_F3, XK_F4, XK_F5, XK_F6, XK_F7, XK_F8, XK_F9, XK_F10, XK_F11, XK_F12,
XK_minus, XK_equal, XK_bracketleft, XK_bracketright, XK_slash, XK_backslash, XK_comma, XK_period, XK_grave, XK_semicolon, XK_apostrophe, XK_Page_Up, XK_Page_Down, XK_Home, XK_End, XK_Delete, XK_Insert, XK_BackSpace
}; };
for (int i = 0; i < COUNT(codes); i++) { for (int i = 0; i < COUNT(codes); i++) {
@ -348,7 +350,7 @@ void WndProc(const XEvent &e,Display*dpy,Window wnd) {
toggle_fullscreen(dpy,wnd); toggle_fullscreen(dpy,wnd);
break; break;
} }
Input::setDown(keyToInputKey(e.xkey.keycode), e.type == KeyPress); Input::setDown(keyToInputKey(e.xkey), e.type == KeyPress);
break; break;
case ButtonPress : case ButtonPress :
case ButtonRelease : { case ButtonRelease : {