ckb-next
v0.2.8 at branch master
ckb-next driver for corsair devices
|
The MacroReaderThread class is responsible for reading Macro Key Values. It is created as a separate thread (worker thread) for reading macro commands from an fresh opened notify channel. Standard notify channel for macro definitions is number 2. More...
#include <src/ckb/macroreader.h>
Public Member Functions | |
MacroReaderThread (int macNum, QString macPath, QPlainTextEdit *macBox, QPlainTextEdit *macText) | |
MacroReaderThread saves the four params to local vars with similar varNames. More... | |
void | run () Q_DECL_OVERRIDE |
run is the notification reader main loop. More... | |
Private Slots | |
void | readMacro (QString line) |
readMacro is called for each line received by the worker thread. The method ist called via signal (metaObject) from the worker thread, which reads the keyboard input. Just display the key code in the macroBox Widget without he trailing newline and reposition the cursor in the macro pane. More... | |
Private Attributes | |
int | macroNumber |
macroNumber Filenames of nofity channels have the structure <input-device-path>/ckb1/notify<number> First part is hold in macroPath, the number is hold in macroNumber. macroNumber may range from 0 to 9. More... | |
QString | macroPath |
macroPath holds the path for the notify channel More... | |
QPlainTextEdit * | macroBox |
macroBox will receive the Macro Key Values sent from the keyboard while defining a new macro. More... | |
QPlainTextEdit * | macroText |
macroText is the other textpane used in the UI while typing new macros. That variable is used for setting the focus to that textpane and to set the cursor at EOT. More... | |
While the worker Thread gets input from the keyboard, the lines are sent via signalling (metaobject) to run a member function in the context of the Qt UI manager.
When the notify channel is closed (that's normally done by pressing "Stop"-Button in the UI), the worker thread closes the channelFile and leaves.
Definition at line 22 of file macroreader.h.
|
inline |
macNum | |
macPath | |
macBox | |
macText |
Definition at line 55 of file macroreader.h.
References macroBox, macroNumber, macroPath, and macroText.
|
privateslot |
This is used, because the worker thread shouldn't get access to the UI elements (and normally has none, because the pointers macroBox and macroText remain on the stack). That mechanism guarantees, that the UI does not freeze if it happens something magic to the reading function.
line | holds the line just got from keyboard |
We want to see the keys as they appear in the macroText Widget.
Because it is possible to change the Focus via keyboard, we must set the focus on each call.
Definition at line 27 of file macroreader.cpp.
References macroBox, and macroText.
void MacroReaderThread::run | ( | ) |
MacroReaderThread::run is the standard main function for a thread. Tries to open a file <macroPath><macroNumber> several times (in this case, it should be possible the first time (the code was recycled from kb.cpp).
While the file is open, read lines an signal them via metaObject() to the main thread. When the file is closed by the sender, close it as reader and terminate.
Definition at line 47 of file macroreader.cpp.
References macroBox, macroNumber, macroPath, and macroText.
|
private |
Definition at line 40 of file macroreader.h.
Referenced by MacroReaderThread(), readMacro(), and run().
|
private |
Definition at line 31 of file macroreader.h.
Referenced by MacroReaderThread(), and run().
|
private |
Definition at line 36 of file macroreader.h.
Referenced by MacroReaderThread(), and run().
|
private |
Definition at line 45 of file macroreader.h.
Referenced by MacroReaderThread(), readMacro(), and run().