attempt at timing so gamepad events don't happen too often in menu

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3355 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2009-04-04 23:47:38 +00:00
parent acab33bc67
commit f66430574c
3 changed files with 28 additions and 1 deletions

View File

@ -57,6 +57,9 @@ m_mode(BOOTSTRAP), m_mouse_val_x(0), m_mouse_val_y(0)
m_device_manager = new DeviceManager();
m_timer_in_use = false;
m_timer = 0;
bool something_new_to_write = false;
if(!m_device_manager->deserialize())
@ -87,6 +90,15 @@ m_mode(BOOTSTRAP), m_mouse_val_x(0), m_mouse_val_y(0)
if(something_new_to_write) m_device_manager->serialize();
}
// -----------------------------------------------------------------------------
void InputManager::update(float dt)
{
if(m_timer_in_use)
{
m_timer -= dt;
if(m_timer < 0) m_timer_in_use = false;
}
}
// -----------------------------------------------------------------------------
/** Initialises joystick/gamepad info.
@ -327,6 +339,8 @@ void InputManager::input(Input::InputType type, int id0, int id1, int id2,
const bool action_found = m_device_manager->mapInputToPlayerAndAction( type, id0, id1, id2, value, &player, &action );
if(!action_found) return;
if(m_timer_in_use) return; // time between keys not elapsed yet
if(action == PA_FIRE || action == PA_NITRO)
evt.Key = irr::KEY_RETURN;
else if(action == PA_ACCEL)
@ -341,6 +355,10 @@ void InputManager::input(Input::InputType type, int id0, int id1, int id2,
return; // only those bindings are accepted in menus for now.
evt.PressedDown = abs(value) > MAX_VALUE/2;
// minimum time between two gamepad events in menu
m_timer_in_use = true;
m_timer = 500;
}
// send event to irrLicht

View File

@ -44,6 +44,10 @@ public:
BOOTSTRAP
};
// to put a delay before a new gamepad axis move is considered in menu
bool m_timer_in_use;
float m_timer;
private:
Input *m_sensed_input;
@ -62,7 +66,7 @@ private:
* makes the mouse behave like an analog axis on a gamepad/joystick.
*/
int m_mouse_val_x, m_mouse_val_y;
void input(Input::InputType, int, int, int, int);
void postIrrLichtMouseEvent(irr::EMOUSE_INPUT_EVENT type, const int x, const int y);
void handleStaticAction(int id0, int value);
@ -74,6 +78,9 @@ public:
void input();
void setMode(InputDriverMode);
bool isInMode(InputDriverMode);
void update(float dt);
Input &getSensedInput();
};

View File

@ -214,6 +214,8 @@ void MainLoop::run()
sound_manager->update(dt);
input_manager->update(dt);
#ifdef HAVE_IRRLICHT
if(!user_config->m_bullet_debug)
irr_driver->update(dt);