Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 6, 2008, 12:31:32 AM (16 years ago)
Author:
rgrieder
Message:

FIRST THINGS FIRST: Delete or rename your keybindings.ini (def_keybindings.ini already has the most important bindings) or else you won't be able to do anything!

Changes:

  • Multiple joy stick support should now fully work with KeyBinder too (only tested with 0/1 joystick)
  • Reloading the OIS Devices now works with KeyBinder too
  • Modified ConfigValueContainer to accept arbitrary section names
  • added tkeybind to temporary bind a command to a key
  • Fixed dlleport issue in ArgumentCompletionFunctions.h

Internal changes:

  • General cleanup in initialisation of KeyBinder
  • All names of keys/buttons/axes are now statically saved in InputInterfaces.h
  • Move a magic value in KeyBinder to a configValue (MouseWheelStepSize_)
  • Separated ConfigValues from Keybinding ConfigValueContainer in KeyBinder (looks much nicer now ;))
  • Moved some performance critical small function to the inline section
  • Removed the ugly keybind function construct from the InputManager
  • More 'harmonising' work in KeyBinder
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/core/input/SimpleInputState.h

    r1881 r1887  
    3838
    3939#include <vector>
     40#include <cassert>
    4041#include "InputInterfaces.h"
    4142#include "InputState.h"
     
    6566        void keyHeld    (const KeyEvent& evt);
    6667
    67         void mouseButtonPressed (MouseButton::Enum id);
    68         void mouseButtonReleased(MouseButton::Enum id);
    69         void mouseButtonHeld    (MouseButton::Enum id);
     68        void mouseButtonPressed (MouseButtonCode::ByEnum id);
     69        void mouseButtonReleased(MouseButtonCode::ByEnum id);
     70        void mouseButtonHeld    (MouseButtonCode::ByEnum id);
    7071        void mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize);
    7172        void mouseScrolled      (int abs, int rel);
    7273
    73         void joyStickButtonPressed (unsigned int joyStickID, JoyStickButton::Enum id);
    74         void joyStickButtonReleased(unsigned int joyStickID, JoyStickButton::Enum id);
    75         void joyStickButtonHeld    (unsigned int joyStickID, JoyStickButton::Enum id);
     74        void joyStickButtonPressed (unsigned int joyStickID, JoyStickButtonCode::ByEnum id);
     75        void joyStickButtonReleased(unsigned int joyStickID, JoyStickButtonCode::ByEnum id);
     76        void joyStickButtonHeld    (unsigned int joyStickID, JoyStickButtonCode::ByEnum id);
    7677        void joyStickAxisMoved     (unsigned int joyStickID, unsigned int axis, float value);
    7778
     
    8384        std::vector<JoyStickHandler*> joyStickHandler_;
    8485        JoyStickHandler*              joyStickHandlerAll_;
    85         std::vector<InputHandler*>   allHandlers_;
     86        std::vector<InputHandler*>    allHandlers_;
    8687    };
     88
     89    inline void SimpleInputState::tickInput(float dt)
     90    {
     91        for (unsigned int i = 0; i < allHandlers_.size(); ++i)
     92        {
     93            allHandlers_[i]->tickInput(dt);
     94        }
     95    }
     96
     97    inline void SimpleInputState::tickInput(float dt, unsigned int device)
     98    {
     99        switch (device)
     100        {
     101        case InputDevice::Keyboard:
     102            if (keyHandler_)
     103                keyHandler_->tickKey(dt);
     104            break;
     105
     106        case InputDevice::Mouse:
     107            if (mouseHandler_)
     108                mouseHandler_->tickMouse(dt);
     109            break;
     110
     111        default: // joy sticks
     112            if (joyStickHandler_[device - 2])
     113                joyStickHandler_[device - 2]->tickJoyStick(dt, device - 2);
     114            break;
     115        }
     116    }
     117
     118    inline void SimpleInputState::keyReleased(const KeyEvent& evt)
     119    {
     120        if (keyHandler_)
     121            keyHandler_->keyReleased(evt);
     122    }
     123
     124    inline void SimpleInputState::keyHeld(const KeyEvent& evt)
     125    {
     126        if (keyHandler_)
     127            keyHandler_->keyHeld(evt);
     128    }
     129
     130    inline void SimpleInputState::mouseMoved(IntVector2 abs, IntVector2 rel, IntVector2 clippingSize)
     131    {
     132        if (mouseHandler_)
     133            mouseHandler_->mouseMoved(abs, rel, clippingSize);
     134    }
     135
     136    inline void SimpleInputState::mouseScrolled(int abs, int rel)
     137    {
     138        if (mouseHandler_)
     139            mouseHandler_->mouseScrolled(abs, rel);
     140    }
     141
     142    inline void SimpleInputState::mouseButtonPressed(MouseButtonCode::ByEnum id)
     143    {
     144        if (mouseHandler_)
     145            mouseHandler_->mouseButtonPressed(id);
     146    }
     147
     148    inline void SimpleInputState::mouseButtonReleased(MouseButtonCode::ByEnum id)
     149    {
     150        if (mouseHandler_)
     151            mouseHandler_->mouseButtonReleased(id);
     152    }
     153
     154    inline void SimpleInputState::mouseButtonHeld(MouseButtonCode::ByEnum id)
     155    {
     156        if (mouseHandler_)
     157            mouseHandler_->mouseButtonHeld(id);
     158    }
     159
     160    inline void SimpleInputState::joyStickAxisMoved(unsigned int joyStickID, unsigned int axis, float value)
     161    {
     162        assert(joyStickID < joyStickHandler_.size());
     163        if (joyStickHandler_[joyStickID])
     164            joyStickHandler_[joyStickID]->joyStickAxisMoved(joyStickID, axis, value);
     165    }
     166
     167    inline void SimpleInputState::joyStickButtonPressed(unsigned int joyStickID, JoyStickButtonCode::ByEnum id)
     168    {
     169        assert(joyStickID < joyStickHandler_.size());
     170        if (joyStickHandler_[joyStickID])
     171            joyStickHandler_[joyStickID]->joyStickButtonPressed(joyStickID, id);
     172    }
     173
     174    inline void SimpleInputState::joyStickButtonReleased(unsigned int joyStickID, JoyStickButtonCode::ByEnum id)
     175    {
     176        assert(joyStickID < joyStickHandler_.size());
     177        if (joyStickHandler_[joyStickID])
     178            joyStickHandler_[joyStickID]->joyStickButtonReleased(joyStickID, id);
     179    }
     180
     181    inline void SimpleInputState::joyStickButtonHeld(unsigned int joyStickID, JoyStickButtonCode::ByEnum id)
     182    {
     183        assert(joyStickID < joyStickHandler_.size());
     184        if (joyStickHandler_[joyStickID])
     185            joyStickHandler_[joyStickID]->joyStickButtonHeld(joyStickID, id);
     186    }
    87187}
    88188
Note: See TracChangeset for help on using the changeset viewer.