more gamepad fixes
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3319 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
9c727717aa
commit
5ca3f169ca
@ -152,16 +152,17 @@ void DeviceManager::checkForGamePad(const int sdl_id)
|
||||
|
||||
for(unsigned int n=0; n<m_gamepad_amount; n++)
|
||||
{
|
||||
std::cout << "gamepad " << n << " is named " << m_gamepads[n].m_name.c_str() << std::endl;
|
||||
std::cout << " (checking...) gamepad " << n << " is named " << m_gamepads[n].m_name.c_str() << std::endl;
|
||||
|
||||
if(m_gamepads[n].m_name == name)
|
||||
{
|
||||
std::cout << "--> that's the one\n";
|
||||
m_gamepads[n].open(sdl_id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "couldn't find" << std::endl;
|
||||
std::cout << "couldn't find this joystick, so creating a new one" << std::endl;
|
||||
add(new GamePadDevice(sdl_id));
|
||||
|
||||
}
|
||||
|
@ -174,7 +174,6 @@ GamePadDevice::GamePadDevice(int sdlIndex)
|
||||
open(sdlIndex);
|
||||
|
||||
m_name = SDL_JoystickName(sdlIndex);
|
||||
std::cout << "creating a device named " << m_name.c_str() << "\n";
|
||||
|
||||
loadDefaults();
|
||||
} // GamePadDevice
|
||||
@ -186,6 +185,8 @@ void GamePadDevice::open(const int sdl_id)
|
||||
const int count = SDL_JoystickNumAxes(m_sdlJoystick);
|
||||
m_prevAxisDirections = new Input::AxisDirection[count];
|
||||
|
||||
std::cout << "(i) This gamepad has " << count << " axes\n";
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
m_prevAxisDirections[i] = Input::AD_NEUTRAL;
|
||||
}
|
||||
|
@ -65,26 +65,23 @@ m_mode(BOOTSTRAP), m_mouse_val_x(0), m_mouse_val_y(0)
|
||||
KeyboardDevice* default_device = new KeyboardDevice();
|
||||
default_device->loadDefaults();
|
||||
m_device_manager->add( default_device );
|
||||
m_device_manager->serialize();
|
||||
}
|
||||
else
|
||||
|
||||
// Prepare a list of connected joysticks.
|
||||
const int numSticks = SDL_NumJoysticks();
|
||||
|
||||
std::cout << "SDL detects " << numSticks << " gamepads" << std::endl;
|
||||
|
||||
// TODO - detect if device is currently known and has an entry in the config
|
||||
// the constructor below should only be used if not
|
||||
for (int i = 0; i < numSticks; i++)
|
||||
{
|
||||
// Prepare a list of connected joysticks.
|
||||
const int numSticks = SDL_NumJoysticks();
|
||||
|
||||
std::cout << "SDL detects " << numSticks << " gamepads" << std::endl;
|
||||
|
||||
// TODO - detect if device is currently known and has an entry in the config
|
||||
// the constructor below should only be used if not
|
||||
for (int i = 0; i < numSticks; i++)
|
||||
{
|
||||
m_device_manager->checkForGamePad(i);
|
||||
}
|
||||
|
||||
// FIXME - for testing purposes (immediately save any new device we might meet)
|
||||
m_device_manager->serialize();
|
||||
m_device_manager->checkForGamePad(i);
|
||||
}
|
||||
|
||||
// immediately save any new device we might meet
|
||||
m_device_manager->serialize();
|
||||
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user