Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 28, 2008, 11:56:31 PM (15 years ago)
Author:
rgrieder
Message:
  • Fixed a bug in ConfigFileManager::getVectorSize(). If there were no entries, 1 was returned instead of 0.
  • Added getSctionName to the ConfigValueContainer
  • Bugfix in Button::clear()
  • Renamed some joy stick buttons and axes to have them sorted corrected in the config file
  • Removed annoying and useless "Key_084=" from keybindings.ini file (there were about a hundred of them)
  • Bugfix in KeyBinder: All the axes were inverted (which was then corrected in the ini file)
  • Also inverted rotateYaw in SpaceShip and Spectator because that actually corrected the bug from above ;)
  • Some small performance optimisation in InputManager
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation/src/core/input/KeyBinder.cc

    r2103 r2543  
    3333
    3434#include "KeyBinder.h"
     35
    3536#include <fstream>
    3637#include <string>
     38
    3739#include "util/Convert.h"
    3840#include "util/Debug.h"
     
    6668            std::string keyname = KeyCode::ByString[i];
    6769            if (!keyname.empty())
    68             {
    6970                keys_[i].name_ = std::string("Key") + keyname;
    70             }
    7171            else
    72             {
    73                 // some keys have name "" because the code is not occupied by OIS
    74                 // Use "Key_" plus the number as name to put it at the end of the config file section
    75                 std::string number = convertToString(i);
    76                 if (i < 100)
    77                     number.insert(0, "0");
    78                 keys_[i].name_ = std::string("Key_") + number;
    79             }
     72                keys_[i].name_ = "";
    8073            keys_[i].paramCommandBuffer_ = &paramCommandBuffer_;
    8174            keys_[i].groupName_ = "Keys";
     
    9790        for (unsigned int i = 0; i < MouseAxisCode::numberOfAxes * 2; i++)
    9891        {
    99             mouseAxes_[i].name_ = std::string("Mouse") + MouseAxisCode::ByString[i >> 1];
     92            mouseAxes_[i].name_ = std::string("Mouse") + MouseAxisCode::ByString[i / 2];
    10093            if (i & 1)
    10194                mouseAxes_[i].name_ += "Pos";
     
    224217        allHalfAxes_.clear();
    225218
     219        // Note: Don't include the dummy keys which don't actually exist in OIS but have a number
    226220        for (unsigned int i = 0; i < KeyCode::numberOfKeys; i++)
    227             allButtons_[keys_[i].name_] = keys_ + i;
     221            if (!keys_[i].name_.empty())
     222                allButtons_[keys_[i].name_] = keys_ + i;
    228223        for (unsigned int i = 0; i < numberOfMouseButtons_; i++)
    229224            allButtons_[mouseButtons_[i].name_] = mouseButtons_ + i;
     
    327322        if (bDeriveMouseInput_)
    328323        {
    329             // only update when derive dt has passed
     324            // only update when derivation dt has passed
    330325            if (deriveTime_ > derivePeriod_)
    331326            {
    332327                for (int i = 0; i < 2; i++)
    333328                {
    334                     if (mouseRelative_[i] > 0)
     329                    if (mouseRelative_[i] < 0)
    335330                    {
    336331                        mouseAxes_[2*i + 0].absVal_
    337                             =  mouseRelative_[i] / deriveTime_ * 0.0005 * mouseSensitivityDerived_;
     332                            = -mouseRelative_[i] / deriveTime_ * 0.0005 * mouseSensitivityDerived_;
    338333                        mouseAxes_[2*i + 1].absVal_ = 0.0f;
    339334                    }
    340                     else if (mouseRelative_[i] < 0)
     335                    else if (mouseRelative_[i] > 0)
    341336                    {
    342337                        mouseAxes_[2*i + 0].absVal_ = 0.0f;
    343338                        mouseAxes_[2*i + 1].absVal_
    344                             = -mouseRelative_[i] / deriveTime_ * 0.0005 * mouseSensitivityDerived_;
     339                            =  mouseRelative_[i] / deriveTime_ * 0.0005 * mouseSensitivityDerived_;
    345340                    }
    346341                    else
     
    363358            // Why dividing relative value by dt? The reason lies in the simple fact, that when you
    364359            // press a button that has relative movement, that value has to be multiplied by dt to be
    365             // frame rate independant. This can easily (and only) be done in tickInput(float).
     360            // frame rate independent. This can easily (and only) be done in tickInput(float).
    366361            // Hence we need to divide by dt here for the mouse to compensate, because the relative
    367362            // move movements have nothing to do with dt.
     
    441436            for (int i = 0; i < 2; i++)
    442437            {
    443                 if (rel[i]) // performance opt. if rel[i] == 0
     438                if (rel[i]) // performance opt. for the case that rel[i] == 0
    444439                {
    445440                    // write absolute values
     
    454449                        mousePosition_[i] = -mouseClippingSize_;
    455450
    456                     if (mousePosition_[i] >= 0)
     451                    if (mousePosition_[i] < 0)
    457452                    {
    458                         mouseAxes_[2*i + 0].absVal_ =   mousePosition_[i]/(float)mouseClippingSize_ * mouseSensitivity_;
     453                        mouseAxes_[2*i + 0].absVal_ =  -mousePosition_[i]/(float)mouseClippingSize_ * mouseSensitivity_;
    459454                        mouseAxes_[2*i + 1].absVal_ =  0.0f;
    460455                    }
     
    462457                    {
    463458                        mouseAxes_[2*i + 0].absVal_ =  0.0f;
    464                         mouseAxes_[2*i + 1].absVal_ =  -mousePosition_[i]/(float)mouseClippingSize_ * mouseSensitivity_;
     459                        mouseAxes_[2*i + 1].absVal_ =   mousePosition_[i]/(float)mouseClippingSize_ * mouseSensitivity_;
    465460                    }
    466461                }
     
    471466        for (int i = 0; i < 2; i++)
    472467        {
    473             if (rel[i] > 0)
    474                 mouseAxes_[0 + 2*i].relVal_ =  ((float)rel[i])/(float)mouseClippingSize_ * mouseSensitivity_;
     468            if (rel[i] < 0)
     469                mouseAxes_[0 + 2*i].relVal_ = -((float)rel[i])/(float)mouseClippingSize_ * mouseSensitivity_;
    475470            else
    476                 mouseAxes_[1 + 2*i].relVal_ = -((float)rel[i])/(float)mouseClippingSize_ * mouseSensitivity_;
     471                mouseAxes_[1 + 2*i].relVal_ =  ((float)rel[i])/(float)mouseClippingSize_ * mouseSensitivity_;
    477472        }
    478473    }
     
    484479    void KeyBinder::mouseScrolled(int abs, int rel)
    485480    {
    486         if (rel > 0)
    487             for (int i = 0; i < rel/mouseWheelStepSize_; i++)
     481        if (rel < 0)
     482            for (int i = 0; i < -rel/mouseWheelStepSize_; i++)
    488483                mouseButtons_[8].execute(KeybindMode::OnPress, ((float)abs)/mouseWheelStepSize_);
    489484        else
    490             for (int i = 0; i < -rel/mouseWheelStepSize_; i++)
     485            for (int i = 0; i < rel/mouseWheelStepSize_; i++)
    491486                mouseButtons_[9].execute(KeybindMode::OnPress, ((float)abs)/mouseWheelStepSize_);
    492487    }
     
    495490    {
    496491        int i = axis * 2;
    497         if (value >= 0)
    498         {
    499             joyStickAxes_[joyStickID][i].absVal_ = value;
    500             joyStickAxes_[joyStickID][i].relVal_ = value;
     492        if (value < 0)
     493        {
     494            joyStickAxes_[joyStickID][i].absVal_ = -value;
     495            joyStickAxes_[joyStickID][i].relVal_ = -value;
    501496            joyStickAxes_[joyStickID][i].hasChanged_ = true;
    502497            if (joyStickAxes_[joyStickID][i + 1].absVal_ > 0.0f)
     
    509504        else
    510505        {
    511             joyStickAxes_[joyStickID][i + 1].absVal_ = -value;
    512             joyStickAxes_[joyStickID][i + 1].relVal_ = -value;
     506            joyStickAxes_[joyStickID][i + 1].absVal_ = value;
     507            joyStickAxes_[joyStickID][i + 1].relVal_ = value;
    513508            joyStickAxes_[joyStickID][i + 1].hasChanged_ = true;
    514509            if (joyStickAxes_[joyStickID][i].absVal_ > 0.0f)
Note: See TracChangeset for help on using the changeset viewer.