SequenceStatus GestureSeqRecorder::progressSequence(Pose::Type gesture, ControlState state, CommandData& response)
{
    SequenceStatus status = SequenceStatus::SUCCESS;
    response.setType(commandType::NONE);

    prevPose = gesture;

    if (activeSequences.size() != 0)
    {
        status = ensureSameState(state);
        if (status == SequenceStatus::SUCCESS)
        {
            status = progressActiveSequences(gesture, state, response);
        }       
    }
    else
    {
        status = findActivation(gesture, state, response);
        
        if (state.getMode() != prevState)
        {
            updateGuiSequences();
        }

        prevState = state.getMode();
    }

    if (response.getType() != commandType::NONE || status != SequenceStatus::SUCCESS)
    { 
        // if the response is not NONE, a sequence has completed. Therefore all
        // active sequences must be cleared so that all valid sequences can potentially
        // be started.
        emptyActiveSequences();

        if (response.getType() != commandType::NONE)
        {
            std::cout << "GestureSeqRecorder returning a registered response." << std::endl;
        }
    }

    return status;
}
void GestureSeqRecorder::progressSequenceTime(int delta, CommandData& response)
{
    if (gestureSignaller.getShowAll() != prevShowAll)
    {
        updateGuiSequences();
        prevShowAll = gestureSignaller.getShowAll();
    }
    if (controlStateHandle->getMode() != timeBasedPrevState)
    {
        updateGuiSequences();
        timeBasedPrevState = controlStateHandle->getMode();
    }

    // Provide response if hold is reached and cut off 'taps' if hold is reached
    if (holdGestTimer > 0 && holdGestTimer - delta <= 0 && activeSequences.size() > 0)
    {
        // This call to progressSequenceTime indicates a 'hold'.
        // Update activeSequences now.
        activeSequencesMutex.lock();
        std::list<sequenceInfo*>::iterator it = activeSequences.begin();
        while (it != activeSequences.end())
        {
            unsigned int seqProg = (*it)->progress;

            if (seqProg < (*it)->seq.size())
            {
                // We just hit the "hold" state, handle accordingly
                if (PoseLength::HOLD == (*it)->seq.at(seqProg).poseLen)
                {
                    (*it)->progress++;
                    if ((*it)->progress == (*it)->seq.size())
                    {
                        // found a complete sequence!
                        response = (*it)->sequenceResponse;
                        break;
                    }
                    it++;
                }
                else
                {
                    if (prevPose != Pose::rest)
                    {
                        // Erase if they're still holding a non-rest pose, since
                        // that means they 'actually' hit a hold-state.
                        (*it)->progress = 0;
                        it = activeSequences.erase(it);
                    }
                    else
                    {
                        it++;
                    }
                }

                updateGuiSequences();
            }
        }
        activeSequencesMutex.unlock();

        if (response.getType() != commandType::NONE)
        {
            // if the response is not NONE, a sequence has completed. Therefore all
            // active sequences must be cleared so that all valid sequences can potentially
            // be started.
            emptyActiveSequences();

            if (response.getType() != commandType::NONE)
            {
                std::cout << "GestureSeqRecorder returning a registered response." << std::endl;
            }
        }
    }

    if (holdGestTimer - delta <= 0)
    {
        // ensure value doesn't loop and cause we're results if decremented too much.
        holdGestTimer = 0;
    }
    else
    {
        holdGestTimer -= delta;
    }
}