diff --git a/src/input/input_manager.cpp b/src/input/input_manager.cpp index 38222f990..ed149cad4 100644 --- a/src/input/input_manager.cpp +++ b/src/input/input_manager.cpp @@ -91,92 +91,6 @@ void InputManager::update(float dt) } } -// ----------------------------------------------------------------------------- -/** Previous code to initialise joystick/gamepad info. - */ - - /* - m_stick_infos = new GamePadDevice *[numSticks]; - std::vector *si = new std::vector; - for (int i = 0; i < numSticks; i++) - si->push_back(m_stick_infos[i] = new GamePadDevice(i)); - - // Get the list of known configs and make a copy of it. - std::vector *sc - = new std::vector(*user_config->getStickConfigs()); - - bool match; - std::vector::iterator si_ite = si->begin(); - - // FIXME: Visual Studio triggers an exception (in debug mode) when si - // becomes empty (incompatible iterators). This is apparently caused - // by using erase. For now I added a work around by checking for - // si->size()>0, which solves the problem for me. But I have only one - // gamepad, I'd suspect that with more gamepads the problem still exists. - while (si->size()>0 && si_ite != si->end()) - { - match = false; - - std::vector::iterator sc_ite = sc->begin(); - while (sc_ite != sc->end()) - { - if (nextIndex <= (*sc_ite)->m_preferredIndex) - nextIndex = (*sc_ite)->m_preferredIndex + 1; - - if (!(*si_ite)->m_id.compare((*sc_ite)->m_id)) - { - // Connected stick matches a stored one. - - // Copy important properties. - - // Deadzone is taken only if its not null. - if ((*sc_ite)->m_deadzone) - (*si_ite)->m_deadzone = (*sc_ite)->m_deadzone; - - // Restore former used index and other properties. - (*si_ite)->m_index = (*sc_ite)->m_preferredIndex; - - // Remove matching entries from the list to prevent double - // allocation. - sc->erase(sc_ite); - si->erase(si_ite); - - match = true; - - break; - } - - sc_ite++; - } - - if (!match) - si_ite++; - } - delete sc; - - // si now contains all those stick infos which have no stick config yet - // and nextIndex is set to the next free index. - - // Now add all those new sticks and generate a config for them. - si_ite = si->begin(); - while (si_ite != si->end()) - { - (*si_ite)->m_index = nextIndex; - - UserConfig::StickConfig *sc = new UserConfig::StickConfig((*si_ite)->m_id); - sc->m_preferredIndex = nextIndex; - sc->m_deadzone = DEADZONE_JOYSTICK; - - user_config->addStickConfig(sc); - - nextIndex++; - si_ite++; - } - - delete si; - */ - - //----------------------------------------------------------------------------- /** Destructor. Frees all data structures. */ @@ -461,150 +375,6 @@ void InputManager::input(const SEvent& event) #endif } -/* -void InputManager::input() -{ - SDL_Event ev; - - while(SDL_PollEvent(&ev)) - { - switch(ev.type) - { - case SDL_QUIT: - main_loop->abort(); - break; - - case SDL_KEYUP: - input(Input::IT_KEYBOARD, ev.key.keysym.sym, 0, 0, 0); - break; - case SDL_KEYDOWN: - - // escape is a little special - if(ev.key.keysym.sym == SDLK_ESCAPE) - { - StateManager::escapePressed(); - return; - } - - - input(Input::IT_KEYBOARD, ev.key.keysym.sym, -#ifdef HAVE_IRRLICHT - // FIXME: not sure why this happens: with plib the unicode - // value is 0. Since all values defined in user_config - // assume that the unicode value is 0, it does not work - // with irrlicht, which has proper unicode values defined - // (keydown is not recognised, but keyup is). So for now - // (till user_config is migrated to ful lirrlicht support) - // we pass the 0 here artifically so that keyboard handling - // works. - 0, -#else - ev.key.keysym.unicode, -#endif - 0, MAX_VALUE); - - break; - - case SDL_MOUSEMOTION: - // Reports absolute pointer values on a separate path to the menu - // system to avoid the trouble that arises because all other input - // methods have only one value to inspect (pressed/release, - // axis value) while the pointer has two. - if (!m_mode) - { - postIrrLichtMouseEvent(irr::EMIE_MOUSE_MOVED, ev.motion.x, ev.motion.y); - } - // If sensing input mouse movements are made less sensitive in order - // to avoid it being detected unwantedly. - else if (m_mode >= INPUT_SENSE_PREFER_AXIS && - m_mode <= INPUT_SENSE_PREFER_BUTTON ) - { - if (ev.motion.xrel <= -DEADZONE_MOUSE_SENSE) - input(Input::IT_MOUSEMOTION, 0, Input::AD_NEGATIVE, 0, 0); - else if (ev.motion.xrel >= DEADZONE_MOUSE_SENSE) - input(Input::IT_MOUSEMOTION, 0, Input::AD_POSITIVE, 0, 0); - - if (ev.motion.yrel <= -DEADZONE_MOUSE_SENSE) - input(Input::IT_MOUSEMOTION, 1, Input::AD_NEGATIVE, 0, 0); - else if (ev.motion.yrel >= DEADZONE_MOUSE_SENSE) - input(Input::IT_MOUSEMOTION, 1, Input::AD_POSITIVE, 0, 0); - } - else - { - // Calculates new values for the mouse helper variables. It - // keeps them in the [-32768, 32768] range. The same values are - // used by SDL for stick axes. - m_mouse_val_x = std::max(-32768, std::min(32768, - m_mouse_val_x + ev.motion.xrel - * MULTIPLIER_MOUSE)); - m_mouse_val_y = std::max(-32768, - std::min(32768, m_mouse_val_y + ev.motion.yrel - * MULTIPLIER_MOUSE)); - } - break; - case SDL_MOUSEBUTTONUP: - postIrrLichtMouseEvent(irr::EMIE_LMOUSE_LEFT_UP, ev.motion.x, ev.motion.y); - //input(Input::IT_MOUSEBUTTON, ev.button.button, 0, 0, 0); - break; - - case SDL_MOUSEBUTTONDOWN: - postIrrLichtMouseEvent(irr::EMIE_LMOUSE_PRESSED_DOWN, ev.motion.x, ev.motion.y); - //input(Input::IT_MOUSEBUTTON, ev.button.button, 0, 0, 32768); - break; - - case SDL_JOYAXISMOTION: - { - const int value = ev.jaxis.value; - - if(user_config->m_gamepad_debug) - { - printf("axis motion: which=%d axis=%d value=%d\n", - ev.jaxis.which, ev.jaxis.axis, value); - } - - // FIXME - AD_NEGATIVE/AD_POSITIVE are probably useless since value contains that info too - if(value < 0) - input(Input::IT_STICKMOTION, ev.jaxis.which, ev.jaxis.axis, Input::AD_NEGATIVE, value); - else - input(Input::IT_STICKMOTION, ev.jaxis.which, ev.jaxis.axis, Input::AD_POSITIVE, value); - } - break; - case SDL_JOYBUTTONUP: - // See the SDL_JOYAXISMOTION case label because of !m_mode thingie. - input(Input::IT_STICKBUTTON, ev.jbutton.which, - ev.jbutton.button, 0, 0); - break; - case SDL_JOYBUTTONDOWN: - // See the SDL_JOYAXISMOTION case label because of !m_mode thingie. - input(Input::IT_STICKBUTTON, ev.jbutton.which, ev.jbutton.button, 0, 32768); - break; - case SDL_USEREVENT: - // TODO - GUI countdown - break; - // used in display_res_confirm for the countdown timer - // (menu_manager->getCurrentMenu())->countdown(); - - } // switch - } // while (SDL_PollEvent()) - - // Makes mouse behave like an analog axis. - if (m_mouse_val_x <= -DEADZONE_MOUSE) - input(Input::IT_MOUSEMOTION, 0, Input::AD_NEGATIVE, 0, -m_mouse_val_x); - else if (m_mouse_val_x >= DEADZONE_MOUSE) - input(Input::IT_MOUSEMOTION, 0, Input::AD_POSITIVE, 0, m_mouse_val_x); - else - m_mouse_val_x = 0; - - if (m_mouse_val_y <= -DEADZONE_MOUSE) - input(Input::IT_MOUSEMOTION, 1, Input::AD_NEGATIVE, 0, -m_mouse_val_y); - else if (m_mouse_val_y >= DEADZONE_MOUSE) - input(Input::IT_MOUSEMOTION, 1, Input::AD_POSITIVE, 0, m_mouse_val_y); - else - m_mouse_val_y = 0; - -} // input -*/ - //----------------------------------------------------------------------------- /** Retrieves the Input instance that has been prepared in the input sense * mode.