Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 25, 2009, 8:02:22 PM (15 years ago)
Author:
rgrieder
Message:

Fixed mouse position problem: Internal value could still be larger than 1.

Location:
code/branches/presentation2/src/libraries/core/input
Files:
2 edited

Legend:

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

    r5929 r6155  
    5050        mouseRelative_[0] = 0;
    5151        mouseRelative_[1] = 0;
    52         mousePosition_[0] = 0;
    53         mousePosition_[1] = 0;
     52        mousePosition_[0] = 0.0;
     53        mousePosition_[1] = 0.0;
    5454
    5555        RegisterRootObject(KeyBinder);
     
    128128        SetConfigValue(mouseSensitivity_, 1.0f)
    129129            .description("Mouse sensitivity.");
     130        this->totalMouseSensitivity_ = this->mouseSensitivity_ / this->mouseClippingSize_;
    130131        SetConfigValue(bDeriveMouseInput_, false)
    131132            .description("Whether or not to derive moues movement for the absolute value.");
     
    426427                    mouseAxes_[2*i + 0].hasChanged_ = true;
    427428                    mouseAxes_[2*i + 1].hasChanged_ = true;
    428                     mousePosition_[i] += rel[i];
     429                    mousePosition_[i] += rel[i] * totalMouseSensitivity_;
    429430
    430431                    // clip absolute position
    431                     if (mousePosition_[i] > mouseClippingSize_)
    432                         mousePosition_[i] =  mouseClippingSize_;
    433                     if (mousePosition_[i] < -mouseClippingSize_)
    434                         mousePosition_[i] = -mouseClippingSize_;
    435 
    436                     if (mousePosition_[i] < 0)
     432                    if (mousePosition_[i] > 1.0)
     433                        mousePosition_[i] =  1.0;
     434                    if (mousePosition_[i] < -1.0)
     435                        mousePosition_[i] = -1.0;
     436
     437                    if (mousePosition_[i] < 0.0)
    437438                    {
    438                         mouseAxes_[2*i + 0].absVal_ = -mouseSensitivity_ * mousePosition_[i] / mouseClippingSize_;
     439                        mouseAxes_[2*i + 0].absVal_ = -mousePosition_[i];
    439440                        mouseAxes_[2*i + 1].absVal_ = 0.0f;
    440441                    }
     
    442443                    {
    443444                        mouseAxes_[2*i + 0].absVal_ = 0.0f;
    444                         mouseAxes_[2*i + 1].absVal_ =  mouseSensitivity_ * mousePosition_[i] / mouseClippingSize_;
     445                        mouseAxes_[2*i + 1].absVal_ =  mousePosition_[i];
    445446                    }
    446447                }
     
    452453        {
    453454            if (rel[i] < 0)
    454                 mouseAxes_[0 + 2*i].relVal_ = -mouseSensitivity_ * rel[i] / mouseClippingSize_;
     455                mouseAxes_[0 + 2*i].relVal_ = -rel[i] * totalMouseSensitivity_;
    455456            else
    456                 mouseAxes_[1 + 2*i].relVal_ =  mouseSensitivity_ * rel[i] / mouseClippingSize_;
     457                mouseAxes_[1 + 2*i].relVal_ =  rel[i] * totalMouseSensitivity_;
    457458        }
    458459    }
  • code/branches/presentation2/src/libraries/core/input/KeyBinder.h

    r5929 r6155  
    138138        std::vector<BufferedParamCommand*> paramCommandBuffer_;
    139139
    140         //! Keeps track of the absolute mouse value (incl. scroll wheel)
    141         int mousePosition_[2];
     140        //! Keeps track of the absolute mouse value
     141        float mousePosition_[2];
    142142        //! Used to derive mouse input if requested
    143143        int mouseRelative_[2];
     
    165165        //! mouse sensitivity if mouse input is derived
    166166        float mouseSensitivityDerived_;
    167         //! Equals one step of the mousewheel
     167        //! Equals one step of the mouse wheel
    168168        int mouseWheelStepSize_;
     169
     170        //! Multiplication of mouse sensitivity and clipping size
     171        float totalMouseSensitivity_;
    169172
    170173        //##### Constant config variables #####
Note: See TracChangeset for help on using the changeset viewer.