tablet-ui: Added 6 pixel deadspot for bringing up the tablet in desktop mode.

This commit is contained in:
Anthony J. Thibault 2017-02-01 14:44:14 -08:00
parent 82efb97654
commit ffaf7a10e8
2 changed files with 14 additions and 2 deletions

View file

@ -73,6 +73,9 @@ void KeyboardMouseDevice::mousePressEvent(QMouseEvent* event) {
_mousePressTime = usecTimestampNow();
_mouseMoved = false;
_mousePressPos = event->pos();
_clickDeadspotActive = true;
eraseMouseClicked();
}
@ -84,9 +87,11 @@ void KeyboardMouseDevice::mouseReleaseEvent(QMouseEvent* event) {
// input for this button we might want to add some small tolerance to this so if you do a small drag it
// still counts as a click.
static const int CLICK_TIME = USECS_PER_MSEC * 500; // 500 ms to click
if (!_mouseMoved && (usecTimestampNow() - _mousePressTime < CLICK_TIME)) {
if (_clickDeadspotActive && (usecTimestampNow() - _mousePressTime < CLICK_TIME)) {
_inputDevice->_buttonPressedMap.insert(_inputDevice->makeInput((Qt::MouseButton) event->button(), true).getChannel());
}
_clickDeadspotActive = false;
}
void KeyboardMouseDevice::eraseMouseClicked() {
@ -109,9 +114,14 @@ void KeyboardMouseDevice::mouseMoveEvent(QMouseEvent* event) {
// outside of the application window, because we don't get MouseEvents when the cursor is outside
// of the application window.
_lastCursor = currentPos;
_mouseMoved = true;
eraseMouseClicked();
const int CLICK_EVENT_DEADSPOT = 6; // pixels
if (_clickDeadspotActive && (_mousePressPos - currentPos).manhattanLength() > CLICK_EVENT_DEADSPOT) {
eraseMouseClicked();
_clickDeadspotActive = false;
}
}
void KeyboardMouseDevice::wheelEvent(QWheelEvent* event) {

View file

@ -118,8 +118,10 @@ public:
protected:
QPoint _lastCursor;
QPoint _mousePressPos;
quint64 _mousePressTime;
bool _mouseMoved;
bool _clickDeadspotActive;
glm::vec2 _lastTouch;
std::shared_ptr<InputDevice> _inputDevice { std::make_shared<InputDevice>() };