Exemple #1
0
void fun2( void )
{
	enum BUTTON_TYPE button;

	buff[0] = 0;
	buff[1] = 9;
	buff[2] = 0;
	buff[3] = 0;
	buff[4] = 3;
	buff[5] = 0;
	buff[6] = 2;
	buff[7] = 0;

	ms50count=0;

	setTimer2_50ms();

	EA = 1;
	while( 1 )
	{
		button = getKeyPressed();

		handleUserInput( button );

		updateSEGLED();
	}

}
Exemple #2
0
void Ultra::play()
{
	float volume = 0.0;
	FMOD_Channel_SetVolume(musicChannel, 1.0);
	FMOD_Channel_GetVolume(musicChannel, &volume);
	
	fout << volume << std::endl;
	
	playMusic(ultraMusic);
	
	setCurrentGamePiece(createNewPiece());
	setNextPiece(createNewPiece());
	
	enableCurrentPiece();
	
	setLinesCompleted(0);
	setLevel(1);
	setFallIterationDelay(computeFallIterationDelay());
	setScore(0);
	setState(RUNNING);
	
	sf::Clock fallingClock;
	fallingClock.Reset();
	
	float currentTime = 0, precTime = 0;
	
	while(renderArea->IsOpened())
	{
		if(getState() == PAUSED)
		{
			setBackground(PAUSE_IMG);
			
			timer.pause();
			
			if(handlePauseInput() == RETURN_MAIN)
				return;
		}
		else
		{
			timer.start();
			currentTime = fallingClock.GetElapsedTime();
			
			handleTimerInput(currentTime, precTime);
			
			handleUserInput();
			
			if(Game::gameOver() || timeElapsed())
			{
				if(handleGameOverInput() == RETURN_MAIN)
					return;
			}
			else
				render();
		}
		
		renderArea->Display();
	}
}
Exemple #3
0
void AddressWidget::notifyRequestedLoadUrl()
{
	const QString input = text().trimmed();

	if (!input.isEmpty())
	{
		handleUserInput(input);
	}
}
Exemple #4
0
void Game::update()
{
    theCar.dump();

    theCar.update();
    car.update();
    handleUserInput();
    checkCollisions();
}
void EventManager::processEvent(const Event& event)
{
	//Event event;
	
	//while (_screen.pollEvent(event))
	//{
		switch(event.type)
		{
			case Event::KeyPressed:
				handleUserInput(event.key.code, true);
				break;
			case Event::KeyReleased:
				handleUserInput(event.key.code, false);
				break;
//			case Event::Closed:
//				_screen.close();
//				break;
		}
	//}
}
Exemple #6
0
void Sprint::play()
{
	playMusic(sprintMusic);
	
	setCurrentGamePiece(createNewPiece());
	setNextPiece(createNewPiece());
	
	enableCurrentPiece();
	
	setLinesCompleted(0);
	setLevel(1);
	setFallIterationDelay(computeFallIterationDelay());
	setScore(0);
	setState(RUNNING);
	
	sf::Clock fallingClock;
	fallingClock.Reset();
	
	float currentTime = 0, precTime = 0;
	
	while(renderArea->IsOpened())
	{
		setNbLinesToDelete(NB_LINES_TO_DELETE - getLinesCompleted());
		
		if(getState() == PAUSED)
		{
			timer.pause();
			if(handlePauseInput() == RETURN_MAIN)
				return;
		}
		else
		{
			timer.start();
			currentTime = fallingClock.GetElapsedTime();
				
			handleTimerInput(currentTime, precTime);
				
			handleUserInput();
				
			if(Game::gameOver() || finished())
			{
				timer.pause();
				if(handleGameOverInput() == RETURN_MAIN)
					return;
			}
			else
				render();
		}
		
		renderArea->Display();
	}
	
}
Exemple #7
0
 void Gui::update()
 {
     try
     {
         // Handle user input
         handleUserInput(mFrameDisplayer, mPoseExtractors, mRenderers, spIsRunning, spVideoSeek);
     }
     catch (const std::exception& e)
     {
         error(e.what(), __LINE__, __FUNCTION__, __FILE__);
     }
 }
Exemple #8
0
void AddressWidget::mouseReleaseEvent(QMouseEvent *event)
{
	if (text().isEmpty() && event->button() == Qt::MiddleButton && !QApplication::clipboard()->text().isEmpty())
	{
		handleUserInput(QApplication::clipboard()->text().trimmed());

		event->accept();
	}
	else
	{
		QLineEdit::mouseReleaseEvent(event);
	}
}
void OpenAddressDialog::keyPressEvent(QKeyEvent *event)
{
	if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return)
	{
		handleUserInput();

		event->accept();
	}
	else
	{
		QDialog::keyPressEvent(event);
	}
}
Exemple #10
0
void AddressWidget::mouseReleaseEvent(QMouseEvent *event)
{
	if (text().isEmpty() && event->button() == Qt::MiddleButton && !QApplication::clipboard()->text().isEmpty() && SettingsManager::getValue(QLatin1String("AddressField/PasteAndGoOnMiddleClick")).toBool())
	{
		handleUserInput(QApplication::clipboard()->text().trimmed());

		event->accept();
	}
	else
	{
		QLineEdit::mouseReleaseEvent(event);
	}
}
Exemple #11
0
/*
 * Initialize and call all necessary functions
 */
int main(int argc, char *argv[]) {
    int i;

    strcpy(path, getenv("PWD"));
    // Usage and invalid command line args
    if (argc > 2) {
        usage();
        return -1;
    } else if (argc == 2) {
        if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0)
            usage();
        else if (strlen(argv[1]) < PATH_MAX) {
            strcpy(path, argv[1]);
            errNum = chdir(path);
            if (errNum != 0)
                fprintf(stderr, "Error changing directory: %s\n", strerror(errNum));
        }
        else
            fprintf(stderr, "Error: input path too long\n");
    }

    initscr();  // Start curses mode
    if (stdscr == NULL) {
        fprintf(stderr, "Error: could not initialize curses\n");
        exit(-1);
    }
    cbreak();               // Disable line buffering
    noecho();               // Disable user input echoing
    keypad(stdscr, TRUE);   // Read function keys

    // Setup color
    start_color();
    init_pair(1, COLOR_RED, COLOR_BLACK);

    current = FILES;
    updateDisplay();
    handleUserInput();

    // Clean up memory
    unpost_menu(menus[0]);
    free_menu(menus[0]);
    for (i = 0; i < numFiles; i++)
        free_item(fileItems[i]);
    unpost_menu(menus[1]);
    free_menu(menus[1]);
    for (i = 0; i < numDirs; i++)
        free_item(dirItems[i]);
    endwin();

    return 0;
}
OpenAddressDialog::OpenAddressDialog(QWidget *parent) : Dialog(parent),
	m_addressWidget(nullptr),
	m_inputInterpreter(nullptr),
	m_ui(new Ui::OpenAddressDialog)
{
	m_ui->setupUi(this);

	m_addressWidget = new AddressWidget(nullptr, this);
	m_addressWidget->setFocus();

	m_ui->verticalLayout->insertWidget(1, m_addressWidget);
	m_ui->label->setBuddy(m_addressWidget);

	connect(this, SIGNAL(accepted()), this, SLOT(handleUserInput()));
}
Exemple #13
0
void Game::play()
{
	playMusic(marathonMusic);
	
	setCurrentGamePiece(createNewPiece());
	setNextPiece(createNewPiece());
	
	enableCurrentPiece();
	
	setLinesCompleted(0);
	setLevel(1);
	setFallIterationDelay(computeFallIterationDelay());
	setScore(0);
	setState(RUNNING);
	
	sf::Clock fallingClock;
	fallingClock.Reset();
	
	float currentTime = 0, precTime = 0;
	
	while(renderArea->IsOpened())
	{
		if(getState() == PAUSED)
		{
			if(handlePauseInput() == RETURN_MAIN)
				return;
		}
		else
		{
			currentTime = fallingClock.GetElapsedTime();
		
			handleTimerInput(currentTime, precTime);
		
			handleUserInput();
			
			
			if(!gameOver())
				render(BG_IMG);
			else
			{
				if(handleGameOverInput() == RETURN_MAIN)
					return;
			}
		}
				
		renderArea->Display();
	}
}
Exemple #14
0
    void Gui::update(const cv::Mat& cvOutputData)
    {
        try
        {
            // Check tDatum integrity
            const bool returnedIsValidFrame = ((spIsRunning == nullptr || *spIsRunning) && !cvOutputData.empty());

            // Display
            if (returnedIsValidFrame)
                mFrameDisplayer.displayFrame(cvOutputData, -1);

            // Handle user input
            handleUserInput(mFrameDisplayer, mPoseExtractors, mRenderers, spIsRunning, spVideoSeek);
        }
        catch (const std::exception& e)
        {
            error(e.what(), __LINE__, __FUNCTION__, __FILE__);
        }
    }
ConsoleInterface::ConsoleInterface()
    : QWidget()
{
    vBoxLayout = new QVBoxLayout();

    output = new QTextEdit();
    input = new QLineEdit();

    vBoxLayout->addWidget(output);
    vBoxLayout->addWidget(input);
    this->setLayout(vBoxLayout);

    connect(input, SIGNAL(returnPressed()), this, SLOT(handleUserInput()));

    print("fast-bit image processing tool  Copyright (C) 2010 - 2014  Jacob Dawid");
    print("This program comes with ABSOLUTELY NO WARRANTY. This is free software,"
          " and you are welcome to redistribute it under certain conditions.");
    print("fast-bit is still in alpha stage. If you encounter any problems,"
          " please feel free to contact us at: [email protected]");
    print(Main::instance().translate("Console", "Ready."));
}
Exemple #16
0
void AddressWidget::notifyRequestedLoadUrl()
{
	handleUserInput(text().trimmed());
}
Exemple #17
0
		optionChanged(SettingsManager::AddressField_ShowBookmarkIconOption, SettingsManager::getValue(SettingsManager::AddressField_ShowBookmarkIconOption));
		optionChanged(SettingsManager::AddressField_ShowFeedsIconOption, SettingsManager::getValue(SettingsManager::AddressField_ShowFeedsIconOption));
		optionChanged(SettingsManager::AddressField_ShowUrlIconOption, SettingsManager::getValue(SettingsManager::AddressField_ShowUrlIconOption));

		m_lineEdit->setPlaceholderText(tr("Enter address or search…"));

		connect(SettingsManager::getInstance(), SIGNAL(valueChanged(int,QVariant)), this, SLOT(optionChanged(int,QVariant)));

		if (toolBar->getIdentifier() != ToolBarsManager::NavigationBar)
		{
			connect(toolBar, SIGNAL(windowChanged(Window*)), this, SLOT(setWindow(Window*)));
		}
	}

	connect(this, SIGNAL(activated(QString)), this, SLOT(openUrl(QString)));
	connect(m_lineEdit, SIGNAL(textDropped(QString)), this, SLOT(handleUserInput(QString)));
	connect(m_completionModel, SIGNAL(completionReady(QString)), this, SLOT(setCompletion(QString)));
	connect(BookmarksManager::getModel(), SIGNAL(modelModified()), this, SLOT(updateBookmark()));
	connect(HistoryManager::getTypedHistoryModel(), SIGNAL(modelModified()), this, SLOT(updateLineEdit()));
}

void AddressWidget::changeEvent(QEvent *event)
{
	ComboBoxWidget::changeEvent(event);

	switch (event->type())
	{
		case QEvent::LanguageChange:
			if (!m_isUsingSimpleMode)
			{
				m_lineEdit->setPlaceholderText(tr("Enter address or search…"));
Exemple #18
0
int main(int argc, char** argv) {

	comPort=openPort(portS);//***PUT YOUR COM PORT NUMBER HERE!***

	// location of the machine running the 3D motion cube
	std::string receiverHost = "localhost";
	
	if (argc > 2) {
		std::cout << "Usage: " << argv[0] << " <hostname>" << std::endl;
		std::cout << "The arguments specify the host of the motion cube (Default: localhost)" << std::endl;
		return 1;
	}

	if (argc > 1) {
		receiverHost = std::string(argv[1]);
	}

	EmoEngineEventHandle eEvent	= EE_EmoEngineEventCreate();
	EmoStateHandle eState		= EE_EmoStateCreate();
	unsigned int userID			= 0;
	
	try {

//		if (EE_EngineConnect() != EDK_OK) {
		if (EE_EngineRemoteConnect("127.0.0.1", 3008) != EDK_OK) {
			throw std::exception("Emotiv Engine start up failed.");
		}
		else {
			std::cout << "Emotiv Engine started!" << std::endl;
			
				neutral();//send all servos to their neutral positions
		}

		int startSendPort = 6868;
		std::map<unsigned int, SocketClient> socketMap;
		promptUser();
		
		while (true) {
			
			// Handle the user input
			if (_kbhit()) {
				if (!handleUserInput()) {
					break;
				}
			}

				
			if(paused == true){
				int state = EE_EngineGetNextEvent(eEvent);

				// New event needs to be handled
				if (state == EDK_OK) {

					EE_Event_t eventType = EE_EmoEngineEventGetType(eEvent);
					EE_EmoEngineEventGetUserId(eEvent, &userID);

					switch (eventType) {

						// New headset connected, create a new socket to send the animation
						case EE_UserAdded:
						{
							std::cout << std::endl << "New user " << userID << " added, sending Cognitiv animation to ";
							std::cout << receiverHost << ":" << startSendPort << "..." << std::endl;
							promptUser();

							socketMap.insert(std::pair<unsigned int, SocketClient>(
								userID, SocketClient(receiverHost, startSendPort, UDP)));
							
							startSendPort++;
							break;
						}
					
						// Headset disconnected, remove the existing socket
						case EE_UserRemoved:
						{
							std::cout << std::endl << "User " << userID << " has been removed." << std::endl;
							promptUser();

							std::map<unsigned int, SocketClient>::iterator iter;
							iter = socketMap.find(userID);
							if (iter != socketMap.end()) {
								socketMap.erase(iter);
							}
							break;
						}
						
						// Send the Cognitiv animation if EmoState has been updated
						case EE_EmoStateUpdated:
						{
							//std::cout << "New EmoState from user " << userID << "..." << std::endl;
							EE_EmoEngineEventGetEmoState(eEvent, eState);

							std::map<unsigned int, SocketClient>::iterator iter;
							iter = socketMap.find(userID);
							if (iter != socketMap.end()) {
								sendCognitiv(eState);
							}
							break;
						}

						// Handle Cognitiv training related event
						case EE_CognitivEvent:
						{
							handleCognitivEvent(std::cout, eEvent);
							break;
						}

						default:
							break;
					}
				}
				else if (state != EDK_NO_EVENT) {
					std::cout << "Internal error in Emotiv Engine!" << std::endl;
					break;
				}
			}
			Sleep(1);
		}
	}
	catch (const std::exception& e) {
		std::cerr << e.what() << std::endl;
		std::cout << "Press any keys to exit..." << std::endl;
		getchar();
	}

	EE_EngineDisconnect();
	EE_EmoStateFree(eState);
	EE_EmoEngineEventFree(eEvent);

	return 0;
}
Exemple #19
0
int main(int argc, char **argv)
{
    // location of the machine running the "BlueGirl" head model
    std::string receiverHost = "localhost";
    
    if (argc > 2) {
        std::cout << "Usage: " << argv[0] << " <hostname>" << std::endl;
        std::cout << "The arguments specify the host of the head model "
                     "(Default: localhost)" << std::endl;
        return 1;
    }

    if (argc > 1) {
        receiverHost = std::string(argv[1]);
    }

    EmoEngineEventHandle eEvent = IEE_EmoEngineEventCreate();
    EmoStateHandle eState       = IEE_EmoStateCreate();
    unsigned int userID         = 0;
    const int CONTROL_PANEL_PORT = 3008;
    
    try {

        // Connect to EmoEngine
        if (IEE_EngineConnect() != EDK_OK) {
            throw std::runtime_error("EmoEngine start up failed.");
        }
        else {
            std::cout << "EmoEngine started!" << std::endl;
        }

        int startSendPort = 30000;
        std::map<unsigned int, SocketClient> socketMap;

        std::cout << "Type \"exit\" to quit, \"help\" to list available commands..."
                  << std::endl;
        promptUser();

        while (true) {

            // Handle the user input
            if (_kbhit()) {
                if (!handleUserInput()) {
                    break;
                }
            }

            int state = IEE_EngineGetNextEvent(eEvent);

            // New event needs to be handled
            if (state == EDK_OK) {

                IEE_Event_t eventType = IEE_EmoEngineEventGetType(eEvent);
                IEE_EmoEngineEventGetUserId(eEvent, &userID);

                switch (eventType) {

                // New headset connected
                // Create a new socket to send the animation
                case IEE_UserAdded:
                {
                    std::cout << std::endl << "New user " << userID
                              << " added, sending FacialExpression animation to ";
                    std::cout << receiverHost << ":" << startSendPort << "..."
                              << std::endl;
                    promptUser();

                    socketMap.insert(std::pair<unsigned int, SocketClient>(
                        userID, SocketClient(receiverHost, startSendPort, UDP)));

                    startSendPort++;
                    break;
                }

                // Headset disconnected, remove the existing socket
                case IEE_UserRemoved:
                {
                    std::cout << std::endl << "User " << userID
                              << " has been removed." << std::endl;

                    promptUser();
                    std::map<unsigned int, SocketClient>::iterator iter;
                    iter = socketMap.find(userID);
                    if (iter != socketMap.end()) {
                        socketMap.erase(iter);
                    }
                    break;
                }

                // Send the FacialExpression animation
                // if EmoState has been updated
                case IEE_EmoStateUpdated:
                {
                    IEE_EmoEngineEventGetEmoState(eEvent, eState);

                    std::map<unsigned int, SocketClient>::iterator iter;
                    iter = socketMap.find(userID);
                    if (iter != socketMap.end()) {
                        sendFacialExpressionAnimation(iter->second, eState);
                    }
                    break;
                }

                // Handle FacialExpression training event
                case IEE_FacialExpressionEvent:
                {
                    handleFacialExpressionEvent(std::cout, eEvent);
                }

                default:
                    break;
                }
            }
            else if (state != EDK_NO_EVENT) {
                std::cout << std::endl << "Internal error in Emotiv Engine!"
                          << std::endl;
                break;
            }

#ifdef _WIN32
            Sleep(15);
#endif
#ifdef __linux__
            sleep(1);
#endif
        }
    }
    catch (const std::runtime_error& e) {
        std::cerr << e.what() << std::endl;
        std::cout << "Press 'Enter' to exit..." << std::endl;
        getchar();
    }

    // Clean up
    IEE_EngineDisconnect();
    IEE_EmoStateFree(eState);
    IEE_EmoEngineEventFree(eEvent);

    return 0;
}