Fixed subtle input issue (problem assigning mouse to the right player when keyboard config used is not the first)

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4381 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2010-01-02 01:55:20 +00:00
parent 7b8fc1e592
commit 4768654113
2 changed files with 11 additions and 7 deletions

View File

@ -88,10 +88,11 @@ public:
// ---- Keyboard(s) ----
void addEmptyKeyboard();
void addKeyboard(KeyboardDevice* d);
int getKeyboardConfigAmount() const { return m_keyboard_configs.size(); }
void clearKeyboard() { m_keyboards.clearAndDeleteAll(); }
int getKeyboardAmount() { return m_keyboards.size(); }
int getKeyboardConfigAmount() const { return m_keyboard_configs.size(); }
KeyboardDevice* getKeyboard(const int i) { return m_keyboards.get(i); }
KeyboardConfig* getKeyboardConfig(const int i) { return m_keyboard_configs.get(i); }
void clearKeyboard() { m_keyboards.clearAndDeleteAll(); }
KeyboardDevice* getKeyboardFromBtnID(const int btnID);

View File

@ -230,15 +230,18 @@ int InputManager::getPlayerKeyboardID() const
// In no-assign mode, just return the GUI player ID (devices not assigned yet)
if (m_device_manager->getAssignMode() == NO_ASSIGN) return GUI_PLAYER_ID;
// Otherwise, after devices are assigned, we can check the ID
// FIXME: don't hardcode keyboard 0, there may be multiple keyboard configs
if (m_device_manager->getKeyboard(0) != NULL)
// Otherwise, after devices are assigned, we can check in more depth
// Return the first keyboard that is actually being used
const int amount = m_device_manager->getKeyboardAmount();
for (int k=0; k<amount; k++)
{
if (m_device_manager->getKeyboard(0)->getPlayer() != NULL)
if (m_device_manager->getKeyboard(k) != NULL &&
m_device_manager->getKeyboard(k)->getPlayer() != NULL)
{
return m_device_manager->getKeyboard(0)->getPlayer()->m_id;
return m_device_manager->getKeyboard(k)->getPlayer()->m_id;
}
}
return -1;
}
//-----------------------------------------------------------------------------