Merge branch 'master' of github.com:highfidelity/hifi into serverless-domains

This commit is contained in:
Seth Alves 2018-03-16 20:07:35 -07:00
commit a4599fe7ce
7 changed files with 198 additions and 125 deletions

View file

@ -5,8 +5,8 @@
{ "from": "TouchscreenVirtualPad.LX", "when": "!Application.CameraIndependent", "filters": { "type": "deadZone", "min": 0.05 }, "to": "Actions.TranslateX" }, { "from": "TouchscreenVirtualPad.LX", "when": "!Application.CameraIndependent", "filters": { "type": "deadZone", "min": 0.05 }, "to": "Actions.TranslateX" },
{ "from": "TouchscreenVirtualPad.RX", "when": "!Application.CameraIndependent", "filters": { "type": "deadZone", "min": 0.05 }, "to": "Actions.Yaw" }, { "from": "TouchscreenVirtualPad.RX", "when": "!Application.CameraIndependent", "filters": [ {"type": "deadZone", "min": 0.05} , "invert" ], "to": "Actions.Yaw" },
{ "from": "TouchscreenVirtualPad.RY", "when": "!Application.CameraIndependent", "to": "Actions.Pitch" } { "from": "TouchscreenVirtualPad.RY", "when": "!Application.CameraIndependent", "filters": [ {"type": "deadZone", "min": 0.05}, "invert" ], "to": "Actions.Pitch" }
] ]
} }

View file

@ -38,7 +38,8 @@ ModalWindow {
keyboardOverride: true // Disable ModalWindow's keyboard. keyboardOverride: true // Disable ModalWindow's keyboard.
function tryDestroy() { function tryDestroy() {
root.destroy() Controller.setVPadHidden(false);
root.destroy();
} }
LoginDialog { LoginDialog {
@ -52,8 +53,9 @@ ModalWindow {
Component.onCompleted: { Component.onCompleted: {
this.anchors.centerIn = undefined; this.anchors.centerIn = undefined;
this.y=150; this.y = 150;
this.x=(parent.width - this.width)/2; this.x = (parent.width - this.width) / 2;
Controller.setVPadHidden(true);
} }
Keys.onPressed: { Keys.onPressed: {

View file

@ -224,7 +224,7 @@ Item {
onClicked: { onClicked: {
Qt.inputMethod.hide(); Qt.inputMethod.hide();
root.destroy(); root.tryDestroy();
} }
} }
} }

View file

@ -20,9 +20,10 @@
InputPluginList getInputPlugins() { InputPluginList getInputPlugins() {
InputPlugin* PLUGIN_POOL[] = { InputPlugin* PLUGIN_POOL[] = {
new KeyboardMouseDevice(), new KeyboardMouseDevice(),
new TouchscreenDevice(),
#if defined(Q_OS_ANDROID) #if defined(Q_OS_ANDROID)
new TouchscreenVirtualPadDevice(), new TouchscreenVirtualPadDevice(),
#else
new TouchscreenDevice(), // Touchscreen and Controller Scripts take care on Android
#endif #endif
nullptr nullptr
}; };

View file

@ -60,6 +60,8 @@ void TouchscreenVirtualPadDevice::init() {
if (_fixedPosition) { if (_fixedPosition) {
virtualPadManager.getLeftVirtualPad()->setShown(virtualPadManager.isEnabled() && !virtualPadManager.isHidden()); // Show whenever it's enabled virtualPadManager.getLeftVirtualPad()->setShown(virtualPadManager.isEnabled() && !virtualPadManager.isHidden()); // Show whenever it's enabled
} }
KeyboardMouseDevice::enableTouch(false); // Touch for view controls is managed by this plugin
} }
void TouchscreenVirtualPadDevice::setupFixedCenter(VirtualPad::Manager& virtualPadManager, bool force) { void TouchscreenVirtualPadDevice::setupFixedCenter(VirtualPad::Manager& virtualPadManager, bool force) {
@ -73,8 +75,8 @@ void TouchscreenVirtualPadDevice::setupFixedCenter(VirtualPad::Manager& virtualP
QScreen* eventScreen = qApp->primaryScreen(); // do not call every time QScreen* eventScreen = qApp->primaryScreen(); // do not call every time
_fixedCenterPosition = glm::vec2( _fixedRadius + margin, eventScreen->size().height() - margin - _fixedRadius - _extraBottomMargin); _fixedCenterPosition = glm::vec2( _fixedRadius + margin, eventScreen->size().height() - margin - _fixedRadius - _extraBottomMargin);
_firstTouchLeftPoint = _fixedCenterPosition; _moveRefTouchPoint = _fixedCenterPosition;
virtualPadManager.getLeftVirtualPad()->setFirstTouch(_firstTouchLeftPoint); virtualPadManager.getLeftVirtualPad()->setFirstTouch(_moveRefTouchPoint);
} }
float clip(float n, float lower, float upper) { float clip(float n, float lower, float upper) {
@ -116,42 +118,35 @@ glm::vec2 TouchscreenVirtualPadDevice::clippedPointInCircle(float radius, glm::v
return vec2(finalX, finalY); return vec2(finalX, finalY);
} }
void TouchscreenVirtualPadDevice::processInputUseCircleMethod(VirtualPad::Manager& virtualPadManager) { void TouchscreenVirtualPadDevice::processInputDeviceForMove(VirtualPad::Manager& virtualPadManager) {
vec2 clippedPoint = clippedPointInCircle(_fixedRadiusForCalc, _firstTouchLeftPoint, _currentTouchLeftPoint); vec2 clippedPoint = clippedPointInCircle(_fixedRadiusForCalc, _moveRefTouchPoint, _moveCurrentTouchPoint);
_inputDevice->_axisStateMap[controller::LX] = (clippedPoint.x - _firstTouchLeftPoint.x) / _fixedRadiusForCalc; _inputDevice->_axisStateMap[controller::LX] = (clippedPoint.x - _moveRefTouchPoint.x) / _fixedRadiusForCalc;
_inputDevice->_axisStateMap[controller::LY] = (clippedPoint.y - _firstTouchLeftPoint.y) / _fixedRadiusForCalc; _inputDevice->_axisStateMap[controller::LY] = (clippedPoint.y - _moveRefTouchPoint.y) / _fixedRadiusForCalc;
virtualPadManager.getLeftVirtualPad()->setFirstTouch(_firstTouchLeftPoint); virtualPadManager.getLeftVirtualPad()->setFirstTouch(_moveRefTouchPoint);
virtualPadManager.getLeftVirtualPad()->setCurrentTouch(clippedPoint); virtualPadManager.getLeftVirtualPad()->setCurrentTouch(clippedPoint);
virtualPadManager.getLeftVirtualPad()->setBeingTouched(true); virtualPadManager.getLeftVirtualPad()->setBeingTouched(true);
virtualPadManager.getLeftVirtualPad()->setShown(true); // If touched, show in any mode (fixed joystick position or non-fixed) virtualPadManager.getLeftVirtualPad()->setShown(true); // If touched, show in any mode (fixed joystick position or non-fixed)
} }
void TouchscreenVirtualPadDevice::processInputUseSquareMethod(VirtualPad::Manager& virtualPadManager) { void TouchscreenVirtualPadDevice::processInputDeviceForView() {
float leftDistanceScaleX, leftDistanceScaleY; float rightDistanceScaleX, rightDistanceScaleY;
leftDistanceScaleX = (_currentTouchLeftPoint.x - _firstTouchLeftPoint.x) / _screenDPIScale.x; rightDistanceScaleX = (_viewCurrentTouchPoint.x - _viewRefTouchPoint.x) / _screenDPIScale.x;
leftDistanceScaleY = (_currentTouchLeftPoint.y - _firstTouchLeftPoint.y) / _screenDPIScale.y; rightDistanceScaleY = (_viewCurrentTouchPoint.y - _viewRefTouchPoint.y) / _screenDPIScale.y;
leftDistanceScaleX = clip(leftDistanceScaleX, -STICK_RADIUS_INCHES, STICK_RADIUS_INCHES); rightDistanceScaleX = clip(rightDistanceScaleX, -_viewStickRadiusInches, _viewStickRadiusInches);
leftDistanceScaleY = clip(leftDistanceScaleY, -STICK_RADIUS_INCHES, STICK_RADIUS_INCHES); rightDistanceScaleY = clip(rightDistanceScaleY, -_viewStickRadiusInches, _viewStickRadiusInches);
// NOW BETWEEN -1 1 // NOW BETWEEN -1 1
leftDistanceScaleX /= STICK_RADIUS_INCHES; rightDistanceScaleX /= _viewStickRadiusInches;
leftDistanceScaleY /= STICK_RADIUS_INCHES; rightDistanceScaleY /= _viewStickRadiusInches;
_inputDevice->_axisStateMap[controller::LX] = leftDistanceScaleX; _inputDevice->_axisStateMap[controller::RX] = rightDistanceScaleX;
_inputDevice->_axisStateMap[controller::LY] = leftDistanceScaleY; _inputDevice->_axisStateMap[controller::RY] = rightDistanceScaleY;
/* Shared variables for stick rendering (clipped to the stick radius)*/ // after use, save last touch point as ref
// Prevent this for being done when not in first person view _viewRefTouchPoint = _viewCurrentTouchPoint;
virtualPadManager.getLeftVirtualPad()->setFirstTouch(_firstTouchLeftPoint);
virtualPadManager.getLeftVirtualPad()->setCurrentTouch(
glm::vec2(clip(_currentTouchLeftPoint.x, -STICK_RADIUS_INCHES * _screenDPIScale.x + _firstTouchLeftPoint.x, STICK_RADIUS_INCHES * _screenDPIScale.x + _firstTouchLeftPoint.x),
clip(_currentTouchLeftPoint.y, -STICK_RADIUS_INCHES * _screenDPIScale.y + _firstTouchLeftPoint.y, STICK_RADIUS_INCHES * _screenDPIScale.y + _firstTouchLeftPoint.y))
);
virtualPadManager.getLeftVirtualPad()->setBeingTouched(true);
virtualPadManager.getLeftVirtualPad()->setShown(true); // If touched, show in any mode (fixed joystick position or non-fixed)
} }
void TouchscreenVirtualPadDevice::pluginUpdate(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) { void TouchscreenVirtualPadDevice::pluginUpdate(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) {
@ -163,8 +158,8 @@ void TouchscreenVirtualPadDevice::pluginUpdate(float deltaTime, const controller
auto& virtualPadManager = VirtualPad::Manager::instance(); auto& virtualPadManager = VirtualPad::Manager::instance();
setupFixedCenter(virtualPadManager); setupFixedCenter(virtualPadManager);
if (_validTouchLeft) { if (_moveHasValidTouch) {
processInputUseCircleMethod(virtualPadManager); processInputDeviceForMove(virtualPadManager);
} else { } else {
virtualPadManager.getLeftVirtualPad()->setBeingTouched(false); virtualPadManager.getLeftVirtualPad()->setBeingTouched(false);
if (_fixedPosition) { if (_fixedPosition) {
@ -175,20 +170,8 @@ void TouchscreenVirtualPadDevice::pluginUpdate(float deltaTime, const controller
} }
} }
if (_validTouchRight) { if (_viewHasValidTouch) {
float rightDistanceScaleX, rightDistanceScaleY; processInputDeviceForView();
rightDistanceScaleX = (_currentTouchRightPoint.x - _firstTouchRightPoint.x) / _screenDPIScale.x;
rightDistanceScaleY = (_currentTouchRightPoint.y - _firstTouchRightPoint.y) / _screenDPIScale.y;
rightDistanceScaleX = clip(rightDistanceScaleX, -STICK_RADIUS_INCHES, STICK_RADIUS_INCHES);
rightDistanceScaleY = clip(rightDistanceScaleY, -STICK_RADIUS_INCHES, STICK_RADIUS_INCHES);
// NOW BETWEEN -1 1
rightDistanceScaleX /= STICK_RADIUS_INCHES;
rightDistanceScaleY /= STICK_RADIUS_INCHES;
_inputDevice->_axisStateMap[controller::RX] = rightDistanceScaleX;
_inputDevice->_axisStateMap[controller::RY] = rightDistanceScaleY;
} }
} }
@ -228,70 +211,133 @@ void TouchscreenVirtualPadDevice::touchBeginEvent(const QTouchEvent* event) {
// touch begin here is a big begin -> begins both pads? maybe it does nothing // touch begin here is a big begin -> begins both pads? maybe it does nothing
debugPoints(event, " BEGIN ++++++++++++++++"); debugPoints(event, " BEGIN ++++++++++++++++");
auto& virtualPadManager = VirtualPad::Manager::instance(); auto& virtualPadManager = VirtualPad::Manager::instance();
if (!virtualPadManager.isEnabled()) { if (!virtualPadManager.isEnabled() && !virtualPadManager.isHidden()) {
return; return;
} }
KeyboardMouseDevice::enableTouch(false);
} }
void TouchscreenVirtualPadDevice::touchEndEvent(const QTouchEvent* event) { void TouchscreenVirtualPadDevice::touchEndEvent(const QTouchEvent* event) {
auto& virtualPadManager = VirtualPad::Manager::instance(); auto& virtualPadManager = VirtualPad::Manager::instance();
if (!virtualPadManager.isEnabled()) { if (!virtualPadManager.isEnabled() && !virtualPadManager.isHidden()) {
touchLeftEnd(); moveTouchEnd();
touchRightEnd(); viewTouchEnd();
return; return;
} }
// touch end here is a big reset -> resets both pads // touch end here is a big reset -> resets both pads
_touchPointCount = 0; _touchPointCount = 0;
KeyboardMouseDevice::enableTouch(true); _unusedTouches.clear();
debugPoints(event, " END ----------------"); debugPoints(event, " END ----------------");
touchLeftEnd(); moveTouchEnd();
touchRightEnd(); viewTouchEnd();
_inputDevice->_axisStateMap.clear(); _inputDevice->_axisStateMap.clear();
} }
void TouchscreenVirtualPadDevice::processUnusedTouches(std::map<int, TouchType> unusedTouchesInEvent) {
std::vector<int> touchesToDelete;
for (auto const& touchEntry : _unusedTouches) {
if (!unusedTouchesInEvent.count(touchEntry.first)) {
touchesToDelete.push_back(touchEntry.first);
}
}
for (int touchToDelete : touchesToDelete) {
_unusedTouches.erase(touchToDelete);
}
for (auto const& touchEntry : unusedTouchesInEvent) {
if (!_unusedTouches.count(touchEntry.first)) {
_unusedTouches[touchEntry.first] = touchEntry.second;
}
}
}
void TouchscreenVirtualPadDevice::touchUpdateEvent(const QTouchEvent* event) { void TouchscreenVirtualPadDevice::touchUpdateEvent(const QTouchEvent* event) {
auto& virtualPadManager = VirtualPad::Manager::instance(); auto& virtualPadManager = VirtualPad::Manager::instance();
if (!virtualPadManager.isEnabled()) { if (!virtualPadManager.isEnabled() && !virtualPadManager.isHidden()) {
touchLeftEnd(); moveTouchEnd();
touchRightEnd(); viewTouchEnd();
return; return;
} }
_touchPointCount = event->touchPoints().count(); _touchPointCount = event->touchPoints().count();
const QList<QTouchEvent::TouchPoint>& tPoints = event->touchPoints(); const QList<QTouchEvent::TouchPoint>& tPoints = event->touchPoints();
bool leftTouchFound = false; bool moveTouchFound = false;
bool rightTouchFound = false; bool viewTouchFound = false;
int idxMoveStartingPointCandidate = -1;
int idxViewStartingPointCandidate = -1;
glm::vec2 thisPoint;
int thisPointId;
std::map<int, TouchType> unusedTouchesInEvent;
for (int i = 0; i < _touchPointCount; ++i) { for (int i = 0; i < _touchPointCount; ++i) {
glm::vec2 thisPoint(tPoints[i].pos().x(), tPoints[i].pos().y()); thisPoint.x = tPoints[i].pos().x();
if (_validTouchLeft) { thisPoint.y = tPoints[i].pos().y();
leftTouchFound = true; thisPointId = tPoints[i].id();
touchLeftUpdate(thisPoint);
} else if (touchLeftBeginPointIsValid(thisPoint)) { if (!moveTouchFound && _moveHasValidTouch && _moveCurrentTouchId == thisPointId) {
if (!leftTouchFound) { // valid if it's an ongoing touch
leftTouchFound = true; moveTouchFound = true;
touchLeftBegin(thisPoint); moveTouchUpdate(thisPoint);
} continue;
}
if (!viewTouchFound && _viewHasValidTouch && _viewCurrentTouchId == thisPointId) {
// valid if it's an ongoing touch
viewTouchFound = true;
viewTouchUpdate(thisPoint);
continue;
}
if (!moveTouchFound && idxMoveStartingPointCandidate == -1 && moveTouchBeginIsValid(thisPoint) &&
(!_unusedTouches.count(thisPointId) || _unusedTouches[thisPointId] == MOVE )) {
idxMoveStartingPointCandidate = i;
continue;
}
if (!viewTouchFound && idxViewStartingPointCandidate == -1 && viewTouchBeginIsValid(thisPoint) &&
(!_unusedTouches.count(thisPointId) || _unusedTouches[thisPointId] == VIEW )) {
idxViewStartingPointCandidate = i;
continue;
}
if (moveTouchBeginIsValid(thisPoint)) {
unusedTouchesInEvent[thisPointId] = MOVE;
} else if (viewTouchBeginIsValid(thisPoint)) {
unusedTouchesInEvent[thisPointId] = VIEW;
}
}
processUnusedTouches(unusedTouchesInEvent);
if (!moveTouchFound) {
if (idxMoveStartingPointCandidate != -1) {
_moveCurrentTouchId = tPoints[idxMoveStartingPointCandidate].id();
_unusedTouches.erase(_moveCurrentTouchId);
moveTouchBegin(thisPoint);
} else { } else {
if (!rightTouchFound) { moveTouchEnd();
rightTouchFound = true;
if (!_validTouchRight) {
touchRightBegin(thisPoint);
} else {
touchRightUpdate(thisPoint);
}
}
} }
} }
if (!leftTouchFound) { if (!viewTouchFound) {
touchLeftEnd(); if (idxViewStartingPointCandidate != -1) {
} _viewCurrentTouchId = tPoints[idxViewStartingPointCandidate].id();
if (!rightTouchFound) { _unusedTouches.erase(_viewCurrentTouchId);
touchRightEnd(); viewTouchBegin(thisPoint);
} else {
viewTouchEnd();
}
} }
} }
bool TouchscreenVirtualPadDevice::touchLeftBeginPointIsValid(glm::vec2 touchPoint) { bool TouchscreenVirtualPadDevice::viewTouchBeginIsValid(glm::vec2 touchPoint) {
return !moveTouchBeginIsValid(touchPoint);
}
bool TouchscreenVirtualPadDevice::moveTouchBeginIsValid(glm::vec2 touchPoint) {
if (_fixedPosition) { if (_fixedPosition) {
// inside circle // inside circle
return pow(touchPoint.x - _fixedCenterPosition.x,2.0) + pow(touchPoint.y - _fixedCenterPosition.y, 2.0) < pow(_fixedRadius, 2.0); return pow(touchPoint.x - _fixedCenterPosition.x,2.0) + pow(touchPoint.y - _fixedCenterPosition.y, 2.0) < pow(_fixedRadius, 2.0);
@ -301,45 +347,46 @@ bool TouchscreenVirtualPadDevice::touchLeftBeginPointIsValid(glm::vec2 touchPoin
} }
} }
void TouchscreenVirtualPadDevice::touchLeftBegin(glm::vec2 touchPoint) { void TouchscreenVirtualPadDevice::moveTouchBegin(glm::vec2 touchPoint) {
auto& virtualPadManager = VirtualPad::Manager::instance(); auto& virtualPadManager = VirtualPad::Manager::instance();
if (virtualPadManager.isEnabled()) { if (virtualPadManager.isEnabled() && !virtualPadManager.isHidden()) {
if (_fixedPosition) { if (_fixedPosition) {
_firstTouchLeftPoint = _fixedCenterPosition; _moveRefTouchPoint = _fixedCenterPosition;
} else { } else {
_firstTouchLeftPoint = touchPoint; _moveRefTouchPoint = touchPoint;
} }
_validTouchLeft = true; _moveHasValidTouch = true;
} }
} }
void TouchscreenVirtualPadDevice::touchLeftUpdate(glm::vec2 touchPoint) { void TouchscreenVirtualPadDevice::moveTouchUpdate(glm::vec2 touchPoint) {
_currentTouchLeftPoint = touchPoint; _moveCurrentTouchPoint = touchPoint;
} }
void TouchscreenVirtualPadDevice::touchLeftEnd() { void TouchscreenVirtualPadDevice::moveTouchEnd() {
if (_validTouchLeft) { // do stuff once if (_moveHasValidTouch) { // do stuff once
_validTouchLeft = false; _moveHasValidTouch = false;
_inputDevice->_axisStateMap[controller::LX] = 0; _inputDevice->_axisStateMap[controller::LX] = 0;
_inputDevice->_axisStateMap[controller::LY] = 0; _inputDevice->_axisStateMap[controller::LY] = 0;
} }
} }
void TouchscreenVirtualPadDevice::touchRightBegin(glm::vec2 touchPoint) { void TouchscreenVirtualPadDevice::viewTouchBegin(glm::vec2 touchPoint) {
auto& virtualPadManager = VirtualPad::Manager::instance(); auto& virtualPadManager = VirtualPad::Manager::instance();
if (virtualPadManager.isEnabled()) { if (virtualPadManager.isEnabled() && !virtualPadManager.isHidden()) {
_firstTouchRightPoint = touchPoint; _viewRefTouchPoint = touchPoint;
_validTouchRight = true; _viewCurrentTouchPoint = touchPoint;
_viewHasValidTouch = true;
} }
} }
void TouchscreenVirtualPadDevice::touchRightUpdate(glm::vec2 touchPoint) { void TouchscreenVirtualPadDevice::viewTouchUpdate(glm::vec2 touchPoint) {
_currentTouchRightPoint = touchPoint; _viewCurrentTouchPoint = touchPoint;
} }
void TouchscreenVirtualPadDevice::touchRightEnd() { void TouchscreenVirtualPadDevice::viewTouchEnd() {
if (_validTouchRight) { // do stuff once if (_viewHasValidTouch) { // do stuff once
_validTouchRight = false; _viewHasValidTouch = false;
_inputDevice->_axisStateMap[controller::RX] = 0; _inputDevice->_axisStateMap[controller::RX] = 0;
_inputDevice->_axisStateMap[controller::RY] = 0; _inputDevice->_axisStateMap[controller::RY] = 0;
} }
@ -347,7 +394,7 @@ void TouchscreenVirtualPadDevice::touchRightEnd() {
void TouchscreenVirtualPadDevice::touchGestureEvent(const QGestureEvent* event) { void TouchscreenVirtualPadDevice::touchGestureEvent(const QGestureEvent* event) {
auto& virtualPadManager = VirtualPad::Manager::instance(); auto& virtualPadManager = VirtualPad::Manager::instance();
if (!virtualPadManager.isEnabled()) { if (!virtualPadManager.isEnabled() && !virtualPadManager.isHidden()) {
return; return;
} }
if (QGesture* gesture = event->gesture(Qt::PinchGesture)) { if (QGesture* gesture = event->gesture(Qt::PinchGesture)) {

View file

@ -20,8 +20,6 @@
class QTouchEvent; class QTouchEvent;
class QGestureEvent; class QGestureEvent;
const float STICK_RADIUS_INCHES = .3f;
class TouchscreenVirtualPadDevice : public InputPlugin { class TouchscreenVirtualPadDevice : public InputPlugin {
Q_OBJECT Q_OBJECT
public: public:
@ -62,17 +60,30 @@ public:
const std::shared_ptr<InputDevice>& getInputDevice() const { return _inputDevice; } const std::shared_ptr<InputDevice>& getInputDevice() const { return _inputDevice; }
protected: protected:
enum TouchType {
MOVE = 1,
VIEW
};
float _lastPinchScale; float _lastPinchScale;
float _pinchScale; float _pinchScale;
float _screenDPI; float _screenDPI;
qreal _screenDPIProvided; qreal _screenDPIProvided;
glm::vec2 _screenDPIScale; glm::vec2 _screenDPIScale;
bool _validTouchLeft;
glm::vec2 _firstTouchLeftPoint; bool _moveHasValidTouch;
glm::vec2 _currentTouchLeftPoint; glm::vec2 _moveRefTouchPoint;
bool _validTouchRight; glm::vec2 _moveCurrentTouchPoint;
glm::vec2 _firstTouchRightPoint; int _moveCurrentTouchId;
glm::vec2 _currentTouchRightPoint;
bool _viewHasValidTouch;
glm::vec2 _viewRefTouchPoint;
glm::vec2 _viewCurrentTouchPoint;
int _viewCurrentTouchId;
std::map<int, TouchType> _unusedTouches;
int _touchPointCount; int _touchPointCount;
int _screenWidthCenter; int _screenWidthCenter;
std::shared_ptr<InputDevice> _inputDevice { std::make_shared<InputDevice>() }; std::shared_ptr<InputDevice> _inputDevice { std::make_shared<InputDevice>() };
@ -83,18 +94,26 @@ protected:
float _fixedRadiusForCalc; float _fixedRadiusForCalc;
int _extraBottomMargin {0}; int _extraBottomMargin {0};
void touchLeftBegin(glm::vec2 touchPoint); float _viewStickRadiusInches {0.1333f}; // agreed default
void touchLeftUpdate(glm::vec2 touchPoint);
void touchLeftEnd(); void moveTouchBegin(glm::vec2 touchPoint);
bool touchLeftBeginPointIsValid(glm::vec2 touchPoint); void moveTouchUpdate(glm::vec2 touchPoint);
void touchRightBegin(glm::vec2 touchPoint); void moveTouchEnd();
void touchRightUpdate(glm::vec2 touchPoint); bool moveTouchBeginIsValid(glm::vec2 touchPoint);
void touchRightEnd();
void viewTouchBegin(glm::vec2 touchPoint);
void viewTouchUpdate(glm::vec2 touchPoint);
void viewTouchEnd();
bool viewTouchBeginIsValid(glm::vec2 touchPoint);
void setupFixedCenter(VirtualPad::Manager& virtualPadManager, bool force = false); void setupFixedCenter(VirtualPad::Manager& virtualPadManager, bool force = false);
void processInputUseCircleMethod(VirtualPad::Manager& virtualPadManager); void processInputDeviceForMove(VirtualPad::Manager& virtualPadManager);
void processInputUseSquareMethod(VirtualPad::Manager& virtualPadManager);
glm::vec2 clippedPointInCircle(float radius, glm::vec2 origin, glm::vec2 touchPoint); glm::vec2 clippedPointInCircle(float radius, glm::vec2 origin, glm::vec2 touchPoint);
void processUnusedTouches(std::map<int, TouchType> unusedTouchesInEvent);
void processInputDeviceForView();
// just for debug // just for debug
private: private:
void debugPoints(const QTouchEvent* event, QString who); void debugPoints(const QTouchEvent* event, QString who);

View file

@ -34,6 +34,7 @@ function fromQml(message) { // messages are {method, params}, like json-rpc. See
App.openUrl("https://metaverse.highfidelity.com/marketplace?category=avatars"); App.openUrl("https://metaverse.highfidelity.com/marketplace?category=avatars");
break; break;
case 'hide': case 'hide':
Controller.setVPadHidden(false);
module.exports.onHidden(); module.exports.onHidden();
break; break;
default: default:
@ -114,26 +115,27 @@ module.exports = {
qml: "hifi/avatarSelection.qml", qml: "hifi/avatarSelection.qml",
visible: false visible: false
}); });
/*,
visible: false*/
if (window) { if (window) {
window.fromQml.connect(fromQml); window.fromQml.connect(fromQml);
} }
init(); init();
}, },
show: function() { show: function() {
Controller.setVPadHidden(true);
if (window) { if (window) {
window.setVisible(true); window.setVisible(true);
isVisible = true; isVisible = true;
} }
}, },
hide: function() { hide: function() {
Controller.setVPadHidden(false);
if (window) { if (window) {
window.setVisible(false); window.setVisible(false);
} }
isVisible = false; isVisible = false;
}, },
destroy: function() { destroy: function() {
Controller.setVPadHidden(false);
if (window) { if (window) {
window.fromQml.disconnect(fromQml); window.fromQml.disconnect(fromQml);
window.close(); window.close();
@ -155,5 +157,7 @@ module.exports = {
refreshSelectedAvatar: function(currentAvatarURL) { refreshSelectedAvatar: function(currentAvatarURL) {
refreshSelected(currentAvatarURL); refreshSelected(currentAvatarURL);
}, },
onHidden: function() { } onHidden: function() {
Controller.setVPadHidden(false);
}
}; };