glutjoystickfunc ?

Started by
-1 comments, last by teslaa66 15 years, 6 months ago
I my glutjoystickfunc doesnt seem to work how i want it only performs an action if a button or direction is hit and not held any ideas? i want the button to act as an accelerator so that when i hold it down the car continues to run forward but at the moment when i push it the car moves forward one space and for me to get it to continue to move forward i have to keep pushing the button repeatidly.


//does work if called with the keyboard function
void updateMatrix(char direction)
{
     if (direction == 'a') 
     {
	heading = heading + 2;
     }
}

//joystick function
void joystick(unsigned int buttons, int xaxis, int yaxis, int zaxis)
{
	char direction[7];

	if (xaxis < 0) direction[0] = 'a';

	if (xaxis > 0) direction[0] = 'd';

	if (buttons&0x0001) direction[2] = 's';
	if (buttons&0x0002) direction[2] = 'w';

	updateMatrix(direction[0]);
	updateMatrix(direction[2]);
	display();
}



//In main game loop
glutJoystickFunc(joystick,50)



any ideas?

This topic is closed to new replies.

Advertisement