mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-26 08:49:37 +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
|
||||
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.
|
||||
DEFINES += TARGET_QT
|
||||
QMAKE_CXXFLAGS_RELEASE += -DNDEBUG
|
||||
|
@ -1,4 +1,7 @@
|
||||
#include "mainwindow.h"
|
||||
#include "keyboard.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QGuiApplication>
|
||||
|
||||
// Qt is the worst.
|
||||
//
|
||||
@ -32,11 +35,15 @@
|
||||
#endif
|
||||
|
||||
#ifdef HAS_X11
|
||||
#include <QX11Info>
|
||||
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/keysym.h>
|
||||
#endif
|
||||
|
||||
KeyboardMapper::KeyboardMapper() {
|
||||
#ifdef HAS_X11
|
||||
qDebug() << "F1 " << XKeysymToKeycode(QX11Info::display(), XK_Escape);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -47,7 +54,7 @@ std::optional<Inputs::Keyboard::Key> KeyboardMapper::keyForEvent(QKeyEvent *even
|
||||
if(QGuiApplication::platformName() == QLatin1String("xcb")) {
|
||||
#define BIND(code, key) case code: return Inputs::Keyboard::Key::key;
|
||||
|
||||
switch(event->nativeVirtualKey()) {
|
||||
switch(event->nativeScanCode()) { /* TODO */
|
||||
default: qDebug() << "Unmapped" << event->nativeScanCode(); return {};
|
||||
|
||||
BIND(XK_Escape, Escape);
|
||||
|
@ -1,8 +1,10 @@
|
||||
#ifndef KEYBOARD_H
|
||||
#define KEYBOARD_H
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
#include <QKeyEvent>
|
||||
#include <map>
|
||||
#include <optional>
|
||||
#include "../../Inputs/Keyboard.hpp"
|
||||
|
||||
class KeyboardMapper {
|
||||
public:
|
||||
@ -10,6 +12,7 @@ class KeyboardMapper {
|
||||
std::optional<Inputs::Keyboard::Key> keyForEvent(QKeyEvent *);
|
||||
|
||||
private:
|
||||
std::map<quint32, Inputs::Keyboard::Key> keyByKeySym;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
Loading…
Reference in New Issue
Block a user