Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 24, 2008, 1:12:31 PM (16 years ago)
Author:
rgrieder
Message:
  • AudioManager is now Tickable
  • NPC update moved to its tick-function
  • corrected CMakeLists
  • added a few window properties to GraphicsEngine
  • OrxListener has been completely replaced
File:
1 edited

Legend:

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

    r918 r919  
    2222 *      Reto Grieder
    2323 *   Co-authors:
    24  *      ...
     24 *      Some guy writing the example code from Ogre
    2525 *
    2626 */
     
    3434#include "OrxonoxStableHeaders.h"
    3535
    36 #include <OgreRenderWindow.h>
    37 
     36#include "Orxonox.h"
    3837#include "InputHandler.h"
    3938
     
    4241  //using namespace OIS;
    4342
     43  /**
     44    @brief Constructor only resets the pointer values to 0.
     45  */
    4446  InputHandler::InputHandler()
    4547  {
    46     RegisterObject(InputHandler);
    47   }
    48 
    49   void InputHandler::initialise(Ogre::RenderWindow *renderWindow)
     48    /*if (orxonox::Identifier::isCreatingHierarchy() && !this->getParents())
     49        this->createParents();
     50    this->setIdentifier(orxonox::ClassManager<InputHandler>::getIdentifier()->registerClass(this->getParents(), "InputHandler", true));
     51    if (orxonox::Identifier::isCreatingHierarchy() && this->getParents())
     52        this->getParents()->insert(this->getParents()->end(), this->getIdentifier());
     53    orxonox::ClassManager<InputHandler>::getIdentifier()->addObject(this);*/
     54
     55    //RegisterObject(InputHandler);
     56
     57    this->mouse_       = 0;
     58    this->keyboard_    = 0;
     59    this->inputSystem_ = 0;
     60
     61    //this->setConfigValues();
     62  }
     63
     64  void InputHandler::setConfigValues()
     65  {
     66    //SetConfigValue(codeFire_, 4).description("test value");
     67
     68    ConfigValueContainer *containercodeFire_ = new ConfigValueContainer("asdfblah", "codeFire_", 4);
     69    containercodeFire_->getValue(&codeFire_).description("test");
     70    //containercodeFire_->
     71  }
     72
     73  /**
     74    @brief The one instance of the InputHandler is stored in this function.
     75    @return The pointer to the only instance of the InputHandler
     76  */
     77  InputHandler* InputHandler::getSingleton()
     78  {
     79    static InputHandler theOnlyInstance;
     80    return &theOnlyInstance;
     81  }
     82
     83  /**
     84    @brief Creates the OIS::InputMananger, the keyboard and the mouse
     85    @param windowHnd The window handle of the render window
     86    @param windowWidth The width of the render window
     87    @param windowHeight The height of the render window
     88  */
     89  void InputHandler::initialise(size_t windowHnd, int windowWidth, int windowHeight)
    5090  {
    5191    if (!inputSystem_)
     
    5393      // Setup basic variables
    5494      OIS::ParamList paramList;
    55       size_t windowHnd = 0;
    5695      std::ostringstream windowHndStr;
    57 
    58       // Get window handle
    59       renderWindow->getCustomAttribute("WINDOW", &windowHnd);
    6096
    6197      // Fill parameter list
     
    67103
    68104      // If possible create a buffered keyboard
    69       // (note: if below line doesn't compile, try:  if (inputSystem_->getNumberOfDevices(OIS::OISKeyboard) > 0) {
    70105      if (inputSystem_->numKeyboards() > 0)
    71106      {
    72         //if (inputSystem_->getNumberOfDevices(OIS::OISKeyboard) > 0)
    73         //{
    74107        keyboard_ = static_cast<OIS::Keyboard*>(inputSystem_->createInputObject(OIS::OISKeyboard, true));
    75108        keyboard_->setEventCallback(this);
     
    77110
    78111      // If possible create a buffered mouse
    79       // (note: if below line doesn't compile, try:  if (inputSystem_->getNumberOfDevices(OIS::OISMouse) > 0) {
    80112      if (inputSystem_->numMice() > 0 )
    81113      {
    82         //if (inputSystem_->getNumberOfDevices(OIS::OISMouse) > 0)
    83         //{
    84114        mouse_ = static_cast<OIS::Mouse*>(inputSystem_->createInputObject(OIS::OISMouse, true));
    85115        mouse_->setEventCallback(this);
    86116
    87         // Get window size
    88         unsigned int width, height, depth;
    89         int left, top;
    90         renderWindow->getMetrics(width, height, depth, left, top);
    91 
    92117        // Set mouse region
    93         this->setWindowExtents(width, height);
     118        this->setWindowExtents(windowWidth, windowHeight);
    94119      }
    95120    }
    96121  }
    97122
     123  /**
     124    @brief Updates the InputHandler
     125    @param dt Delta time
     126  */
    98127  void InputHandler::tick(float dt)
    99128  {
     
    110139  }
    111140
     141  /**
     142    @brief Adjusts the mouse window metrics.
     143    This method has to be called every time the size of the window changes.
     144    @param width The new width of the render window
     145    @param height the new height of the render window
     146  */
    112147  void InputHandler::setWindowExtents(int width, int height)
    113148  {
     
    118153  }
    119154
     155  /**
     156    @brief Event handler for the keyPressed Event.
     157    @param e Event information
     158  */
    120159  bool InputHandler::keyPressed(const OIS::KeyEvent &e)
    121160  {
    122     return true;
    123   }
    124 
     161    if (e.key == OIS::KC_ESCAPE)
     162      Orxonox::getSingleton()->abortRequest();
     163    return true;
     164  }
     165
     166  /**
     167    @brief Event handler for the keyReleased Event.
     168    @param e Event information
     169  */
    125170  bool InputHandler::keyReleased(const OIS::KeyEvent &e)
    126171  {
     
    128173  }
    129174
     175  /**
     176    @brief Event handler for the mouseMoved Event.
     177    @param e Event information
     178  */
    130179  bool InputHandler::mouseMoved(const OIS::MouseEvent &e)
    131180  {
     
    133182  }
    134183
     184  /**
     185    @brief Event handler for the mousePressed Event.
     186    @param e Event information
     187    @param id The ID of the mouse button
     188  */
    135189  bool InputHandler::mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id)
    136190  {
     
    138192  }
    139193
     194  /**
     195    @brief Event handler for the mouseReleased Event.
     196    @param e Event information
     197    @param id The ID of the mouse button
     198  */
    140199  bool InputHandler::mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id)
    141200  {
Note: See TracChangeset for help on using the changeset viewer.