direct.controls.InputState
from direct.controls.InputState import InputState, InputStateForceToken, InputStateToken, InputStateTokenGroup, InputStateWatchToken
Inheritance diagram
- class InputState[source]
Bases:
DirectObject
InputState is for tracking the on/off state of some events. The initial usage is to watch some keyboard keys so that another task can poll the key states. By the way, in general polling is not a good idea, but it is useful in some situations. Know when to use it:) If in doubt, don’t use this class and listen for events instead.
- ArrowKeys = 'ArrowKeys'
- Keyboard = 'Keyboard'
- Mouse = 'Mouse'
- QE = 'QE'
- WASD = 'WASD'
- force(self, name, value, inputSource)[source]
Force isSet(name) to return ‘value’.
This returns a token; hold onto the token and call token.release() when you no longer want to force the state.
Example:
# set up token = inputState.force('forward', True, inputSource='myForwardForcer') ... # tear down token.release()
- notify = <direct.directnotify.Notifier.Notifier object>
- watch(self, name, eventOn, eventOff, startState=False, inputSource=None)[source]
This returns a token; hold onto the token and call token.release() when you no longer want to watch for these events.
Example:
# set up token = inputState.watch('forward', 'w', 'w-up', inputSource=inputState.WASD) ... # tear down token.release()
- class InputStateForceToken(inputState)[source]
Bases:
InputStateToken
- class InputStateWatchToken(inputState)[source]
Bases:
InputStateToken
,DirectObject