mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-04-20 03:25:02 +00:00
feat: add repeat
This commit is contained in:
parent
cb01b990ea
commit
d0b548720b
2 changed files with 12 additions and 12 deletions
|
@ -33,6 +33,9 @@ protected:
|
|||
void sendControlMsg(ControlMsg *msg);
|
||||
|
||||
QPointer<Controller> m_controller;
|
||||
// Qt reports repeated events as a boolean, but Android expects the actual
|
||||
// number of repetitions. This variable keeps track of the count.
|
||||
unsigned m_repeat = 0;
|
||||
};
|
||||
|
||||
#endif // INPUTCONVERTBASE_H
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include <cmath>
|
||||
#include <QDebug>
|
||||
|
||||
#include "inputconvertnormal.h"
|
||||
#include "controller.h"
|
||||
|
@ -85,19 +86,8 @@ void InputConvertNormal::keyEvent(const QKeyEvent *from, const QSize &frameSize,
|
|||
return;
|
||||
}
|
||||
|
||||
bool ctrl = from->modifiers() & Qt::ControlModifier;
|
||||
bool shift = from->modifiers() & Qt::ShiftModifier;
|
||||
bool down = from->type() == QEvent::KeyPress;
|
||||
bool repeat = from->isAutoRepeat();
|
||||
|
||||
if (ctrl && !shift && from->key() == Qt::Key_V && down && !repeat) {
|
||||
// Synchronize the computer clipboard to the device clipboard before
|
||||
// sending Ctrl+v, to allow seamless copy-paste.
|
||||
if (m_controller) {
|
||||
m_controller->onSetDeviceClipboard(false);
|
||||
}
|
||||
}
|
||||
|
||||
// action
|
||||
AndroidKeyeventAction action;
|
||||
switch (from->type()) {
|
||||
|
@ -122,7 +112,14 @@ void InputConvertNormal::keyEvent(const QKeyEvent *from, const QSize &frameSize,
|
|||
if (!controlMsg) {
|
||||
return;
|
||||
}
|
||||
controlMsg->setInjectKeycodeMsgData(action, keyCode, 0, convertMetastate(from->modifiers()));
|
||||
|
||||
if (repeat) {
|
||||
m_repeat++;
|
||||
} else {
|
||||
m_repeat = 0;
|
||||
}
|
||||
|
||||
controlMsg->setInjectKeycodeMsgData(action, keyCode, m_repeat, convertMetastate(from->modifiers()));
|
||||
sendControlMsg(controlMsg);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue