mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-26 08:49:37 +00:00
Correct keypad symbols, push X11 into a namespace.
This commit is contained in:
parent
9c29655da2
commit
4774676e2a
@ -884,7 +884,14 @@ void MainWindow::keyReleaseEvent(QKeyEvent *event) {
|
||||
|
||||
#ifdef HAS_X11
|
||||
#include <QX11Info>
|
||||
#include <X11/keysymdef.h>
|
||||
|
||||
// X11 collides with my 'Time' namespace; that's probably my fault for lazy namespace
|
||||
// selection, but this fixes the problem.
|
||||
namespace X11 {
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/keysym.h>
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
std::optional<Inputs::Keyboard::Key> MainWindow::keyForEvent(QKeyEvent *event) {
|
||||
@ -893,10 +900,10 @@ std::optional<Inputs::Keyboard::Key> MainWindow::keyForEvent(QKeyEvent *event) {
|
||||
#ifdef HAS_X11
|
||||
if(QGuiApplication::platformName() == QLatin1String("xcb")) {
|
||||
// Convert from a machine-specific keycode to a more general keysym.
|
||||
int keysyms = 0;
|
||||
const KeySym *const keysyms = XGetKeyboardMapping(QX11Info::display(), event->nativeScanCode(), 1, &keysyms);
|
||||
const KeySym keysym = keysyms[0];
|
||||
XFree(keysyms);
|
||||
int keysym_count = 0;
|
||||
KeySym *const keysyms = X11::XGetKeyboardMapping(QX11Info::display(), event->nativeScanCode(), 1, &keysym_count);
|
||||
const auto keysym = keysyms[0];
|
||||
X11::XFree(keysyms);
|
||||
|
||||
#define BIND(code, key) case code: return Inputs::Keyboard::Key::key;
|
||||
|
||||
@ -960,9 +967,9 @@ std::optional<Inputs::Keyboard::Key> MainWindow::keyForEvent(QKeyEvent *event) {
|
||||
BIND(XK_KP_Divide, KeypadSlash);
|
||||
BIND(XK_KP_Multiply, KeypadAsterisk);
|
||||
BIND(XK_KP_Delete, KeypadDelete);
|
||||
BIND(XP_KP_7, Keypad7); BIND(XP_KP_8, Keypad8); BIND(XP_KP_9, Keypad9); BIND(XK_KP_Add, KeypadPlus);
|
||||
BIND(XP_KP_4, Keypad4); BIND(XP_KP_5, Keypad5); BIND(XP_KP_6, Keypad6); BIND(XK_KP_Subtract, KeypadMinus);
|
||||
BIND(XP_KP_1, Keypad1); BIND(XP_KP_2, Keypad2); BIND(XP_KP_3, Keypad3); BIND(XK_KP_Enter, KeypadEnter);
|
||||
BIND(XK_KP_7, Keypad7); BIND(XK_KP_8, Keypad8); BIND(XK_KP_9, Keypad9); BIND(XK_KP_Add, KeypadPlus);
|
||||
BIND(XK_KP_4, Keypad4); BIND(XK_KP_5, Keypad5); BIND(XK_KP_6, Keypad6); BIND(XK_KP_Subtract, KeypadMinus);
|
||||
BIND(XK_KP_1, Keypad1); BIND(XK_KP_2, Keypad2); BIND(XK_KP_3, Keypad3); BIND(XK_KP_Enter, KeypadEnter);
|
||||
BIND(XP_KP_0, Keypad0);
|
||||
BIND(XK_KP_Decimal, KeypadDecimalPoint);
|
||||
BIND(XK_KP_Equal, KeypadEquals);
|
||||
|
Loading…
Reference in New Issue
Block a user