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/KeyBinder.cc

    r3269 r3274  
    100100
    101101        // initialise joy sticks separatly to allow for reloading
    102         numberOfJoySticks_ = InputManager::getInstance().numberOfJoySticks();
     102        numberOfJoySticks_ = InputManager::getInstance().getJoyStickQuantity();
    103103        initialiseJoyStickBindings();
    104104
     
    152152    }
    153153
    154     void KeyBinder::JoyStickDeviceNumberChanged(unsigned int value)
     154    void KeyBinder::JoyStickQuantityChanged(unsigned int value)
    155155    {
    156156        unsigned int oldValue = numberOfJoySticks_;
     
    311311    }
    312312
    313     void KeyBinder::updateMouse(float dt)
     313    void KeyBinder::mouseUpdated(float dt)
    314314    {
    315315        if (bDeriveMouseInput_)
     
    364364    }
    365365
    366     void KeyBinder::updateJoyStick(float dt, unsigned int joyStick)
     366    void KeyBinder::joyStickUpdated(unsigned int joyStick, float dt)
    367367    {
    368368        for (unsigned int i = 0; i < JoyStickAxisCode::numberOfAxes * 2; i++)
     
    480480    }
    481481
    482     void KeyBinder::joyStickAxisMoved(unsigned int joyStickID, unsigned int axis, float value)
    483     {
    484         int i = axis * 2;
     482    void KeyBinder::axisMoved(unsigned int device, unsigned int axisID, float value)
     483    {
     484        int i = axisID * 2;
     485        JoyStickAxisVector& axis = joyStickAxes_[device];
    485486        if (value < 0)
    486487        {
    487             joyStickAxes_[joyStickID][i].absVal_ = -value;
    488             joyStickAxes_[joyStickID][i].relVal_ = -value;
    489             joyStickAxes_[joyStickID][i].hasChanged_ = true;
    490             if (joyStickAxes_[joyStickID][i + 1].absVal_ > 0.0f)
    491             {
    492                 joyStickAxes_[joyStickID][i + 1].absVal_ = -0.0f;
    493                 joyStickAxes_[joyStickID][i + 1].relVal_ = -0.0f;
    494                 joyStickAxes_[joyStickID][i + 1].hasChanged_ = true;
     488            axis[i].absVal_ = -value;
     489            axis[i].relVal_ = -value;
     490            axis[i].hasChanged_ = true;
     491            if (axis[i + 1].absVal_ > 0.0f)
     492            {
     493                axis[i + 1].absVal_ = -0.0f;
     494                axis[i + 1].relVal_ = -0.0f;
     495                axis[i + 1].hasChanged_ = true;
    495496            }
    496497        }
    497498        else
    498499        {
    499             joyStickAxes_[joyStickID][i + 1].absVal_ = value;
    500             joyStickAxes_[joyStickID][i + 1].relVal_ = value;
    501             joyStickAxes_[joyStickID][i + 1].hasChanged_ = true;
    502             if (joyStickAxes_[joyStickID][i].absVal_ > 0.0f)
    503             {
    504                 joyStickAxes_[joyStickID][i].absVal_ = -0.0f;
    505                 joyStickAxes_[joyStickID][i].relVal_ = -0.0f;
    506                 joyStickAxes_[joyStickID][i].hasChanged_ = true;
     500            axis[i + 1].absVal_ = value;
     501            axis[i + 1].relVal_ = value;
     502            axis[i + 1].hasChanged_ = true;
     503            if (axis[i].absVal_ > 0.0f)
     504            {
     505                axis[i].absVal_ = -0.0f;
     506                axis[i].relVal_ = -0.0f;
     507                axis[i].hasChanged_ = true;
    507508            }
    508509        }
Note: See TracChangeset for help on using the changeset viewer.