Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 23, 2008, 3:37:29 PM (16 years ago)
Author:
rgrieder
Message:
  • changed the static interface of the InputManager to a member one with getInstance()
  • converted InputManager and InGameConsole to Ogre Singletons (c'tor and d'tor public, but assert in c'tor to prevent multiple instances at runtime)
  • added toluabind_orxonox files to tolua folder that contains a pimped version of tolua (I'll write a little cmake project soon to automate it; Currently that only works with msvc)
  • commented out Loader::unload() from Orxonox destructor because that deleted the ParticleSpawners, which were using a method of a sceneNode that belonged to a already destroyed SpaceShip. —> Results in a memory leak. Previously Loader::unload() was called for all BaseObjects (now calling unload(level_)). And since 'P' from ParticleSpawner comes before 'S' like SpaceShip, the order was correct.
  • Added factory feature for InputStates (can now be created by string if there is Factory entry for it)
  • Created factory entries for SimpleInputState and ExtendedInputState
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/gui/src/core/input/InputManager.h

    r1641 r1642  
    8686        // --> setConfigValues is private
    8787        friend ClassIdentifier<InputManager>;
    88 
    89     public: // static functions
    90         static bool initialise(const size_t windowHnd, int windowWidth, int windowHeight,
     88        // let Core class use tick(.)
     89        friend Core;
     90
     91    public:
     92        InputManager ();
     93        ~InputManager();
     94
     95        bool initialise(const size_t windowHnd, int windowWidth, int windowHeight,
    9196                               bool createKeyboard = true, bool createMouse = true, bool createJoySticks = false);
    92         static int  numberOfKeyboards();
    93         static int  numberOfMice();
    94         static int  numberOfJoySticks();
    95 
    96         static void destroy();
    97 
    98         //static bool isModifierDown(KeyboardModifier::Enum modifier);
    99         //static bool isKeyDown(KeyCode::Enum key);
    100         //static const MouseState getMouseState();
    101         //static const JoyStickState getJoyStickState(unsigned int ID);
    102 
    103         static void setWindowExtents(const int width, const int height);
    104 
     97
     98        int  numberOfKeyboards() { return keyboard_ ? 1 : 0; }
     99        int  numberOfMice()      { return mouse_    ? 1 : 0; }
     100        int  numberOfJoySticks() { return joySticksSize_; }
     101
     102        void setWindowExtents(const int width, const int height);
     103
     104        SimpleInputState*   createSimpleInputState  (const std::string& name, int priority);
     105        ExtendedInputState* createExtendedInputState(const std::string& name, int priority);
     106        InputState*         createInputState(const std::string& type, const std::string &name, int priority);
     107        bool destroyState          (const std::string& name);
     108        InputState* getState       (const std::string& name);
     109        InputState* getCurrentState();
     110        bool requestEnterState     (const std::string& name);
     111        bool requestLeaveState     (const std::string& name);
     112
     113        static InputManager& getInstance()    { assert(singletonRef_s); return *singletonRef_s; }
     114        static InputManager* getInstancePtr() { return singletonRef_s; }
     115
     116    public: // console commands
    105117        static void storeKeyStroke(const std::string& name);
    106118        static void keyBind(const std::string& command);
    107 
    108119        static void calibrate();
    109 
    110         static void tick(float dt);
    111 
    112         static SimpleInputState*   createSimpleInputState  (const std::string& name, int priority);
    113         static ExtendedInputState* createExtendedInputState(const std::string& name, int priority);
    114         static bool destroyState (const std::string& name);
    115         static InputState* getState       (const std::string& name);
    116         static InputState* getCurrentState();
    117         static bool requestEnterState     (const std::string& name);
    118         static bool requestLeaveState     (const std::string& name);
    119120
    120121    private: // functions
    121122        // don't mess with a Singleton
    122         InputManager ();
    123123        InputManager (const InputManager&);
    124         ~InputManager();
    125124
    126125        // Intenal methods
    127         bool _initialise(const size_t, int, int, bool, bool, bool);
    128126        bool _initialiseKeyboard();
    129127        bool _initialiseMouse();
     
    131129        void _redimensionLists();
    132130
    133         void _destroy();
    134131        void _destroyKeyboard();
    135132        void _destroyMouse();
     
    142139        unsigned int _getJoystick(const OIS::JoyStickEvent& arg);
    143140
    144         void _tick(float dt);
    145 
    146141        void _updateActiveStates();
    147142        bool _configureInputState(InputState* state, const std::string& name, int priority);
     143
     144        void tick(float dt);
    148145
    149146        // input events
     
    158155        bool sliderMoved   (const OIS::JoyStickEvent &arg, int id);
    159156        bool povMoved      (const OIS::JoyStickEvent &arg, int id);
     157        // don't remove that! Or else add OIS as dependency library to orxonox.
     158        bool vector3Moved  (const OIS::JoyStickEvent &arg, int id) { return true; }
    160159
    161160        void setConfigValues();
    162 
    163         static InputManager& _getInstance();
    164161
    165162    private: // variables
     
    204201
    205202        static std::string                  bindingCommmandString_s;
    206     };
    207 
     203        static InputManager*                singletonRef_s;
     204    };
    208205}
    209206
Note: See TracChangeset for help on using the changeset viewer.