OMKInputExtension.h

Go to the documentation of this file.
00001 /************************************************************************/
00002 /* This file is part of openMask(c) INRIA, CNRS, Universite de Rennes 1 */
00003 /* 1993-2002, thereinafter the Software                                 */
00004 /*                                                                      */
00005 /* The Software has been developped within the Siames Project.          */
00006 /* INRIA, the University of Rennes 1 and CNRS jointly hold intellectual */
00007 /* property rights                                                      */
00008 /*                                                                      */
00009 /* The Software has been registered with the Agence pour la Protection  */
00010 /* des Programmes (APP) under registration number                       */
00011 /* IDDN.FR.001.510008.00.S.P.2001.000.41200                             */
00012 /*                                                                      */
00013 /* This file may be distributed under the terms of the Q Public License */
00014 /* version 1.0 as defined by Trolltech AS of Norway and appearing in    */
00015 /* the file LICENSE.QPL included in the packaging of this file.         */
00016 /*                                                                      */
00017 /* Licensees holding valid specific licenses issued by INRIA, CNRS or   */
00018 /* Universite Rennes 1 for the software may use this file in            */
00019 /* acordance with that specific license                                 */
00020 /************************************************************************/
00021 #ifndef OMK_INP_INPUTEXTENSION_H
00022 #define OMK_INP_INPUTEXTENSION_H
00023 
00024 #include "OMKEventListenerCallBack.h"
00025 #include "OMKExtension.h"
00026 #include "OISInputManager.h"
00027 #include "OISException.h"
00028 #include "OISKeyboard.h"
00029 #include "OISMouse.h"
00030 #include "OISJoyStick.h"
00031 #include "OISEvents.h"
00032 #include "OMKOgreVis.h"
00033 #include "OBTPrototypeFactory.h"
00034 #include "OMKInputs.h"
00035 
00036 namespace OMK
00037 {
00038     namespace Inp
00039     {
00040  
00041 //-----------------------------------------------------------------------------
00042 
00043 class AddInputListenerPrm ;
00044 class AddInputKeyPrm ;
00045 class InputListener ;
00046 class InputCreatorListener ;
00047  
00048 //-----------------------------------------------------------------------------
00049 
00288 class OMKINPUTS_API InputExtension 
00289 : public ExtensionT< OMK::Vis::OgreVis >,
00290   public OIS::KeyListener,
00291   public OIS::MouseListener,
00292   public OIS::JoyStickListener
00293 {
00294 public:
00296   static EventIdentifier ADD_INPUT ;
00298   static EventIdentifier REMOVE_INPUT ;
00300   static EventIdentifier ADD_KEY ;
00303   DECLARE_EXTENSION_FACTORY( InputExtension ) ;
00304 
00306 
00307 
00308   virtual bool loadExtensionParameters( const ConfigurationParameterDescriptor * node ) ;
00310   virtual void preComputeParameters() ;
00312 
00314 
00315 
00316   bool addListener( const Name& id, InputListener *listener ) ;
00318   bool addListener( const Name& id, 
00319                     const Name& classId, 
00320                     const ConfigurationParameterDescriptor* configParam ) ;
00323   bool addListener( const AddInputListenerPrm& prm ) ;
00325   bool removeListener( const Name& id ) ;
00327   bool addKeyListener( const std::string& key,
00328                        const Name& listeningObject ) ;
00330   bool addKeyListener( const AddInputKeyPrm& prm ) ;
00332   
00334 
00335 
00336 
00337 
00338 
00339 
00340 
00341 
00342 
00343 
00344 
00345 
00346 
00347 
00348 
00349 
00350 
00351 
00352 
00353 
00354 
00355 
00356 
00357 
00358 
00359 
00360 
00361 
00362 
00363 
00364 
00365 
00366 
00367 
00368 
00369 
00370 
00371 
00372 
00373 
00374 
00375 
00376 
00377 
00378 
00379 
00380 
00381 
00382 
00383 
00384 
00385 
00386 
00387 
00388 
00389 
00390 
00391 
00392 
00393 
00394 
00395 
00396   template< class CallerClass >
00397   static EventListenerCallBack< CallerClass >* initCallBackForKey( 
00398         const ConfigurationParameterDescriptor * node,
00399         const std::string& keyId,
00400         std::string& key,
00401         CallerClass* caller,
00402         typename EventListenerCallBack< CallerClass >::CallBackFct fct,
00403         SimulatedObject* sender,
00404         const std::string& visuName ) ;
00406 
00407 
00408 
00409 private:
00410   friend class InputCreatorListener ;
00412   InputExtension( const InputExtension& vis ) ;
00414   const InputExtension& operator=( const InputExtension& vis );
00417   void setWindowExtents( int width, int height )  ;
00419   void capture() ;
00421   void createOISInputSystem(const ConfigurationParameterDescriptor * node) ;
00423   void initOIS() ;
00424 
00425   
00427 
00428 
00429   virtual bool keyPressed( const OIS::KeyEvent &e );
00431   virtual bool keyReleased( const OIS::KeyEvent &e );
00433   virtual bool mouseMoved( const OIS::MouseEvent &e );
00435   virtual bool mousePressed( const OIS::MouseEvent &e, OIS::MouseButtonID id );
00437   virtual bool mouseReleased( const OIS::MouseEvent &e, OIS::MouseButtonID id );
00439   virtual bool povMoved( const OIS::JoyStickEvent &e, int pov );
00441   virtual bool axisMoved( const OIS::JoyStickEvent &e, int axis );
00443   virtual bool sliderMoved( const OIS::JoyStickEvent &e, int sliderID );
00445   virtual bool buttonPressed( const OIS::JoyStickEvent &e, int button );
00447   virtual bool buttonReleased( const OIS::JoyStickEvent &e, int button );
00449 
00450 protected:
00452 
00453 
00454   OIS::InputManager* _inputSystem;
00456 
00457 
00458 
00459   OIS::Keyboard* _keyboard ;
00461   OIS::Mouse* _mouse ;
00463   std::vector< OIS::JoyStick* > _joysticks ;
00465 
00467 
00468 
00469   std::map< Name, InputListener* > _inputListeners;
00471   std::map< Name, OIS::KeyListener* > _keyListeners;
00473   std::map< Name, OIS::MouseListener* > _mouseListeners;
00475   std::map< Name, OIS::JoyStickListener* > _joystickListeners;
00477 
00478   InputCreatorListener* _inputCreatorListener;
00480   unsigned int _currentWidth;
00482   unsigned int _currentHeight;
00484   Ogre::RenderWindow* _window;
00485 } ;    
00486  
00487 //-----------------------------------------------------------------------------
00488 
00497 class InputCreatorListener 
00498 : public EventListener
00499 {
00500 private:
00501   friend class InputExtension ;
00503   InputCreatorListener( OMK::Vis::OgreVis* owner, InputExtension* inputExtension ) ;
00505   virtual ~InputCreatorListener() ;
00506 
00508 
00509 
00510   virtual void registerEvents() ;
00512   virtual bool processEvent( Event * event ) ;
00514 
00516   InputExtension* _inputExtension ;
00517 } ;    
00518  
00519 //-----------------------------------------------------------------------------
00520 
00521     } // namespace Inp
00522 } // namespace OMK
00523 
00524 #endif // OMK_INP_INPUTEXTENSION_H

logo OpenMask

Documentation generated on Mon Jun 9 11:45:56 2008

Generated with doxygen by Dimitri van Heesch ,   1997-2007