Panda3D
Loading...
Searching...
No Matches
InputState Class Reference
Inheritance diagram for InputState:
DirectObject

Public Member Functions

 __init__ (self)
 
 debugPrint (self, message)
 
 delete (self)
 
 force (self, name, value, inputSource)
 
 getEventName (self, name)
 
 isSet (self, name, inputSource=None)
 
 releaseInputs (self, name)
 
 set (self, name, isActive, inputSource=None)
 
 watch (self, name, eventOn, eventOff, startState=False, inputSource=None)
 
 watchWithModifiers (self, name, event, startState=False, inputSource=None)
 
- Public Member Functions inherited from DirectObject
 __init__ (self)
 
 accept (self, event, method, extraArgs=[])
 
 acceptOnce (self, event, method, extraArgs=[])
 
 addTask (self, *args, **kwargs)
 
 detectLeaks (self)
 
 doMethodLater (self, *args, **kwargs)
 
 getAllAccepting (self)
 
 ignore (self, event)
 
 ignoreAll (self)
 
 isAccepting (self, event)
 
 isIgnoring (self, event)
 
 removeAllTasks (self)
 
 removeTask (self, taskOrName)
 

Public Attributes

 set
 

Static Public Attributes

str ArrowKeys = 'ArrowKeys'
 
 debug_print = debugPrint
 
 get_event_name = getEventName
 
 is_set = isSet
 
str Keyboard = 'Keyboard'
 
str Mouse = 'Mouse'
 
 notify = DirectNotifyGlobal.directNotify.newCategory("InputState")
 
str QE = 'QE'
 
 release_inputs = releaseInputs
 
str WASD = 'WASD'
 
 watch_with_modifiers = watchWithModifiers
 
- Static Public Attributes inherited from DirectObject
 accept_once = acceptOnce
 
 add_task = addTask
 
 detect_leaks = detectLeaks
 
 do_method_later = doMethodLater
 
 get_all_accepting = getAllAccepting
 
 ignore_all = ignoreAll
 
 is_accepting = isAccepting
 
 is_ignoring = isIgnoring
 
 remove_all_tasks = removeAllTasks
 
 remove_task = removeTask
 

Protected Member Functions

 _ignore (self, token)
 
 _unforce (self, token)
 
- Protected Member Functions inherited from DirectObject
 _addTask (self, task)
 
 _clearTask (self, task)
 

Protected Attributes

dict _forcingOff = {}
 
dict _forcingOn = {}
 
dict _state = {}
 
dict _token2forceInfo = {}
 
dict _token2inputSource = {}
 
dict _watching = {}
 
- Protected Attributes inherited from DirectObject
dict _taskList = {}
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ __init__()

__init__ ( self)

Member Function Documentation

◆ _ignore()

_ignore ( self,
token )
protected
Undo a watch(). Don't call this directly, call release() on the token that watch() returned.

◆ _unforce()

_unforce ( self,
token )
protected
Stop forcing a value. Don't call this directly, call release() on your token.

◆ debugPrint()

debugPrint ( self,
message )
for debugging

◆ delete()

delete ( self)

◆ force()

force ( self,
name,
value,
inputSource )
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()

getEventName ( self,
name )

◆ isSet()

isSet ( self,
name,
inputSource = None )
returns True/False

◆ releaseInputs()

releaseInputs ( self,
name )

◆ set()

set ( self,
name,
isActive,
inputSource = None )

◆ watch()

watch ( self,
name,
eventOn,
eventOff,
startState = False,
inputSource = None )
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()

watchWithModifiers ( self,
name,
event,
startState = False,
inputSource = None )

Member Data Documentation

◆ _forcingOff

dict _forcingOff = {}
protected

◆ _forcingOn

dict _forcingOn = {}
protected

◆ _state

_state = {}
protected

◆ _token2forceInfo

dict _token2forceInfo = {}
protected

◆ _token2inputSource

dict _token2inputSource = {}
protected

◆ _watching

dict _watching = {}
protected

◆ ArrowKeys

str ArrowKeys = 'ArrowKeys'
static

◆ debug_print

debug_print = debugPrint
static

◆ get_event_name

get_event_name = getEventName
static

◆ is_set

is_set = isSet
static

◆ Keyboard

str Keyboard = 'Keyboard'
static

◆ Mouse

str Mouse = 'Mouse'
static

◆ notify

notify = DirectNotifyGlobal.directNotify.newCategory("InputState")
static

◆ QE

str QE = 'QE'
static

◆ release_inputs

release_inputs = releaseInputs
static

◆ set

set

◆ WASD

str WASD = 'WASD'
static

◆ watch_with_modifiers

watch_with_modifiers = watchWithModifiers
static