projects
/
multypo.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b02f9fd
)
Add per-device output label
author
Ralf Jung
<post@ralfj.de>
Sat, 13 Jul 2013 14:41:11 +0000
(16:41 +0200)
committer
Ralf Jung
<post@ralfj.de>
Sat, 13 Jul 2013 14:41:11 +0000
(16:41 +0200)
qt/multypo.cpp
patch
|
blob
|
history
qt/multypo.h
patch
|
blob
|
history
diff --git
a/qt/multypo.cpp
b/qt/multypo.cpp
index 638114cde667c80b15703d107d4589e3e4ee3bd9..2584c0c7b1f7bca5635214db1eabf26ab2d9dab2 100644
(file)
--- a/
qt/multypo.cpp
+++ b/
qt/multypo.cpp
@@
-2,7
+2,7
@@
#include <QX11Info>
#include <QDebug>
#include <QX11Info>
#include <QDebug>
-#include <Q
H
BoxLayout>
+#include <Q
V
BoxLayout>
#include <QLabel>
#include <X11/Xlib.h>
#include <QLabel>
#include <X11/Xlib.h>
@@
-13,13
+13,18
@@
MultypoWindow::MultypoWindow(QWidget *parent) :
QWidget(parent),
xiInited(false)
{
QWidget(parent),
xiInited(false)
{
- QHBoxLayout *layout = new QHBoxLayout(this);
- set
Layout(layout
);
+ /* Prepare colors */
+ set
StyleSheet("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 <Esc> to quit", this);
+ layout()->addWidget(mainLabel);
+
+ /* Fullscreen, no cursor */
+ setWindowState(Qt::WindowFullScreen);
+ setCursor(QCursor(Qt::BlankCursor));
}
MultypoWindow::~MultypoWindow()
}
MultypoWindow::~MultypoWindow()
@@
-29,7
+34,16
@@
MultypoWindow::~MultypoWindow()
void MultypoWindow::handleKeyPress(int device, QString string)
{
qDebug() << "Device" << device << "String" << string;
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)
}
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);
}
qDebug() << "Found master keyboard with ID" << devices[i].deviceid;
XISetFocus(dpy, devices[i].deviceid, winId(), CurrentTime);
}
+ XIFreeDeviceInfo(devices);
xiInited = true;
xiInited = true;
diff --git
a/qt/multypo.h
b/qt/multypo.h
index b9dbf3faefc1d49c7a58b000473eb679a1b63f0c..49b70b1bdf7d079d5252c97c81743e8245809d92 100644
(file)
--- a/
qt/multypo.h
+++ b/
qt/multypo.h
@@
-2,6
+2,7
@@
#define MULTIKBD_H
#include <QWidget>
#define MULTIKBD_H
#include <QWidget>
+#include <QMap>
class QLabel;
class QLabel;
@@
-22,6
+23,8
@@
private:
bool xiInited;
int xiOpcode;
QLabel *mainLabel;
bool xiInited;
int xiOpcode;
QLabel *mainLabel;
+
+ QMap<int, QLabel*> players;
};
#endif // MULTIKBD_H
};
#endif // MULTIKBD_H