Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/network/src/core/InputManager.cc @ 1422

Last change on this file since 1422 was 1422, checked in by rgrieder, 16 years ago
  • added a little text box to the HUD that says how much of the main loop we spend with rendering. (can easily be commented)
  • fixed a bug in KeyBinder.cc
File size: 42.2 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Reto Grieder
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30  @file
31  @brief Implementation of the InputManager that captures all the input from OIS
32         and redirects it to handlers.
33 */
34
35#include "InputManager.h"
36#include "CoreIncludes.h"
37#include "Debug.h"
38#include "InputBuffer.h"
39#include "KeyBinder.h"
40
41namespace orxonox
42{
43  // ###############################
44  // ###    Internal Methods     ###
45  // ###############################
46  // ###############################
47
48  /**
49    @brief Constructor only sets member fields to initial zero values
50           and registers the class in the class hierarchy.
51  */
52  InputManager::InputManager() :
53      inputSystem_(0), keyboard_(0), mouse_(0),
54      joySticksSize_(0),
55      keyBinder_(0), buffer_(0), keyDetector_(0),
56      state_(IS_UNINIT), stateRequest_(IS_UNINIT),
57      keyboardModifiers_(0)
58  {
59    RegisterObject(InputManager);
60  }
61
62  /**
63    @brief The one instance of the InputManager is stored in this function.
64    @return A reference to the only instance of the InputManager
65  */
66  InputManager& InputManager::_getSingleton()
67  {
68    static InputManager theOnlyInstance;
69    return theOnlyInstance;
70  }
71
72  /**
73    @brief Destructor only called at the end of the program, after main.
74  */
75  InputManager::~InputManager()
76  {
77    _destroy();
78  }
79
80  /**
81    @brief Creates the OIS::InputMananger, the keyboard, the mouse and
82           the joysticks and assigns the key bindings.
83    @param windowHnd The window handle of the render window
84    @param windowWidth The width of the render window
85    @param windowHeight The height of the render window
86  */
87  bool InputManager::_initialise(const size_t windowHnd, int windowWidth, int windowHeight,
88        bool createKeyboard, bool createMouse, bool createJoySticks)
89  {
90    if (state_ == IS_UNINIT)
91    {
92      CCOUT(3) << "Initialising Input System..." << std::endl;
93      CCOUT(ORX_DEBUG) << "Initialising OIS components..." << std::endl;
94
95      OIS::ParamList paramList;
96      std::ostringstream windowHndStr;
97
98      // Fill parameter list
99      windowHndStr << (unsigned int)windowHnd;
100      paramList.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
101      //paramList.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_NONEXCLUSIVE")));
102      //paramList.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_FOREGROUND")));
103//#if defined OIS_LINUX_PLATFORM
104//      paramList.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true")));
105//#endif
106
107      try
108      {
109        inputSystem_ = OIS::InputManager::createInputSystem(paramList);
110        CCOUT(ORX_DEBUG) << "Created OIS input system" << std::endl;
111      }
112      catch (OIS::Exception ex)
113      {
114        CCOUT(ORX_ERROR) << "Error: Failed creating an OIS input system."
115            << "OIS message: \"" << ex.eText << "\"" << std::endl;
116        inputSystem_ = 0;
117        return false;
118      }
119
120      if (createKeyboard)
121        _initialiseKeyboard();
122
123      if (createMouse)
124        _initialiseMouse();
125
126      if (createJoySticks)
127        _initialiseJoySticks();
128
129      // Set mouse/joystick region
130      if (mouse_)
131      {
132        //// hack the mouse position
133        //((OIS::MouseState&)mouse_->getMouseState()).X.abs = windowWidth/2;
134        //((OIS::MouseState&)mouse_->getMouseState()).Y.abs = windowHeight/2;
135        setWindowExtents(windowWidth, windowHeight);
136      }
137
138      state_ = IS_NONE;
139      CCOUT(ORX_DEBUG) << "Initialising OIS components done." << std::endl;
140    }
141    else
142    {
143      CCOUT(ORX_WARNING) << "Warning: OIS compoments already initialised, skipping" << std::endl;
144    }
145
146    // InputManager holds the input buffer --> create one and add it.
147    buffer_ = new InputBuffer();
148    addKeyHandler(buffer_, "buffer");
149
150    keyBinder_ = new KeyBinder();
151    keyBinder_->loadBindings();
152    addKeyHandler(keyBinder_, "keybinder");
153    addMouseHandler(keyBinder_, "keybinder");
154    addJoyStickHandler(keyBinder_, "keybinder");
155
156    keyDetector_ = new KeyDetector();
157    keyDetector_->loadBindings();
158    addKeyHandler(keyDetector_, "keydetector");
159    addMouseHandler(keyDetector_, "keydetector");
160    addJoyStickHandler(keyDetector_, "keydetector");
161
162    CCOUT(ORX_DEBUG) << "Initialising complete." << std::endl;
163    return true;
164  }
165
166  /**
167    @brief Creates a keyboard and sets the event handler.
168    @return False if keyboard stays uninitialised, true otherwise.
169  */
170  bool InputManager::_initialiseKeyboard()
171  {
172    if (keyboard_ != 0)
173    {
174      CCOUT(2) << "Warning: Keyboard already initialised, skipping." << std::endl;
175      return true;
176    }
177    try
178    {
179      if (inputSystem_->getNumberOfDevices(OIS::OISKeyboard) > 0)
180      {
181        keyboard_ = (OIS::Keyboard*)inputSystem_->createInputObject(OIS::OISKeyboard, true);
182        // register our listener in OIS.
183        keyboard_->setEventCallback(this);
184        // note: OIS will not detect keys that have already been down when the keyboard was created.
185        CCOUT(ORX_DEBUG) << "Created OIS keyboard" << std::endl;
186        return true;
187      }
188      else
189      {
190        CCOUT(ORX_WARNING) << "Warning: No keyboard found!" << std::endl;
191        return false;
192      }
193    }
194    catch (OIS::Exception ex)
195    {
196      // TODO: Test this output regarding formatting
197      CCOUT(ORX_WARNING) << "Warning: Failed to create an OIS keyboard\n"
198          << "OIS error message: \"" << ex.eText << "\"" << std::endl;
199      keyboard_ = 0;
200      return false;
201    }
202  }
203
204  /**
205    @brief Creates a mouse and sets the event handler.
206    @return False if mouse stays uninitialised, true otherwise.
207  */
208  bool InputManager::_initialiseMouse()
209  {
210    if (mouse_ != 0)
211    {
212      CCOUT(2) << "Warning: Mouse already initialised, skipping." << std::endl;
213      return true;
214    }
215    try
216    {
217      if (inputSystem_->getNumberOfDevices(OIS::OISMouse) > 0)
218      {
219        mouse_ = static_cast<OIS::Mouse*>(inputSystem_->createInputObject(OIS::OISMouse, true));
220        // register our listener in OIS.
221        mouse_->setEventCallback(this);
222        CCOUT(ORX_DEBUG) << "Created OIS keyboard" << std::endl;
223        return true;
224      }
225      else
226      {
227        CCOUT(ORX_WARNING) << "Warning: No mouse found!" << std::endl;
228        return false;
229      }
230    }
231    catch (OIS::Exception ex)
232    {
233      CCOUT(ORX_WARNING) << "Warning: Failed to create an OIS mouse\n"
234          << "OIS error message: \"" << ex.eText << "\"" << std::endl;
235      mouse_ = 0;
236      return false;
237    }
238  }
239
240  /**
241    @brief Creates all joy sticks and sets the event handler.
242    @return False joy stick stay uninitialised, true otherwise.
243  */
244  bool InputManager::_initialiseJoySticks()
245  {
246    if (joySticksSize_ > 0)
247    {
248      CCOUT(2) << "Warning: Joy sticks already initialised, skipping." << std::endl;
249      return true;
250    }
251    bool success = false;
252    if (inputSystem_->getNumberOfDevices(OIS::OISJoyStick) > 0)
253    {
254      for (int i = 0; i < inputSystem_->getNumberOfDevices(OIS::OISJoyStick); i++)
255      {
256        try
257        {
258          OIS::JoyStick* stig = static_cast<OIS::JoyStick*>(inputSystem_->createInputObject(OIS::OISJoyStick, true));
259          joySticks_.push_back(stig);
260          // register our listener in OIS.
261          stig->setEventCallback(this);
262          CCOUT(ORX_DEBUG) << "Created OIS joy stick with ID " << stig->getID() << std::endl;
263          success = true;
264        }
265        catch (OIS::Exception ex)
266        {
267          CCOUT(ORX_WARNING) << "Warning: Failed to create OIS joy number" << i << "\n"
268              << "OIS error message: \"" << ex.eText << "\"" << std::endl;
269        }
270      }
271    }
272    else
273    {
274      CCOUT(ORX_WARNING) << "Warning: Joy stick support requested, but no joy stick was found" << std::endl;
275      return false;
276    }
277    joySticksSize_ = joySticks_.size();
278    activeJoyStickHandlers_.resize(joySticksSize_);
279    joyStickButtonsDown_.resize(joySticksSize_);
280    povStates_.resize(joySticksSize_);
281    sliderStates_.resize(joySticksSize_);
282    return success;
283  }
284
285  /**
286    @brief Destroys all the created input devices and sets the InputManager to construction state.
287  */
288  void InputManager::_destroy()
289  {
290    if (state_ != IS_UNINIT)
291    {
292      CCOUT(ORX_DEBUG) << "Destroying ..." << std::endl;
293
294      if (buffer_)
295        delete buffer_;
296
297      if (keyBinder_)
298        delete keyBinder_;
299
300      if (keyDetector_)
301        delete keyDetector_;
302
303      keyHandlers_.clear();
304      mouseHandlers_.clear();
305      joyStickHandlers_.clear();
306
307      _destroyKeyboard();
308      _destroyMouse();
309      _destroyJoySticks();
310
311      // inputSystem_ can never be 0, or else the code is mistaken
312      OIS::InputManager::destroyInputSystem(inputSystem_);
313      inputSystem_ = 0;
314
315      state_ = IS_UNINIT;
316      CCOUT(ORX_DEBUG) << "Destroying done." << std::endl;
317    }
318  }
319
320  /**
321    @brief Destroys the keyboard and sets it to 0.
322  */
323  void InputManager::_destroyKeyboard()
324  {
325    if (keyboard_)
326      // inputSystem_ can never be 0, or else the code is mistaken
327      inputSystem_->destroyInputObject(keyboard_);
328    keyboard_ = 0;
329    activeKeyHandlers_.clear();
330    keysDown_.clear();
331    CCOUT(ORX_DEBUG) << "Keyboard destroyed." << std::endl;
332  }
333
334  /**
335    @brief Destroys the mouse and sets it to 0.
336  */
337  void InputManager::_destroyMouse()
338  {
339    if (mouse_)
340      // inputSystem_ can never be 0, or else the code is mistaken
341      inputSystem_->destroyInputObject(mouse_);
342    mouse_ = 0;
343    activeMouseHandlers_.clear();
344    mouseButtonsDown_.clear();
345    CCOUT(ORX_DEBUG) << "Mouse destroyed." << std::endl;
346  }
347
348  /**
349    @brief Destroys all the joy sticks and resizes the lists to 0.
350  */
351  void InputManager::_destroyJoySticks()
352  {
353    if (joySticksSize_ > 0)
354    {
355      // note: inputSystem_ can never be 0, or else the code is mistaken
356      for (unsigned int i = 0; i < joySticksSize_; i++)
357        if (joySticks_[i] != 0)
358          inputSystem_->destroyInputObject(joySticks_[i]);
359
360      joySticks_.clear();
361      joySticksSize_ = 0;
362      activeJoyStickHandlers_.clear();
363      joyStickButtonsDown_.clear();
364    }
365    CCOUT(ORX_DEBUG) << "Joy sticks destroyed." << std::endl;
366  }
367
368  void InputManager::_updateTickables()
369  {
370    // we can use a map to have a list of unique pointers (an object can implement all 3 handlers)
371    std::map<InputTickable*, HandlerState> tempSet;
372    for (unsigned int iHandler = 0; iHandler < activeKeyHandlers_.size(); iHandler++)
373      tempSet[activeKeyHandlers_[iHandler]].joyStick = true;
374    for (unsigned int iHandler = 0; iHandler < activeMouseHandlers_.size(); iHandler++)
375      tempSet[activeMouseHandlers_[iHandler]].mouse = true;
376    for (unsigned int iJoyStick  = 0; iJoyStick < joySticksSize_; iJoyStick++)
377      for (unsigned int iHandler = 0; iHandler  < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
378        tempSet[activeJoyStickHandlers_[iJoyStick][iHandler]].joyStick = true;
379
380    // copy the content of the map back to the actual vector
381    activeHandlers_.clear();
382    for (std::map<InputTickable*, HandlerState>::const_iterator itHandler = tempSet.begin();
383        itHandler != tempSet.end(); itHandler++)
384      activeHandlers_.push_back(std::pair<InputTickable*, HandlerState>((*itHandler).first, (*itHandler).second));
385  }
386
387
388  // #################################
389  // ### Private Interface Methods ###
390  // #################################
391  // #################################
392
393  /**
394    @brief Updates the InputManager. Tick is called by Orxonox.
395    @param dt Delta time
396  */
397  void InputManager::tick(float dt)
398  {
399    if (state_ == IS_UNINIT)
400      return;
401
402    // reset the game if it has changed
403    if (state_ != stateRequest_)
404    {
405      if (stateRequest_ != IS_CUSTOM)
406      {
407        activeKeyHandlers_.clear();
408        activeMouseHandlers_.clear();
409        for (unsigned int i = 0; i < joySticksSize_; i++)
410          activeJoyStickHandlers_[i].clear();
411
412        switch (stateRequest_)
413        {
414        case IS_NORMAL:
415          // normal play mode
416          // note: we assume that the handlers exist since otherwise, something's wrong anyway.
417          enableKeyHandler("keybinder");
418          enableMouseHandler("keybinder");
419          enableJoyStickHandler("keybinder", 0);
420          break;
421
422        case IS_GUI:
423          break;
424
425        case IS_CONSOLE:
426          enableMouseHandler("keybinder");
427          enableJoyStickHandler("keybinder", 0);
428          enableKeyHandler("buffer");
429          break;
430
431        case IS_DETECTION:
432          if (mouse_)
433            mouse_->capture();
434          if (keyboard_)
435            keyboard_->capture();
436          for (unsigned  int i = 0; i < joySticksSize_; i++)
437            joySticks_[i]->capture();
438
439          lastStroke_ = "";
440          enableKeyHandler("keydetector");
441          enableMouseHandler("keydetector");
442          enableJoyStickHandler("keydetector", 0);
443          break;
444
445        default:
446          break;
447        }
448        state_ = stateRequest_;
449      }
450    }
451
452    // Capture all the input. This calls the event handlers in InputManager.
453    if (mouse_)
454      mouse_->capture();
455    if (keyboard_)
456      keyboard_->capture();
457    for (unsigned  int i = 0; i < joySticksSize_; i++)
458      joySticks_[i]->capture();
459
460
461    // call all the handlers for the held key events
462    for (unsigned int iKey = 0; iKey < keysDown_.size(); iKey++)
463      for (unsigned int iHandler = 0; iHandler < activeKeyHandlers_.size(); iHandler++)
464        activeKeyHandlers_[iHandler]->keyHeld(KeyEvent(keysDown_[iKey], keyboardModifiers_));
465
466    // call all the handlers for the held mouse button events
467    for (unsigned int iButton = 0; iButton < mouseButtonsDown_.size(); iButton++)
468      for (unsigned int iHandler = 0; iHandler < activeMouseHandlers_.size(); iHandler++)
469        activeMouseHandlers_[iHandler]->mouseButtonHeld(mouseButtonsDown_[iButton]);
470
471    // call all the handlers for the held joy stick button events
472    for (unsigned int iJoyStick  = 0; iJoyStick < joySticksSize_; iJoyStick++)
473      for (unsigned int iButton   = 0; iButton   < joyStickButtonsDown_[iJoyStick].size(); iButton++)
474        for (unsigned int iHandler = 0; iHandler  < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
475          activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickButtonHeld(iJoyStick, joyStickButtonsDown_[iJoyStick][iButton]);
476
477
478    // call the ticks for the handlers (need to be treated specially)
479    for (unsigned int iHandler = 0; iHandler < activeHandlers_.size(); iHandler++)
480      activeHandlers_[iHandler].first->tickInput(dt, activeHandlers_[iHandler].second);
481
482    /*for (unsigned int iHandler = 0; iHandler < activeKeyHandlers_.size(); iHandler++)
483      activeKeyHandlers_[iHandler]->tickKey(dt);
484    for (unsigned int iHandler = 0; iHandler < activeMouseHandlers_.size(); iHandler++)
485      activeMouseHandlers_[iHandler]->tickMouse(dt);
486    for (unsigned int iJoyStick  = 0; iJoyStick < joySticksSize_; iJoyStick++)
487      for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
488        activeJoyStickHandlers_[iJoyStick][iHandler]->tickJoyStick(dt);*/
489  }
490
491  // ###### Key Events ######
492
493  /**
494    @brief Event handler for the keyPressed Event.
495    @param e Event information
496  */
497  bool InputManager::keyPressed(const OIS::KeyEvent &e)
498  {
499    // check whether the key already is in the list (can happen when focus was lost)
500    unsigned int iKey = 0;
501    while (iKey < keysDown_.size() && keysDown_[iKey].key != (KeyCode::Enum)e.key)
502      iKey++;
503    if (iKey == keysDown_.size())
504      keysDown_.push_back(Key(e));
505
506    // update modifiers
507    if(e.key == OIS::KC_RMENU    || e.key == OIS::KC_LMENU)
508      keyboardModifiers_ |= KeyboardModifier::Alt;   // alt key
509    if(e.key == OIS::KC_RCONTROL || e.key == OIS::KC_LCONTROL)
510      keyboardModifiers_ |= KeyboardModifier::Ctrl;  // ctrl key
511    if(e.key == OIS::KC_RSHIFT   || e.key == OIS::KC_LSHIFT)
512      keyboardModifiers_ |= KeyboardModifier::Shift; // shift key
513
514    for (unsigned int i = 0; i < activeKeyHandlers_.size(); i++)
515      activeKeyHandlers_[i]->keyPressed(KeyEvent(e, keyboardModifiers_));
516
517    return true;
518  }
519
520  /**
521    @brief Event handler for the keyReleased Event.
522    @param e Event information
523  */
524  bool InputManager::keyReleased(const OIS::KeyEvent &e)
525  {
526    // remove the key from the keysDown_ list
527    for (unsigned int iKey = 0; iKey < keysDown_.size(); iKey++)
528    {
529      if (keysDown_[iKey].key == (KeyCode::Enum)e.key)
530      {
531        keysDown_.erase(keysDown_.begin() + iKey);
532        break;
533      }
534    }
535
536    // update modifiers
537    if(e.key == OIS::KC_RMENU    || e.key == OIS::KC_LMENU)
538      keyboardModifiers_ &= ~KeyboardModifier::Alt;   // alt key
539    if(e.key == OIS::KC_RCONTROL || e.key == OIS::KC_LCONTROL)
540      keyboardModifiers_ &= ~KeyboardModifier::Ctrl;  // ctrl key
541    if(e.key == OIS::KC_RSHIFT   || e.key == OIS::KC_LSHIFT)
542      keyboardModifiers_ &= ~KeyboardModifier::Shift; // shift key
543
544    for (unsigned int i = 0; i < activeKeyHandlers_.size(); i++)
545      activeKeyHandlers_[i]->keyReleased(KeyEvent(e, keyboardModifiers_));
546
547    return true;
548  }
549
550
551  // ###### Mouse Events ######
552
553  /**
554    @brief Event handler for the mouseMoved Event.
555    @param e Event information
556  */
557  bool InputManager::mouseMoved(const OIS::MouseEvent &e)
558  {
559    // check for actual moved event
560    if (e.state.X.rel != 0 || e.state.Y.rel != 0)
561    {
562      for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
563        activeMouseHandlers_[i]->mouseMoved(IntVector2(e.state.X.abs, e.state.Y.abs),
564            IntVector2(e.state.X.rel, e.state.Y.rel), IntVector2(e.state.width, e.state.height));
565    }
566
567    // check for mouse scrolled event
568    if (e.state.Z.rel != 0)
569    {
570      for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
571        activeMouseHandlers_[i]->mouseScrolled(e.state.Z.abs, e.state.Z.rel);
572    }
573
574    return true;
575  }
576
577  /**
578    @brief Event handler for the mousePressed Event.
579    @param e Event information
580    @param id The ID of the mouse button
581  */
582  bool InputManager::mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id)
583  {
584    // check whether the button already is in the list (can happen when focus was lost)
585    unsigned int iButton = 0;
586    while (iButton < mouseButtonsDown_.size() && mouseButtonsDown_[iButton] != (MouseButton::Enum)id)
587      iButton++;
588    if (iButton == mouseButtonsDown_.size())
589      mouseButtonsDown_.push_back((MouseButton::Enum)id);
590
591    for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
592      activeMouseHandlers_[i]->mouseButtonPressed((MouseButton::Enum)id);
593
594    return true;
595  }
596
597  /**
598    @brief Event handler for the mouseReleased Event.
599    @param e Event information
600    @param id The ID of the mouse button
601  */
602  bool InputManager::mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id)
603  {
604    // remove the button from the keysDown_ list
605    for (unsigned int iButton = 0; iButton < mouseButtonsDown_.size(); iButton++)
606    {
607      if (mouseButtonsDown_[iButton] == (MouseButton::Enum)id)
608      {
609        mouseButtonsDown_.erase(mouseButtonsDown_.begin() + iButton);
610        break;
611      }
612    }
613
614    for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
615      activeMouseHandlers_[i]->mouseButtonReleased((MouseButton::Enum)id);
616
617    return true;
618  }
619
620
621  // ###### Joy Stick Events ######
622
623  bool InputManager::buttonPressed(const OIS::JoyStickEvent &arg, int button)
624  {
625    // use the device to identify which one called the method
626    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
627    unsigned int iJoyStick = 0;
628    while (joySticks_[iJoyStick] != joyStick)
629      iJoyStick++;
630
631    // check whether the button already is in the list (can happen when focus was lost)
632    std::vector<int>& buttonsDown = joyStickButtonsDown_[iJoyStick];
633    unsigned int iButton = 0;
634    while (iButton < buttonsDown.size() && buttonsDown[iButton] != button)
635      iButton++;
636    if (iButton == buttonsDown.size())
637      buttonsDown.push_back(button);
638
639    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
640      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickButtonPressed(iJoyStick, button);
641
642    return true;
643  }
644
645  bool InputManager::buttonReleased(const OIS::JoyStickEvent &arg, int button)
646  {
647    // use the device to identify which one called the method
648    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
649    unsigned int iJoyStick = 0;
650    while (joySticks_[iJoyStick] != joyStick)
651      iJoyStick++;
652
653    // remove the button from the joyStickButtonsDown_ list
654    std::vector<int>& buttonsDown = joyStickButtonsDown_[iJoyStick];
655    for (unsigned int iButton = 0; iButton < buttonsDown.size(); iButton++)
656    {
657      if (buttonsDown[iButton] == button)
658      {
659        buttonsDown.erase(buttonsDown.begin() + iButton);
660        break;
661      }
662    }
663
664    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
665      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickButtonReleased(iJoyStick, button);
666
667    return true;
668  }
669
670  bool InputManager::axisMoved(const OIS::JoyStickEvent &arg, int axis)
671  {
672    //if (arg.state.mAxes[axis].abs > 10000 || arg.state.mAxes[axis].abs < -10000)
673    //{ CCOUT(3) << "axis " << axis << " moved" << arg.state.mAxes[axis].abs << std::endl;}
674    // use the device to identify which one called the method
675    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
676    unsigned int iJoyStick = 0;
677    while (joySticks_[iJoyStick] != joyStick)
678      iJoyStick++;
679
680    // keep in mind that the first 8 axes are reserved for the sliders
681    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
682      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickAxisMoved(iJoyStick, axis + 8, arg.state.mAxes[axis].abs);
683
684    return true;
685  }
686
687  bool InputManager::sliderMoved(const OIS::JoyStickEvent &arg, int id)
688  {
689    //if (arg.state.mSliders[id].abX > 10000 || arg.state.mSliders[id].abX < -10000)
690    //{CCOUT(3) << "slider " << id << " moved" << arg.state.mSliders[id].abX << std::endl;}
691    //CCOUT(3) << arg.state.mSliders[id].abX << "\t |" << arg.state.mSliders[id].abY << std::endl;
692    // use the device to identify which one called the method
693    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
694    unsigned int iJoyStick = 0;
695    while (joySticks_[iJoyStick] != joyStick)
696      iJoyStick++;
697
698    if (sliderStates_[iJoyStick].sliderStates[id].x != arg.state.mSliders[id].abX)
699    {
700      // slider X axis changed
701      sliderStates_[iJoyStick].sliderStates[id].x = arg.state.mSliders[id].abX;
702      for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
703        activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickAxisMoved(iJoyStick, id * 2, arg.state.mSliders[id].abX);
704    }
705    else if (sliderStates_[iJoyStick].sliderStates[id].y != arg.state.mSliders[id].abY)
706    {
707      // slider Y axis changed
708      sliderStates_[iJoyStick].sliderStates[id].y = arg.state.mSliders[id].abY;
709      for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
710        activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickAxisMoved(iJoyStick, id * 2 + 1, arg.state.mSliders[id].abY);
711    }
712
713    return true;
714  }
715
716  bool InputManager::povMoved(const OIS::JoyStickEvent &arg, int id)
717  {
718    // use the device to identify which one called the method
719    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
720    unsigned int iJoyStick = 0;
721    while (joySticks_[iJoyStick] != joyStick)
722      iJoyStick++;
723
724    // translate the POV into 8 simple buttons
725    int lastState = povStates_[iJoyStick][id];
726    if (lastState & OIS::Pov::North)
727      buttonReleased(arg, 32 + id * 4 + 0);
728    if (lastState & OIS::Pov::South)
729      buttonReleased(arg, 32 + id * 4 + 1);
730    if (lastState & OIS::Pov::East)
731      buttonReleased(arg, 32 + id * 4 + 2);
732    if (lastState & OIS::Pov::West)
733      buttonReleased(arg, 32 + id * 4 + 3);
734   
735    povStates_[iJoyStick].povStates[id] = arg.state.mPOV[id].direction;
736    int currentState = povStates_[iJoyStick][id];
737    if (currentState & OIS::Pov::North)
738      buttonPressed(arg, 32 + id * 4 + 0);
739    if (currentState & OIS::Pov::South)
740      buttonPressed(arg, 32 + id * 4 + 1);
741    if (currentState & OIS::Pov::East)
742      buttonPressed(arg, 32 + id * 4 + 2);
743    if (currentState & OIS::Pov::West)
744      buttonPressed(arg, 32 + id * 4 + 3);
745
746    return true;
747  }
748
749  /*bool InputManager::vector3Moved(const OIS::JoyStickEvent &arg, int id)
750  {
751    // use the device to identify which one called the method
752    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
753    unsigned int iJoyStick = 0;
754    while (joySticks_[iJoyStick] != joyStick)
755      iJoyStick++;
756
757    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
758      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickVector3Moved(JoyStickState(arg.state, iJoyStick), id);
759
760    return true;
761  }*/
762
763
764  // ################################
765  // ### Static Interface Methods ###
766  // ################################
767  // ################################
768
769  bool InputManager::initialise(const size_t windowHnd, int windowWidth, int windowHeight,
770    bool createKeyboard, bool createMouse, bool createJoySticks)
771  {
772    return _getSingleton()._initialise(windowHnd, windowWidth, windowHeight,
773          createKeyboard, createMouse, createJoySticks);
774  }
775
776  bool InputManager::initialiseKeyboard()
777  {
778    return _getSingleton()._initialiseKeyboard();
779  }
780
781  bool InputManager::initialiseMouse()
782  {
783    return _getSingleton()._initialiseMouse();
784  }
785
786  bool InputManager::initialiseJoySticks()
787  {
788    return _getSingleton()._initialiseJoySticks();
789  }
790
791  int InputManager::numberOfKeyboards()
792  {
793    if (_getSingleton().keyboard_ != 0)
794      return 1;
795    else
796      return 0;
797  }
798
799  int InputManager::numberOfMice()
800  {
801    if (_getSingleton().mouse_ != 0)
802      return 1;
803    else
804      return 0;
805  }
806
807  int InputManager::numberOfJoySticks()
808  {
809    return _getSingleton().joySticksSize_;
810  }
811
812  /*bool InputManager::isKeyDown(KeyCode::Enum key)
813  {
814    if (_getSingleton().keyboard_)
815      return _getSingleton().keyboard_->isKeyDown((OIS::KeyCode)key);
816    else
817      return false;
818  }*/
819
820  /*bool InputManager::isModifierDown(KeyboardModifier::Enum modifier)
821  {
822    if (_getSingleton().keyboard_)
823      return isModifierDown(modifier);
824    else
825      return false;
826  }*/
827
828  /*const MouseState InputManager::getMouseState()
829  {
830    if (_getSingleton().mouse_)
831      return _getSingleton().mouse_->getMouseState();
832    else
833      return MouseState();
834  }*/
835
836  /*const JoyStickState InputManager::getJoyStickState(unsigned int ID)
837  {
838    if (ID < _getSingleton().joySticksSize_)
839      return JoyStickState(_getSingleton().joySticks_[ID]->getJoyStickState(), ID);
840    else
841      return JoyStickState();
842  }*/
843
844  void InputManager::destroy()
845  {
846    _getSingleton()._destroy();
847  }
848
849  void InputManager::destroyKeyboard()
850  {
851    return _getSingleton()._destroyKeyboard();
852  }
853
854  void InputManager::destroyMouse()
855  {
856    return _getSingleton()._destroyMouse();
857  }
858
859  void InputManager::destroyJoySticks()
860  {
861    return _getSingleton()._destroyJoySticks();
862  }
863
864
865  /**
866    @brief Adjusts the mouse window metrics.
867    This method has to be called every time the size of the window changes.
868    @param width The new width of the render window
869    @param height the new height of the render window
870  */
871  void InputManager::setWindowExtents(const int width, const int height)
872  {
873    if (_getSingleton().mouse_)
874    {
875      // Set mouse region (if window resizes, we should alter this to reflect as well)
876      const OIS::MouseState &mouseState = _getSingleton().mouse_->getMouseState();
877      mouseState.width  = width;
878      mouseState.height = height;
879    }
880  }
881
882  /**
883    @brief Sets the input mode to either GUI, inGame or Buffer
884    @param mode The new input mode
885    @remark Only has an affect if the mode actually changes
886  */
887  void InputManager::setInputState(const InputState state)
888  {
889    _getSingleton().stateRequest_ = state;
890  }
891
892  /**
893    @brief Returns the current input handling method
894    @return The current input mode.
895  */
896  InputManager::InputState InputManager::getInputState()
897  {
898    return _getSingleton().state_;
899  }
900
901  void InputManager::storeKeyStroke(const std::string& name)
902  {
903    if (_getSingleton().lastStroke_ == "")
904      _getSingleton().lastStroke_ = name;
905  }
906
907  const std::string& InputManager::getLastKeyStroke()
908  {
909    return _getSingleton().lastStroke_;
910  }
911
912
913  // ###### KeyHandler ######
914
915  /**
916    @brief Adds a new key handler.
917    @param handler Pointer to the handler object.
918    @param name Unique name of the handler.
919    @return True if added, false if name already existed.
920  */
921  bool InputManager::addKeyHandler(KeyHandler* handler, const std::string& name)
922  {
923    if (!handler)
924      return false;
925    if (_getSingleton().keyHandlers_.find(name) == _getSingleton().keyHandlers_.end())
926    {
927      _getSingleton().keyHandlers_[name] = handler;
928      return true;
929    }
930    else
931      return false;
932  }
933
934  /**
935    @brief Removes a Key handler from the list.
936    @param name Unique name of the handler.
937    @return True if removal was successful, false if name was not found.
938  */
939  bool InputManager::removeKeyHandler(const std::string &name)
940  {
941    disableKeyHandler(name);
942    std::map<std::string, KeyHandler*>::iterator it = _getSingleton().keyHandlers_.find(name);
943    if (it != _getSingleton().keyHandlers_.end())
944    {
945      _getSingleton().keyHandlers_.erase(it);
946      return true;
947    }
948    else
949      return false;
950  }
951
952  /**
953    @brief Returns the pointer to a handler.
954    @param name Unique name of the handler.
955    @return Pointer to the instance, 0 if name was not found.
956  */
957  KeyHandler* InputManager::getKeyHandler(const std::string& name)
958  {
959    std::map<std::string, KeyHandler*>::iterator it = _getSingleton().keyHandlers_.find(name);
960    if (it != _getSingleton().keyHandlers_.end())
961    {
962      return (*it).second;
963    }
964    else
965      return 0;
966  }
967
968  /**
969    @brief Enables a specific key handler that has already been added.
970    @param name Unique name of the handler.
971    @return False if name was not found, true otherwise.
972  */
973  bool InputManager::enableKeyHandler(const std::string& name)
974  {
975    // get pointer from the map with all stored handlers
976    std::map<std::string, KeyHandler*>::const_iterator mapIt = _getSingleton().keyHandlers_.find(name);
977    if (mapIt == _getSingleton().keyHandlers_.end())
978      return false;
979    // see whether the handler already is in the list
980    for (std::vector<KeyHandler*>::iterator it = _getSingleton().activeKeyHandlers_.begin();
981          it != _getSingleton().activeKeyHandlers_.end(); it++)
982    {
983      if ((*it) == (*mapIt).second)
984      {
985        return true;
986      }
987    }
988    _getSingleton().activeKeyHandlers_.push_back((*mapIt).second);
989    _getSingleton().stateRequest_ = IS_CUSTOM;
990    _getSingleton()._updateTickables();
991    return true;
992  }
993
994  /**
995    @brief Disables a specific key handler.
996    @param name Unique name of the handler.
997    @return False if name was not found, true otherwise.
998  */
999  bool InputManager::disableKeyHandler(const std::string &name)
1000  {
1001    // get pointer from the map with all stored handlers
1002    std::map<std::string, KeyHandler*>::const_iterator mapIt = _getSingleton().keyHandlers_.find(name);
1003    if (mapIt == _getSingleton().keyHandlers_.end())
1004      return false;
1005    // look for the handler in the list
1006    for (std::vector<KeyHandler*>::iterator it = _getSingleton().activeKeyHandlers_.begin();
1007          it != _getSingleton().activeKeyHandlers_.end(); it++)
1008    {
1009      if ((*it) == (*mapIt).second)
1010      {
1011        _getSingleton().activeKeyHandlers_.erase(it);
1012        _getSingleton().stateRequest_ = IS_CUSTOM;
1013        _getSingleton()._updateTickables();
1014        return true;
1015      }
1016    }
1017    return true;
1018  }
1019
1020  /**
1021    @brief Checks whether a key handler is active
1022    @param name Unique name of the handler.
1023    @return False if key handler is not active or doesn't exist, true otherwise.
1024  */
1025  bool InputManager::isKeyHandlerActive(const std::string& name)
1026  {
1027    // get pointer from the map with all stored handlers
1028    std::map<std::string, KeyHandler*>::const_iterator mapIt = _getSingleton().keyHandlers_.find(name);
1029    if (mapIt == _getSingleton().keyHandlers_.end())
1030      return false;
1031    // see whether the handler already is in the list
1032    for (std::vector<KeyHandler*>::iterator it = _getSingleton().activeKeyHandlers_.begin();
1033          it != _getSingleton().activeKeyHandlers_.end(); it++)
1034    {
1035      if ((*it) == (*mapIt).second)
1036        return true;
1037    }
1038    return false;
1039  }
1040
1041
1042  // ###### MouseHandler ######
1043  /**
1044    @brief Adds a new mouse handler.
1045    @param handler Pointer to the handler object.
1046    @param name Unique name of the handler.
1047    @return True if added, false if name already existed.
1048  */
1049  bool InputManager::addMouseHandler(MouseHandler* handler, const std::string& name)
1050  {
1051    if (!handler)
1052      return false;
1053    if (_getSingleton().mouseHandlers_.find(name) == _getSingleton().mouseHandlers_.end())
1054    {
1055      _getSingleton().mouseHandlers_[name] = handler;
1056      return true;
1057    }
1058    else
1059      return false;
1060  }
1061
1062  /**
1063    @brief Removes a Mouse handler from the list.
1064    @param name Unique name of the handler.
1065    @return True if removal was successful, false if name was not found.
1066  */
1067  bool InputManager::removeMouseHandler(const std::string &name)
1068  {
1069    disableMouseHandler(name);
1070    std::map<std::string, MouseHandler*>::iterator it = _getSingleton().mouseHandlers_.find(name);
1071    if (it != _getSingleton().mouseHandlers_.end())
1072    {
1073      _getSingleton().mouseHandlers_.erase(it);
1074      return true;
1075    }
1076    else
1077      return false;
1078  }
1079
1080  /**
1081    @brief Returns the pointer to a handler.
1082    @param name Unique name of the handler.
1083    @return Pointer to the instance, 0 if name was not found.
1084  */
1085  MouseHandler* InputManager::getMouseHandler(const std::string& name)
1086  {
1087    std::map<std::string, MouseHandler*>::iterator it = _getSingleton().mouseHandlers_.find(name);
1088    if (it != _getSingleton().mouseHandlers_.end())
1089    {
1090      return (*it).second;
1091    }
1092    else
1093      return 0;
1094  }
1095
1096  /**
1097    @brief Enables a specific mouse handler that has already been added.
1098    @param name Unique name of the handler.
1099    @return False if name was not found, true otherwise.
1100  */
1101  bool InputManager::enableMouseHandler(const std::string& name)
1102  {
1103    // get pointer from the map with all stored handlers
1104    std::map<std::string, MouseHandler*>::const_iterator mapIt = _getSingleton().mouseHandlers_.find(name);
1105    if (mapIt == _getSingleton().mouseHandlers_.end())
1106      return false;
1107    // see whether the handler already is in the list
1108    for (std::vector<MouseHandler*>::iterator it = _getSingleton().activeMouseHandlers_.begin();
1109          it != _getSingleton().activeMouseHandlers_.end(); it++)
1110    {
1111      if ((*it) == (*mapIt).second)
1112      {
1113        return true;
1114      }
1115    }
1116    _getSingleton().activeMouseHandlers_.push_back((*mapIt).second);
1117    _getSingleton().stateRequest_ = IS_CUSTOM;
1118    _getSingleton()._updateTickables();
1119    return true;
1120  }
1121
1122  /**
1123    @brief Disables a specific mouse handler.
1124    @param name Unique name of the handler.
1125    @return False if name was not found, true otherwise.
1126  */
1127  bool InputManager::disableMouseHandler(const std::string &name)
1128  {
1129    // get pointer from the map with all stored handlers
1130    std::map<std::string, MouseHandler*>::const_iterator mapIt = _getSingleton().mouseHandlers_.find(name);
1131    if (mapIt == _getSingleton().mouseHandlers_.end())
1132      return false;
1133    // look for the handler in the list
1134    for (std::vector<MouseHandler*>::iterator it = _getSingleton().activeMouseHandlers_.begin();
1135          it != _getSingleton().activeMouseHandlers_.end(); it++)
1136    {
1137      if ((*it) == (*mapIt).second)
1138      {
1139        _getSingleton().activeMouseHandlers_.erase(it);
1140        _getSingleton().stateRequest_ = IS_CUSTOM;
1141        _getSingleton()._updateTickables();
1142        return true;
1143      }
1144    }
1145    return true;
1146  }
1147
1148  /**
1149    @brief Checks whether a mouse handler is active
1150    @param name Unique name of the handler.
1151    @return False if key handler is not active or doesn't exist, true otherwise.
1152  */
1153  bool InputManager::isMouseHandlerActive(const std::string& name)
1154  {
1155    // get pointer from the map with all stored handlers
1156    std::map<std::string, MouseHandler*>::const_iterator mapIt = _getSingleton().mouseHandlers_.find(name);
1157    if (mapIt == _getSingleton().mouseHandlers_.end())
1158      return false;
1159    // see whether the handler already is in the list
1160    for (std::vector<MouseHandler*>::iterator it = _getSingleton().activeMouseHandlers_.begin();
1161          it != _getSingleton().activeMouseHandlers_.end(); it++)
1162    {
1163      if ((*it) == (*mapIt).second)
1164        return true;
1165    }
1166    return false;
1167  }
1168
1169
1170  // ###### JoyStickHandler ######
1171
1172  /**
1173    @brief Adds a new joy stick handler.
1174    @param handler Pointer to the handler object.
1175    @param name Unique name of the handler.
1176    @return True if added, false if name already existed.
1177  */
1178  bool InputManager::addJoyStickHandler(JoyStickHandler* handler, const std::string& name)
1179  {
1180    if (!handler)
1181      return false;
1182    if (_getSingleton().joyStickHandlers_.find(name) == _getSingleton().joyStickHandlers_.end())
1183    {
1184      _getSingleton().joyStickHandlers_[name] = handler;
1185      return true;
1186    }
1187    else
1188      return false;
1189  }
1190
1191  /**
1192    @brief Removes a JoyStick handler from the list.
1193    @param name Unique name of the handler.
1194    @return True if removal was successful, false if name was not found.
1195  */
1196  bool InputManager::removeJoyStickHandler(const std::string &name)
1197  {
1198    for (std::vector<OIS::JoyStick*>::iterator itstick = _getSingleton().joySticks_.begin();
1199          itstick != _getSingleton().joySticks_.end(); itstick++)
1200      disableJoyStickHandler(name, itstick - _getSingleton().joySticks_.begin());
1201
1202    std::map<std::string, JoyStickHandler*>::iterator it = _getSingleton().joyStickHandlers_.find(name);
1203    if (it != _getSingleton().joyStickHandlers_.end())
1204    {
1205      _getSingleton().joyStickHandlers_.erase(it);
1206      return true;
1207    }
1208    else
1209      return false;
1210  }
1211
1212  /**
1213    @brief Returns the pointer to a handler.
1214    @param name Unique name of the handler.
1215    @return Pointer to the instance, 0 if name was not found.
1216  */
1217  JoyStickHandler* InputManager::getJoyStickHandler(const std::string& name)
1218  {
1219    std::map<std::string, JoyStickHandler*>::iterator it = _getSingleton().joyStickHandlers_.find(name);
1220    if (it != _getSingleton().joyStickHandlers_.end())
1221    {
1222      return (*it).second;
1223    }
1224    else
1225      return 0;
1226  }
1227
1228  /**
1229    @brief Enables a specific joy stick handler that has already been added.
1230    @param name Unique name of the handler.
1231    @return False if name or id was not found, true otherwise.
1232  */
1233  bool InputManager::enableJoyStickHandler(const std::string& name, unsigned int ID)
1234  {
1235    // get handler pointer from the map with all stored handlers
1236    std::map<std::string, JoyStickHandler*>::const_iterator handlerIt = _getSingleton().joyStickHandlers_.find(name);
1237    if (handlerIt == _getSingleton().joyStickHandlers_.end())
1238      return false;
1239
1240    // check for existence of the ID
1241    if (ID >= _getSingleton().joySticksSize_)
1242      return false;
1243
1244    // see whether the handler already is in the list
1245    for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[ID].begin();
1246          it != _getSingleton().activeJoyStickHandlers_[ID].end(); it++)
1247    {
1248      if ((*it) == (*handlerIt).second)
1249      {
1250        return true;
1251      }
1252    }
1253    _getSingleton().activeJoyStickHandlers_[ID].push_back((*handlerIt).second);
1254    _getSingleton().stateRequest_ = IS_CUSTOM;
1255    _getSingleton()._updateTickables();
1256    return true;
1257  }
1258
1259  /**
1260    @brief Disables a specific joy stick handler.
1261    @param name Unique name of the handler.
1262    @return False if name or id was not found, true otherwise.
1263  */
1264  bool InputManager::disableJoyStickHandler(const std::string &name, unsigned int ID)
1265  {
1266    // get handler pointer from the map with all stored handlers
1267    std::map<std::string, JoyStickHandler*>::const_iterator handlerIt = _getSingleton().joyStickHandlers_.find(name);
1268    if (handlerIt == _getSingleton().joyStickHandlers_.end())
1269      return false;
1270
1271    // check for existence of the ID
1272    if (ID >= _getSingleton().joySticksSize_)
1273      return false;
1274
1275    // look for the handler in the list
1276    for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[ID].begin();
1277          it != _getSingleton().activeJoyStickHandlers_[ID].end(); it++)
1278    {
1279      if ((*it) == (*handlerIt).second)
1280      {
1281        _getSingleton().activeJoyStickHandlers_[ID].erase(it);
1282        _getSingleton().stateRequest_ = IS_CUSTOM;
1283        _getSingleton()._updateTickables();
1284        return true;
1285      }
1286    }
1287    return true;
1288  }
1289
1290  /**
1291    @brief Checks whether a joy stick handler is active
1292    @param name Unique name of the handler.
1293    @return False if key handler is not active or doesn't exist, true otherwise.
1294  */
1295  bool InputManager::isJoyStickHandlerActive(const std::string& name, unsigned int ID)
1296  {
1297    // get handler pointer from the map with all stored handlers
1298    std::map<std::string, JoyStickHandler*>::const_iterator handlerIt = _getSingleton().joyStickHandlers_.find(name);
1299    if (handlerIt == _getSingleton().joyStickHandlers_.end())
1300      return false;
1301
1302    // check for existence of the ID
1303    if (ID >= _getSingleton().joySticksSize_)
1304      return false;
1305
1306    // see whether the handler already is in the list
1307    for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[ID].begin();
1308          it != _getSingleton().activeJoyStickHandlers_[ID].end(); it++)
1309    {
1310      if ((*it) == (*handlerIt).second)
1311        return true;
1312    }
1313    return false;
1314  }
1315
1316}
Note: See TracBrowser for help on using the repository browser.