Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 10, 2008, 5:12:02 PM (16 years ago)
Author:
rgrieder
Message:
  • modified the input handler
  • few more little changes
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/input/src/orxonox/core/InputHandler.cc

    r973 r1022  
    3131 */
    3232
     33#include "Debug.h"
     34#include "util/Convert.h"
     35#include "InputEventListener.h"
     36#include "InputEvent.h"
    3337#include "InputHandler.h"
    3438
     
    5458
    5559  /**
     60    @brief Loads the key bindings from the ini file.
     61    Currently, this is just a simple test routine that fills the list with numbers.
     62  */
     63  bool InputHandlerGame::loadBindings()
     64  {
     65    for (int i = 0; i < numberOfKeys_s; i++)
     66    {
     67      // simply write the key number (i) in the string
     68      this->bindingsKeyPressed_[i] = ConvertValueAndReturn<int, std::string>(i);
     69      this->bindingsKeyReleased_[i] = ConvertValueAndReturn<int, std::string>(i);
     70    }
     71    return true;
     72  }
     73
     74  /**
    5675    @brief Event handler for the keyPressed Event.
    5776    @param e Event information
     
    5978  bool InputHandlerGame::keyPressed(const OIS::KeyEvent &e)
    6079  {
     80    if (e.key == OIS::KC_ESCAPE)
     81    {
     82      InputEvent e = {1, true, 0, 0, 0};
     83      InputHandlerGame::callListeners(e);
     84    }
     85    else
     86    {
     87      // find the appropriate key binding
     88      std::string cmdStr = bindingsKeyPressed_[int(e.key)];
     89      //COUT(3) << cmdStr << " pressed" << std::endl;
     90    }
    6191    return true;
    6292  }
     
    6898  bool InputHandlerGame::keyReleased(const OIS::KeyEvent &e)
    6999  {
     100    // find the appropriate key binding
     101    std::string cmdStr = bindingsKeyReleased_[int(e.key)];
     102    //COUT(3) << cmdStr << " released" << std::endl;
    70103    return true;
    71104  }
     
    100133  }
    101134
     135  /**
     136    @brief Calls all the objects from classes that derive from InputEventListener.
     137    @param evt The input event that occured.
     138  */
     139  inline void InputHandlerGame::callListeners(orxonox::InputEvent &evt)
     140  {
     141    for (Iterator<InputEventListener> it = ObjectList<InputEventListener>::start(); it; )
     142    {
     143      if (it->bActive_)
     144        (it++)->eventOccured(evt);
     145      else
     146        it++;
     147    }
     148  }
     149
     150
    102151  // ###############################
    103152  // ###     InputHandlerGUI     ###
     
    124173  bool InputHandlerGUI::keyPressed(const OIS::KeyEvent &e)
    125174  {
     175                //CEGUI::System::getSingleton().injectKeyDown( arg.key );
     176                //CEGUI::System::getSingleton().injectChar( arg.text );
    126177    return true;
    127178  }
     
    133184  bool InputHandlerGUI::keyReleased(const OIS::KeyEvent &e)
    134185  {
     186                //CEGUI::System::getSingleton().injectKeyUp( arg.key );
    135187    return true;
    136188  }
     
    142194  bool InputHandlerGUI::mouseMoved(const OIS::MouseEvent &e)
    143195  {
     196                //CEGUI::System::getSingleton().injectMouseMove( arg.state.X.rel, arg.state.Y.rel );
    144197    return true;
    145198  }
     
    152205  bool InputHandlerGUI::mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id)
    153206  {
     207                //CEGUI::System::getSingleton().injectMouseButtonDown(convertOISMouseButtonToCegui(id));
    154208    return true;
    155209  }
     
    162216  bool InputHandlerGUI::mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id)
    163217  {
     218                //CEGUI::System::getSingleton().injectMouseButtonUp(convertOISMouseButtonToCegui(id));
    164219    return true;
    165220  }
Note: See TracChangeset for help on using the changeset viewer.