mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-18 01:30:56 +00:00
Wrangles a single working call to XKeysymToKeycode.
This commit is contained in:
parent
6fe947b8b9
commit
335e839b31
@ -12,7 +12,11 @@ CONFIG += object_parallel_to_source
|
|||||||
INCLUDEPATH += $$[QT_INSTALL_PREFIX]/src/3rdparty/zlib
|
INCLUDEPATH += $$[QT_INSTALL_PREFIX]/src/3rdparty/zlib
|
||||||
LIBS += -lz
|
LIBS += -lz
|
||||||
|
|
||||||
# Add flags (i) to identify that this is a Qt build; and
|
# If targetting X11, link against that.
|
||||||
|
QT += x11extras
|
||||||
|
LIBS += -lX11
|
||||||
|
|
||||||
|
# Add flags (i) to identify that this is a Qt build; and
|
||||||
# (ii) to disable asserts in release builds.
|
# (ii) to disable asserts in release builds.
|
||||||
DEFINES += TARGET_QT
|
DEFINES += TARGET_QT
|
||||||
QMAKE_CXXFLAGS_RELEASE += -DNDEBUG
|
QMAKE_CXXFLAGS_RELEASE += -DNDEBUG
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
#include "mainwindow.h"
|
#include "keyboard.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QGuiApplication>
|
||||||
|
|
||||||
// Qt is the worst.
|
// Qt is the worst.
|
||||||
//
|
//
|
||||||
@ -32,11 +35,15 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAS_X11
|
#ifdef HAS_X11
|
||||||
|
#include <QX11Info>
|
||||||
|
|
||||||
|
#include <X11/Xutil.h>
|
||||||
#include <X11/keysym.h>
|
#include <X11/keysym.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
KeyboardMapper::KeyboardMapper() {
|
KeyboardMapper::KeyboardMapper() {
|
||||||
#ifdef HAS_X11
|
#ifdef HAS_X11
|
||||||
|
qDebug() << "F1 " << XKeysymToKeycode(QX11Info::display(), XK_Escape);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +54,7 @@ std::optional<Inputs::Keyboard::Key> KeyboardMapper::keyForEvent(QKeyEvent *even
|
|||||||
if(QGuiApplication::platformName() == QLatin1String("xcb")) {
|
if(QGuiApplication::platformName() == QLatin1String("xcb")) {
|
||||||
#define BIND(code, key) case code: return Inputs::Keyboard::Key::key;
|
#define BIND(code, key) case code: return Inputs::Keyboard::Key::key;
|
||||||
|
|
||||||
switch(event->nativeVirtualKey()) {
|
switch(event->nativeScanCode()) { /* TODO */
|
||||||
default: qDebug() << "Unmapped" << event->nativeScanCode(); return {};
|
default: qDebug() << "Unmapped" << event->nativeScanCode(); return {};
|
||||||
|
|
||||||
BIND(XK_Escape, Escape);
|
BIND(XK_Escape, Escape);
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
#ifndef KEYBOARD_H
|
#ifndef KEYBOARD_H
|
||||||
#define KEYBOARD_H
|
#define KEYBOARD_H
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QKeyEvent>
|
||||||
|
#include <map>
|
||||||
|
#include <optional>
|
||||||
|
#include "../../Inputs/Keyboard.hpp"
|
||||||
|
|
||||||
class KeyboardMapper {
|
class KeyboardMapper {
|
||||||
public:
|
public:
|
||||||
@ -10,6 +12,7 @@ class KeyboardMapper {
|
|||||||
std::optional<Inputs::Keyboard::Key> keyForEvent(QKeyEvent *);
|
std::optional<Inputs::Keyboard::Key> keyForEvent(QKeyEvent *);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::map<quint32, Inputs::Keyboard::Key> keyByKeySym;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user