mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-08 06:22:14 +02:00
Android - Make it possible to look around and move with touchscreen controls. Zoom-in not in 'My View' mode.
This commit is contained in:
parent
3f762c7900
commit
321896142c
2 changed files with 17 additions and 10 deletions
|
@ -20,9 +20,10 @@
|
|||
InputPluginList getInputPlugins() {
|
||||
InputPlugin* PLUGIN_POOL[] = {
|
||||
new KeyboardMouseDevice(),
|
||||
new TouchscreenDevice(),
|
||||
#if defined(Q_OS_ANDROID)
|
||||
new TouchscreenVirtualPadDevice(),
|
||||
#else
|
||||
new TouchscreenDevice(), // Touchscreen and Controller Scripts take care on Android
|
||||
#endif
|
||||
nullptr
|
||||
};
|
||||
|
|
|
@ -262,22 +262,28 @@ void TouchscreenVirtualPadDevice::touchUpdateEvent(const QTouchEvent* event) {
|
|||
const QList<QTouchEvent::TouchPoint>& tPoints = event->touchPoints();
|
||||
bool leftTouchFound = false;
|
||||
bool rightTouchFound = false;
|
||||
glm::vec2 thisPoint;
|
||||
for (int i = 0; i < _touchPointCount; ++i) {
|
||||
glm::vec2 thisPoint(tPoints[i].pos().x(), tPoints[i].pos().y());
|
||||
if (_validTouchLeft) {
|
||||
leftTouchFound = true;
|
||||
touchLeftUpdate(thisPoint);
|
||||
} else if (touchLeftBeginPointIsValid(thisPoint)) {
|
||||
if (!leftTouchFound) {
|
||||
thisPoint.x = tPoints[i].pos().x();
|
||||
thisPoint.y = tPoints[i].pos().y();
|
||||
// left side and the first one detected counts
|
||||
if (thisPoint.x < _screenWidthCenter && !leftTouchFound) {
|
||||
if (_validTouchLeft) {
|
||||
// valid if it's an ongoing touch
|
||||
leftTouchFound = true;
|
||||
touchLeftBegin(thisPoint);
|
||||
}
|
||||
} else {
|
||||
touchLeftUpdate(thisPoint);
|
||||
} else if (touchLeftBeginPointIsValid(thisPoint)) {
|
||||
// valid if it's start point is valid
|
||||
leftTouchFound = true;
|
||||
touchLeftBegin(thisPoint);
|
||||
} // if it wasn't even a valid starting point, it won't count as left touch valid
|
||||
} else if (thisPoint.x >= _screenWidthCenter) { // right side
|
||||
if (!rightTouchFound) {
|
||||
rightTouchFound = true;
|
||||
if (!_validTouchRight) {
|
||||
touchRightBegin(thisPoint);
|
||||
} else {
|
||||
// as we don't have a stick on the right side, there is no condition to process right touch
|
||||
touchRightUpdate(thisPoint);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue