@@ -24,14 +24,29 @@ void InputConvertGame::keyEvent(const QKeyEvent *from, const QSize& frameSize, c
24
24
return ;
25
25
}
26
26
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
+
27
43
// action
28
- AndroidMotioneventAction action;
29
44
switch (from->type ()) {
30
45
case QEvent::KeyPress:
31
- action = AMOTION_EVENT_ACTION_DOWN;
46
+ action | = AMOTION_EVENT_ACTION_DOWN;
32
47
break ;
33
48
case QEvent::KeyRelease:
34
- action = AMOTION_EVENT_ACTION_UP;
49
+ action | = AMOTION_EVENT_ACTION_UP;
35
50
break ;
36
51
default :
37
52
return ;
@@ -51,7 +66,7 @@ void InputConvertGame::keyEvent(const QKeyEvent *from, const QSize& frameSize, c
51
66
if (!controlEvent) {
52
67
return ;
53
68
}
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));
55
70
sendControlEvent (controlEvent);
56
71
57
72
if (QEvent::KeyPress == from->type ()) {
@@ -60,7 +75,9 @@ void InputConvertGame::keyEvent(const QKeyEvent *from, const QSize& frameSize, c
60
75
return ;
61
76
}
62
77
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));
64
81
sendControlEvent (controlEvent2);
65
82
}
66
83
}
0 commit comments