mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-04-22 04:24:59 +00:00
常规更新
This commit is contained in:
parent
297381defc
commit
4e386e879e
1 changed files with 18 additions and 8 deletions
|
@ -25,14 +25,20 @@ void InputConvertGame::keyEvent(const QKeyEvent *from, const QSize& frameSize, c
|
|||
}
|
||||
|
||||
int action = 0;
|
||||
// pos
|
||||
QPointF pos;
|
||||
|
||||
// pointer index
|
||||
int pointerIndex = 0;
|
||||
|
||||
if (from->key() == Qt::Key_W) {
|
||||
pointerIndex = 0x0000;
|
||||
pos.setX(showSize.width() * 0.25f);
|
||||
pos.setY(showSize.height() * 0.5f);
|
||||
} else if (from->key() == Qt::Key_D) {
|
||||
pointerIndex = 0x0100;
|
||||
pos.setX(showSize.width() * 0.5f);
|
||||
pos.setY(showSize.height() * 0.25f);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
@ -43,19 +49,22 @@ void InputConvertGame::keyEvent(const QKeyEvent *from, const QSize& frameSize, c
|
|||
// action
|
||||
switch (from->type()) {
|
||||
case QEvent::KeyPress:
|
||||
action |= AMOTION_EVENT_ACTION_DOWN;
|
||||
if (from->key() == Qt::Key_W) {
|
||||
action |= AMOTION_EVENT_ACTION_DOWN;
|
||||
} else {
|
||||
action |= AMOTION_EVENT_ACTION_POINTER_DOWN;
|
||||
}
|
||||
break;
|
||||
case QEvent::KeyRelease:
|
||||
action |= AMOTION_EVENT_ACTION_UP;
|
||||
if (from->key() == Qt::Key_W) {
|
||||
action |= AMOTION_EVENT_ACTION_UP;
|
||||
} else {
|
||||
action |= AMOTION_EVENT_ACTION_POINTER_UP;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
// pos
|
||||
QPointF pos;
|
||||
pos.setX(showSize.width() * 0.25f);
|
||||
pos.setY(showSize.height() * 0.5f);
|
||||
}
|
||||
|
||||
// convert pos
|
||||
pos.setX(pos.x() * frameSize.width() / showSize.width());
|
||||
|
@ -68,6 +77,7 @@ void InputConvertGame::keyEvent(const QKeyEvent *from, const QSize& frameSize, c
|
|||
}
|
||||
controlEvent->setMouseEventData((AndroidMotioneventAction)action, AMOTION_EVENT_BUTTON_PRIMARY, QRect(pos.toPoint(), frameSize));
|
||||
sendControlEvent(controlEvent);
|
||||
return;
|
||||
|
||||
if (QEvent::KeyPress == from->type()) {
|
||||
ControlEvent* controlEvent2 = new ControlEvent(ControlEvent::CET_MOUSE);
|
||||
|
|
Loading…
Add table
Reference in a new issue