A QLineEdit subclass for capturing keyboard and mouse input for key mapping.
More...
#include <buttoninputbox.hpp>
|
| bool | event (QEvent *event) override |
| void | keyPressEvent (QKeyEvent *event) override |
| | Captures a key press and stores the platform-native key code.
|
| void | mousePressEvent (QMouseEvent *event) override |
A QLineEdit subclass for capturing keyboard and mouse input for key mapping.
This widget captures a single key press or mouse button click and stores the platform-native key code for use in input simulation.
◆ ButtonInputBox()
| ButtonInputBox::ButtonInputBox |
( |
QWidget * | parent = nullptr | ) |
|
|
explicit |
◆ ~ButtonInputBox()
| ButtonInputBox::~ButtonInputBox |
( |
| ) |
|
|
overridedefault |
◆ clearKeyCode()
| void ButtonInputBox::clearKeyCode |
( |
| ) |
|
Clears the captured key code and display name.
◆ displayName()
| QString ButtonInputBox::displayName |
( |
| ) |
const |
Returns the human-readable display name of the captured key.
◆ event()
| bool ButtonInputBox::event |
( |
QEvent * | event | ) |
|
|
overrideprotected |
◆ keyCode()
Returns the captured platform-native key code.
◆ keyPressEvent()
| void ButtonInputBox::keyPressEvent |
( |
QKeyEvent * | event | ) |
|
|
overrideprotected |
Captures a key press and stores the platform-native key code.
- Platform-Specific Behavior
Qt provides two native key identifiers, but their meaning differs by platform:
- Linux (X11/XCB):
- nativeVirtualKey() returns X11 keysyms (defined in X11/keysymdef.h)
- For Latin letters, these match ASCII codes (e.g., XK_k = 0x006b = 107)
- Represent the logical/semantic meaning of a key
- nativeScanCode() returns evdev keycodes (defined in linux/input-event-codes.h)
- Hardware-oriented codes for physical key positions (e.g., KEY_K = 37)
- Used by Linux kernel input subsystem (evdev/uinput)
Since KeyboardInjector uses libevdev/uinput, we use nativeScanCode() on Linux.
- Windows:
- nativeVirtualKey() returns Windows virtual key codes (VK_*)
- These are directly usable with SendInput API
- Example Mappings (Linux)
| Key | nativeVirtualKey() | nativeScanCode() |
| K | 107 (XK_k) | 37 (KEY_K) |
| A | 97 (XK_a) | 30 (KEY_A) |
| Enter | 0xff0d (XK_Return) | 28 (KEY_ENTER) |
- See also
- https://doc.qt.io/qt-6/qkeyevent.html#nativeVirtualKey
-
https://wiki.archlinux.org/title/Keyboard_input
◆ mousePressEvent()
| void ButtonInputBox::mousePressEvent |
( |
QMouseEvent * | event | ) |
|
|
overrideprotected |
◆ setDisplayName()
| void ButtonInputBox::setDisplayName |
( |
const QString & | displayName | ) |
|
Sets the display name without changing the key code.
◆ setKeyCodeAndDisplayName()
| void ButtonInputBox::setKeyCodeAndDisplayName |
( |
KeyCodeType | vk, |
|
|
const QString & | displayName ) |
Sets both the key code and display name.
◆ updateDisplay()
| void ButtonInputBox::updateDisplay |
( |
| ) |
|
|
private |
◆ m_displayName
| QString ButtonInputBox::m_displayName |
|
private |
◆ m_vk
The documentation for this class was generated from the following files: