Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #438

Merged
merged 21 commits into from
Jun 28, 2021
Merged

Dev #438

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix: drag delay timer too big bug
  • Loading branch information
barry-ran committed Jun 28, 2021
commit e23c566c030b7a8509354bc04d5211dce8e0dae0
16 changes: 8 additions & 8 deletions QtScrcpy/device/controller/inputconvert/inputconvertgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,9 @@ int InputConvertGame::getTouchID(int key)
// -------- steer wheel event --------

void InputConvertGame::getDelayQueue(const QPointF& start, const QPointF& end,
const double& distanceStep, const double& posStepconst, const double& timerStep,
QQueue<QPointF>& queuePos, QQueue<double>& queueTimer) {
double timerBase = 5.0f; // ms
const double& distanceStep, const double& posStepconst,
quint32 lowestTimer, quint32 highestTimer,
QQueue<QPointF>& queuePos, QQueue<quint32>& queueTimer) {
double x1 = start.x();
double y1 = start.y();
double x2 = end.x();
Expand All @@ -262,11 +262,11 @@ void InputConvertGame::getDelayQueue(const QPointF& start, const QPointF& end,
dy/=e;

QQueue<QPointF> queue;
QQueue<double> queue2;
QQueue<quint32> queue2;
for(int i=1;i<=e;i++) {
QPointF pos(x1+(QRandomGenerator::global()->bounded(posStepconst*2)-posStepconst), y1+(QRandomGenerator::global()->bounded(posStepconst*2)-posStepconst));
queue.enqueue(pos);
queue2.enqueue(QRandomGenerator::global()->bounded(timerStep*2)-timerStep + timerBase);
queue2.enqueue(QRandomGenerator::global()->bounded(lowestTimer, highestTimer));
x1+=dx;
y1+=dy;
}
Expand Down Expand Up @@ -355,12 +355,12 @@ void InputConvertGame::processSteerWheel(const KeyMap::KeyMapNode &node, const Q
sendTouchDownEvent(id, node.data.steerWheel.centerPos);

getDelayQueue(node.data.steerWheel.centerPos, node.data.steerWheel.centerPos+offset,
0.01f, 0.002f, 3.0f,
0.01f, 0.002f, 2, 8,
m_ctrlSteerWheel.delayData.queuePos,
m_ctrlSteerWheel.delayData.queueTimer);
} else {
getDelayQueue(m_ctrlSteerWheel.delayData.currentPos, node.data.steerWheel.centerPos+offset,
0.01f, 0.002f, 3.0f,
0.01f, 0.002f, 2, 8,
m_ctrlSteerWheel.delayData.queuePos,
m_ctrlSteerWheel.delayData.queueTimer);
}
Expand Down Expand Up @@ -477,7 +477,7 @@ void InputConvertGame::processKeyDrag(const QPointF &startPos, QPointF endPos, c
m_dragDelayData.queuePos.clear();
m_dragDelayData.queueTimer.clear();
getDelayQueue(startPos, endPos,
0.01f, 0.002f, 2.0f,
0.01f, 0.002f, 0, 2,
m_dragDelayData.queuePos,
m_dragDelayData.queueTimer);
m_dragDelayData.timer->start();
Expand Down
9 changes: 5 additions & 4 deletions QtScrcpy/device/controller/inputconvert/inputconvertgame.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ class InputConvertGame : public InputConvertNormal
void hideMouseCursor(bool hide);

void getDelayQueue(const QPointF& start, const QPointF& end,
const double& distanceStep, const double& posStepconst, const double& timerStep,
QQueue<QPointF>& queuePos, QQueue<double>& queueTimer);
const double& distanceStep, const double& posStepconst,
quint32 lowestTimer, quint32 highestTimer,
QQueue<QPointF>& queuePos, QQueue<quint32>& queueTimer);

protected:
void timerEvent(QTimerEvent *event);
Expand Down Expand Up @@ -97,7 +98,7 @@ private slots:
QPointF currentPos;
QTimer* timer = nullptr;
QQueue<QPointF> queuePos;
QQueue<double> queueTimer;
QQueue<quint32> queueTimer;
int pressedNum = 0;
} delayData;
} m_ctrlSteerWheel;
Expand All @@ -117,7 +118,7 @@ private slots:
QPointF currentPos;
QTimer* timer = nullptr;
QQueue<QPointF> queuePos;
QQueue<double> queueTimer;
QQueue<quint32> queueTimer;
int pressKey = 0;
} m_dragDelayData;
};
Expand Down