⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 oasisinputsystembase.h

📁 使用stl技术,(还没看,是听说的)
💻 H
字号:
/******************************************************************************

 * This source file is part of Bad Camel Gaming

 * Copyright (C) 2003  Zephie Greyvenstein

 * See Readme.html for acknowledgements

 *

 * This library is free software; you can redistribute it and/or

 * modify it under the terms of the GNU Lesser General Public

 * License as published by the Free Software Foundation; either

 * version 2.1 of the License, or (at your option) any later version.

 *

 * This library is distributed in the hope that it will be useful,

 * but WITHOUT ANY WARRANTY; without even the implied warranty of

 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU

 * Lesser General Public License for more details.

 *

 * You should have received a copy of the GNU Lesser General Public

 * License along with this library; if not, write to the Free Software

 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

 *****************************************************************************/



/******************************************************************************

 * FILENAME    : oasisInputSystemBase.h

 * DESCRIPTION : The input system base

 * AUTHOR      : Zephie Greyvenstein

 *****************************************************************************/



/// Avoid double inclusion

#ifndef __INPUTSYSTEMBASE_H__

#define __INPUTSYSTEMBASE_H__



/// Include the common headers

#include "oasisCommon.h"

#include "oasisKeyListener.h"



/// Include Ogre stuff

#include "OgreEventListeners.h"

#include "OgreEventProcessor.h"

#include "OgreInput.h"

#include "OgreKeyEvent.h"

#include "OgreCamera.h"



namespace Oasis {

  /// The input system base

  class inputSystemBase : public Ogre::KeyListener,

                          public Ogre::MouseMotionListener,

                          public Ogre::MouseListener {

  public:

    /// Constructor

    inputSystemBase( );

    /// Deconstructor

    virtual ~inputSystemBase( );

      

    /// Register a key listener

    void addKeyListener( keyListener *newKeyListener );

    /// Remove a key listener

    void removeKeyListener( keyListener *oldKeyListener );



    /// Register a mouse listener

    void addMouseListener( mouseListener *newMouseListener );

    /// Remove a mouse listener

    void removeMouseListener( mouseListener *oldMouseListener );

    

    /// Get the state of a key

    const bool isKeyDown( keyListener::KeyCode code ) const;

    

  private:

    /// Handle to the event processor

    Ogre::EventProcessor *eventProcessor;

    /// Handle to the input reader

    Ogre::InputReader *inputReader;

    

    /// Key listener set

    typedef std::set< keyListener* > keyListenerSet;

    /// Mouse listener set

    typedef std::set< mouseListener* > mouseListenerSet;

    /// A vector of booleans

    typedef std::vector< bool > boolVector;



    /// Keylisteners

    keyListenerSet keyListeners;

    /// Mouselisteners

    mouseListenerSet mouseListeners;

    /// Key downs

    boolVector keyDowns;

    

    /// Overloaded keylistener functions

    void keyClicked( Ogre::KeyEvent *event );

    void keyPressed( Ogre::KeyEvent *event );

    void keyReleased( Ogre::KeyEvent *event );



    /// Overload mouse motionlistener functions

    void mouseMoved( Ogre::MouseEvent *event );

    void mouseDragged( Ogre::MouseEvent *event ) {}   



    /// Overload the mouse listener functions

    void mouseClicked( Ogre::MouseEvent *event ) {}

    void mouseEntered( Ogre::MouseEvent *event ) {}

    void mouseExited( Ogre::MouseEvent *event ) {}

    void mousePressed( Ogre::MouseEvent *event );

    void mouseReleased( Ogre::MouseEvent *event ) {}

  };  

};



#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -