Handling of Control Pad input too sensitive?
Posted: Sun Aug 12, 2012 6:49 pm
So after I worked on the different performance enhancements, one other thing I ran into was that the "pause" feature I had in my game when you press start is way over sensitive to the point it is hard to pause with out many attempts. If you just press the key normally, it almost immediately pauses then quickly un-pauses. For normal character movement its not a problem since you usually just continue in one direction, but I could imagine other functions, like attacks might need to be more precise. I've borrowed this code from ChillyWilly's examples I think
What is the best way to control this generically?
Here is a sanitized version of my handleInput() function that is called every iteration of the main game loop. (do you not call each time if the game loop is very fast?)
What is the best way to control this generically?
Here is a sanitized version of my handleInput() function that is called every iteration of the main game loop. (do you not call each time if the game loop is very fast?)
Code: Select all
void handle_input(GameCharacter* player)
{
unsigned short new_buttons, curr_buttons;
unsigned short buttons = 0;
// MARS_SYS_COMM10 holds the current button values: - - - - M X Y Z S A C B R L D U
curr_buttons = MARS_SYS_COMM8;
if ((curr_buttons & SEGA_CTRL_TYPE) == SEGA_CTRL_NONE)
curr_buttons = MARS_SYS_COMM10; // if no pad 1, try using pad 2
// set if button changed
new_buttons = curr_buttons ^ buttons;
buttons = curr_buttons;
//pause
if (new_buttons & SEGA_CTRL_START )
{
if(paused != 1){
paused = 1;
}else{
paused = 0;
//clear pause and debug messages
HwMdClearScreen ();
}
}
if(paused == 0)
{
if (new_buttons & SEGA_CTRL_B && (player->action != CHARACTER_ATTACK1))
{
}
if (buttons & SEGA_CTRL_LEFT && (player->action != CHARACTER_ATTACK1))
{
}
if (buttons & SEGA_CTRL_RIGHT && (player->action != CHARACTER_ATTACK1))
{
}
}
}