Exemplo n.º 1
0
int main(void)
{
    joystick = initializeJoystick();
    serialPort = openSerial();
    
    printf("Joystick's file descriptor: %d\n\r", joystick.fd);
    printf("Serial port's file descriptor: %d\n\r", serialPort.fd);
    
    // Launch threads
    pthread_attr_t attr;
    pthread_attr_init(&attr);
    pthread_t tids[4];
    
    pthread_create(&tids[0], &attr, joystickUpdater, NULL);
    pthread_create(&tids[1], &attr, serialReader, NULL);
    pthread_create(&tids[2], &attr, serialWriter, NULL);
    pthread_create(&tids[3], &attr, terminalWriter, NULL);
    
    for (int i = 0; i < 4; i++)
    {
        pthread_join(tids[i], NULL);
    }
    
    // Never reached because the threads run forever
    terminateJoystick(&joystick);
    closeSerial(&serialPort);
    
    return 0;
}
Exemplo n.º 2
0
bool Input::initialize()
{
	m_uCurrentInput	= 0;
	m_uLastInput	= 0;

	if (false == initializeKeyboard())
	{
		return	false;
	}

	if (false == initializeJoystick())
	{
		return	false;
	}

	return	true;
}