summaryrefslogtreecommitdiffstats
path: root/plugin/cursornavigation.cpp
diff options
context:
space:
mode:
authorAntti Hölttä <AHoelttae@luxoft.com>2018-11-26 15:39:51 +0100
committerAntti Hölttä <AHoelttae@luxoft.com>2019-03-18 16:33:53 +0100
commit5c75a9e125ca636dbc29767805b2279a80deb8ff (patch)
treee1ec59e5bdd5bdbb16a159837066497916e4f235 /plugin/cursornavigation.cpp
parentc9a97de34ca56d4cab671beeeb6d27a66ac3da4e (diff)
Bugfixes to 360 algorithm, added cooldown for gamepad control
Joystick produce change events very rapidly and continuously, so a cooldown time is needed so that the cursor wont jump over multiple items
Diffstat (limited to 'plugin/cursornavigation.cpp')
-rw-r--r--plugin/cursornavigation.cpp26
1 files changed, 7 insertions, 19 deletions
diff --git a/plugin/cursornavigation.cpp b/plugin/cursornavigation.cpp
index 4eaff64..1a81f76 100644
--- a/plugin/cursornavigation.cpp
+++ b/plugin/cursornavigation.cpp
@@ -26,18 +26,14 @@ void CursorNavigation::move(qreal angle, qreal tolerance, bool discrete)
{
qreal a = qDegreesToRadians(angle);
qreal t = qDegreesToRadians(qFabs(std::fmod(tolerance, 180)));
- qWarning() << "move, angle = " << a << " tolerance = " << t << " discrete = " << discrete;
- CursorNavigationCommand cmd(a, t);
- handleMove(cmd, discrete);
+ handleMove(a, t, discrete);
}
void CursorNavigation::move(const QVector2D& vector, qreal tolerance, bool discrete)
{
- qreal angle = qAtan2(vector.y(), vector.x());
+ qreal a = qAtan2(vector.y(), vector.x());
qreal t = qDegreesToRadians(qFabs(std::fmod(tolerance, 180)));
- qWarning() << "move(vector2d), angle = " << angle << " tolerance = " << t << " discrete = " << discrete;
- CursorNavigationCommand cmd(angle, tolerance);
- handleMove(cmd, discrete);
+ handleMove(a, t, discrete);
}
void CursorNavigation::action(Action action)
@@ -80,16 +76,6 @@ void CursorNavigation::action(Action action)
}
}
-/*bool CursorNavigation::inputCommand(const CursorNavigationCommand &cmd)
-{
-
- if (cmd.action == CursorNavigationCommand::NoAction) {
- return handleDirectionCommand(cmd);
- } else {
- return handleActionCommand(cmd);
- }
-}*/
-
CursorNavigationAttached *CursorNavigation::qmlAttachedProperties(QObject *object)
{
// if the object is a window, use its contentItem instead
@@ -198,11 +184,13 @@ void CursorNavigation::unregisterItem(CursorNavigationAttached* item)
item->m_parentNavigable->m_children.removeOne(item);
}
-bool CursorNavigation::handleMove(const CursorNavigationCommand &cmd, bool discrete)
+bool CursorNavigation::handleMove(qreal angle, qreal tolerance, bool discrete)
{
- qWarning() << "handleDirectionCommand";
CursorNavigationAttached *nextItem = nullptr;
+ qWarning() << "handleMove, angle = " << angle << " tolerance = " << tolerance << " discrete = " << discrete;
+ CursorNavigationCommand cmd(angle, tolerance);
+
QList<CursorNavigationAttached*> &candidates = m_currentItem ?
m_currentItem->m_parentNavigable->m_children :
m_rootItem->m_children;