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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core4/src/core/input/InputBuffer.cc

    r3196 r3274  
    184184
    185185
    186     void InputBuffer::processKey(const KeyEvent &evt)
    187     {
    188         if (evt.isModifierDown(KeyboardModifier::Alt) && evt.key == KeyCode::Tab)
     186    void InputBuffer::processKey(const KeyEvent& evt)
     187    {
     188        if (evt.isModifierDown(KeyboardModifier::Alt) && evt.getKeyCode() == KeyCode::Tab)
    189189            return;
    190190
    191191        for (std::list<BaseInputBufferListenerTuple*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
    192192        {
    193             if ((*it)->trueKeyFalseChar_ && ((*it)->key_ == evt.key))
     193            if ((*it)->trueKeyFalseChar_ && ((*it)->key_ == evt.getKeyCode()))
    194194                (*it)->callFunction();
    195195        }
     
    197197        if (evt.isModifierDown(KeyboardModifier::Ctrl))
    198198        {
    199             if (evt.key == KeyCode::V)
     199            if (evt.getKeyCode() == KeyCode::V)
    200200                this->insert(fromClipboard());
    201             else if (evt.key == KeyCode::C)
     201            else if (evt.getKeyCode() == KeyCode::C)
    202202                toClipboard(this->buffer_);
    203             else if (evt.key == KeyCode::X)
     203            else if (evt.getKeyCode() == KeyCode::X)
    204204            {
    205205                toClipboard(this->buffer_);
     
    209209        else if (evt.isModifierDown(KeyboardModifier::Shift))
    210210        {
    211             if (evt.key == KeyCode::Insert)
     211            if (evt.getKeyCode() == KeyCode::Insert)
    212212                this->insert(fromClipboard());
    213             else if (evt.key == KeyCode::Delete)
     213            else if (evt.getKeyCode() == KeyCode::Delete)
    214214            {
    215215                toClipboard(this->buffer_);
     
    218218        }
    219219
    220         this->insert((char)evt.text);
     220        this->insert((char)evt.getText());
    221221    }
    222222
     
    225225        @param dt Delta time
    226226    */
    227     void InputBuffer::updateInput(float dt)
     227    void InputBuffer::keyboardUpdated(float dt)
    228228    {
    229229        timeSinceKeyPressed_ += dt;
     
    239239    }
    240240
    241     void InputBuffer::keyPressed(const KeyEvent &evt)
    242     {
    243         lastKey_ = evt.key;
     241    void InputBuffer::buttonPressed(const KeyEvent& evt)
     242    {
     243        lastKey_ = evt.getKeyCode();
    244244        timeSinceKeyPressed_ = 0.0;
    245245        timeSinceKeyRepeated_ = keyRepeatDeleay_;
     
    249249    }
    250250
    251     void InputBuffer::keyHeld(const KeyEvent& evt)
    252     {
    253         if (evt.key == lastKey_)
     251    void InputBuffer::buttonHeld(const KeyEvent& evt)
     252    {
     253        if (evt.getKeyCode() == lastKey_)
    254254        {
    255255            while (keysToRepeat_)
Note: See TracChangeset for help on using the changeset viewer.