change context menu to RightPrimaryThumb, add filter to mouse click to not count slow clicks

This commit is contained in:
Brad Hefta-Gaub 2015-11-10 16:46:58 -08:00
parent a2abc11df1
commit fc3602d780
4 changed files with 10 additions and 6 deletions

View file

@ -64,7 +64,7 @@ OmniTool = function(left) {
}); });
this.mapping = Controller.newMapping(); this.mapping = Controller.newMapping();
this.mapping.from(left ? standard.LeftPrimaryThumb : standard.RightPrimaryThumb).to(function(value){ this.mapping.from(left ? standard.LeftPrimaryThumb : standard.RightSecondaryThumb).to(function(value){
that.onUpdateTrigger(value); that.onUpdateTrigger(value);
}) })
this.mapping.enable(); this.mapping.enable();

View file

@ -33,7 +33,7 @@
{ "from": "Standard.Start", "to": "Standard.RightSecondaryThumb" }, { "from": "Standard.Start", "to": "Standard.RightSecondaryThumb" },
{ "from": "Standard.LeftSecondaryThumb", "to": "Actions.CycleCamera" }, { "from": "Standard.LeftSecondaryThumb", "to": "Actions.CycleCamera" },
{ "from": "Standard.RightSecondaryThumb", "to": "Actions.ContextMenu" }, { "from": "Standard.RightPrimaryThumb", "to": "Actions.ContextMenu" },
{ "from": "Standard.LT", "to": "Actions.LeftHandClick" }, { "from": "Standard.LT", "to": "Actions.LeftHandClick" },
{ "from": "Standard.RT", "to": "Actions.RightHandClick" }, { "from": "Standard.RT", "to": "Actions.RightHandClick" },

View file

@ -16,6 +16,7 @@
#include <controllers/UserInputMapper.h> #include <controllers/UserInputMapper.h>
#include <PathUtils.h> #include <PathUtils.h>
#include <NumericalConstants.h>
const QString KeyboardMouseDevice::NAME = "Keyboard/Mouse"; const QString KeyboardMouseDevice::NAME = "Keyboard/Mouse";
@ -64,6 +65,7 @@ void KeyboardMouseDevice::mousePressEvent(QMouseEvent* event, unsigned int devic
} }
_lastCursor = event->pos(); _lastCursor = event->pos();
_mousePressAt = event->pos(); _mousePressAt = event->pos();
_mousePressTime = usecTimestampNow();
eraseMouseClicked(); eraseMouseClicked();
} }
@ -72,10 +74,11 @@ void KeyboardMouseDevice::mouseReleaseEvent(QMouseEvent* event, unsigned int dev
auto input = _inputDevice->makeInput((Qt::MouseButton) event->button()); auto input = _inputDevice->makeInput((Qt::MouseButton) event->button());
_inputDevice->_buttonPressedMap.erase(input.getChannel()); _inputDevice->_buttonPressedMap.erase(input.getChannel());
// if we pressed and released at the same location, then create a "_CLICKED" input for this button // if we pressed and released at the same location within a small time window, then create a "_CLICKED"
// we might want to add some small tolerance to this so if you do a small drag it still counts as // input for this button we might want to add some small tolerance to this so if you do a small drag it
// a clicked. // till counts as a clicked.
if (_mousePressAt == event->pos()) { static const int CLICK_TIME = USECS_PER_MSEC * 500; // 500 ms to click
if (_mousePressAt == event->pos() && (usecTimestampNow() - _mousePressTime < CLICK_TIME)) {
_inputDevice->_buttonPressedMap.insert(_inputDevice->makeInput((Qt::MouseButton) event->button(), true).getChannel()); _inputDevice->_buttonPressedMap.insert(_inputDevice->makeInput((Qt::MouseButton) event->button(), true).getChannel());
} }
} }

View file

@ -116,6 +116,7 @@ public:
protected: protected:
QPoint _lastCursor; QPoint _lastCursor;
QPoint _mousePressAt; QPoint _mousePressAt;
quint64 _mousePressTime;
glm::vec2 _lastTouch; glm::vec2 _lastTouch;
std::shared_ptr<InputDevice> _inputDevice { std::make_shared<InputDevice>() }; std::shared_ptr<InputDevice> _inputDevice { std::make_shared<InputDevice>() };