mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-07-31 12:58:39 +00:00
feat: add repeat
This commit is contained in:
parent
b73498c6b5
commit
db97c4e0a5
2 changed files with 12 additions and 12 deletions
|
@ -33,6 +33,9 @@ protected:
|
||||||
void sendControlMsg(ControlMsg *msg);
|
void sendControlMsg(ControlMsg *msg);
|
||||||
|
|
||||||
QPointer<Controller> m_controller;
|
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
|
#endif // INPUTCONVERTBASE_H
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
#include "inputconvertnormal.h"
|
#include "inputconvertnormal.h"
|
||||||
#include "controller.h"
|
#include "controller.h"
|
||||||
|
@ -85,19 +86,8 @@ void InputConvertNormal::keyEvent(const QKeyEvent *from, const QSize &frameSize,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ctrl = from->modifiers() & Qt::ControlModifier;
|
|
||||||
bool shift = from->modifiers() & Qt::ShiftModifier;
|
|
||||||
bool down = from->type() == QEvent::KeyPress;
|
|
||||||
bool repeat = from->isAutoRepeat();
|
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
|
// action
|
||||||
AndroidKeyeventAction action;
|
AndroidKeyeventAction action;
|
||||||
switch (from->type()) {
|
switch (from->type()) {
|
||||||
|
@ -122,7 +112,14 @@ void InputConvertNormal::keyEvent(const QKeyEvent *from, const QSize &frameSize,
|
||||||
if (!controlMsg) {
|
if (!controlMsg) {
|
||||||
return;
|
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);
|
sendControlMsg(controlMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue