Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 12, 2009, 4:12:04 PM (15 years ago)
Author:
rgrieder
Message:

Added a few more generic parts to the input library:

  • Created Mouse and Keyboard to join JoyStick and provided them with a templated base class (InputDeviceTemplated) that does most of the work (reduces quite some redundancy)
  • Created InputPrereqs.h from InputInterfaces.h and destroyed the latter
  • Exported InputHandler to its own file and replaced KeyHandler, MouseHandler and JoyStickHandler with the single InputHandler.
  • Deleted the SimpleInputState: There is only one class now which fulfills all our needs.

In general there is now less code and the code itself has more 'pluses'. However I haven't really thrown away any feature at all.

Location:
code/branches/core4/src/orxonox
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core4/src/orxonox/gamestates/GSGraphics.cc

    r3270 r3274  
    3838#include <OgreRenderWindow.h>
    3939
     40#include "util/Convert.h"
    4041#include "core/ConfigValueIncludes.h"
    4142#include "core/Clock.h"
     43#include "core/CommandExecutor.h"
    4244#include "core/ConsoleCommand.h"
    4345#include "core/Core.h"
     
    4749#include "core/input/InputManager.h"
    4850#include "core/input/KeyBinder.h"
    49 #include "core/input/SimpleInputState.h"
     51#include "core/input/InputState.h"
    5052#include "core/Loader.h"
    5153#include "core/XMLFile.h"
     
    125127
    126128        // load master key bindings
    127         masterInputState_ = InputManager::getInstance().createInputState<SimpleInputState>("master", true);
     129        masterInputState_ = InputManager::getInstance().createInputState("master", true);
    128130        masterKeyBinder_ = new KeyBinder();
    129131        masterKeyBinder_->loadBindings("masterKeybindings.ini");
     
    244246    {
    245247        // OIS needs this under linux even if we only use relative input measurement.
    246         if (this->inputManager_)
    247             this->inputManager_->setWindowExtents(newWidth, newHeight);
     248        // HACK:
     249        CommandExecutor::execute("setWindowExtents_s " + multi_cast<std::string>(newWidth) + " " + multi_cast<std::string>(newHeight));
    248250    }
    249251
  • code/branches/core4/src/orxonox/gamestates/GSGraphics.h

    r3243 r3274  
    7575
    7676        KeyBinder*            masterKeyBinder_;     //!< Key binder for master key bindings
    77         SimpleInputState*     masterInputState_;    //!< Special input state for master input
     77        InputState*           masterInputState_;    //!< Special input state for master input
    7878        XMLFile*              debugOverlay_;
    7979        ConsoleCommand*       ccToggleGUI_;         //!< Console command to toggle GUI
  • code/branches/core4/src/orxonox/gamestates/GSLevel.cc

    r3249 r3274  
    3131
    3232#include "core/input/InputManager.h"
    33 #include "core/input/SimpleInputState.h"
     33#include "core/input/InputState.h"
    3434#include "core/input/KeyBinder.h"
    3535#include "core/Clock.h"
     
    9090        if (GameMode::showsGraphics())
    9191        {
    92             gameInputState_ = InputManager::getInstance().createInputState<SimpleInputState>("game");
     92            gameInputState_ = InputManager::getInstance().createInputState("game");
    9393            keyBinder_ = new KeyBinder();
    9494            keyBinder_->loadBindings("keybindings.ini");
    9595            gameInputState_->setHandler(keyBinder_);
    9696
    97             guiMouseOnlyInputState_ = InputManager::getInstance().createInputState<SimpleInputState>("guiMouseOnly");
     97            guiMouseOnlyInputState_ = InputManager::getInstance().createInputState("guiMouseOnly");
    9898            guiMouseOnlyInputState_->setMouseHandler(GUIManager::getInstancePtr());
    9999
    100             guiKeysOnlyInputState_ = InputManager::getInstance().createInputState<SimpleInputState>("guiKeysOnly");
     100            guiKeysOnlyInputState_ = InputManager::getInstance().createInputState("guiKeysOnly");
    101101            guiKeysOnlyInputState_->setKeyHandler(GUIManager::getInstancePtr());
    102102
  • code/branches/core4/src/orxonox/gamestates/GSLevel.h

    r3245 r3274  
    6363
    6464        KeyBinder*            keyBinder_;               //!< tool that loads and manages the input bindings
    65         SimpleInputState*     gameInputState_;          //!< input state for normal ingame playing
    66         SimpleInputState*     guiMouseOnlyInputState_;  //!< input state if we only need the mouse to use the GUI
    67         SimpleInputState*     guiKeysOnlyInputState_;   //!< input state if we only need the keys to use the GUI
     65        InputState*           gameInputState_;          //!< input state for normal ingame playing
     66        InputState*           guiMouseOnlyInputState_;  //!< input state if we only need the mouse to use the GUI
     67        InputState*           guiKeysOnlyInputState_;   //!< input state if we only need the keys to use the GUI
    6868        Radar*                radar_;                   //!< represents the Radar (not the HUD part)
    6969        CameraManager*        cameraManager_;           //!< camera manager for this level
  • code/branches/core4/src/orxonox/gamestates/GSMainMenu.cc

    r3245 r3274  
    3232
    3333#include "core/input/InputManager.h"
    34 #include "core/input/SimpleInputState.h"
     34#include "core/input/InputState.h"
    3535#include "core/Game.h"
    3636#include "core/Clock.h"
     
    5757    void GSMainMenu::activate()
    5858    {
    59         inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("mainMenu");
     59        inputState_ = InputManager::getInstance().createInputState("mainMenu");
    6060        inputState_->setHandler(GUIManager::getInstancePtr());
    61         inputState_->setJoyStickHandler(&InputManager::EMPTY_HANDLER);
     61        inputState_->setJoyStickHandler(&InputHandler::EMPTY);
    6262
    6363        // create an empty Scene
  • code/branches/core4/src/orxonox/gamestates/GSMainMenu.h

    r3243 r3274  
    5353
    5454    private:
    55         SimpleInputState* inputState_;
     55        InputState*      inputState_;
    5656        Scene*            scene_;
    5757        Ogre::Camera*     camera_;
  • code/branches/core4/src/orxonox/gui/GUIManager.cc

    r3261 r3274  
    366366    void GUIManager::keyPressed(const KeyEvent& evt)
    367367    {
    368         guiSystem_->injectKeyDown(evt.key); guiSystem_->injectChar(evt.text);
     368        guiSystem_->injectKeyDown(evt.getKeyCode());
     369        guiSystem_->injectChar(evt.getText());
    369370    }
    370371    void GUIManager::keyReleased(const KeyEvent& evt)
    371372    {
    372         guiSystem_->injectKeyUp(evt.key);
     373        guiSystem_->injectKeyUp(evt.getKeyCode());
    373374    }
    374375
     
    382383        It is for CEGUI to process the event.
    383384    */
    384     void GUIManager::mouseButtonPressed(MouseButtonCode::ByEnum id)
     385    void GUIManager::buttonPressed(MouseButtonCode::ByEnum id)
    385386    {
    386387        try
     
    404405        It is for CEGUI to process the event.
    405406    */
    406     void GUIManager::mouseButtonReleased(MouseButtonCode::ByEnum id)
     407    void GUIManager::buttonReleased(MouseButtonCode::ByEnum id)
    407408    {
    408409        try
  • code/branches/core4/src/orxonox/gui/GUIManager.h

    r3261 r3274  
    4444
    4545#include "util/OgreForwardRefs.h"
    46 #include "core/input/InputInterfaces.h"
     46#include "core/input/InputHandler.h"
    4747
    4848// tolua_begin
     
    6262    class _OrxonoxExport GUIManager
    6363// tolua_end
    64         : public KeyHandler, public MouseHandler
     64        : public InputHandler
    6565// tolua_begin
    6666    {
     
    106106        void keyPressed (const KeyEvent& evt);
    107107        void keyReleased(const KeyEvent& evt);
    108         void keyHeld    (const KeyEvent& evt) { }
    109108
    110109        // mouseHandler functions
    111         void mouseButtonPressed (MouseButtonCode::ByEnum id);
    112         void mouseButtonReleased(MouseButtonCode::ByEnum id);
    113         void mouseButtonHeld    (MouseButtonCode::ByEnum id) { }
    114         void mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize);
    115         void mouseScrolled      (int abs, int rel);
    116 
    117         void updateInput(float dt)  { }
    118         void updateKey  (float dt)  { }
    119         void updateMouse(float dt)  { }
     110        void buttonPressed (MouseButtonCode::ByEnum id);
     111        void buttonReleased(MouseButtonCode::ByEnum id);
     112        void mouseMoved    (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize);
     113        void mouseScrolled (int abs, int rel);
    120114
    121115        Ogre::RenderWindow*         renderWindow_;      //!< Ogre's render window to give CEGUI access to it
  • code/branches/core4/src/orxonox/overlays/console/InGameConsole.cc

    r3265 r3274  
    4949#include "core/ConsoleCommand.h"
    5050#include "core/input/InputManager.h"
    51 #include "core/input/SimpleInputState.h"
     51#include "core/input/InputState.h"
    5252#include "core/input/InputBuffer.h"
    5353
     
    158158            if (bHidesAllInput_)
    159159            {
    160                 inputState_->setMouseHandler(&InputManager::EMPTY_HANDLER);
    161                 inputState_->setJoyStickHandler(&InputManager::EMPTY_HANDLER);
     160                inputState_->setMouseHandler(&InputHandler::EMPTY);
     161                inputState_->setJoyStickHandler(&InputHandler::EMPTY);
    162162            }
    163163            else
     
    175175    {
    176176        // create the corresponding input state
    177         inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("console", false, false, InputStatePriority::Console);
     177        inputState_ = InputManager::getInstance().createInputState("console", false, false, InputStatePriority::Console);
    178178        inputState_->setKeyHandler(Shell::getInstance().getInputBuffer());
    179179        bHidesAllInputChanged();
  • code/branches/core4/src/orxonox/overlays/console/InGameConsole.h

    r3196 r3274  
    101101
    102102        // input related
    103         SimpleInputState* inputState_;
     103        InputState* inputState_;
    104104
    105105        // config values
Note: See TracChangeset for help on using the changeset viewer.