diff --git a/src/input/device_manager.cpp b/src/input/device_manager.cpp index a3728e694..27de897be 100644 --- a/src/input/device_manager.cpp +++ b/src/input/device_manager.cpp @@ -152,16 +152,17 @@ void DeviceManager::checkForGamePad(const int sdl_id) for(unsigned int n=0; n 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)); } diff --git a/src/input/input_device.cpp b/src/input/input_device.cpp index 96f89957c..bcb5a41e3 100644 --- a/src/input/input_device.cpp +++ b/src/input/input_device.cpp @@ -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; } diff --git a/src/input/input_manager.cpp b/src/input/input_manager.cpp index c873bcd79..fd6e666e1 100644 --- a/src/input/input_manager.cpp +++ b/src/input/input_manager.cpp @@ -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(); + } // -----------------------------------------------------------------------------