Sign in to follow this  
teslaa66

glutjoystickfunc ?

Recommended Posts

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?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this