mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-10-17 21:08:14 +00:00
[client] all: use the defined keyboard mapping for keybinds
Fixes #1007
This commit is contained in:
@@ -36,6 +36,8 @@
|
||||
#include <X11/extensions/Xpresent.h>
|
||||
#include <X11/Xcursor/Xcursor.h>
|
||||
|
||||
#include <xkbcommon/xkbcommon.h>
|
||||
|
||||
#include <GL/glx.h>
|
||||
#include <GL/glxext.h>
|
||||
|
||||
@@ -514,6 +516,10 @@ static bool x11Init(const LG_DSInitParams params)
|
||||
goto fail_window;
|
||||
}
|
||||
|
||||
XDisplayKeycodes(x11.display, &x11.minKeycode, &x11.maxKeycode);
|
||||
x11.keysyms = XGetKeyboardMapping(x11.display, x11.minKeycode,
|
||||
x11.maxKeycode - x11.minKeycode, &x11.symsPerKeycode);
|
||||
|
||||
XIFreeDeviceInfo(devinfo);
|
||||
|
||||
XQueryExtension(x11.display, "XInputExtension", &x11.xinputOp, &event, &error);
|
||||
@@ -738,6 +744,9 @@ static void x11Free(void)
|
||||
if (x11.cursors[i])
|
||||
XFreeCursor(x11.display, x11.cursors[i]);
|
||||
|
||||
if (x11.keysyms)
|
||||
XFree(x11.keysyms);
|
||||
|
||||
XCloseDisplay(x11.display);
|
||||
}
|
||||
|
||||
@@ -1035,6 +1044,17 @@ static void setFocus(bool focused, double x, double y)
|
||||
app_handleFocusEvent(focused);
|
||||
}
|
||||
|
||||
static int getCharcode(int detail)
|
||||
{
|
||||
if (detail < x11.minKeycode || detail > x11.maxKeycode)
|
||||
return 0;
|
||||
|
||||
KeySym sym = x11.keysyms[(detail - x11.minKeycode) *
|
||||
x11.symsPerKeycode];
|
||||
sym = xkb_keysym_to_upper(sym);
|
||||
return xkb_keysym_to_utf32(sym);
|
||||
}
|
||||
|
||||
static void x11XInputEvent(XGenericEventCookie *cookie)
|
||||
{
|
||||
static int button_state = 0;
|
||||
@@ -1126,7 +1146,8 @@ static void x11XInputEvent(XGenericEventCookie *cookie)
|
||||
return;
|
||||
|
||||
XIDeviceEvent *device = cookie->data;
|
||||
app_handleKeyPress(device->detail - 8);
|
||||
app_handleKeyPress(device->detail - x11.minKeycode,
|
||||
getCharcode(device->detail));
|
||||
|
||||
if (!x11.xic || !app_isOverlayMode())
|
||||
return;
|
||||
@@ -1176,7 +1197,8 @@ static void x11XInputEvent(XGenericEventCookie *cookie)
|
||||
return;
|
||||
|
||||
XIDeviceEvent *device = cookie->data;
|
||||
app_handleKeyRelease(device->detail - 8);
|
||||
app_handleKeyRelease(device->detail - x11.minKeycode,
|
||||
getCharcode(device->detail));
|
||||
|
||||
if (!x11.xic || !app_isOverlayMode())
|
||||
return;
|
||||
@@ -1205,7 +1227,8 @@ static void x11XInputEvent(XGenericEventCookie *cookie)
|
||||
return;
|
||||
|
||||
XIRawEvent *raw = cookie->data;
|
||||
app_handleKeyPress(raw->detail - 8);
|
||||
app_handleKeyPress(raw->detail - x11.minKeycode,
|
||||
getCharcode(raw->detail));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1215,7 +1238,8 @@ static void x11XInputEvent(XGenericEventCookie *cookie)
|
||||
return;
|
||||
|
||||
XIRawEvent *raw = cookie->data;
|
||||
app_handleKeyRelease(raw->detail - 8);
|
||||
app_handleKeyRelease(raw->detail - x11.minKeycode,
|
||||
getCharcode(raw->detail));
|
||||
return;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user