I'm trying to register controller button/dpad presses and continuous hold of said buttons that way it spits the output out continuously instead of one press at a time and then exiting the poll event loop. Right now I have a small piece of dummy code that I'm trying to print in a stream if I hold a button down. Any assistance into this issue?
while( !quit_program )
{
//Handle events on queue
while( SDL_PollEvent( &e ))
{
//User requests quit
if( e.type == SDL_QUIT )
{
quit_program = true;
}
else if(e.type == SDL_CONTROLLERBUTTONDOWN)
{
count++;
cout<<"button pushed# "<<count<<endl;
}
}
}
Until you get a SDL_CONTROLLERBUTTONUP (for the same button of course) you can consider the button as being pressed. Then to count you could do something like this (for a single button):
Of course this counter would also depend on your loop timings. Here that_button_pressed would represent one of the SDL_GameControllerButton's.