Package AccessEngine :: Package AEDevice :: Package AEInput :: Module Base :: Class AEInput
[hide private]
[frames] | no frames]

Class AEInput

source code

                     object --+    
                              |    
AEUserInterface.AEUserInterface --+
                                  |
                                 AEInput

Most abstract base class for all AEInput devices. Maintains a collection of Gesture listeners that can be notified using _notifyInputListeners. Defines simple init and close methods that change the state of the ready flag.

This class is abstract as most of its methods raise NotImplementedError and need to be overriden with input device specific code in subclasses.

Instance Methods [hide private]
 
__init__(self)
Initializes the listeners list to empty and sets the ready flag to False.
source code
 
init(self)
Called after the instance is created to initialize the device.
source code
list of string
getCapabilities(self)
Gets a list of strings representing the capabilities of this device.
source code
 
close(self)
Closes an initialized input device.
source code
 
addInputListener(self, listener)
Adds a listener to be notified whenever a Gesture occurs on an input device.
source code
 
removeInputListener(self, listener)
Removes an existing listener for Gestures.
source code
boolean
inputListenersExist(self)
Gets if there are any registered Gesture listeners for this device.
source code
 
_notifyInputListeners(self, gesture, timestamp, **kwargs)
Notifies registered listeners about a Gesture seen on the input device.
source code
list of integer
sortGesture(self, gesture)
Sorts the actions in the given AEInput.Gesture and returns them as a list of integers.
source code
integer
getMaxActions(self)
Abstract method.
source code
string
asString(self, gesture)
Abstract method.
source code
 
addKeyCmd(self, codes)
Abstract method.
source code
 
removeKeyCmd(self, codes)
Abstract method.
source code

Inherited from AEUserInterface.AEUserInterface: getClassName, getDescription, getName, getPath

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Instance Variables [hide private]
list of callable listeners
Collection of listeners that are notified about Gestures on an input device
boolean ready
Is the input device initialized?
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 
Initializes the listeners list to empty and sets the ready flag to False.
Overrides: object.__init__

init(self)

source code 

Called after the instance is created to initialize the device.

If called when already initialized, this will restore the device to it's initialized state. May also be called to re-initialize the device after a call to close.
Raises:
  • NotImplementedError - When not overridden in a subclass
  • Error.InitError - When a communication or state problem exists for the specific device

getCapabilities(self)

source code 

Gets a list of strings representing the capabilities of this device. Typical output capabilities include "system input," "braille," "switch," etc. though others are certainly possible.

The AEDeviceManager will only load a device if another device doesn't already provide all of its capabilities.
Returns: list of string
Lowercase names of output capabilities

close(self)

source code 
Closes an initialized input device.
Raises:
  • NotImplementedError - When not overridden in a subclass

addInputListener(self, listener)

source code 
Adds a listener to be notified whenever a Gesture occurs on an input device. Listeners are called in the order they are added and are given the Gesture detected.
Parameters:
  • listener (callable) - Object to call when a Gesture occurs

removeInputListener(self, listener)

source code 
Removes an existing listener for Gestures.
Parameters:
  • listener (callable) - Object to remove from the listener list
Raises:
  • ValueError - When removing a listener that is not registered

inputListenersExist(self)

source code 
Gets if there are any registered Gesture listeners for this device.
Returns: boolean
Is there at least one listener registered?

_notifyInputListeners(self, gesture, timestamp, **kwargs)

source code 
Notifies registered listeners about a Gesture seen on the input device. Catches all exceptions from the callback and logs them.
Parameters:
  • gesture (Gesture) - Gesture to send to listeners
  • timestamp (float) - Time at which at the gesture happened
  • kwargs (dictionary) - Additional data to include in the notification

sortGesture(self, gesture)

source code 
Sorts the actions in the given AEInput.Gesture and returns them as a list of integers. The sort is done on a copy so the action codes held by the provided AEInput.Gesture are not touched.
Parameters:
Returns: list of integer
Sorted list of action codes that may be wrapped in a new AEInput.Gesture

getMaxActions(self)

source code 
Abstract method. Gets the maximum number of actions that can be in a Gesture on this input device.
Returns: integer
Maximum number of actions per Gesture supported by this device
Raises:
  • NotImplementedError - When this method is not overridden by a subclass

asString(self, gesture)

source code 
Abstract method. Gets a human readable representation of the given Gesture.
Parameters:
Returns: string
Text representation of the Gesture
Raises:
  • NotImplementedError - When this method is not overridden by a subclass

addKeyCmd(self, codes)

source code 
Abstract method. Registers KEY_CMD with device .
Parameters:
  • codes (list) - list of lists of KEY_CMD* codes
Raises:
  • NotImplementedError - When this method is not overridden by a subclass

removeKeyCmd(self, codes)

source code 
Abstract method. Unregisters KEY_CMD with device .
Parameters:
  • codes (list) - list of lists of KEY_CMD* codes
Raises:
  • NotImplementedError - When this method is not overridden by a subclass