diff --git a/QtScrcpy/dialog.ui b/QtScrcpy/dialog.ui
index 0e7f8a8..46a4dd3 100644
--- a/QtScrcpy/dialog.ui
+++ b/QtScrcpy/dialog.ui
@@ -41,7 +41,7 @@
Wireless
-
+
-
diff --git a/QtScrcpy/inputcontrol/controlevent.cpp b/QtScrcpy/inputcontrol/controlevent.cpp
index 99c8a79..70b5e44 100644
--- a/QtScrcpy/inputcontrol/controlevent.cpp
+++ b/QtScrcpy/inputcontrol/controlevent.cpp
@@ -2,8 +2,6 @@
#include "controlevent.h"
-#define TEXT_MAX_CHARACTER_LENGTH 300
-
ControlEvent::ControlEvent(ControlEventType controlEventType)
: QScrcpyEvent(Control)
{
@@ -19,7 +17,14 @@ void ControlEvent::setKeycodeEventData(AndroidKeyeventAction action, AndroidKeyc
void ControlEvent::setTextEventData(QString text)
{
- m_data.textEvent.text = text;
+ // write length (2 byte) + date (non nul-terminated)
+ if (TEXT_MAX_CHARACTER_LENGTH < text.length()) {
+ // injecting a text takes time, so limit the text length
+ text = text.left(TEXT_MAX_CHARACTER_LENGTH);
+ }
+ QByteArray tmp = text.toUtf8();
+ memset(m_data.textEvent.text, 0, sizeof (m_data.textEvent.text));
+ memcpy(m_data.textEvent.text, tmp.data(), tmp.length());
}
void ControlEvent::setMouseEventData(AndroidMotioneventAction action, AndroidMotioneventButtons buttons, QRect position)
@@ -85,14 +90,8 @@ QByteArray ControlEvent::serializeData()
break;
case CET_TEXT:
{
- // write length (2 byte) + date (non nul-terminated)
- if (TEXT_MAX_CHARACTER_LENGTH < m_data.textEvent.text.length()) {
- // injecting a text takes time, so limit the text length
- m_data.textEvent.text = m_data.textEvent.text.left(TEXT_MAX_CHARACTER_LENGTH);
- }
- QByteArray tmp = m_data.textEvent.text.toUtf8();
- write16(buffer, tmp.length());
- buffer.write(tmp.data(), tmp.length());
+ write16(buffer, strlen(m_data.textEvent.text));
+ buffer.write(m_data.textEvent.text, strlen(m_data.textEvent.text));
}
break;
case CET_MOUSE:
diff --git a/QtScrcpy/inputcontrol/controlevent.h b/QtScrcpy/inputcontrol/controlevent.h
index 3dd2f83..6198779 100644
--- a/QtScrcpy/inputcontrol/controlevent.h
+++ b/QtScrcpy/inputcontrol/controlevent.h
@@ -10,6 +10,8 @@
#include "keycodes.h"
#define CONTROL_EVENT_COMMAND_BACK_OR_SCREEN_ON 0
+
+#define TEXT_MAX_CHARACTER_LENGTH 300
// ControlEvent
class ControlEvent : public QScrcpyEvent
{
@@ -52,7 +54,7 @@ private:
AndroidMetastate metastate;
} keycodeEvent;
struct {
- QString text;
+ char text[TEXT_MAX_CHARACTER_LENGTH + 1];
} textEvent;
struct {
AndroidMotioneventAction action;
diff --git a/QtScrcpy/videoform.cpp b/QtScrcpy/videoform.cpp
index dcf5d45..360bf66 100644
--- a/QtScrcpy/videoform.cpp
+++ b/QtScrcpy/videoform.cpp
@@ -259,6 +259,16 @@ void VideoForm::postTurnOn()
m_inputConvert.sendControlEvent(controlEvent);
}
+void VideoForm::postTextInput(const QString& text)
+{
+ ControlEvent* controlEvent = new ControlEvent(ControlEvent::CET_TEXT);
+ if (!controlEvent) {
+ return;
+ }
+ controlEvent->setTextEventData(text);
+ m_inputConvert.sendControlEvent(controlEvent);
+}
+
void VideoForm::postGoHome()
{
postKeyCodeClick(AKEYCODE_HOME);
diff --git a/QtScrcpy/videoform.h b/QtScrcpy/videoform.h
index 7610c51..76b142b 100644
--- a/QtScrcpy/videoform.h
+++ b/QtScrcpy/videoform.h
@@ -33,6 +33,7 @@ public:
void postVolumeDown();
// turn the screen on if it was off, press BACK otherwise
void postTurnOn();
+ void postTextInput(const QString& text);
private:
void updateShowSize(const QSize &newSize);
diff --git a/TODO.txt b/TODO.txt
index d0205fb..ee7c1c3 100644
--- a/TODO.txt
+++ b/TODO.txt
@@ -1,6 +1,3 @@
-
-中英文翻译
-tool tips
server移除
mp4录制
工具栏扩展(模拟点击指定次数等)