From: Ralf Jung Date: Sat, 13 Jul 2013 14:41:11 +0000 (+0200) Subject: Add per-device output label X-Git-Url: https://git.ralfj.de/multypo.git/commitdiff_plain/9892f674393394ef97f5f9dad6a9e4e435f771ed Add per-device output label --- diff --git a/qt/multypo.cpp b/qt/multypo.cpp index 638114c..2584c0c 100644 --- a/qt/multypo.cpp +++ b/qt/multypo.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include @@ -13,13 +13,18 @@ MultypoWindow::MultypoWindow(QWidget *parent) : QWidget(parent), xiInited(false) { - QHBoxLayout *layout = new QHBoxLayout(this); - setLayout(layout); + /* Prepare colors */ + setStyleSheet("background-color: black; color: green"); - mainLabel = new QLabel(this); - layout->addWidget(mainLabel); + /* Prepare conents */ + setLayout(new QVBoxLayout(this)); - setMinimumSize(300, 300); + mainLabel = new QLabel("Hit to quit", this); + layout()->addWidget(mainLabel); + + /* Fullscreen, no cursor */ + setWindowState(Qt::WindowFullScreen); + setCursor(QCursor(Qt::BlankCursor)); } MultypoWindow::~MultypoWindow() @@ -29,7 +34,16 @@ MultypoWindow::~MultypoWindow() void MultypoWindow::handleKeyPress(int device, QString string) { qDebug() << "Device" << device << "String" << string; - mainLabel->setText(QString("%1 pressed on %2").arg(string).arg(device)); + + if (string == "Escape") + close(); + + if (!players.contains(device)) { + QLabel *label = new QLabel(this); + layout()->addWidget(label); + players[device] = label; + } + players[device]->setText(players[device]->text() + string); } bool MultypoWindow::handleX11Event(XEvent *event) @@ -70,6 +84,7 @@ bool MultypoWindow::handleX11Event(XEvent *event) qDebug() << "Found master keyboard with ID" << devices[i].deviceid; XISetFocus(dpy, devices[i].deviceid, winId(), CurrentTime); } + XIFreeDeviceInfo(devices); xiInited = true; diff --git a/qt/multypo.h b/qt/multypo.h index b9dbf3f..49b70b1 100644 --- a/qt/multypo.h +++ b/qt/multypo.h @@ -2,6 +2,7 @@ #define MULTIKBD_H #include +#include class QLabel; @@ -22,6 +23,8 @@ private: bool xiInited; int xiOpcode; QLabel *mainLabel; + + QMap players; }; #endif // MULTIKBD_H