direct.controls.InputState

from direct.controls.InputState import InputState, InputStateForceToken, InputStateToken, InputStateTokenGroup, InputStateWatchToken

Inheritance diagram

Inheritance diagram of direct.controls.InputState

class InputState[source]

Bases: direct.showbase.DirectObject.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'
__init__(self)[source]
debugPrint(self, message)[source]

for debugging

delete(self)[source]
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()
getEventName(self, name)[source]
isSet(self, name, inputSource=None)[source]

returns True/False

notify = <direct.directnotify.Notifier.Notifier object>
releaseInputs(self, name)[source]
set(self, name, isActive, inputSource=None)[source]
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()
watchWithModifiers(self, name, event, startState=False, inputSource=None)[source]
class InputStateForceToken(inputState)[source]

Bases: direct.controls.InputState.InputStateToken

release(self)[source]
class InputStateToken(inputState)[source]

Bases: object

Inval = 'invalidatedToken'
__init__(self, inputState)[source]
invalidate(self)[source]
isValid(self)[source]
release(self)[source]
class InputStateTokenGroup[source]

Bases: object

__init__(self)[source]
addToken(self, token)[source]
release(self)[source]
class InputStateWatchToken(inputState)[source]

Bases: direct.controls.InputState.InputStateToken, direct.showbase.DirectObject.DirectObject

release(self)[source]