Showing 1 changed files with 300 additions and 0 deletions
+300
Systems/multikey.xml
... ...
@@ -2,6 +2,41 @@
2 2
 
3 3
 <PropertyList>
4 4
   <multikey>
5
+    <nasal>
6
+      <script><![CDATA[
7
+        var zkv1000_devices = [];
8
+        foreach (var c; zkv1000.zkv.getChildren()) {
9
+          if (c.getNode('status') != nil) {
10
+            var name = c.getName();
11
+            var role = substr(name, 0, 3);
12
+            if (role == 'MFD' or role == 'PFD') {
13
+              append(zkv1000_devices, name);
14
+              printf("ZKV1000 multikey added %s (:z%u)", name, size(zkv1000_devices));
15
+            }
16
+          }
17
+        }
18
+        var zkv1000_device_available = func (device) {
19
+          return contains(zkv1000.flightdeck, device)
20
+          and zkv1000.zkv.getNode(device).getValue("status") == 1;
21
+        }
22
+        var zkv1000_pushButton = func (device_id, button) {
23
+          if (device_id > 0 and device_id <= size(zkv1000_devices)) {
24
+            var device_name = zkv1000_devices[device_id - 1];
25
+            if (zkv1000_device_available(device_name))
26
+              call(zkv1000.flightdeck[device_name].buttons[button], nil, zkv1000.flightdeck[device_name].buttons);
27
+          }
28
+        }
29
+        var zkv1000_turnKnob = func (device_id, knob, dir, display_name) {
30
+          if (device_id > 0 and device_id <= size(zkv1000_devices)) {
31
+            var device_name = zkv1000_devices[device_id - 1];
32
+            if (zkv1000_device_available(device_name)) {
33
+              _ = sprintf("%s %s", device_name, display_name, dir  > 0 ? "clockwise" : "counterclockwise");
34
+              call(zkv1000.flightdeck[device_name].knobs[knob], [ dir ], zkv1000.flightdeck[device_name].knobs);
35
+            }
36
+          }
37
+        }
38
+      ]]></script>
39
+    </nasal>
5 40
     <key n="122">
6 41
       <name>z</name>
7 42
       <desc>ZKV1000 commands</desc>
... ...
@@ -14,6 +49,271 @@
14 49
           <script>zkv1000.powerOn();</script>
15 50
         </binding>
16 51
       </key>
52
+
53
+      <key n="100">
54
+        <name>d</name>
55
+        <desc>display list of available devices and their numeric label</desc>
56
+        <no-exit/>
57
+        <binding>
58
+          <command>nasal</command>
59
+          <script>
60
+            var list = "List of available ZKV1000 devices";
61
+            forindex (var i; zkv1000_devices)
62
+              list ~= sprintf("\n%u: %s", i+1, zkv1000_devices[i]);
63
+            gui.popupTip(list);
64
+          </script>
65
+        </binding>
66
+      </key>
67
+
68
+      <key n="902">
69
+        <name>%u</name>
70
+        <desc>zkv1000 device index %u</desc>
71
+        <key n="100">
72
+          <name>d</name>
73
+          <desc>DirectTo</desc>
74
+          <exit/>
75
+          <binding>
76
+            <command>nasal</command>
77
+            <script>zkv1000_pushButton(arg[0], "DirectTo");</script>
78
+          </binding>
79
+        </key>
80
+        <key n="109">
81
+          <name>m</name>
82
+          <desc>MENU</desc>
83
+          <exit/>
84
+          <binding>
85
+            <command>nasal</command>
86
+            <script>zkv1000_pushButton(arg[0], "MENU");</script>
87
+          </binding>
88
+        </key>
89
+        <key n="102">
90
+          <name>f</name>
91
+          <desc>FPL</desc>
92
+          <exit/>
93
+          <binding>
94
+            <command>nasal</command>
95
+            <script>zkv1000_pushButton(arg[0], "FPL");</script>
96
+          </binding>
97
+        </key>
98
+        <key n="112">
99
+          <name>p</name>
100
+          <desc>PROC</desc>
101
+          <exit/>
102
+          <binding>
103
+            <command>nasal</command>
104
+            <script>zkv1000_pushButton(arg[0], "PROC");</script>
105
+          </binding>
106
+        </key>
107
+        <key n="99">
108
+          <name>c</name>
109
+          <desc>CLR</desc>
110
+          <exit/>
111
+          <binding>
112
+            <command>nasal</command>
113
+            <script>zkv1000_pushButton(arg[0], "CLR");</script>
114
+          </binding>
115
+        </key>
116
+        <key n="101">
117
+          <name>e</name>
118
+          <desc>ENT</desc>
119
+          <exit/>
120
+          <binding>
121
+            <command>nasal</command>
122
+            <script>zkv1000_pushButton(arg[0], "ENT");</script>
123
+          </binding>
124
+        </key>
125
+        <key n="105">
126
+          <name>i</name>
127
+          <desc>FMS inner knob</desc>
128
+          <key n="94">
129
+            <name>^</name>
130
+            <desc>clockwise</desc>
131
+            <no-exit/>
132
+            <binding>
133
+              <command>nasal</command>
134
+              <script>zkv1000_turnKnob(arg[0], "FmsInner", 1, "FMS inner");</script>
135
+            </binding>
136
+          </key>
137
+          <key n="95">
138
+            <name>_</name>
139
+            <desc>clockwise</desc>
140
+            <no-exit/>
141
+            <binding>
142
+              <command>nasal</command>
143
+              <script>zkv1000_turnKnob(arg[0], "FmsInner", -1, "FMS inner");</script>
144
+            </binding>
145
+          </key>
146
+          <key n="99">
147
+            <name>c</name>
148
+            <desc>CLR</desc>
149
+            <exit/>
150
+            <binding>
151
+              <command>nasal</command>
152
+              <script>zkv1000_pushButton(arg[0], "CLR");</script>
153
+            </binding>
154
+          </key>
155
+          <key n="101">
156
+            <name>e</name>
157
+            <desc>ENT</desc>
158
+            <exit/>
159
+            <binding>
160
+              <command>nasal</command>
161
+              <script>zkv1000_pushButton(arg[0], "ENT");</script>
162
+            </binding>
163
+          </key>
164
+        </key>
165
+        <key n="111">
166
+          <name>o</name>
167
+          <desc>FMS outer knob</desc>
168
+          <key n="94">
169
+            <name>^</name>
170
+            <desc>clockwise</desc>
171
+            <no-exit/>
172
+            <binding>
173
+              <command>nasal</command>
174
+              <script>zkv1000_turnKnob(arg[0], "FmsOuter", -1, "FMS outer");</script>
175
+            </binding>
176
+          </key>
177
+          <key n="95">
178
+            <name>_</name>
179
+            <desc>counterclockwise</desc>
180
+            <no-exit/>
181
+            <binding>
182
+              <command>nasal</command>
183
+              <script>zkv1000_turnKnob(arg[0], "FmsOuter", 1, "FMS outer");</script>
184
+            </binding>
185
+          </key>
186
+          <key n="99">
187
+            <name>c</name>
188
+            <desc>CLR</desc>
189
+            <exit/>
190
+            <binding>
191
+              <command>nasal</command>
192
+              <script>zkv1000_pushButton(arg[0], "CLR");</script>
193
+            </binding>
194
+          </key>
195
+          <key n="101">
196
+            <name>e</name>
197
+            <desc>ENT</desc>
198
+            <exit/>
199
+            <binding>
200
+              <command>nasal</command>
201
+              <script>zkv1000_pushButton(arg[0], "ENT");</script>
202
+            </binding>
203
+          </key>
204
+        </key>
205
+      </key>
206
+
207
+      <key n="97">
208
+        <name>a</name>
209
+        <desc>Autopilot buttons</desc>
210
+        <key n="111">
211
+          <name>o</name>
212
+          <desc>AP</desc>
213
+          <exit/>
214
+          <binding>
215
+            <command>nasal</command>
216
+            <script>zkv1000.autopilot.softkey('L', 0, 1);</script>
217
+          </binding>
218
+        </key>
219
+        <key n="102">
220
+          <name>f</name>
221
+          <desc>FD</desc>
222
+          <exit/>
223
+          <binding>
224
+            <command>nasal</command>
225
+            <script>zkv1000.autopilot.softkey('L', 1, 1);</script>
226
+          </binding>
227
+        </key>
228
+        <key n="110">
229
+          <name>n</name>
230
+          <desc>NAV</desc>
231
+          <exit/>
232
+          <binding>
233
+            <command>nasal</command>
234
+            <script>zkv1000.autopilot.softkey('L', 2, 1);</script>
235
+          </binding>
236
+        </key>
237
+        <key n="97">
238
+          <name>a</name>
239
+          <desc>ALT</desc>
240
+          <exit/>
241
+          <binding>
242
+            <command>nasal</command>
243
+            <script>zkv1000.autopilot.softkey('L', 3, 1);</script>
244
+          </binding>
245
+        </key>
246
+        <key n="118">
247
+          <name>v</name>
248
+          <desc>VS</desc>
249
+          <exit/>
250
+          <binding>
251
+            <command>nasal</command>
252
+            <script>zkv1000.autopilot.softkey('L', 4, 1);</script>
253
+          </binding>
254
+        </key>
255
+        <key n="99">
256
+          <name>c</name>
257
+          <desc>FLC</desc>
258
+          <exit/>
259
+          <binding>
260
+            <command>nasal</command>
261
+            <script>zkv1000.autopilot.softkey('L', 5, 1);</script>
262
+          </binding>
263
+        </key>
264
+        <key n="121">
265
+          <name>y</name>
266
+          <desc>YD</desc>
267
+          <exit/>
268
+          <binding>
269
+            <command>nasal</command>
270
+            <script>zkv1000.autopilot.softkey('R', 0, 1);</script>
271
+          </binding>
272
+        </key>
273
+        <key n="104">
274
+          <name>h</name>
275
+          <desc>HDG</desc>
276
+          <exit/>
277
+          <binding>
278
+            <command>nasal</command>
279
+            <script>zkv1000.autopilot.softkey('R', 1, 1);</script>
280
+          </binding>
281
+        </key>
282
+        <key n="65">
283
+          <name>A</name>
284
+          <desc>APR</desc>
285
+          <exit/>
286
+          <binding>
287
+            <command>nasal</command>
288
+            <script>zkv1000.autopilot.softkey('R', 2, 1);</script>
289
+          </binding>
290
+        </key>
291
+        <key n="">
292
+          <name>V</name>
293
+          <desc>VNV</desc>
294
+          <exit/>
295
+          <binding>
296
+            <command>nasal</command>
297
+            <script>zkv1000.autopilot.softkey('R', 3, 1);</script>
298
+          </binding>
299
+        </key>
300
+        <key n="117">
301
+          <name>u</name>
302
+          <desc>nose UP</desc>
303
+          <binding>
304
+            <command>nasal</command>
305
+            <script>zkv1000.autopilot.softkey('R', 4, 1);</script>
306
+          </binding>
307
+        </key>
308
+        <key n="100">
309
+          <name>d</name>
310
+          <desc>nose DOWN</desc>
311
+          <binding>
312
+            <command>nasal</command>
313
+            <script>zkv1000.autopilot.softkey('R', 5, 1);</script>
314
+          </binding>
315
+        </key>
316
+      </key>
17 317
     </key>
18 318
   </multikey>
19 319
 </PropertyList>