diff --git a/QtScrcpy/device/controller/inputconvert/inputconvertbase.h b/QtScrcpy/device/controller/inputconvert/inputconvertbase.h index ee1c6da..d9f8dc5 100644 --- a/QtScrcpy/device/controller/inputconvert/inputconvertbase.h +++ b/QtScrcpy/device/controller/inputconvert/inputconvertbase.h @@ -33,6 +33,9 @@ protected: void sendControlMsg(ControlMsg *msg); QPointer 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 diff --git a/QtScrcpy/device/controller/inputconvert/inputconvertnormal.cpp b/QtScrcpy/device/controller/inputconvert/inputconvertnormal.cpp index 91d0681..260604e 100644 --- a/QtScrcpy/device/controller/inputconvert/inputconvertnormal.cpp +++ b/QtScrcpy/device/controller/inputconvert/inputconvertnormal.cpp @@ -1,4 +1,5 @@ #include +#include #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); }