diff options
author | Kevin Ottens <kevin.ottens@kdab.com> | 2016-08-23 16:26:10 +0200 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2016-08-24 19:33:24 +0000 |
commit | 335052336eb0e1816f24a4f120551ee2b23ac1aa (patch) | |
tree | 1be1483acc4071a44f665686eeb45e7991a38b65 /src/input/backend/updateaxisactionjob.cpp | |
parent | 81ecbf04bf7c8a091916f0fa4c8840d499099453 (diff) |
Move input, chord and sequence logic out of job
The bookkeeping and activation logic of ActionInput, InputChord and
InputSequence now move outside of the job, which make them testable
properly. The tests already show bugs which will be fixed in following
commits.
Change-Id: I4e434118a6ba285d08632c43d487b17ee5b4cb66
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/input/backend/updateaxisactionjob.cpp')
-rw-r--r-- | src/input/backend/updateaxisactionjob.cpp | 62 |
1 files changed, 3 insertions, 59 deletions
diff --git a/src/input/backend/updateaxisactionjob.cpp b/src/input/backend/updateaxisactionjob.cpp index 3a1bfb465..0cbd325c9 100644 --- a/src/input/backend/updateaxisactionjob.cpp +++ b/src/input/backend/updateaxisactionjob.cpp @@ -101,65 +101,9 @@ void UpdateAxisActionJob::updateAction(LogicalDevice *device) bool UpdateAxisActionJob::processActionInput(const Qt3DCore::QNodeId actionInputId) { - - if (m_handler->actionInputManager()->lookupResource(actionInputId)) { - ActionInput *actionInput = m_handler->actionInputManager()->lookupResource(actionInputId); - QAbstractPhysicalDeviceBackendNode *physicalDeviceBackend = nullptr; - - const auto integrations = m_handler->inputDeviceIntegrations(); - for (QInputDeviceIntegration *integration : integrations) { - if ((physicalDeviceBackend = integration->physicalDevice(actionInput->sourceDevice())) != nullptr) - break; - } - - if (physicalDeviceBackend != nullptr) { - // Update the value - return anyOfRequiredButtonsPressed(actionInput->buttons(), physicalDeviceBackend); - } - } else if (m_handler->inputSequenceManager()->lookupResource(actionInputId)) { - InputSequence *inputSequence = m_handler->inputSequenceManager()->lookupResource(actionInputId); - const qint64 startTime = inputSequence->startTime(); - if (startTime != 0) { - // Check if we are still inside the time limit for the chord - if ((m_currentTime - startTime) > inputSequence->timeout()) { - inputSequence->reset(); - return false; - } - } - bool actionTriggered = false; - const auto actionInputIds = inputSequence->sequences(); - for (const Qt3DCore::QNodeId actionInputId : actionInputIds) { - if (processActionInput(actionInputId)){ - actionTriggered |= inputSequence->actionTriggered(actionInputId, m_currentTime); - // Set the start time if it wasn't set before - if (startTime == 0) - inputSequence->setStartTime(m_currentTime); - } - } - return actionTriggered; - } else if (m_handler->inputChordManager()->lookupResource(actionInputId)) { - InputChord *inputChord = m_handler->inputChordManager()->lookupResource(actionInputId); - const qint64 startTime = inputChord->startTime(); - if (startTime != 0) { - // Check if we are still inside the time limit for the chord - if ((m_currentTime - startTime) > inputChord->timeout()) { - inputChord->reset(); - return false; - } - } - bool actionTriggered = false; - const auto actionInputIds = inputChord->chords(); - for (const Qt3DCore::QNodeId actionInputId : actionInputIds) { - if (processActionInput(actionInputId)){ - actionTriggered |= inputChord->actionTriggered(actionInputId); - if (startTime == 0) - inputChord->setStartTime(m_currentTime); - } - } - return actionTriggered; - } - //Should Never reach this point - return false; + AbstractActionInput *actionInput = m_handler->lookupActionInput(actionInputId); + Q_ASSERT(actionInput); + return actionInput->process(m_handler, m_currentTime); } void UpdateAxisActionJob::updateAxis(LogicalDevice *device) |