Skip to content

Commit dfadeeb

Browse files
author
rankun
committed
多点触控测试
1 parent b9e9c97 commit dfadeeb

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

src/inputcontrol/inputconvertgame.cpp

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,29 @@ void InputConvertGame::keyEvent(const QKeyEvent *from, const QSize& frameSize, c
2424
return;
2525
}
2626

27+
int action = 0;
28+
29+
// pointer index
30+
int pointerIndex = 0;
31+
32+
if (from->key() == Qt::Key_W) {
33+
pointerIndex = 0x0000;
34+
} else if (from->key() == Qt::Key_D) {
35+
pointerIndex = 0x0100;
36+
} else {
37+
return;
38+
}
39+
40+
41+
action |= pointerIndex;
42+
2743
// action
28-
AndroidMotioneventAction action;
2944
switch (from->type()) {
3045
case QEvent::KeyPress:
31-
action = AMOTION_EVENT_ACTION_DOWN;
46+
action |= AMOTION_EVENT_ACTION_DOWN;
3247
break;
3348
case QEvent::KeyRelease:
34-
action = AMOTION_EVENT_ACTION_UP;
49+
action |= AMOTION_EVENT_ACTION_UP;
3550
break;
3651
default:
3752
return;
@@ -51,7 +66,7 @@ void InputConvertGame::keyEvent(const QKeyEvent *from, const QSize& frameSize, c
5166
if (!controlEvent) {
5267
return;
5368
}
54-
controlEvent->setMouseEventData(action, AMOTION_EVENT_BUTTON_PRIMARY, QRect(pos.toPoint(), frameSize));
69+
controlEvent->setMouseEventData((AndroidMotioneventAction)action, AMOTION_EVENT_BUTTON_PRIMARY, QRect(pos.toPoint(), frameSize));
5570
sendControlEvent(controlEvent);
5671

5772
if (QEvent::KeyPress == from->type()) {
@@ -60,7 +75,9 @@ void InputConvertGame::keyEvent(const QKeyEvent *from, const QSize& frameSize, c
6075
return;
6176
}
6277
pos.setY(pos.y() - 50);
63-
controlEvent2->setMouseEventData(AMOTION_EVENT_ACTION_MOVE, AMOTION_EVENT_BUTTON_PRIMARY, QRect(pos.toPoint(), frameSize));
78+
action &= AMOTION_EVENT_ACTION_POINTER_INDEX_MASK;
79+
action |= AMOTION_EVENT_ACTION_MOVE;
80+
controlEvent2->setMouseEventData((AndroidMotioneventAction)action, AMOTION_EVENT_BUTTON_PRIMARY, QRect(pos.toPoint(), frameSize));
6481
sendControlEvent(controlEvent2);
6582
}
6683
}

0 commit comments

Comments
 (0)