@@ -78,7 +78,7 @@ void InputConvertGame::keyEvent(const QKeyEvent *from, const QSize &frameSize, c
78
78
}
79
79
80
80
// small eyes
81
- if (from->key () == m_keyMap.getMouseMoveMap ().data .mouseMove .smallEyes .key ) {
81
+ if (m_keyMap. isValidMouseMoveMap () && from->key () == m_keyMap.getMouseMoveMap ().data .mouseMove .smallEyes .key ) {
82
82
m_ctrlMouseMove.smallEyes = (QEvent::KeyPress == from->type ());
83
83
84
84
if (QEvent::KeyPress == from->type ()) {
@@ -110,6 +110,9 @@ void InputConvertGame::keyEvent(const QKeyEvent *from, const QSize &frameSize, c
110
110
case KeyMap::KMT_CLICK_TWICE:
111
111
processKeyClick (node.data .clickTwice .keyNode .pos , true , false , from);
112
112
return ;
113
+ case KeyMap::KMT_CLICK_MULTI:
114
+ processKeyClickMulti (node.data .clickMulti .keyNode .delayClickNodes , node.data .clickMulti .keyNode .delayClickNodesCount , from);
115
+ return ;
113
116
case KeyMap::KMT_DRAG:
114
117
processKeyDrag (node.data .drag .keyNode .pos , node.data .drag .keyNode .extendPos , from);
115
118
return ;
@@ -121,6 +124,11 @@ void InputConvertGame::keyEvent(const QKeyEvent *from, const QSize &frameSize, c
121
124
}
122
125
}
123
126
127
+ bool InputConvertGame::isCurrentCustomKeymap ()
128
+ {
129
+ return m_gameMap;
130
+ }
131
+
124
132
void InputConvertGame::loadKeyMap (const QString &json)
125
133
{
126
134
m_keyMap.loadKeyMap (json);
@@ -164,8 +172,15 @@ void InputConvertGame::sendTouchEvent(int id, QPointF pos, AndroidMotioneventAct
164
172
if (!controlMsg) {
165
173
return ;
166
174
}
167
- controlMsg->setInjectTouchMsgData (
168
- static_cast <quint64>(id), action, static_cast <AndroidMotioneventButtons>(0 ), QRect (calcFrameAbsolutePos (pos).toPoint (), m_frameSize), 1 .0f );
175
+
176
+ QPoint absolutePos = calcFrameAbsolutePos (pos).toPoint ();
177
+ static QPoint lastAbsolutePos = absolutePos;
178
+ if (AMOTION_EVENT_ACTION_MOVE == action && lastAbsolutePos == absolutePos) {
179
+ return ;
180
+ }
181
+ lastAbsolutePos = absolutePos;
182
+
183
+ controlMsg->setInjectTouchMsgData (static_cast <quint64>(id), action, static_cast <AndroidMotioneventButtons>(0 ), QRect (absolutePos, m_frameSize), 1 .0f );
169
184
sendControlMsg (controlMsg);
170
185
}
171
186
@@ -302,6 +317,34 @@ void InputConvertGame::processKeyClick(const QPointF &clickPos, bool clickTwice,
302
317
}
303
318
}
304
319
320
+ void InputConvertGame::processKeyClickMulti (const KeyMap::DelayClickNode *nodes, const int count, const QKeyEvent *from)
321
+ {
322
+ if (QEvent::KeyPress != from->type ()) {
323
+ return ;
324
+ }
325
+
326
+ int key = from->key ();
327
+ int delay = 0 ;
328
+ QPointF clickPos;
329
+
330
+ for (int i = 0 ; i < count; i++) {
331
+ delay += nodes[i].delay ;
332
+ clickPos = nodes[i].pos ;
333
+ QTimer::singleShot (delay, this , [this , key, clickPos]() {
334
+ int id = attachTouchID (key);
335
+ sendTouchDownEvent (id, clickPos);
336
+ });
337
+
338
+ // Don't up it too fast
339
+ delay += 20 ;
340
+ QTimer::singleShot (delay, this , [this , key, clickPos]() {
341
+ int id = getTouchID (key);
342
+ sendTouchUpEvent (id, clickPos);
343
+ detachTouchID (key);
344
+ });
345
+ }
346
+ }
347
+
305
348
void InputConvertGame::processKeyDrag (const QPointF &startPos, QPointF endPos, const QKeyEvent *from)
306
349
{
307
350
if (QEvent::KeyPress == from->type ()) {
@@ -361,8 +404,8 @@ bool InputConvertGame::processMouseMove(const QMouseEvent *from)
361
404
m_ctrlMouseMove.lastConverPos .setX (m_ctrlMouseMove.lastConverPos .x () + distance.x () / m_showSize.width ());
362
405
m_ctrlMouseMove.lastConverPos .setY (m_ctrlMouseMove.lastConverPos .y () + distance.y () / m_showSize.height ());
363
406
364
- if (m_ctrlMouseMove.lastConverPos .x () < 0.1 || m_ctrlMouseMove.lastConverPos .x () > 0.8 || m_ctrlMouseMove.lastConverPos .y () < 0.1
365
- || m_ctrlMouseMove.lastConverPos .y () > 0.8 ) {
407
+ if (m_ctrlMouseMove.lastConverPos .x () < 0.05 || m_ctrlMouseMove.lastConverPos .x () > 0.95 || m_ctrlMouseMove.lastConverPos .y () < 0.05
408
+ || m_ctrlMouseMove.lastConverPos .y () > 0.95 ) {
366
409
if (m_ctrlMouseMove.smallEyes ) {
367
410
m_processMouseMove = false ;
368
411
int delay = 30 ;
@@ -442,7 +485,7 @@ void InputConvertGame::mouseMoveStopTouch()
442
485
void InputConvertGame::startMouseMoveTimer ()
443
486
{
444
487
stopMouseMoveTimer ();
445
- m_ctrlMouseMove.timer = startTimer (1000 );
488
+ m_ctrlMouseMove.timer = startTimer (500 );
446
489
}
447
490
448
491
void InputConvertGame::stopMouseMoveTimer ()
@@ -456,6 +499,7 @@ void InputConvertGame::stopMouseMoveTimer()
456
499
bool InputConvertGame::switchGameMap ()
457
500
{
458
501
m_gameMap = !m_gameMap;
502
+ qInfo () << tr (" current keymap mode: %1" ).arg (m_gameMap ? tr (" custom" ) : tr (" normal" ));
459
503
460
504
if (!m_keyMap.isValidMouseMoveMap ()) {
461
505
return m_gameMap;
0 commit comments