Ver Fonte

"don't reset input states when destroying a control manager"

Josh Wilson há 18 anos atrás
pai
commit
7c1ebe56c8

+ 2 - 5
direct/src/controls/ControlManager.py

@@ -41,9 +41,6 @@ class ControlManager:
         ist.append(inputState.watchWithModifiers("reverse", "mouse4", inputSource=inputState.Mouse))
         ist.append(inputState.watchWithModifiers("reverse", "mouse4", inputSource=inputState.Mouse))
         
         
         if self.wantWASD:
         if self.wantWASD:
-
-            
-            
             ist.append(inputState.watchWithModifiers("turnLeft", "arrow_left", inputSource=inputState.ArrowKeys))
             ist.append(inputState.watchWithModifiers("turnLeft", "arrow_left", inputSource=inputState.ArrowKeys))
             ist.append(inputState.watch("turnLeft", "mouse-look_left", "mouse-look_left-done"))
             ist.append(inputState.watch("turnLeft", "mouse-look_left", "mouse-look_left-done"))
             ist.append(inputState.watch("turnLeft", "force-turnLeft", "force-turnLeft-stop"))
             ist.append(inputState.watch("turnLeft", "force-turnLeft", "force-turnLeft-stop"))
@@ -61,7 +58,6 @@ class ControlManager:
             # Used to switch between strafe and turn. We will default to turn
             # Used to switch between strafe and turn. We will default to turn
             self.WASDTurnTokens = ()
             self.WASDTurnTokens = ()
             self.setWASDTurn(1)
             self.setWASDTurn(1)
-
         else:
         else:
             ist.append(inputState.watchWithModifiers("turnLeft", "arrow_left", inputSource=inputState.ArrowKeys))
             ist.append(inputState.watchWithModifiers("turnLeft", "arrow_left", inputSource=inputState.ArrowKeys))
             ist.append(inputState.watch("turnLeft", "mouse-look_left", "mouse-look_left-done"))
             ist.append(inputState.watch("turnLeft", "mouse-look_left", "mouse-look_left-done"))
@@ -109,7 +105,8 @@ class ControlManager:
             the controls when they were added (e.g.
             the controls when they were added (e.g.
             using the add(<controls>, <name>) call).
             using the add(<controls>, <name>) call).
 
 
-        Remove a control instance from the list of available control systems.
+        Remove a control instance from the list of
+        available control systems.
 
 
         See also: add().
         See also: add().
         """
         """

+ 8 - 1
direct/src/controls/InputState.py

@@ -133,6 +133,9 @@ class InputState(DirectObject.DirectObject):
             name, eventOn, eventOff, startState))
             name, eventOn, eventOff, startState))
         if inputSource is None:
         if inputSource is None:
             inputSource = "eventPair('%s','%s')" % (eventOn, eventOff)
             inputSource = "eventPair('%s','%s')" % (eventOn, eventOff)
+        # Do we really need to reset the input state just because
+        # we're watching it?  Remember, there may be multiple things
+        # watching this input state.
         self.set(name, startState, inputSource)
         self.set(name, startState, inputSource)
         token = InputStateWatchToken(self)
         token = InputStateWatchToken(self)
         # make the token listen for the events, to allow multiple listeners for the same event
         # make the token listen for the events, to allow multiple listeners for the same event
@@ -162,7 +165,11 @@ class InputState(DirectObject.DirectObject):
         DirectObject.DirectObject.ignore(self, eventOff)
         DirectObject.DirectObject.ignore(self, eventOff)
         if len(self._watching[inputSource]) == 0:
         if len(self._watching[inputSource]) == 0:
             del self._watching[inputSource]
             del self._watching[inputSource]
-        self.set(name, False, inputSource)
+
+        # I commented this out because we shouldn't be modifying an
+        # input state simply because we're not looking at it anymore.
+        # self.set(name, False, inputSource)
+
 
 
     def force(self, name, value, inputSource):
     def force(self, name, value, inputSource):
         """
         """

+ 7 - 7
direct/src/controls/ShipPilot.py

@@ -328,7 +328,7 @@ class ShipPilot(PhysicsWalker):
                     base.localAvatar.getPos().pPrintValues(),))
                     base.localAvatar.getPos().pPrintValues(),))
                 onScreenDebug.append("localAvatar hpr = %s\n"%(
                 onScreenDebug.append("localAvatar hpr = %s\n"%(
                     base.localAvatar.getHpr().pPrintValues(),))
                     base.localAvatar.getHpr().pPrintValues(),))
-        # assert self.debugPrint("handleAvatarControls(task=%s)"%(task,))
+        assert self.debugPrint("handleAvatarControls(task=%s)"%(task,))
         physObject = self.actorNode.getPhysicsObject()
         physObject = self.actorNode.getPhysicsObject()
         contact = self.actorNode.getContactVector()
         contact = self.actorNode.getContactVector()
         # get the button states:
         # get the button states:
@@ -576,14 +576,14 @@ class ShipPilot(PhysicsWalker):
         """
         """
         Activate the arrow keys, etc.
         Activate the arrow keys, etc.
         """
         """
-        assert self.debugPrint("enableAvatarControls()")
+        assert self.debugPrint("enableShipControls()")
         assert self.collisionsActive
         assert self.collisionsActive
 
 
         if __debug__:
         if __debug__:
             #self.accept("control-f3", self.spawnTest) #*#
             #self.accept("control-f3", self.spawnTest) #*#
             self.accept("f3", self.reset) # for debugging only.
             self.accept("f3", self.reset) # for debugging only.
 
 
-        taskName = "AvatarControls-%s"%(id(self),)
+        taskName = "ShipControls-%s"%(id(self),)
         # remove any old
         # remove any old
         taskMgr.remove(taskName)
         taskMgr.remove(taskName)
         # spawn the new task
         # spawn the new task
@@ -591,17 +591,17 @@ class ShipPilot(PhysicsWalker):
         if self.physVelocityIndicator:
         if self.physVelocityIndicator:
             taskMgr.add(
             taskMgr.add(
                 self.avatarPhysicsIndicator,
                 self.avatarPhysicsIndicator,
-                "AvatarControlsIndicator%s"%(id(self),), 35)
+                "ShipControlsIndicator%s"%(id(self),), 35)
             
             
     def disableAvatarControls(self):
     def disableAvatarControls(self):
         """
         """
         Ignore the arrow keys, etc.
         Ignore the arrow keys, etc.
         """
         """
-        assert self.debugPrint("disableAvatarControls()")
-        taskName = "AvatarControls-%s"%(id(self),)
+        assert self.debugPrint("disableShipControls()")
+        taskName = "ShipControls-%s"%(id(self),)
         taskMgr.remove(taskName)
         taskMgr.remove(taskName)
 
 
-        taskName = "AvatarControlsIndicator%s"%(id(self),)
+        taskName = "ShipControlsIndicator%s"%(id(self),)
         taskMgr.remove(taskName)
         taskMgr.remove(taskName)
 
 
         if __debug__:
         if __debug__: