Fixed issues with press a key dialog - the keypress was considered after the dialog had been closed. fixed that by closing dialog only when key is released

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5446 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2010-05-15 19:49:59 +00:00
parent 45dfd6d415
commit 2cd92bb6af
2 changed files with 18 additions and 8 deletions

View File

@ -209,8 +209,16 @@ void InputManager::inputSensing(Input::InputType type, int deviceID, int btnID,
if (type == Input::IT_KEYBOARD && value > Input::MAX_VALUE/2) if (type == Input::IT_KEYBOARD && value > Input::MAX_VALUE/2)
{ {
OptionsScreenInput2::getInstance()->gotSensedInput(m_sensed_input); m_sensed_input_high_kbd.insert(btnID);
return; }
else if (type == Input::IT_KEYBOARD && value == 0)
{
// only notify on key release
if (m_sensed_input_high_kbd.find(m_sensed_input->btnID) != m_sensed_input_high_kbd.end())
{
OptionsScreenInput2::getInstance()->gotSensedInput(m_sensed_input);
return;
}
} }
else if (type == Input::IT_STICKMOTION) else if (type == Input::IT_STICKMOTION)
{ {
@ -235,12 +243,12 @@ void InputManager::inputSensing(Input::InputType type, int deviceID, int btnID,
// It is necessary to test both ids because the center position is always positive (0) // It is necessary to test both ids because the center position is always positive (0)
const int input_id = axisDirection*50 + btnID; const int input_id = axisDirection*50 + btnID;
const int input_id_inverse = (axisDirection?0:-1) *50 + btnID; const int input_id_inverse = (axisDirection?0:-1) *50 + btnID;
bool id_has_high_value = m_sensed_input_high.find(input_id) != m_sensed_input_high.end(); bool id_has_high_value = m_sensed_input_high_gamepad.find(input_id) != m_sensed_input_high_gamepad.end();
bool inverse_id_has_high_value = m_sensed_input_high.find(input_id_inverse) != m_sensed_input_high.end(); bool inverse_id_has_high_value = m_sensed_input_high_gamepad.find(input_id_inverse) != m_sensed_input_high_gamepad.end();
if (!id_has_high_value && abs(value) > Input::MAX_VALUE*6.0f/7.0f) if (!id_has_high_value && abs(value) > Input::MAX_VALUE*6.0f/7.0f)
{ {
m_sensed_input_high.insert(input_id); m_sensed_input_high_gamepad.insert(input_id);
} }
else if ( abs(value) < Input::MAX_VALUE/8.0f && id_has_high_value ) else if ( abs(value) < Input::MAX_VALUE/8.0f && id_has_high_value )
{ {
@ -751,7 +759,8 @@ void InputManager::setMode(InputDriverMode new_mode)
// Leaving input sense mode. // Leaving input sense mode.
//irr_driver->showPointer(); //irr_driver->showPointer();
m_sensed_input_high.clear(); m_sensed_input_high_gamepad.clear();
m_sensed_input_high_kbd.clear();
// The order is deliberate just in case someone starts to make // The order is deliberate just in case someone starts to make
// STK multithreaded: m_sensed_input must not be 0 when // STK multithreaded: m_sensed_input must not be 0 when

View File

@ -57,8 +57,9 @@ private:
Input *m_sensed_input; Input *m_sensed_input;
DeviceManager *m_device_manager; DeviceManager *m_device_manager;
std::set<int> m_sensed_input_high; std::set<int> m_sensed_input_high_gamepad;
std::set<int> m_sensed_input_high_kbd;
InputDriverMode m_mode; InputDriverMode m_mode;
/** When at true, only the master player can play with menus */ /** When at true, only the master player can play with menus */