mirror of
https://github.com/barry-ran/QtScrcpy.git
synced 2025-08-02 05:48:38 +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;
|
int action = 0;
|
||||||
|
// pos
|
||||||
|
QPointF pos;
|
||||||
|
|
||||||
// pointer index
|
// pointer index
|
||||||
int pointerIndex = 0;
|
int pointerIndex = 0;
|
||||||
|
|
||||||
if (from->key() == Qt::Key_W) {
|
if (from->key() == Qt::Key_W) {
|
||||||
pointerIndex = 0x0000;
|
pointerIndex = 0x0000;
|
||||||
|
pos.setX(showSize.width() * 0.25f);
|
||||||
|
pos.setY(showSize.height() * 0.5f);
|
||||||
} else if (from->key() == Qt::Key_D) {
|
} else if (from->key() == Qt::Key_D) {
|
||||||
pointerIndex = 0x0100;
|
pointerIndex = 0x0100;
|
||||||
|
pos.setX(showSize.width() * 0.5f);
|
||||||
|
pos.setY(showSize.height() * 0.25f);
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -43,19 +49,22 @@ void InputConvertGame::keyEvent(const QKeyEvent *from, const QSize& frameSize, c
|
||||||
// action
|
// action
|
||||||
switch (from->type()) {
|
switch (from->type()) {
|
||||||
case QEvent::KeyPress:
|
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;
|
break;
|
||||||
case QEvent::KeyRelease:
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// pos
|
|
||||||
QPointF pos;
|
|
||||||
pos.setX(showSize.width() * 0.25f);
|
|
||||||
pos.setY(showSize.height() * 0.5f);
|
|
||||||
|
|
||||||
// convert pos
|
// convert pos
|
||||||
pos.setX(pos.x() * frameSize.width() / showSize.width());
|
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));
|
controlEvent->setMouseEventData((AndroidMotioneventAction)action, AMOTION_EVENT_BUTTON_PRIMARY, QRect(pos.toPoint(), frameSize));
|
||||||
sendControlEvent(controlEvent);
|
sendControlEvent(controlEvent);
|
||||||
|
return;
|
||||||
|
|
||||||
if (QEvent::KeyPress == from->type()) {
|
if (QEvent::KeyPress == from->type()) {
|
||||||
ControlEvent* controlEvent2 = new ControlEvent(ControlEvent::CET_MOUSE);
|
ControlEvent* controlEvent2 = new ControlEvent(ControlEvent::CET_MOUSE);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue