예제 #1
0
/***************************************************************
*  Function: processEvent()
***************************************************************/
bool Maze2::processEvent(InteractionEvent *event)
{
	if (event->getEventType() == KEYBOARD_INTER_EVENT)
	{
		KeyboardInteractionEvent *keyEvent = event->asKeyboardEvent();
		int key = keyEvent->getKey();
		if (keyEvent->getInteraction() == KEY_DOWN) mNaviHandler->updateKeys(key, true);
		else mNaviHandler->updateKeys(key, false);
	}

	return false;
}
예제 #2
0
bool VroomView::processEvent(cvr::InteractionEvent * event)
{
    KeyboardInteractionEvent * kie = event->asKeyboardEvent();
    if(kie && kie->getKey() == (int)'N' && kie->getInteraction() == KEY_UP)
    {
	if(ComController::instance()->isMaster())
	{
	    std::cerr << "Print Screen" << std::endl;
	    _localSS->takeScreenShot();
	}
	return true;
    }
    return false;
}
예제 #3
0
bool CameraFlight::processEvent(InteractionEvent * event)
{
    TrackedButtonInteractionEvent * tie = event->asTrackedButtonEvent();
    KeyboardInteractionEvent * kie = event->asKeyboardEvent();

    if(event->asMouseEvent())
    {
	
    }
    if(kie) 
    {
	if(kie->getInteraction() == KEY_DOWN)
	{
	    buttonEvent(kie->getKey());
	}
    }

    return false;
}
예제 #4
0
bool WaterMaze::processEvent(InteractionEvent * event)
{
    KeyboardInteractionEvent * kie = event->asKeyboardEvent();
    if (kie)
    {
		if (kie->getInteraction() == KEY_UP)
		{
			switch(kie->getKey())
			{
				case 'n':
					//next paradigm
					changeParadigm(1);
					break;
				case 'b':
					changeParadigm(-1);
					break;
				case 'f':
					//next trial
					changeTrial(1);
					break;
				case 'a':
					//override trial limit add trial
					addTrial();
					break;
				case 's':
					// start/abort trail and reset position
					startStop();
					break;
				case 'l':
					//load geometry
					load();
					break;
				case 'i':
					/* info */
					cout << endl << endl;
					//running state of application
					cout << "Current Running State: " << _state << endl;
					//Paradigm ID
					cout << "Current Paradigm: " << _paradigms[_currentParadigm]->getID() << endl;
					//trials ran
					cout << "Trial: " << _paradigms[_currentParadigm]->getTrialNumber() << endl;
					//android controller data
					 if(ComController::instance()->isMaster())
						cout << "# of Connected Devices: " << _controller->getNumControllers() << endl;
					//volume
					cout << "Master Volume: " << _masterVolume << endl;
					break;
				case 'h':
					//help menu
					 std::cout << "Welcome to WaterMaze!\n" <<
								  "l - load geometry\n" <<
								  "n - proceed to next paradigm\n" <<
								  "s - start/stop trial\n" << 
								  "f - proceed to next trial\n" <<	
								  "a - override trial limit/add trial\n" <<
								  "i - info\n" <<
								  "h - help menu" << std::endl;
					break;
				case osgGA::GUIEventAdapter::KeySymbol::KEY_Up:
					//raise master volume
					cout << "Raising Volume" << endl;
					_masterVolume = min(1.0, _masterVolume + 0.1);
					for(int i = 0; i < _paradigms.size(); ++i)
					{
						_paradigms[i]->setVolume(_masterVolume);
					}
					break;
				case osgGA::GUIEventAdapter::KeySymbol::KEY_Down:
					//lower master volume
					cout << "Lowering Volume" << endl;
					_masterVolume = max(0.0, _masterVolume - 0.1);
					for(int i = 0; i < _paradigms.size(); ++i)
					{
						_paradigms[i]->setVolume(_masterVolume);
					}
					break;
			}
		}
    }
    
    TrackedButtonInteractionEvent * tie = event->asTrackedButtonEvent();
    if (tie)
    {
        if(tie->getHand() == 0 && tie->getButton() == 0)
        {
            if (tie->getInteraction() == BUTTON_DOWN && !_runningTrial)
            {
                return true;
            }
            else if (tie->getInteraction() == BUTTON_DRAG && !_runningTrial)
            {
                return true;
            }
            else if (tie->getInteraction() == BUTTON_UP)
            {
                return false;
            }
            return false;
        }
    }
    return false;
}
예제 #5
0
bool WaterMaze::processEvent(InteractionEvent * event)
{
    KeyboardInteractionEvent * kie = event->asKeyboardEvent();
    if (kie)
    {
        if (kie->getInteraction() == KEY_UP && kie->getKey() == 'n')
        {
            // next trial
            if (_runningTrial)
            {
                return true;
            }

            if (_currentTrial == _trials.size() - 1)
            {
                std::cout << "No more trials." << std::endl;
                return true;
            }

            _currentTrial++;
            
            std::cout << "Loading next trial." << std::endl;
            std::cout << _trials[_currentTrial].width << " x " << 
                _trials[_currentTrial].height << ", " << _trials[_currentTrial].timeSec
                << " seconds." << std::endl;

            clear();
            load(_trials[_currentTrial].width, _trials[_currentTrial].height); 

            return true;
        }

        else if (kie->getInteraction() == KEY_UP && kie->getKey() == 'r')
        {
            // repeat last trial
            if (_runningTrial)
            {
                return true;
            }

            std::cout << "Repeating last trial." << std::endl;
            std::cout << _trials[_currentTrial].width << " x " << 
                _trials[_currentTrial].height << ", " << _trials[_currentTrial].timeSec
                << " seconds." << std::endl;

            return true;
        }

        else if (kie->getInteraction() == KEY_UP && kie->getKey() == 'b')
        {
            // back to previous trial
            if (_runningTrial)
            {
                return true;
            }

            if (_currentTrial - 1 < 0)
            {
                std::cout << "No previous trials." << std::endl;
                return true;
            }

            _currentTrial--;
            
            std::cout << "Back to previous trial." << std::endl;
            std::cout << _trials[_currentTrial].width << " x " << 
                _trials[_currentTrial].height << ", " << _trials[_currentTrial].timeSec
                << " seconds." << std::endl;

            clear();
            load(_trials[_currentTrial].width, _trials[_currentTrial].height); 
            
            return true;
        }

        else if (kie->getInteraction() == KEY_UP && kie->getKey() == 'p')
        {
            // pause/play
            if (_runningTrial)
            {
                std::cout << "Paused." << std::endl; 
                _runningTrial = false;
            }
            else
            {
                std::cout << "Play." << std::endl; 
                _runningTrial = true;

                if (_resetTime)
                {
                    _startTime = PluginHelper::getProgramDuration();
                    _resetTime = false;
                    _lastTimeLeft = _trials[_currentTrial].timeSec;


                    // Setup write to data file
                    time_t timet;
                    time(&timet);
                    char buf[100];

                    sprintf(buf, "/Logs/%dx%d-%dsec-%ld.txt", _trials[_currentTrial].width, 
                        _trials[_currentTrial].height, _trials[_currentTrial].timeSec, timet);
                    _dataFile = _dataDir + buf;
                    std::cout << "Recording trial to" << _dataFile << std::endl;

                    _fileTimer = PluginHelper::getProgramDuration();
                }
            }
        }

        else if (kie->getInteraction() == KEY_UP && kie->getKey() == 's')
        {
            // start/stop
            if (_runningTrial)
            {
                std::cout << "Stopping trial." << std::endl; 
                _runningTrial = false;
                _resetTime = true;
            }
            else
            {
                std::cout << "Starting trial." << std::endl; 
                _runningTrial = true;
            }
        }

        else if (kie->getInteraction() == KEY_UP && kie->getKey() == 'l')
        {
            std::cout << "Loading geometry." << std::endl;
            load(_trials[_currentTrial].width, _trials[_currentTrial].height);
        }

        else if (kie->getInteraction() == KEY_UP && kie->getKey() == 'h')
        {
            std::cout << "Welcome to WaterMaze!\n" <<
            "l - load geometry\n" <<
            "n - next trial\n" <<
            "r - repeat trial\n" <<
            "b - back to previous trial\n" <<
            "p - play/pause\n" << 
            "h - help\n" << 
            "1-9 - reset position" << std::endl;
        }

        else if (kie->getInteraction() == KEY_UP && kie->getKey() == '1')
        {
            if (_runningTrial)
            {
                return true;
            }
            osg::Matrixd mat;
            mat = _tilePositions[0]->getMatrix();
            PluginHelper::setObjectMatrix(mat);
        }

        else if (kie->getInteraction() == KEY_UP && kie->getKey() == '2')
        {
            if (_runningTrial)
            {
                return true;
            }
            osg::Matrixd mat;
            mat = _tilePositions[1]->getMatrix();
            PluginHelper::setObjectMatrix(mat);
        }

        else if (kie->getInteraction() == KEY_UP && kie->getKey() == '3')
        {
            if (_runningTrial)
            {
                return true;
            }
            osg::Matrixd mat;
            mat = _tilePositions[2]->getMatrix();
            PluginHelper::setObjectMatrix(mat);
        }

        else if (kie->getInteraction() == KEY_UP && kie->getKey() == '4')
        {
            if (_runningTrial)
            {
                return true;
            }
            osg::Matrixd mat;
            mat = _tilePositions[3]->getMatrix();
            PluginHelper::setObjectMatrix(mat);
        }
    }


    TrackedButtonInteractionEvent * tie = event->asTrackedButtonEvent();
    if (tie)
    {
        return false;
        if(tie->getHand() == 0 && tie->getButton() == 0)
        {
            if (tie->getInteraction() == BUTTON_DOWN)
            {
                return true;
            }
            else if (tie->getInteraction() == BUTTON_DRAG)
            {
                return true;
            }
            else if (tie->getInteraction() == BUTTON_UP)
            {
                return true;
            }
            return true;
        }
    }
    return true;
}