Browse Source

*** empty log message ***

gregw 24 years ago
parent
commit
59f0a51f6c

+ 1 - 5
direct/src/directdevices/DirectDeviceManager.py

@@ -146,11 +146,7 @@ class DirectAnalogs(AnalogNode, DirectObject):
     
     
     def normalizeChannel(self, chan, minVal = -1, maxVal = 1):
     def normalizeChannel(self, chan, minVal = -1, maxVal = 1):
         try:
         try:
-            if (chan == 2) or (chan == 6):
-                # These channels have reduced range
-                return self.normalize(self[chan] * 3.0, minVal, maxVal)
-            else:
-                return self.normalize(self[chan], minVal, maxVal)
+            return self.normalize(self[chan], minVal, maxVal)
         except IndexError:
         except IndexError:
             return 0.0
             return 0.0
 
 

+ 23 - 9
direct/src/directdevices/DirectJoybox.py

@@ -137,7 +137,7 @@ class DirectJoybox(PandaObject):
         self.lastTime = cTime
         self.lastTime = cTime
         # Update analogs
         # Update analogs
         for i in range(len(self.analogs)):
         for i in range(len(self.analogs)):
-            self.aList[i] = self.analogs.normalizeChannel(i)
+            self.aList[i] = self.normalizeChannel(i)
         # Update buttons
         # Update buttons
         for i in range(len(self.buttons)):
         for i in range(len(self.buttons)):
             try:
             try:
@@ -217,9 +217,9 @@ class DirectJoybox(PandaObject):
         if self.nodePath == None:
         if self.nodePath == None:
             return
             return
         """
         """
-        hprScale = (self.analogs.normalizeChannel(L_SLIDE, 0.1, 100) *
+        hprScale = (self.normalizeChannel(L_SLIDE, 0.1, 100) *
                     DirectJoybox.hprMultiplier)
                     DirectJoybox.hprMultiplier)
-        posScale = (self.analogs.normalizeChannel(R_SLIDE, 0.1, 100) *
+        posScale = (self.normalizeChannel(R_SLIDE, 0.1, 100) *
                     DirectJoybox.xyzMultiplier)
                     DirectJoybox.xyzMultiplier)
         """
         """
         hprScale = (self.aList[L_SLIDE] + 1.0) * 50.0 * DirectJoybox.hprMultiplier
         hprScale = (self.aList[L_SLIDE] + 1.0) * 50.0 * DirectJoybox.hprMultiplier
@@ -297,9 +297,9 @@ class DirectJoybox(PandaObject):
         # Do nothing if no nodePath selected
         # Do nothing if no nodePath selected
         if self.nodePath == None:
         if self.nodePath == None:
             return
             return
-        hprScale = (self.analogs.normalizeChannel(L_SLIDE, 0.1, 100) *
+        hprScale = (self.normalizeChannel(L_SLIDE, 0.1, 100) *
                     DirectJoybox.hprMultiplier)
                     DirectJoybox.hprMultiplier)
-        posScale = (self.analogs.normalizeChannel(R_SLIDE, 0.1, 100) *
+        posScale = (self.normalizeChannel(R_SLIDE, 0.1, 100) *
                     DirectJoybox.xyzMultiplier)
                     DirectJoybox.xyzMultiplier)
         dr = -1 * hprScale * self.aList[R_TWIST] * self.deltaTime
         dr = -1 * hprScale * self.aList[R_TWIST] * self.deltaTime
         dp = -1 * hprScale * self.aList[R_FWD_BACK] * self.deltaTime
         dp = -1 * hprScale * self.aList[R_FWD_BACK] * self.deltaTime
@@ -316,9 +316,9 @@ class DirectJoybox(PandaObject):
         # Do nothing if no nodePath selected
         # Do nothing if no nodePath selected
         if self.nodePath == None:
         if self.nodePath == None:
             return
             return
-        hprScale = (self.analogs.normalizeChannel(L_SLIDE, 0.1, 100) *
+        hprScale = (self.normalizeChannel(L_SLIDE, 0.1, 100) *
                     DirectJoybox.hprMultiplier)
                     DirectJoybox.hprMultiplier)
-        posScale = (self.analogs.normalizeChannel(R_SLIDE, 0.1, 100) *
+        posScale = (self.normalizeChannel(R_SLIDE, 0.1, 100) *
                     DirectJoybox.xyzMultiplier)
                     DirectJoybox.xyzMultiplier)
         dr = -1 * hprScale * self.aList[R_TWIST] * self.deltaTime
         dr = -1 * hprScale * self.aList[R_TWIST] * self.deltaTime
         dp = -1 * hprScale * self.aList[R_FWD_BACK] * self.deltaTime
         dp = -1 * hprScale * self.aList[R_FWD_BACK] * self.deltaTime
@@ -367,9 +367,9 @@ class DirectJoybox(PandaObject):
         # Do nothing if no nodePath selected
         # Do nothing if no nodePath selected
         if self.nodePath == None:
         if self.nodePath == None:
             return
             return
-        hprScale = (self.analogs.normalizeChannel(L_SLIDE, 0.1, 100) *
+        hprScale = (self.normalizeChannel(L_SLIDE, 0.1, 100) *
                     DirectJoybox.hprMultiplier)
                     DirectJoybox.hprMultiplier)
-        posScale = (self.analogs.normalizeChannel(R_SLIDE, 0.1, 100) *
+        posScale = (self.normalizeChannel(R_SLIDE, 0.1, 100) *
                     DirectJoybox.xyzMultiplier)
                     DirectJoybox.xyzMultiplier)
         r = -0.01 * posScale * self.aList[R_FWD_BACK] * self.deltaTime
         r = -0.01 * posScale * self.aList[R_FWD_BACK] * self.deltaTime
         rx = hprScale * self.aList[R_LEFT_RIGHT] * self.deltaTime
         rx = hprScale * self.aList[R_LEFT_RIGHT] * self.deltaTime
@@ -403,3 +403,17 @@ class DirectJoybox(PandaObject):
         # Restore the original hpr of the orbiter
         # Restore the original hpr of the orbiter
         self.nodePath.setHpr(self.tempCS, 0, 0, 0)
         self.nodePath.setHpr(self.tempCS, 0, 0, 0)
 
 
+
+    # We need to override the DirectAnalog normalizeChannel to
+    # correct the ranges of the two twist axes of the joybox.
+    def normalizeChannel(self, chan, minVal = -1, maxVal = 1):
+        try:
+            if (chan == L_TWIST) or (chan == R_TWIST):
+                # These channels have reduced range
+                return self.analogs.normalize(self[chan] * 3.0, minVal, maxVal)
+            else:
+                return self.analogs.normalize(self[chan], minVal, maxVal)
+        except IndexError:
+            return 0.0
+
+