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:
parent
acab33bc67
commit
f66430574c
@ -57,6 +57,9 @@ m_mode(BOOTSTRAP), m_mouse_val_x(0), m_mouse_val_y(0)
|
|||||||
|
|
||||||
m_device_manager = new DeviceManager();
|
m_device_manager = new DeviceManager();
|
||||||
|
|
||||||
|
m_timer_in_use = false;
|
||||||
|
m_timer = 0;
|
||||||
|
|
||||||
bool something_new_to_write = false;
|
bool something_new_to_write = false;
|
||||||
|
|
||||||
if(!m_device_manager->deserialize())
|
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();
|
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.
|
/** 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 );
|
const bool action_found = m_device_manager->mapInputToPlayerAndAction( type, id0, id1, id2, value, &player, &action );
|
||||||
if(!action_found) return;
|
if(!action_found) return;
|
||||||
|
|
||||||
|
if(m_timer_in_use) return; // time between keys not elapsed yet
|
||||||
|
|
||||||
if(action == PA_FIRE || action == PA_NITRO)
|
if(action == PA_FIRE || action == PA_NITRO)
|
||||||
evt.Key = irr::KEY_RETURN;
|
evt.Key = irr::KEY_RETURN;
|
||||||
else if(action == PA_ACCEL)
|
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.
|
return; // only those bindings are accepted in menus for now.
|
||||||
|
|
||||||
evt.PressedDown = abs(value) > MAX_VALUE/2;
|
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
|
// send event to irrLicht
|
||||||
|
@ -44,6 +44,10 @@ public:
|
|||||||
BOOTSTRAP
|
BOOTSTRAP
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// to put a delay before a new gamepad axis move is considered in menu
|
||||||
|
bool m_timer_in_use;
|
||||||
|
float m_timer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Input *m_sensed_input;
|
Input *m_sensed_input;
|
||||||
@ -74,6 +78,9 @@ public:
|
|||||||
void input();
|
void input();
|
||||||
void setMode(InputDriverMode);
|
void setMode(InputDriverMode);
|
||||||
bool isInMode(InputDriverMode);
|
bool isInMode(InputDriverMode);
|
||||||
|
|
||||||
|
void update(float dt);
|
||||||
|
|
||||||
Input &getSensedInput();
|
Input &getSensedInput();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -214,6 +214,8 @@ void MainLoop::run()
|
|||||||
|
|
||||||
sound_manager->update(dt);
|
sound_manager->update(dt);
|
||||||
|
|
||||||
|
input_manager->update(dt);
|
||||||
|
|
||||||
#ifdef HAVE_IRRLICHT
|
#ifdef HAVE_IRRLICHT
|
||||||
if(!user_config->m_bullet_debug)
|
if(!user_config->m_bullet_debug)
|
||||||
irr_driver->update(dt);
|
irr_driver->update(dt);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user