2 |
Libvob input framework for custom controllers |
Libvob input framework for custom controllers |
3 |
============================================= |
============================================= |
4 |
|
|
5 |
How to read controllers built from LEGO(r) bricks. |
How to read joysticks and custom |
6 |
|
controllers built from LEGO(r) bricks. |
7 |
|
|
8 |
|
|
9 |
Introduction |
Introduction |
81 |
Design |
Design |
82 |
====== |
====== |
83 |
|
|
84 |
First of all, a central class which allows programs to access the currently |
The ``*Model`` classes are a central piece of the API. |
85 |
configured input devices: ``InputDeviceManager``. From this class, users may get |
This is a design similar |
86 |
instances of the ``InputDevice`` class. This class also contains the methods for |
to swing: for each numeric . |
|
beginning and ending calibration. |
|
87 |
|
|
88 |
The ``InputDevice`` classes again allow users to get the axes. |
.. UML:: custominput_models |
89 |
|
|
90 |
.. UML:: custominput_1 |
class Model "interface" |
91 |
|
methods |
92 |
|
addActionListener(...) |
93 |
|
|
94 |
|
class BoundedFloatModel "interface" |
95 |
|
inherit Model |
96 |
|
fields |
97 |
|
minimum |
98 |
|
maximum |
99 |
|
value |
100 |
|
|
101 |
|
class ModFloatModel "interface" |
102 |
|
inherit Model |
103 |
|
fields |
104 |
|
modulus |
105 |
|
value |
106 |
|
methods |
107 |
|
addActionListener(...) |
108 |
|
|
109 |
|
--- |
110 |
|
horizontally(50, xx, BoundedFloatModel, ModFloatModel); |
111 |
|
vertically(50, xx, Model, xx); |
112 |
|
|
|
class InputDeviceManager |
|
113 |
|
|
114 |
class InputDevice |
There can only be one main model per axis - to not confuse the user. |
115 |
|
If desired, we may later add the capability to put in "non-main" |
116 |
|
listeners, but this is not a priority. |
117 |
|
|
118 |
class Axis |
The input devices, on the other hand, are represented by a central class |
119 |
|
which allows programs to access the currently configured input devices: |
120 |
|
``InputDeviceManager``. From this class, users may get instances of |
121 |
|
the ``InputDevice`` class. This class also contains the methods for |
122 |
|
beginning and ending calibration and choosing axes by moving them. |
123 |
|
The ``InputDevice`` classes again allow users to get the axes. |
124 |
|
|
125 |
|
.. UML:: custominput_inputs |
126 |
|
|
127 |
|
class InputDeviceManager "interface" |
128 |
|
fields |
129 |
|
STATE_CALIBRATING |
130 |
|
STATE_CHOOSING |
131 |
|
STATE_NORMAL |
132 |
methods |
methods |
133 |
void setMainAxisListener() |
void setState(int state) |
134 |
|
Axis getCurrentChoice() |
135 |
|
assoc multi(1) - multi(*) InputDevice |
136 |
|
|
137 |
class AxisListener "interface" |
class InputDevice "interface" |
138 |
|
assoc multi(1) - multi(*) Axis |
139 |
|
|
140 |
|
class Axis "interface" |
141 |
|
methods |
142 |
|
getName() |
143 |
|
|
144 |
|
--- |
145 |
|
horizontally(60, InputDeviceManager, InputDevice, Axis); |
146 |
|
|
147 |
|
The models are connected to the axes through absolute and relative |
148 |
|
axis listeners: |
149 |
|
|
150 |
|
.. UML:: custominput_adapters |
151 |
|
|
152 |
|
class Axis "interface" |
153 |
|
assoc multi(1) - multi(0..1) role(mainListener) AxisListener |
154 |
methods |
methods |
155 |
void changed(float value) |
setMainListener(AxisListener l) |
156 |
|
|
157 |
|
class AxisListener "interface" |
158 |
|
|
159 |
|
|
160 |
class AbsoluteAxisListener "interface" |
class AbsoluteAxisListener "interface" |
161 |
inherit AxisListener |
inherit AxisListener |
162 |
|
methods |
163 |
|
void changedAbsolute(float newvalue) |
164 |
|
|
165 |
class RelativeAxisListener "interface" |
class RelativeAxisListener "interface" |
166 |
inherit AxisListener |
inherit AxisListener |
167 |
|
methods |
168 |
|
void changedRelative(float delta) |
169 |
|
|
170 |
class AbsoluteLinearAxisListener |
class BoundedFloatLinearAbsoluteAdapter inherit AbsoluteAxisListener |
171 |
realize AbsoluteAxisListener |
realize AbsoluteAxisListener |
172 |
fields |
dep "use" BoundedFloatModel |
|
AbsoluteAxisListener child |
|
|
float min, max |
|
173 |
|
|
174 |
class AbsoluteLogAxisListener |
class BoundedFloatLogAbsoluteAdapter inherit AbsoluteAxisListener |
175 |
realize AbsoluteAxisListener |
realize AbsoluteAxisListener |
176 |
fields |
dep "use" BoundedFloatModel |
|
AbsoluteAxisListener child |
|
|
float min, max |
|
177 |
|
|
178 |
class FirstDerivativeAxisListener |
class ModFloatRelativeAdapter inherit RelativeAxisListener |
|
fields |
|
|
AbsoluteAxisListener child |
|
|
float min, max |
|
|
float value |
|
|
float sensitivity |
|
179 |
|
|
180 |
class RelativeModAxisListener |
class BoundedFloatModel "interface" |
|
fields |
|
|
AbsoluteAxisListener child |
|
|
float mod |
|
|
float value |
|
181 |
|
|
182 |
|
class ModFloatModel "interface" |
183 |
|
|
184 |
The user end of the picture is handled by the "model" classes: this is a design similar |
--- |
|
to swing. |
|
185 |
|
|
|
class BoundedFloatModel "interface" |
|
|
fields |
|
|
minimum |
|
|
maximum |
|
|
value |
|
|
methods |
|
|
addActionListener(...) |
|
186 |
|
|
|
XXX |
|
187 |
|
|
|
There can only be one main axis listener per axis - to not confuse the user. |
|
|
If desired, we may later add the capability to put in "non-main" listeners. |
|
188 |
|
|
|
.. vim: set syntax=text |
|
189 |
|
|
|
An example use in python code would |
|
190 |
|
|
191 |
|
|
192 |
|
|
193 |
|
.. vim: set syntax=text |