def enable(self):
     if self.isEnabled:
         return
     self.isEnabled = 1
     keymap = settings.get('keymap', {})
     self.inputStateTokens.extend((inputState.watch('run', 'runningEvent', 'running-on', 'running-off'), inputState.watch('forward', 'force-forward', 'force-forward-stop')))
     if self.wantWASD:
         self.istWASD.extend((inputState.watch('turnLeft', 'mouse-look_left', 'mouse-look_left-done'),
          inputState.watch('turnLeft', 'force-turnLeft', 'force-turnLeft-stop'),
          inputState.watch('turnRight', 'mouse-look_right', 'mouse-look_right-done'),
          inputState.watch('turnRight', 'force-turnRight', 'force-turnRight-stop'),
          inputState.watchWithModifiers('forward', keymap.get('MOVE_UP', base.MOVE_UP), inputSource=inputState.WASD),
          inputState.watchWithModifiers('reverse', keymap.get('MOVE_DOWN', base.MOVE_DOWN), inputSource=inputState.WASD),
          inputState.watchWithModifiers('jump', keymap.get('JUMP', base.JUMP))))
         self.setWASDTurn(True)
     else:
         self.istNormal.extend((inputState.watchWithModifiers('forward', base.MOVE_UP, inputSource=inputState.ArrowKeys),
          inputState.watchWithModifiers('reverse', base.MOVE_DOWN, inputSource=inputState.ArrowKeys),
          inputState.watchWithModifiers('turnLeft', base.MOVE_LEFT, inputSource=inputState.ArrowKeys),
          inputState.watchWithModifiers('turnRight', base.MOVE_RIGHT, inputSource=inputState.ArrowKeys),
          inputState.watch('jump', base.JUMP, base.JUMP + '-up')))
         self.istNormal.extend((inputState.watch('turnLeft', 'mouse-look_left', 'mouse-look_left-done'),
          inputState.watch('turnLeft', 'force-turnLeft', 'force-turnLeft-stop'),
          inputState.watch('turnRight', 'mouse-look_right', 'mouse-look_right-done'),
          inputState.watch('turnRight', 'force-turnRight', 'force-turnRight-stop')))
     if self.currentControls:
         self.currentControls.enableAvatarControls()
Esempio n. 2
0
	def __setupUserInput(self):
		'''
		Sets up user input
		'''
		#print "setupinput"
		self.doMouseStuff = False
		def toggleMouse():
			self.doMouseStuff = not self.doMouseStuff 
		
		self.accept('m', toggleMouse)
		self.accept('escape-up',self.close)
		self.mf = inputState.watch('foward','w','w-up')#note self.mf has to be released	
		self.bw = inputState.watch('backward','s','s-up')
		self.left = inputState.watch('left','a','a-up')
		self.right = inputState.watch('right','d','d-up')
Esempio n. 3
0
 def startSeeking(self):
     LocationSeeker.startSeeking(self)
     if not self.dropShadow:
         return
     self.avatar.ignore('mouse1')
     self.lMouseDn = inputState.watch(self.mouseDownName, 'mouse1', 'mouse1-up')
     base.taskMgr.add(self.__pollMouseHeldDown, self.pollMouseTaskName)
Esempio n. 4
0
 def startSeeking(self):
     LocationSeeker.startSeeking(self)
     if not self.dropShadow:
         return
     self.avatar.ignore('mouse1')
     self.lMouseDn = inputState.watch(self.mouseDownName, 'mouse1', 'mouse1-up')
     base.taskMgr.add(self.__pollMouseHeldDown, self.pollMouseTaskName)
Esempio n. 5
0
 def generalMovement(self):
     # Keyboard
     self.tokenGroup.release()
     self.tokenGroup.addToken(inputState.watchWithModifiers('forward', 'w', inputSource=inputState.WASD))
     self.tokenGroup.addToken(inputState.watchWithModifiers('left', 'a', inputSource=inputState.WASD))
     self.tokenGroup.addToken(inputState.watchWithModifiers('reverse', 's', inputSource=inputState.WASD))
     self.tokenGroup.addToken(inputState.watchWithModifiers('right', 'd', inputSource=inputState.WASD))
     self.tokenGroup.addToken(inputState.watchWithModifiers('turnLeft', 'q', inputSource=inputState.QE))
     self.tokenGroup.addToken(inputState.watchWithModifiers('turnRight', 'e', inputSource=inputState.QE))
     self.tokenGroup.addToken(inputState.watchWithModifiers('space', 'space', inputSource=inputState.Keyboard))
     self.tokenGroup.addToken(inputState.watch('ctrl', 'lcontrol_down', 'lcontrol-up', inputSource=inputState.Keyboard))
     self.isGrabMovement = False
    def startSeeking(self):
        LocationSeeker.startSeeking(self)
        if not self.dropShadow:
            return

        # Let's actually ignore LEFT mouse clicks.
        self.avatar.ignore('mouse1')

        # Instead, let's start listening to LEFT mouse hold downs.
        self.lMouseDn = inputState.watch(self.mouseDownName, 'mouse1',
                                         'mouse1-up')
        base.taskMgr.add(self.__pollMouseHeldDown, self.pollMouseTaskName)
Esempio n. 7
0
    def __init__(self, **kwargs):
        animes = {}
        for a, b, c in os.walk('models/char/animes'):
            for d in c:
                animes[d] = 'models/char/animes/%s' % (d)

        super(character, self).__init__(kwargs['char'], anims=animes)

        self.name = kwargs['name']
        FSM.__init__(self, self.name)
        self.setH(180)

        self.setupAnimes()
        self.interval_setup()
        self.setPos(0, 0, -.2)
        self.setScale(.2)
        self.lockedOnTarget = True
        self.targets = []

        self.anim_playList = []
        self.isAction = {
            'run': False,
            'jump': False,
            'hit_distance': False,
            'idle': False,
            'jumpPunch': False,
            'punch': False,
            'kick': False,
            'strifeLeft': False,
            'strifeRight': False,
            'runLeft': False,
            'runRight': False
        }
        self.animes = {
            'jump': self.jumpping,
            'run': self.running,
            'jumpPunch': self.jumpPunch
        }
        inputState.watch('run', 'player1axis1', None)
    def enable(self):
        assert self.notify.debugCall(id(self))

        if self.isEnabled:
            assert self.notify.debug('already isEnabled')
            return
        
        self.isEnabled = 1

        # keep track of what we do on the inputState so we can undo it later on
        #self.inputStateTokens = []
        ist = self.inputStateTokens
        ist.append(inputState.watch("run", 'runningEvent', "running-on", "running-off"))
        
        ist.append(inputState.watchWithModifiers("forward", "arrow_up", inputSource=inputState.ArrowKeys))
        ist.append(inputState.watch("forward", "force-forward", "force-forward-stop"))
        
        ist.append(inputState.watchWithModifiers("reverse", "arrow_down", inputSource=inputState.ArrowKeys))
        ist.append(inputState.watchWithModifiers("reverse", "mouse4", inputSource=inputState.Mouse))
        
        if self.wantWASD:
            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", "force-turnLeft", "force-turnLeft-stop"))
            
            ist.append(inputState.watchWithModifiers("turnRight", "arrow_right", inputSource=inputState.ArrowKeys))
            ist.append(inputState.watch("turnRight", "mouse-look_right", "mouse-look_right-done"))
            ist.append(inputState.watch("turnRight", "force-turnRight", "force-turnRight-stop"))

            ist.append(inputState.watchWithModifiers("forward", "w", inputSource=inputState.WASD))
            ist.append(inputState.watchWithModifiers("reverse", "s", inputSource=inputState.WASD))

            ist.append(inputState.watchWithModifiers("slideLeft", "q", inputSource=inputState.QE))
            ist.append(inputState.watchWithModifiers("slideRight", "e", inputSource=inputState.QE))

            self.setWASDTurn(self.__WASDTurn)
        else:
            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", "force-turnLeft", "force-turnLeft-stop"))
            
            ist.append(inputState.watchWithModifiers("turnRight", "arrow_right", inputSource=inputState.ArrowKeys))
            ist.append(inputState.watch("turnRight", "mouse-look_right", "mouse-look_right-done"))
            ist.append(inputState.watch("turnRight", "force-turnRight", "force-turnRight-stop"))

        # Jump controls
        if self.wantWASD:
            ist.append(inputState.watchWithModifiers("jump", "space"))
        else:
            ist.append(inputState.watch("jump", "control", "control-up"))
        
        if self.currentControls:
            self.currentControls.enableAvatarControls()
    def enable(self):
        if self.isEnabled:
            assert self.notify.debug('already isEnabled')
            return

        self.isEnabled = 1

        #self.inputStateTokens = []
        ist = self.inputStateTokens
        ist.append(
            inputState.watch("run", 'runningEvent', "running-on",
                             "running-off"))

        ist.append(
            inputState.watch("forward", "force-forward", "force-forward-stop"))

        ist.append(
            inputState.watchWithModifiers("reverse",
                                          "mouse4",
                                          inputSource=inputState.Mouse))

        if self.wantWASD:
            self.istWASD.append(
                inputState.watch("turnLeft", "mouse-look_left",
                                 "mouse-look_left-done"))
            self.istWASD.append(
                inputState.watch("turnLeft", "force-turnLeft",
                                 "force-turnLeft-stop"))

            self.istWASD.append(
                inputState.watch("turnRight", "mouse-look_right",
                                 "mouse-look_right-done"))
            self.istWASD.append(
                inputState.watch("turnRight", "force-turnRight",
                                 "force-turnRight-stop"))

            self.istWASD.append(
                inputState.watchWithModifiers("forward",
                                              "w",
                                              inputSource=inputState.WASD))
            self.istWASD.append(
                inputState.watchWithModifiers("reverse",
                                              "s",
                                              inputSource=inputState.WASD))
            self.setWASDTurn(self.__WASDTurn)
        else:
            self.istNormal.append(
                inputState.watchWithModifiers(
                    "forward", "arrow_up", inputSource=inputState.ArrowKeys))
            self.istNormal.append(
                inputState.watchWithModifiers(
                    "reverse", "arrow_down", inputSource=inputState.ArrowKeys))
            self.istNormal.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", "force-turnLeft",
                                 "force-turnLeft-stop"))

            self.istNormal.append(
                inputState.watchWithModifiers(
                    "turnRight",
                    "arrow_right",
                    inputSource=inputState.ArrowKeys))
            ist.append(
                inputState.watch("turnRight", "mouse-look_right",
                                 "mouse-look_right-done"))
            ist.append(
                inputState.watch("turnRight", "force-turnRight",
                                 "force-turnRight-stop"))

        if self.wantWASD:
            self.istWASD.append(inputState.watchWithModifiers("jump", "shift"))
        else:
            self.istNormal.append(
                inputState.watch("jump", "control", "control-up"))

        if self.currentControls:
            self.currentControls.enableAvatarControls()
    def enable(self):
        if self.isEnabled:
            assert self.notify.debug('already isEnabled')
            return
        
        self.isEnabled = 1

        
        #self.inputStateTokens = []
        ist = self.inputStateTokens
        ist.append(inputState.watch("run", 'runningEvent', "running-on", "running-off"))
        
        ist.append(inputState.watch("forward", "force-forward", "force-forward-stop"))
        
        
        ist.append(inputState.watchWithModifiers("reverse", "mouse4", inputSource=inputState.Mouse))
        
        if self.wantWASD:
            self.istWASD.append(inputState.watch("turnLeft", "mouse-look_left", "mouse-look_left-done"))
            self.istWASD.append(inputState.watch("turnLeft", "force-turnLeft", "force-turnLeft-stop"))

            self.istWASD.append(inputState.watch("turnRight", "mouse-look_right", "mouse-look_right-done"))
            self.istWASD.append(inputState.watch("turnRight", "force-turnRight", "force-turnRight-stop"))
            
            self.istWASD.append(inputState.watchWithModifiers("forward", "w", inputSource=inputState.WASD))
            self.istWASD.append(inputState.watchWithModifiers("reverse", "s", inputSource=inputState.WASD))
            self.setWASDTurn(self.__WASDTurn)
        else:
            self.istNormal.append(inputState.watchWithModifiers("forward", "arrow_up", inputSource=inputState.ArrowKeys))
            self.istNormal.append(inputState.watchWithModifiers("reverse", "arrow_down", inputSource=inputState.ArrowKeys))
            self.istNormal.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", "force-turnLeft", "force-turnLeft-stop"))
            
            self.istNormal.append(inputState.watchWithModifiers("turnRight", "arrow_right", inputSource=inputState.ArrowKeys))
            ist.append(inputState.watch("turnRight", "mouse-look_right", "mouse-look_right-done"))
            ist.append(inputState.watch("turnRight", "force-turnRight", "force-turnRight-stop"))

        
        if self.wantWASD:
            self.istWASD.append(inputState.watchWithModifiers("jump", "shift"))
        else:
            self.istNormal.append(inputState.watch("jump", "control", "control-up"))

        
        if self.currentControls:
            self.currentControls.enableAvatarControls()
Esempio n. 11
0
    def init_controls(self):
        """Set up controls.  Use direct input and keymaps
        
        TODO
            -Allow user to control keys from config settings
        """
        
        # Now, assign some controls to the events that the GravityWalker will
        #watch for 
        #Create a dictionary to save controls
        """WASD Settings"""
        self.controls = {}
      
        self.controls['forwardControl'] = inputState.watch('forward', 'w', 
                                'w-up', inputSource=inputState.WASD)
        self.controls['reverseControl'] = inputState.watch('reverse', 's', 
                                's-up', inputSource=inputState.WASD)
        self.controls['turnLeftControl'] = inputState.watch('turnLeft', 'a',
                                'a-up', inputSource=inputState.WASD)
        self.controls['turnRightControl'] = inputState.watch('turnRight', 'd', 
                                'd-up', inputSource=inputState.WASD)
        self.controls['jumpControl'] = inputState.watch('jump', 'space', 
                                'space-up', inputSource=inputState.Keyboard)
        
        self.controls['isMoving'] = False
        
        """Key map settings"""
        self.controls['key_map'] = {"cam_left":0, "cam_right":0, "cam_up":0,
                                    "cam_down":0, "mouse1":0, "mouse2": 0,
                                    "mouse3": 0, "scroll_up":0, 
                                    "scroll_down":0}
        
        #Camera Control Keys
        self.accept("arrow_left", self.controls_set_key, ["cam_left",1])
        self.accept("arrow_right", self.controls_set_key, ["cam_right",1])
        self.accept("arrow_left-up", self.controls_set_key, ["cam_left",0])
        self.accept("arrow_right-up", self.controls_set_key, ["cam_right",0])
        self.accept("arrow_up", self.controls_set_key, ["cam_up",1])
        self.accept("arrow_down", self.controls_set_key, ["cam_down",1])
        self.accept("arrow_up-up", self.controls_set_key, ["cam_up",0])
        self.accept("arrow_down-up", self.controls_set_key, ["cam_down",0])

        """Mouse settings"""
        #Previous mouse coordinates, used for camera and dragging elements
        self.controls['mouse_prev_x'] = 0
        self.controls['mouse_prev_y'] = 0
        self.controls['mouse_camera_dragging'] = False
        
        #mouse keys
        #mouse1 is left click
        #Call function to set the player's target
        #set_target_on_mouseclick also sets the mouse1 key value...need to make
        #   this more extensible
        self.accept("mouse1", self.set_target_on_mouseclick)
        self.accept("mouse1-up", self.controls_set_key, ["mouse1", 0])
        #mouse3 is right click
        self.accept("mouse3", self.controls_set_key, ["mouse3", 1])
        self.accept("mouse3-up", self.controls_set_key, ["mouse3", 0]) 
        #mouse2 is scroll wheel click
        self.accept("mouse2", self.controls_set_key, ["mouse2", 1])
        self.accept("mouse2-up", self.controls_set_key, ["mouse2", 0])
        #mouse scroll
        self.accept('wheel_up', self.controls_set_key,["scroll_up", 1 ]) 
        self.accept('wheel_down', self.controls_set_key, ["scroll_down", 1])        
        self.accept ('escape', sys.exit)  # hit escape to quit!
    def enable(self):
        if self.isEnabled:
            assert self.notify.debug("already isEnabled")
            return
        self.isEnabled = 1

        # Let's keep track of what we do on the inputState so that we can undo it later on.
        ist = self.inputStateTokens
        ist.append(inputState.watch("run", "runningEvent", "running-on", "running-off"))
        ist.append(inputState.watch("forward", "force-forward", "force-forward-stop"))
        ist.append(inputState.watchWithModifiers("reverse", "mouse4", inputSource=inputState.Mouse))
        if self.wantWASD:
            self.istWASD.append(inputState.watch("turnLeft", "mouse-look_left", "mouse-look_left-done"))
            self.istWASD.append(inputState.watch("turnLeft", "force-turnLeft", "force-turnLeft-stop"))
            self.istWASD.append(inputState.watch("turnRight", "mouse-look_right", "mouse-look_right-done"))
            self.istWASD.append(inputState.watch("turnRight", "force-turnRight", "force-turnRight-stop"))
            self.istWASD.append(inputState.watchWithModifiers("forward", "w", inputSource=inputState.WASD))
            self.istWASD.append(inputState.watchWithModifiers("reverse", "s", inputSource=inputState.WASD))
            self.setWASDTurn(self.__WASDTurn)
        else:
            self.istNormal.append(
                inputState.watchWithModifiers("forward", "arrow_up", inputSource=inputState.ArrowKeys)
            )
            self.istNormal.append(
                inputState.watchWithModifiers("reverse", "arrow_down", inputSource=inputState.ArrowKeys)
            )
            self.istNormal.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", "force-turnLeft", "force-turnLeft-stop"))
            self.istNormal.append(
                inputState.watchWithModifiers("turnRight", "arrow_right", inputSource=inputState.ArrowKeys)
            )
            ist.append(inputState.watch("turnRight", "mouse-look_right", "mouse-look_right-done"))
            ist.append(inputState.watch("turnRight", "force-turnRight", "force-turnRight-stop"))

        # Jump controls
        if self.wantWASD:
            jumpKey = config.GetString("WASD-jump-key", "space")
            self.istWASD.append(inputState.watchWithModifiers("jump", jumpKey))
        else:
            self.istNormal.append(inputState.watch("jump", "control", "control-up"))
        if self.currentControls:
            self.currentControls.enableAvatarControls()
    def enable(self):
        if self.isEnabled:
            return None

        self.isEnabled = 1
        ist = self.inputStateTokens
        ist.append(
            inputState.watch('run', 'runningEvent', 'running-on',
                             'running-off'))
        ist.append(
            inputState.watchWithModifiers('forward',
                                          'arrow_up',
                                          inputSource=inputState.ArrowKeys))
        ist.append(
            inputState.watch('forward', 'force-forward', 'force-forward-stop'))
        ist.append(
            inputState.watchWithModifiers('reverse',
                                          'arrow_down',
                                          inputSource=inputState.ArrowKeys))
        ist.append(
            inputState.watchWithModifiers('reverse',
                                          'mouse4',
                                          inputSource=inputState.Mouse))
        if self.wantWASD:
            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', 'force-turnLeft',
                                 'force-turnLeft-stop'))
            ist.append(
                inputState.watchWithModifiers(
                    'turnRight',
                    'arrow_right',
                    inputSource=inputState.ArrowKeys))
            ist.append(
                inputState.watch('turnRight', 'mouse-look_right',
                                 'mouse-look_right-done'))
            ist.append(
                inputState.watch('turnRight', 'force-turnRight',
                                 'force-turnRight-stop'))
            ist.append(
                inputState.watchWithModifiers('forward',
                                              'w',
                                              inputSource=inputState.WASD))
            ist.append(
                inputState.watchWithModifiers('reverse',
                                              's',
                                              inputSource=inputState.WASD))
            ist.append(
                inputState.watchWithModifiers('slideLeft',
                                              'q',
                                              inputSource=inputState.QE))
            ist.append(
                inputState.watchWithModifiers('slideRight',
                                              'e',
                                              inputSource=inputState.QE))
            self.setWASDTurn(self._ControlManager__WASDTurn)
        else:
            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', 'force-turnLeft',
                                 'force-turnLeft-stop'))
            ist.append(
                inputState.watchWithModifiers(
                    'turnRight',
                    'arrow_right',
                    inputSource=inputState.ArrowKeys))
            ist.append(
                inputState.watch('turnRight', 'mouse-look_right',
                                 'mouse-look_right-done'))
            ist.append(
                inputState.watch('turnRight', 'force-turnRight',
                                 'force-turnRight-stop'))
        if self.wantWASD:
            ist.append(inputState.watchWithModifiers('jump', 'space'))
        else:
            ist.append(inputState.watch('jump', 'control', 'control-up'))
        if self.currentControls:
            self.currentControls.enableAvatarControls()
Esempio n. 14
0
    def enable(self):
        if self.isEnabled:
            assert self.notify.debug('already isEnabled')
            return
        self.isEnabled = 1

        # Let's keep track of what we do on the inputState so that we can undo it later on.
        ist = self.inputStateTokens
        ist.append(
            inputState.watch("run", 'runningEvent', "running-on",
                             "running-off"))
        ist.append(
            inputState.watch("forward", "force-forward", "force-forward-stop"))
        ist.append(
            inputState.watchWithModifiers("reverse",
                                          "mouse4",
                                          inputSource=inputState.Mouse))
        if self.wantWASD:
            self.istWASD.append(
                inputState.watch("turnLeft", "mouse-look_left",
                                 "mouse-look_left-done"))
            self.istWASD.append(
                inputState.watch("turnLeft", "force-turnLeft",
                                 "force-turnLeft-stop"))
            self.istWASD.append(
                inputState.watch("turnRight", "mouse-look_right",
                                 "mouse-look_right-done"))
            self.istWASD.append(
                inputState.watch("turnRight", "force-turnRight",
                                 "force-turnRight-stop"))
            self.istWASD.append(
                inputState.watchWithModifiers("forward",
                                              "w",
                                              inputSource=inputState.WASD))
            self.istWASD.append(
                inputState.watchWithModifiers("reverse",
                                              "s",
                                              inputSource=inputState.WASD))
            self.setWASDTurn(self.__WASDTurn)
        else:
            self.istNormal.append(
                inputState.watchWithModifiers(
                    "forward", "arrow_up", inputSource=inputState.ArrowKeys))
            self.istNormal.append(
                inputState.watchWithModifiers(
                    "reverse", "arrow_down", inputSource=inputState.ArrowKeys))
            self.istNormal.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", "force-turnLeft",
                                 "force-turnLeft-stop"))
            self.istNormal.append(
                inputState.watchWithModifiers(
                    "turnRight",
                    "arrow_right",
                    inputSource=inputState.ArrowKeys))
            ist.append(
                inputState.watch("turnRight", "mouse-look_right",
                                 "mouse-look_right-done"))
            ist.append(
                inputState.watch("turnRight", "force-turnRight",
                                 "force-turnRight-stop"))

        # Jump controls
        if self.wantWASD:
            jumpKey = config.GetString('WASD-jump-key', 'space')
            self.istWASD.append(inputState.watchWithModifiers("jump", jumpKey))
        else:
            self.istNormal.append(
                inputState.watch("jump", "control", "control-up"))
        if self.currentControls:
            self.currentControls.enableAvatarControls()
Esempio n. 15
0
    def enable(self):
        assert self.notify.debugCall(id(self))

        if self.isEnabled:
            assert self.notify.debug('already isEnabled')
            return

        self.isEnabled = 1

        # keep track of what we do on the inputState so we can undo it later on
        #self.inputStateTokens = []
        ist = self.inputStateTokens
        ist.append(inputState.watch("run", 'runningEvent', "running-on", "running-off"))

        ist.append(inputState.watchWithModifiers("forward", "arrow_up", inputSource=inputState.ArrowKeys))
        ist.append(inputState.watch("forward", "force-forward", "force-forward-stop"))

        ist.append(inputState.watchWithModifiers("reverse", "arrow_down", inputSource=inputState.ArrowKeys))
        ist.append(inputState.watchWithModifiers("reverse", "mouse4", inputSource=inputState.Mouse))

        if self.wantWASD:
            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", "force-turnLeft", "force-turnLeft-stop"))

            ist.append(inputState.watchWithModifiers("turnRight", "arrow_right", inputSource=inputState.ArrowKeys))
            ist.append(inputState.watch("turnRight", "mouse-look_right", "mouse-look_right-done"))
            ist.append(inputState.watch("turnRight", "force-turnRight", "force-turnRight-stop"))

            ist.append(inputState.watchWithModifiers("forward", "w", inputSource=inputState.WASD))
            ist.append(inputState.watchWithModifiers("reverse", "s", inputSource=inputState.WASD))

            ist.append(inputState.watchWithModifiers("slideLeft", "q", inputSource=inputState.QE))
            ist.append(inputState.watchWithModifiers("slideRight", "e", inputSource=inputState.QE))

            self.setWASDTurn(self.__WASDTurn)
        else:
            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", "force-turnLeft", "force-turnLeft-stop"))

            ist.append(inputState.watchWithModifiers("turnRight", "arrow_right", inputSource=inputState.ArrowKeys))
            ist.append(inputState.watch("turnRight", "mouse-look_right", "mouse-look_right-done"))
            ist.append(inputState.watch("turnRight", "force-turnRight", "force-turnRight-stop"))

        # Jump controls
        if self.wantWASD:
            ist.append(inputState.watchWithModifiers("jump", "space"))
        else:
            ist.append(inputState.watch("jump", "control", "control-up"))

        if self.currentControls:
            self.currentControls.enableAvatarControls()
Esempio n. 16
0
    def enable(self):
        if self.isEnabled:
            return

        self.isEnabled = 1
        keymap = settings.get('keymap', {})
        # Keep track of what we do on the inputState so we can undo it later on
        self.inputStateTokens.extend((
            inputState.watch('run', 'runningEvent', 'running-on',
                             'running-off'),
            inputState.watch('forward', 'force-forward', 'force-forward-stop'),
        ))

        if self.wantWASD:
            self.istWASD.extend(
                (inputState.watch('turnLeft', 'mouse-look_left',
                                  'mouse-look_left-done'),
                 inputState.watch('turnLeft', 'force-turnLeft',
                                  'force-turnLeft-stop'),
                 inputState.watch('turnRight', 'mouse-look_right',
                                  'mouse-look_right-done'),
                 inputState.watch('turnRight', 'force-turnRight',
                                  'force-turnRight-stop'),
                 inputState.watchWithModifiers('forward',
                                               keymap.get(
                                                   'MOVE_UP', base.MOVE_UP),
                                               inputSource=inputState.WASD),
                 inputState.watchWithModifiers('reverse',
                                               keymap.get(
                                                   'MOVE_DOWN',
                                                   base.MOVE_DOWN),
                                               inputSource=inputState.WASD),
                 inputState.watchWithModifiers('jump',
                                               keymap.get('JUMP', base.JUMP))))

            self.setWASDTurn(True)

        else:
            self.istNormal.extend((inputState.watchWithModifiers(
                'forward', 'arrow_up', inputSource=inputState.ArrowKeys),
                                   inputState.watchWithModifiers(
                                       'reverse',
                                       'arrow_down',
                                       inputSource=inputState.ArrowKeys),
                                   inputState.watchWithModifiers(
                                       'turnLeft',
                                       'arrow_left',
                                       inputSource=inputState.ArrowKeys),
                                   inputState.watchWithModifiers(
                                       'turnRight',
                                       'arrow_right',
                                       inputSource=inputState.ArrowKeys),
                                   inputState.watch('jump', 'control',
                                                    'control-up')))

            self.istNormal.extend(
                (inputState.watch('turnLeft', 'mouse-look_left',
                                  'mouse-look_left-done'),
                 inputState.watch('turnLeft', 'force-turnLeft',
                                  'force-turnLeft-stop'),
                 inputState.watch('turnRight', 'mouse-look_right',
                                  'mouse-look_right-done'),
                 inputState.watch('turnRight', 'force-turnRight',
                                  'force-turnRight-stop')))

        if self.currentControls:
            self.currentControls.enableAvatarControls()
Esempio n. 17
0
    def __init__(self):
        assert self.notify.debugCall(id(self))
        self.controls = {}
        self.currentControls = None
        self.currentControlsName = None
        self.isEnabled = 1
        #self.monitorTask = taskMgr.add(self.monitor, "ControlManager-%s"%(id(self)), priority=-1)
        self.forceAvJumpToken = None
        # keep track of what we do on the inputState so we can undo it later on
        self.inputStateTokens = []
        ist=self.inputStateTokens
        ist.append(inputState.watch("run", 'runningEvent', "running-on", "running-off"))
        
        ist.append(inputState.watchWithModifiers("forward", "arrow_up", inputSource=inputState.ArrowKeys))
        ist.append(inputState.watch("forward", "force-forward", "force-forward-stop"))
        
        ist.append(inputState.watchWithModifiers("reverse", "arrow_down", inputSource=inputState.ArrowKeys))
        ist.append(inputState.watchWithModifiers("reverse", "mouse4", inputSource=inputState.Mouse))
        
        if self.wantWASD:

            
            
            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", "force-turnLeft", "force-turnLeft-stop"))
            
            ist.append(inputState.watchWithModifiers("turnRight", "arrow_right", inputSource=inputState.ArrowKeys))
            ist.append(inputState.watch("turnRight", "mouse-look_right", "mouse-look_right-done"))
            ist.append(inputState.watch("turnRight", "force-turnRight", "force-turnRight-stop"))

            ist.append(inputState.watchWithModifiers("forward", "w", inputSource=inputState.WASD))
            ist.append(inputState.watchWithModifiers("reverse", "s", inputSource=inputState.WASD))

            # Used to switch between strafe and turn. We will default to turn
            self.WASDTurnTokens = ()
            self.setWASDTurn(1)

        else:
            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", "force-turnLeft", "force-turnLeft-stop"))
            
            ist.append(inputState.watchWithModifiers("turnRight", "arrow_right", inputSource=inputState.ArrowKeys))
            ist.append(inputState.watch("turnRight", "mouse-look_right", "mouse-look_right-done"))
            ist.append(inputState.watch("turnRight", "force-turnRight", "force-turnRight-stop"))


        # Jump controls
        if self.wantWASD:
            ist.append(inputState.watchWithModifiers("jump", "space"))
        else:
            ist.append(inputState.watch("jump", "control", "control-up"))