| Trees | Indices | Help |
|
|---|
|
|
1 '''
2 Defines methods for getting input on any
3 L{AEInput <AccessEngine.AEInput.AEInput>} device.
4
5 @author: Peter Parente
6 @organization: IBM Corporation
7 @copyright: Copyright (c) 2005, 2007 IBM Corporation
8
9 @author: Nicole Anacker
10 @author: Ramona Bunk
11 @organization: IT Science Center Ruegen gGmbH, Germany
12 @copyright: Copyright (c) 2007, 2008 ITSC Ruegen
13
14 @license: I{The BSD License}
15 All rights reserved. This program and the accompanying materials are made
16 available under the terms of the BSD license which accompanies
17 this distribution, and is available at
18 U{http://www.opensource.org/licenses/bsd-license.php}
19 '''
20
21 import AccessEngine
22 from AEApiError import *
23
25 '''
26 Gets an L{AEInput <AccessEngine.AEInput.AEInput>} device from the
27 L{AEDeviceManager} given its name or its capabilities. The capabilities list
28 may include strings naming L{AEInput <AccessEngine.AEInput.AEInput>}
29 interfaces ("braille" and/or "system input" at present).
30
31 If neither is specified, the first available output device in the
32 L{AEDeviceManager} is returned.
33
34 @param name: Class (UIE) name of the L{AEInput <AccessEngine.AEInput.AEInput>}
35 device to get
36 @type name: string
37 @param capabilities: Names of capabilities required on the device
38 @type capabilities: list of string
39 @return: The named output device
40 @rtype: L{AEInput <AccessEngine.AEInput.AEInput>}
41 @raise InvalidDeviceError: When the specified
42 L{AEInput <AccessEngine.AEInput.AEInput>} device is not found
43 '''
44 if name is not None:
45 device = AccessEngine.AEDeviceManager.getInputByName(name)
46 elif len(capabilities):
47 device = AccessEngine.AEDeviceManager.getInputByCaps(capabilities)
48 else:
49 # TODO: method getFirstInput does not exist
50 device = AccessEngine.AEDeviceManager.getFirstInput()
51 if device is None:
52 # let the system report the device isn't available
53 raise InvalidDeviceError
54 return device
55
57 '''
58 Adds the given device code as a modifier on the named
59 L{AEInput <AccessEngine.AEInput.AEInput>} device. If the device doesn't
60 support modifiers, ignores the error since it's a non-critical operation.
61
62 @param script: The L{AEScript <AEScript.AEScript>} that call this method
63 @type script: L{AEScript <AEScript.AEScript>}
64 @param dev: Reference to an input device
65 @type dev: L{AEInput <AccessEngine.AEInput.AEInput>}
66 @param codes: Action codes to add as modifiers
67 @type codes: list of integer
68 '''
69 # notify device
70 try:
71 func = dev.addModifier
72 except AttributeError:
73 return
74 map(func, codes)
75 # register modifier with script
76 script.registerModifiers(dev, codes)
77
79 '''
80 Removes the given device code as a modifier on the named
81 L{AEInput <AccessEngine.AEInput.AEInput>} device. If the device doesn't
82 support modifiers, ignores the error since it's a non-critical operation.
83
84 @param script: The L{AEScript <AEScript.AEScript>} that call this method
85 @type script: L{AEScript <AEScript.AEScript>}
86 @param dev: Reference to an input device
87 @type dev: L{AEInput <AccessEngine.AEInput.AEInput>}
88 @param codes: Action codes to add as modifiers
89 @type codes: list of integer
90 '''
91 # notify device
92 try:
93 func = dev.removeModifier
94 except AttributeError:
95 return
96 map(func, codes)
97
98 try:
99 # unregister modifier from script
100 script.unregisterModifiers(dev, codes)
101 except AttributeError:
102 pass
103
| Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0beta1 on Mon Jun 30 13:06:13 2008 | http://epydoc.sourceforge.net |