[Orxonox-commit 1437] r6155 - code/branches/presentation2/src/libraries/core/input

rgrieder at orxonox.net rgrieder at orxonox.net
Wed Nov 25 20:02:22 CET 2009


Author: rgrieder
Date: 2009-11-25 20:02:22 +0100 (Wed, 25 Nov 2009)
New Revision: 6155

Modified:
   code/branches/presentation2/src/libraries/core/input/KeyBinder.cc
   code/branches/presentation2/src/libraries/core/input/KeyBinder.h
Log:
Fixed mouse position problem: Internal value could still be larger than 1.

Modified: code/branches/presentation2/src/libraries/core/input/KeyBinder.cc
===================================================================
--- code/branches/presentation2/src/libraries/core/input/KeyBinder.cc	2009-11-25 18:51:42 UTC (rev 6154)
+++ code/branches/presentation2/src/libraries/core/input/KeyBinder.cc	2009-11-25 19:02:22 UTC (rev 6155)
@@ -49,8 +49,8 @@
     {
         mouseRelative_[0] = 0;
         mouseRelative_[1] = 0;
-        mousePosition_[0] = 0;
-        mousePosition_[1] = 0;
+        mousePosition_[0] = 0.0;
+        mousePosition_[1] = 0.0;
 
         RegisterRootObject(KeyBinder);
 
@@ -127,6 +127,7 @@
             .description("Specifies whether to filter small analog values like joy stick fluctuations.");
         SetConfigValue(mouseSensitivity_, 1.0f)
             .description("Mouse sensitivity.");
+        this->totalMouseSensitivity_ = this->mouseSensitivity_ / this->mouseClippingSize_;
         SetConfigValue(bDeriveMouseInput_, false)
             .description("Whether or not to derive moues movement for the absolute value.");
         SetConfigValue(derivePeriod_, 0.05f)
@@ -425,23 +426,23 @@
                     // write absolute values
                     mouseAxes_[2*i + 0].hasChanged_ = true;
                     mouseAxes_[2*i + 1].hasChanged_ = true;
-                    mousePosition_[i] += rel[i];
+                    mousePosition_[i] += rel[i] * totalMouseSensitivity_;
 
                     // clip absolute position
-                    if (mousePosition_[i] > mouseClippingSize_)
-                        mousePosition_[i] =  mouseClippingSize_;
-                    if (mousePosition_[i] < -mouseClippingSize_)
-                        mousePosition_[i] = -mouseClippingSize_;
+                    if (mousePosition_[i] > 1.0)
+                        mousePosition_[i] =  1.0;
+                    if (mousePosition_[i] < -1.0)
+                        mousePosition_[i] = -1.0;
 
-                    if (mousePosition_[i] < 0)
+                    if (mousePosition_[i] < 0.0)
                     {
-                        mouseAxes_[2*i + 0].absVal_ = -mouseSensitivity_ * mousePosition_[i] / mouseClippingSize_;
+                        mouseAxes_[2*i + 0].absVal_ = -mousePosition_[i];
                         mouseAxes_[2*i + 1].absVal_ = 0.0f;
                     }
                     else
                     {
                         mouseAxes_[2*i + 0].absVal_ = 0.0f;
-                        mouseAxes_[2*i + 1].absVal_ =  mouseSensitivity_ * mousePosition_[i] / mouseClippingSize_;
+                        mouseAxes_[2*i + 1].absVal_ =  mousePosition_[i];
                     }
                 }
             }
@@ -451,9 +452,9 @@
         for (int i = 0; i < 2; i++)
         {
             if (rel[i] < 0)
-                mouseAxes_[0 + 2*i].relVal_ = -mouseSensitivity_ * rel[i] / mouseClippingSize_;
+                mouseAxes_[0 + 2*i].relVal_ = -rel[i] * totalMouseSensitivity_;
             else
-                mouseAxes_[1 + 2*i].relVal_ =  mouseSensitivity_ * rel[i] / mouseClippingSize_;
+                mouseAxes_[1 + 2*i].relVal_ =  rel[i] * totalMouseSensitivity_;
         }
     }
 

Modified: code/branches/presentation2/src/libraries/core/input/KeyBinder.h
===================================================================
--- code/branches/presentation2/src/libraries/core/input/KeyBinder.h	2009-11-25 18:51:42 UTC (rev 6154)
+++ code/branches/presentation2/src/libraries/core/input/KeyBinder.h	2009-11-25 19:02:22 UTC (rev 6155)
@@ -137,8 +137,8 @@
         */
         std::vector<BufferedParamCommand*> paramCommandBuffer_;
 
-        //! Keeps track of the absolute mouse value (incl. scroll wheel)
-        int mousePosition_[2];
+        //! Keeps track of the absolute mouse value
+        float mousePosition_[2];
         //! Used to derive mouse input if requested
         int mouseRelative_[2];
         float deriveTime_;
@@ -164,9 +164,12 @@
         float mouseSensitivity_;
         //! mouse sensitivity if mouse input is derived
         float mouseSensitivityDerived_;
-        //! Equals one step of the mousewheel
+        //! Equals one step of the mouse wheel
         int mouseWheelStepSize_;
 
+        //! Multiplication of mouse sensitivity and clipping size
+        float totalMouseSensitivity_;
+
         //##### Constant config variables #####
         // Use some value at about 1000. This can be configured with mouseSensitivity_ anyway.
         static const int mouseClippingSize_ = 1024;




More information about the Orxonox-commit mailing list