Hold Keys mode: keys stay down while touched, like a hardware keyboard
- HardwareKeys presses a key's unshifted keysym on touch and releases it on lift, through fake input; held keys repeat and combine as on a physical keyboard (games, Shift+click) - Shift/Ctrl/Alt/Super are plain held keys, caps lock is the system's, dead keys compose in the app - No long-press, flick, trackpad or rollover in this mode; nothing is left held when the mode is turned off or touches are cancelled - Settings switch; default stays the touch (virtual keyboard) mode Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "engine/InputEngine.h"
|
||||
|
||||
#include <QList>
|
||||
#include <QSet>
|
||||
#include <QString>
|
||||
|
||||
// Records what the keyboard sends and applies it to a simulated field, so
|
||||
@@ -27,8 +28,25 @@ public:
|
||||
lastModifiers = modifiers;
|
||||
}
|
||||
|
||||
void setKeyPressed(quint32 keysym, bool pressed) override
|
||||
{
|
||||
keyEvents.append({keysym, pressed});
|
||||
if (pressed)
|
||||
held.insert(keysym);
|
||||
else
|
||||
held.remove(keysym);
|
||||
}
|
||||
|
||||
struct KeyEvent {
|
||||
quint32 keysym;
|
||||
bool pressed;
|
||||
bool operator==(const KeyEvent &) const = default;
|
||||
};
|
||||
|
||||
QString output; // the field's text
|
||||
int mismatchedReplacements = 0; // replaced text that wasn't before the cursor
|
||||
QList<quint32> keysyms;
|
||||
Qt::KeyboardModifiers lastModifiers;
|
||||
QList<KeyEvent> keyEvents; // setKeyPressed calls
|
||||
QSet<quint32> held;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user