1 | /* Copyright (c) 2013 by István Váradi
|
---|
2 | *
|
---|
3 | * This file is part of XPLRA, a remote-access plugin for X-Plane
|
---|
4 | *
|
---|
5 | * Redistribution and use in source and binary forms, with or without
|
---|
6 | * modification, are permitted provided that the following conditions are met:
|
---|
7 | *
|
---|
8 | * 1. Redistributions of source code must retain the above copyright notice, this
|
---|
9 | * list of conditions and the following disclaimer.
|
---|
10 | * 2. Redistributions in binary form must reproduce the above copyright notice,
|
---|
11 | * this list of conditions and the following disclaimer in the documentation
|
---|
12 | * and/or other materials provided with the distribution.
|
---|
13 | *
|
---|
14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
---|
15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
---|
16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
---|
17 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
---|
18 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
---|
19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
---|
20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
---|
21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
---|
23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
24 | *
|
---|
25 | * The views and conclusions contained in the software and documentation are those
|
---|
26 | * of the authors and should not be interpreted as representing official policies,
|
---|
27 | * either expressed or implied, of the FreeBSD Project.
|
---|
28 | */
|
---|
29 |
|
---|
30 | #ifndef HU_VARADIISTVAN_XPLRA_XPLRA_H
|
---|
31 | #define HU_VARADIISTVAN_XPLRA_XPLRA_H
|
---|
32 | /*----------------------------------------------------------------------------*/
|
---|
33 |
|
---|
34 | #include <stdlib.h>
|
---|
35 | #include <inttypes.h>
|
---|
36 |
|
---|
37 | /*----------------------------------------------------------------------------*/
|
---|
38 |
|
---|
39 | #ifdef __cplusplus
|
---|
40 | extern "C" {
|
---|
41 | #endif
|
---|
42 |
|
---|
43 | /*----------------------------------------------------------------------------*/
|
---|
44 |
|
---|
45 | /** No error occured */
|
---|
46 | #define ERROR_NONE 0
|
---|
47 |
|
---|
48 | /**
|
---|
49 | * An I/O error has occured. The subcode is the errno value on Linux, or the
|
---|
50 | * Windows error code.
|
---|
51 | */
|
---|
52 | #define ERROR_IO 1
|
---|
53 |
|
---|
54 | /**
|
---|
55 | * A protocol error has occured. The subcode is one of the
|
---|
56 | * ERROR_PROTOCOL_XXX values.
|
---|
57 | */
|
---|
58 | #define ERROR_PROTOCOL 2
|
---|
59 |
|
---|
60 | /** Invalid command was passed to the plugin */
|
---|
61 | #define ERROR_PROTOCOL_INVALID_COMMAND = 1
|
---|
62 |
|
---|
63 | /** An unknown dataref was specified */
|
---|
64 | #define ERROR_PROTOCOL_UNKNOWN_DATAREF = 2
|
---|
65 |
|
---|
66 | /** An invalid type was specified */
|
---|
67 | #define ERROR_PROTOCOL_INVALID_TYPE = 3
|
---|
68 |
|
---|
69 | /** An invalid length was specified */
|
---|
70 | #define ERROR_PROTOCOL_INVALID_LENGTH = 4
|
---|
71 |
|
---|
72 | /** An invalid offset was specified */
|
---|
73 | #define ERROR_PROTOCOL_INVALID_OFFSET = 5
|
---|
74 |
|
---|
75 | /** An invalid count was specified */
|
---|
76 | #define ERROR_PROTOCOL_INVALID_COUNT = 6
|
---|
77 |
|
---|
78 | /** An invalid ID was specified */
|
---|
79 | #define ERROR_PROTOCOL_INVALID_ID = 7
|
---|
80 |
|
---|
81 | /** An invalid duration was specified */
|
---|
82 | #define ERROR_PROTOCOL_INVALID_DURATION = 8
|
---|
83 |
|
---|
84 | /** Other protocol error */
|
---|
85 | #define ERROR_PROTOCOL_OTHER = 255
|
---|
86 |
|
---|
87 | /** A function requiring a connection is called without a connection */
|
---|
88 | #define ERROR_NOT_CONNECTED 3
|
---|
89 |
|
---|
90 | /** A type-specific function was called for a dataref of a different type */
|
---|
91 | #define ERROR_TYPE_MISMATCH 4
|
---|
92 |
|
---|
93 | /** An invalid ID was passed to a function */
|
---|
94 | #define ERROR_INVALID_ID 5
|
---|
95 |
|
---|
96 | /** Some other error */
|
---|
97 | #define ERROR_OTHER 255
|
---|
98 |
|
---|
99 | /*----------------------------------------------------------------------------*/
|
---|
100 |
|
---|
101 | /** Hotkey modifier: Shift */
|
---|
102 | #define HOTKEY_MODIFIER_SHIFT 0x01
|
---|
103 |
|
---|
104 | /** Hotkey modifier: Control */
|
---|
105 | #define HOTKEY_MODIFIER_CONTROL 0x02
|
---|
106 |
|
---|
107 | /*----------------------------------------------------------------------------*/
|
---|
108 |
|
---|
109 | #define INVALID_DATAREF_ID ((size_t)-1)
|
---|
110 |
|
---|
111 | /*----------------------------------------------------------------------------*/
|
---|
112 |
|
---|
113 | /**
|
---|
114 | * Get the last error code with the subcode.
|
---|
115 | *
|
---|
116 | * @return the last error code, or -1 if the given connection ID is invalid.
|
---|
117 | */
|
---|
118 | int xplra_get_last_error(int connectionID, unsigned long* subCode);
|
---|
119 |
|
---|
120 | /**
|
---|
121 | * Get a string representation of the last error.
|
---|
122 | *
|
---|
123 | * @return the string representation of the last error, or 0 if there
|
---|
124 | * was no last error, or the connection ID is invalid.
|
---|
125 | */
|
---|
126 | const char* xplra_get_last_error_string(int connectionID);
|
---|
127 |
|
---|
128 | /**
|
---|
129 | * Clear the last error.
|
---|
130 | */
|
---|
131 | void xplra_clear_last_error(int connectionID);
|
---|
132 |
|
---|
133 | /*----------------------------------------------------------------------------*/
|
---|
134 |
|
---|
135 | /**
|
---|
136 | * Connect to the simulator.
|
---|
137 | *
|
---|
138 | * @return an ID for the created connection, or -1 on error.
|
---|
139 | */
|
---|
140 | int xplra_connect();
|
---|
141 |
|
---|
142 | /*----------------------------------------------------------------------------*/
|
---|
143 |
|
---|
144 | /**
|
---|
145 | * Get the versions of X-Plane, the XPLM library and XPLRA
|
---|
146 | */
|
---|
147 | int xplra_get_versions(int connectionID,
|
---|
148 | int* xplaneVersion, int* xplmVersion,
|
---|
149 | int* xplraVersion);
|
---|
150 |
|
---|
151 | /*----------------------------------------------------------------------------*/
|
---|
152 |
|
---|
153 | /**
|
---|
154 | * Reload the plugins in X-Plane. After this the connection fails.
|
---|
155 | */
|
---|
156 | int xplra_reload_plugins(int connectionID);
|
---|
157 |
|
---|
158 | /*----------------------------------------------------------------------------*/
|
---|
159 | /* Single dataref support */
|
---|
160 | /*----------------------------------------------------------------------------*/
|
---|
161 |
|
---|
162 | /**
|
---|
163 | * Get an integer value from the simulator.
|
---|
164 | *
|
---|
165 | * @return 0 on success, -1 on error
|
---|
166 | */
|
---|
167 | int xplra_get_int(int* value, int connectionID, const char* name);
|
---|
168 |
|
---|
169 | /*----------------------------------------------------------------------------*/
|
---|
170 |
|
---|
171 | /**
|
---|
172 | * Get a float value from the simulator.
|
---|
173 | *
|
---|
174 | * @return 0 on success, -1 on error
|
---|
175 | */
|
---|
176 | int xplra_get_float(float* value, int connectionID, const char* name);
|
---|
177 |
|
---|
178 | /*----------------------------------------------------------------------------*/
|
---|
179 |
|
---|
180 | /**
|
---|
181 | * Get a double value from the simulator.
|
---|
182 | *
|
---|
183 | * @return 0 on success, -1 on error
|
---|
184 | */
|
---|
185 | int xplra_get_double(double* value, int connectionID, const char* name);
|
---|
186 |
|
---|
187 | /*----------------------------------------------------------------------------*/
|
---|
188 |
|
---|
189 | /**
|
---|
190 | * Get an array of floats into a buffer.
|
---|
191 | *
|
---|
192 | * @param dest the array into which to get the data
|
---|
193 | * @param length the length of the destination buffer
|
---|
194 | * @param offset the offset from which to query the array
|
---|
195 | *
|
---|
196 | * @return the actual number of elements returned in case of success,
|
---|
197 | * -1 on error
|
---|
198 | */
|
---|
199 | ssize_t xplra_get_float_array(float* dest, size_t length, size_t offset,
|
---|
200 | int connectionID, const char* name);
|
---|
201 |
|
---|
202 | /*----------------------------------------------------------------------------*/
|
---|
203 |
|
---|
204 | /**
|
---|
205 | * Get an array of floats into a newly allocated buffer.
|
---|
206 | *
|
---|
207 | * @param length pointer to a variable containing the length to
|
---|
208 | * query. On return it will be set to the actual length, which can be
|
---|
209 | * less than or equal to the input value.
|
---|
210 | * @param offset the offset from which to query the array
|
---|
211 | *
|
---|
212 | * @return the new array on success, 0 on error
|
---|
213 | */
|
---|
214 | float* xplra_get_float_array_new(size_t* length, size_t offset,
|
---|
215 | int connectionID, const char* name);
|
---|
216 |
|
---|
217 | /*----------------------------------------------------------------------------*/
|
---|
218 |
|
---|
219 | /**
|
---|
220 | * Get an array of integers into a buffer.
|
---|
221 | *
|
---|
222 | * @param dest the array into which to get the data
|
---|
223 | * @param length the length of the destination buffer
|
---|
224 | * @param offset the offset from which to query the array
|
---|
225 | *
|
---|
226 | * @return the actual number of elements returned in case of success,
|
---|
227 | * -1 on error
|
---|
228 | */
|
---|
229 | ssize_t xplra_get_int_array(int32_t* dest, size_t length, size_t offset,
|
---|
230 | int connectionID, const char* name);
|
---|
231 |
|
---|
232 | /*----------------------------------------------------------------------------*/
|
---|
233 |
|
---|
234 | /**
|
---|
235 | * Get an array of integers into a newly allocated buffer.
|
---|
236 | *
|
---|
237 | * @param length pointer to a variable containing the length to
|
---|
238 | * query. On return it will be set to the actual length, which can be
|
---|
239 | * less than or equal to the input value.
|
---|
240 | * @param offset the offset from which to query the array
|
---|
241 | *
|
---|
242 | * @return the new array on success, 0 on error
|
---|
243 | */
|
---|
244 | int32_t* xplra_get_int_array_new(size_t* length, size_t offset,
|
---|
245 | int connectionID, const char* name);
|
---|
246 |
|
---|
247 | /*----------------------------------------------------------------------------*/
|
---|
248 |
|
---|
249 | /**
|
---|
250 | * Get an array of bytes into a buffer.
|
---|
251 | *
|
---|
252 | * @param dest the array into which to get the data
|
---|
253 | * @param length the length of the destination buffer
|
---|
254 | * @param offset the offset from which to query the array
|
---|
255 | *
|
---|
256 | * @return the actual number of elements returned in case of success,
|
---|
257 | * -1 on error
|
---|
258 | */
|
---|
259 | ssize_t xplra_get_byte_array(void* dest, size_t length, size_t offset,
|
---|
260 | int connectionID, const char* name);
|
---|
261 |
|
---|
262 | /*----------------------------------------------------------------------------*/
|
---|
263 |
|
---|
264 | /**
|
---|
265 | * Get an array of bytes into a newly allocated buffer.
|
---|
266 | *
|
---|
267 | * @param length pointer to a variable containing the length to
|
---|
268 | * query. On return it will be set to the actual length, which can be
|
---|
269 | * less than or equal to the input value.
|
---|
270 | * @param offset the offset from which to query the array
|
---|
271 | *
|
---|
272 | * @return the new array on success, 0 on error
|
---|
273 | */
|
---|
274 | uint8_t* xplra_get_byte_array_new(size_t* length, size_t offset,
|
---|
275 | int connectionID, const char* name);
|
---|
276 |
|
---|
277 | /*----------------------------------------------------------------------------*/
|
---|
278 |
|
---|
279 | /**
|
---|
280 | * Set the integer dataref with the given name to the given value.
|
---|
281 | *
|
---|
282 | * @return 0 on success, -1 on error.
|
---|
283 | */
|
---|
284 | int xplra_set_int(int connectionID, const char* name, int value);
|
---|
285 |
|
---|
286 | /*----------------------------------------------------------------------------*/
|
---|
287 |
|
---|
288 | /**
|
---|
289 | * Set the float dataref with the given name to the given value.
|
---|
290 | *
|
---|
291 | * @return 0 on success, -1 on error.
|
---|
292 | */
|
---|
293 | int xplra_set_float(int connectionID, const char* name, float value);
|
---|
294 |
|
---|
295 | /*----------------------------------------------------------------------------*/
|
---|
296 |
|
---|
297 | /**
|
---|
298 | * Set the double dataref with the given name to the given value.
|
---|
299 | *
|
---|
300 | * @return 0 on success, -1 on error.
|
---|
301 | */
|
---|
302 | int xplra_set_double(int connectionID, const char* name, double value);
|
---|
303 |
|
---|
304 | /*----------------------------------------------------------------------------*/
|
---|
305 |
|
---|
306 | /**
|
---|
307 | * Set the array of float values with the given name from the given
|
---|
308 | * buffer.
|
---|
309 | *
|
---|
310 | * @return 0 on success, -1 on error.
|
---|
311 | */
|
---|
312 | int xplra_set_float_array(int connectionID, const char* name,
|
---|
313 | const float* values, size_t length, size_t offset);
|
---|
314 |
|
---|
315 | /*----------------------------------------------------------------------------*/
|
---|
316 |
|
---|
317 | /**
|
---|
318 | * Set the array of integer values with the given name from the given
|
---|
319 | * buffer.
|
---|
320 | *
|
---|
321 | * @return 0 on success, -1 on error.
|
---|
322 | */
|
---|
323 | int xplra_set_int_array(int connectionID, const char* name,
|
---|
324 | const int32_t* values, size_t length, size_t offset);
|
---|
325 |
|
---|
326 | /*----------------------------------------------------------------------------*/
|
---|
327 |
|
---|
328 | /**
|
---|
329 | * Set the array of byte values with the given name from the given
|
---|
330 | * buffer.
|
---|
331 | *
|
---|
332 | * @return 0 on success, -1 on error.
|
---|
333 | */
|
---|
334 | int xplra_set_byte_array(int connectionID, const char* name,
|
---|
335 | const void* values, size_t length, size_t offset);
|
---|
336 |
|
---|
337 | /*----------------------------------------------------------------------------*/
|
---|
338 |
|
---|
339 | /**
|
---|
340 | * Set the array of byte values with the given name from the given
|
---|
341 | * string. The string will be padded with 0 if it has a length less
|
---|
342 | * than the given length.
|
---|
343 | *
|
---|
344 | * @return 0 on success, -1 on error.
|
---|
345 | */
|
---|
346 | int xplra_set_string(int connectionID, const char* name,
|
---|
347 | const char* value, size_t length, size_t offset);
|
---|
348 |
|
---|
349 | /*----------------------------------------------------------------------------*/
|
---|
350 | /* Multi-dataref support */
|
---|
351 | /*----------------------------------------------------------------------------*/
|
---|
352 |
|
---|
353 | /**
|
---|
354 | * Create a multi-dataref getter for the given connection.
|
---|
355 | *
|
---|
356 | * @return the ID of the new getter, or -1 on error
|
---|
357 | */
|
---|
358 | int xplra_multi_create_getter(int connectionID);
|
---|
359 |
|
---|
360 | /*----------------------------------------------------------------------------*/
|
---|
361 |
|
---|
362 | /**
|
---|
363 | * Create a multi-dataref setter for the given connection.
|
---|
364 | *
|
---|
365 | * @return the ID of the new setter, or -1 on error
|
---|
366 | */
|
---|
367 | int xplra_multi_create_setter(int connectionID);
|
---|
368 |
|
---|
369 | /*----------------------------------------------------------------------------*/
|
---|
370 |
|
---|
371 | /**
|
---|
372 | * Add an integer dataref to a multi-dataref buffer.
|
---|
373 | *
|
---|
374 | * @return the ID of the dataref that can be used later. If the buffer
|
---|
375 | * ID is invalid, INVALID_DATAREF_ID is returned.
|
---|
376 | */
|
---|
377 | size_t xplra_multi_add_int(int bufferID, const char* name);
|
---|
378 |
|
---|
379 | /*----------------------------------------------------------------------------*/
|
---|
380 |
|
---|
381 | /**
|
---|
382 | * Add a float dataref to a multi-dataref buffer.
|
---|
383 | *
|
---|
384 | * @return the ID of the dataref that can be used later. If the buffer
|
---|
385 | * ID is invalid, INVALID_DATAREF_ID is returned.
|
---|
386 | */
|
---|
387 | size_t xplra_multi_add_float(int bufferID, const char* name);
|
---|
388 |
|
---|
389 | /*----------------------------------------------------------------------------*/
|
---|
390 |
|
---|
391 | /**
|
---|
392 | * Add a double dataref to a multi-dataref buffer.
|
---|
393 | *
|
---|
394 | * @return the ID of the dataref that can be used later. If the buffer
|
---|
395 | * ID is invalid, INVALID_DATAREF_ID is returned.
|
---|
396 | */
|
---|
397 | size_t xplra_multi_add_double(int bufferID, const char* name);
|
---|
398 |
|
---|
399 | /*----------------------------------------------------------------------------*/
|
---|
400 |
|
---|
401 | /**
|
---|
402 | * Add a float array dataref to a multi-dataref buffer.
|
---|
403 | *
|
---|
404 | * @return the ID of the dataref that can be used later. If the buffer
|
---|
405 | * ID is invalid, INVALID_DATAREF_ID is returned.
|
---|
406 | */
|
---|
407 | size_t xplra_multi_add_float_array(int bufferID, const char* name,
|
---|
408 | size_t length, size_t offset);
|
---|
409 |
|
---|
410 | /*----------------------------------------------------------------------------*/
|
---|
411 |
|
---|
412 | /**
|
---|
413 | * Add an integer array dataref to a multi-dataref buffer.
|
---|
414 | *
|
---|
415 | * @return the ID of the dataref that can be used later. If the buffer
|
---|
416 | * ID is invalid, INVALID_DATAREF_ID is returned.
|
---|
417 | */
|
---|
418 | size_t xplra_multi_add_int_array(int bufferID, const char* name,
|
---|
419 | size_t length, size_t offset);
|
---|
420 |
|
---|
421 | /*----------------------------------------------------------------------------*/
|
---|
422 |
|
---|
423 | /**
|
---|
424 | * Add a byte array dataref to a multi-dataref buffer.
|
---|
425 | *
|
---|
426 | * @return the ID of the dataref that can be used later. If the buffer
|
---|
427 | * ID is invalid, INVALID_DATAREF_ID is returned.
|
---|
428 | */
|
---|
429 | size_t xplra_multi_add_byte_array(int bufferID, const char* name,
|
---|
430 | size_t length, size_t offset);
|
---|
431 |
|
---|
432 | /*----------------------------------------------------------------------------*/
|
---|
433 |
|
---|
434 | /**
|
---|
435 | * Finalize the given buffer, if not finalized yet.
|
---|
436 | *
|
---|
437 | * @return -1 on error (if the buffer ID is invalid), 0 if there is no
|
---|
438 | * data in the buffer, 1 if there is data in it.
|
---|
439 | */
|
---|
440 | int xplra_multi_finalize(int bufferID);
|
---|
441 |
|
---|
442 | /*----------------------------------------------------------------------------*/
|
---|
443 |
|
---|
444 | /**
|
---|
445 | * Register the buffer with the given ID in X-Plane. If needed, it
|
---|
446 | * will be finalized too.
|
---|
447 | *
|
---|
448 | * @return 0 on success, -1 on error
|
---|
449 | */
|
---|
450 | int xplra_multi_register(int bufferID);
|
---|
451 |
|
---|
452 | /*----------------------------------------------------------------------------*/
|
---|
453 |
|
---|
454 | /**
|
---|
455 | * Unregister the buffer with the given ID from X-Plane. If needed, it
|
---|
456 | * will be finalized too.
|
---|
457 | *
|
---|
458 | * @return 0 on success, -1 on error
|
---|
459 | */
|
---|
460 | int xplra_multi_unregister(int bufferID);
|
---|
461 |
|
---|
462 | /*----------------------------------------------------------------------------*/
|
---|
463 |
|
---|
464 | /**
|
---|
465 | * Execute the buffer with the given ID. If the buffer is not
|
---|
466 | * finalized, it will be finalized. If it is not finalized, but
|
---|
467 | * registered, the registration will be cleared, and it will be
|
---|
468 | * re-registered after finalizing.
|
---|
469 | *
|
---|
470 | * @return 0 on success, -1 on error
|
---|
471 | */
|
---|
472 | int xplra_multi_execute(int bufferID);
|
---|
473 |
|
---|
474 | /*----------------------------------------------------------------------------*/
|
---|
475 |
|
---|
476 | /**
|
---|
477 | * Set the value of an integer dataref with the given ID.
|
---|
478 | *
|
---|
479 | * @return 0 on success, -1 on error.
|
---|
480 | */
|
---|
481 | int xplra_multi_set_int(int bufferID, size_t datarefID, int value);
|
---|
482 |
|
---|
483 | /*----------------------------------------------------------------------------*/
|
---|
484 |
|
---|
485 | /**
|
---|
486 | * Get the value of an integer dataref with the given ID.
|
---|
487 | *
|
---|
488 | * @param dest pointer to the variable that will receive the value
|
---|
489 | *
|
---|
490 | * @return 0 on success, -1 on error.
|
---|
491 | */
|
---|
492 | int xplra_multi_get_int(int* dest, int bufferID, size_t datarefID);
|
---|
493 |
|
---|
494 | /*----------------------------------------------------------------------------*/
|
---|
495 |
|
---|
496 | /**
|
---|
497 | * Get a const pointer to the integer dataref with the given ID
|
---|
498 | *
|
---|
499 | * @return the pointer or success, 0 on error.
|
---|
500 | */
|
---|
501 | const int32_t* xplra_multi_get_int_const_ptr(int bufferID, size_t datarefID);
|
---|
502 |
|
---|
503 | /*----------------------------------------------------------------------------*/
|
---|
504 |
|
---|
505 | /**
|
---|
506 | * Get a pointer to the integer dataref with the given ID
|
---|
507 | *
|
---|
508 | * @return the pointer or success, 0 on error.
|
---|
509 | */
|
---|
510 | int32_t* xplra_multi_get_int_ptr(int bufferID, size_t datarefID);
|
---|
511 |
|
---|
512 | /*----------------------------------------------------------------------------*/
|
---|
513 |
|
---|
514 | /**
|
---|
515 | * Set the value of a float dataref with the given ID.
|
---|
516 | *
|
---|
517 | * @return 0 on success, -1 on error.
|
---|
518 | */
|
---|
519 | int xplra_multi_set_float(int bufferID, size_t datarefID, float value);
|
---|
520 |
|
---|
521 | /*----------------------------------------------------------------------------*/
|
---|
522 |
|
---|
523 | /**
|
---|
524 | * Get the value of a float dataref with the given ID.
|
---|
525 | *
|
---|
526 | * @param dest pointer to the variable that will receive the value
|
---|
527 | *
|
---|
528 | * @return 0 on success, -1 on error.
|
---|
529 | */
|
---|
530 | int xplra_multi_get_float(float* dest, int bufferID, size_t datarefID);
|
---|
531 |
|
---|
532 | /*----------------------------------------------------------------------------*/
|
---|
533 |
|
---|
534 | /**
|
---|
535 | * Get a const pointer to the float dataref with the given ID
|
---|
536 | *
|
---|
537 | * @return the pointer or success, 0 on error.
|
---|
538 | */
|
---|
539 | const float* xplra_multi_get_float_const_ptr(int bufferID, size_t datarefID);
|
---|
540 |
|
---|
541 | /*----------------------------------------------------------------------------*/
|
---|
542 |
|
---|
543 | /**
|
---|
544 | * Get a pointer to the float dataref with the given ID
|
---|
545 | *
|
---|
546 | * @return the pointer or success, 0 on error.
|
---|
547 | */
|
---|
548 | float* xplra_multi_get_float_ptr(int bufferID, size_t datarefID);
|
---|
549 |
|
---|
550 | /*----------------------------------------------------------------------------*/
|
---|
551 |
|
---|
552 | /**
|
---|
553 | * Set the value of a double dataref with the given ID.
|
---|
554 | *
|
---|
555 | * @return 0 on success, -1 on error.
|
---|
556 | */
|
---|
557 | int xplra_multi_set_double(int bufferID, size_t datarefID, double value);
|
---|
558 |
|
---|
559 | /*----------------------------------------------------------------------------*/
|
---|
560 |
|
---|
561 | /**
|
---|
562 | * Get the value of a double dataref with the given ID.
|
---|
563 | *
|
---|
564 | * @param dest pointer to the variable that will receive the value
|
---|
565 | *
|
---|
566 | * @return 0 on success, -1 on error.
|
---|
567 | */
|
---|
568 | int xplra_multi_get_double(double* dest, int bufferID, size_t datarefID);
|
---|
569 |
|
---|
570 | /*----------------------------------------------------------------------------*/
|
---|
571 |
|
---|
572 | /**
|
---|
573 | * Get a const pointer to the double dataref with the given ID
|
---|
574 | *
|
---|
575 | * @return the pointer or success, 0 on error.
|
---|
576 | */
|
---|
577 | const double* xplra_multi_get_double_const_ptr(int bufferID, size_t datarefID);
|
---|
578 |
|
---|
579 | /*----------------------------------------------------------------------------*/
|
---|
580 |
|
---|
581 | /**
|
---|
582 | * Get a pointer to the double dataref with the given ID
|
---|
583 | *
|
---|
584 | * @return the pointer or success, 0 on error.
|
---|
585 | */
|
---|
586 | double* xplra_multi_get_double_ptr(int bufferID, size_t datarefID);
|
---|
587 |
|
---|
588 | /*----------------------------------------------------------------------------*/
|
---|
589 |
|
---|
590 | /**
|
---|
591 | * Set the contents of the float array dataref with the given ID.
|
---|
592 | *
|
---|
593 | * @param length the amount of data. If 0, it is assumed to be the
|
---|
594 | * length of the data in the buffer minus the offset.
|
---|
595 | * @param offset the offset within the buffer to set the data from
|
---|
596 | *
|
---|
597 | * @return the number of data items set, or -1 on error.
|
---|
598 | */
|
---|
599 | ssize_t xplra_multi_set_float_array(int bufferID, size_t datarefID,
|
---|
600 | const float* value, size_t length,
|
---|
601 | size_t offset);
|
---|
602 |
|
---|
603 | /*----------------------------------------------------------------------------*/
|
---|
604 |
|
---|
605 | /**
|
---|
606 | * Get the contents of the float array with the given ID.
|
---|
607 | *
|
---|
608 | * @param length the amount of data. If 0, it is assumed to be the
|
---|
609 | * length of the data in the buffer minus the offset.
|
---|
610 | * @param offset the offset within the buffer to get the data from
|
---|
611 | *
|
---|
612 | * @return the number of data items retrieved, or -1 on error.
|
---|
613 | */
|
---|
614 | ssize_t xplra_multi_get_float_array(float* value,
|
---|
615 | size_t length, size_t offset,
|
---|
616 | int bufferID, size_t datarefID);
|
---|
617 |
|
---|
618 | /*----------------------------------------------------------------------------*/
|
---|
619 |
|
---|
620 | /**
|
---|
621 | * Get a pointer to the float array with the given ID.
|
---|
622 | *
|
---|
623 | * @param offset the offset within the buffer.
|
---|
624 | *
|
---|
625 | * @return the pointer on success, 0 on error.
|
---|
626 | */
|
---|
627 | const float* xplra_multi_get_float_array_ptr(int bufferID, size_t datarefID,
|
---|
628 | size_t offset);
|
---|
629 |
|
---|
630 | /*----------------------------------------------------------------------------*/
|
---|
631 |
|
---|
632 | /**
|
---|
633 | * Set the contents of the integer array dataref with the given ID.
|
---|
634 | *
|
---|
635 | * @param length the amount of data. If 0, it is assumed to be the
|
---|
636 | * length of the data in the buffer minus the offset.
|
---|
637 | * @param offset the offset within the buffer to set the data from
|
---|
638 | *
|
---|
639 | * @return the number of data items set, or -1 on error.
|
---|
640 | */
|
---|
641 | ssize_t xplra_multi_set_int_array(int bufferID, size_t datarefID,
|
---|
642 | const int32_t* value, size_t length,
|
---|
643 | size_t offset);
|
---|
644 |
|
---|
645 | /*----------------------------------------------------------------------------*/
|
---|
646 |
|
---|
647 | /**
|
---|
648 | * Get the contents of the integer array with the given ID.
|
---|
649 | *
|
---|
650 | * @param length the amount of data. If 0, it is assumed to be the
|
---|
651 | * length of the data in the buffer minus the offset.
|
---|
652 | * @param offset the offset within the buffer to get the data from
|
---|
653 | *
|
---|
654 | * @return the number of data items retrieved, or -1 on error.
|
---|
655 | */
|
---|
656 | ssize_t xplra_multi_get_int_array(int32_t* value,
|
---|
657 | size_t length, size_t offset,
|
---|
658 | int bufferID, size_t datarefID);
|
---|
659 |
|
---|
660 | /*----------------------------------------------------------------------------*/
|
---|
661 |
|
---|
662 | /**
|
---|
663 | * Get a pointer to the integer array with the given ID.
|
---|
664 | *
|
---|
665 | * @param offset the offset within the buffer.
|
---|
666 | *
|
---|
667 | * @return the pointer on success, 0 on error.
|
---|
668 | */
|
---|
669 | const int32_t* xplra_multi_get_int_array_ptr(int bufferID, size_t datarefID,
|
---|
670 | size_t offset);
|
---|
671 |
|
---|
672 | /*----------------------------------------------------------------------------*/
|
---|
673 |
|
---|
674 | /**
|
---|
675 | * Set the contents of the byte array dataref with the given ID.
|
---|
676 | *
|
---|
677 | * @param length the amount of data. If 0, it is assumed to be the
|
---|
678 | * length of the data in the buffer minus the offset.
|
---|
679 | * @param offset the offset within the buffer to set the data from
|
---|
680 | *
|
---|
681 | * @return the number of data items set, or -1 on error.
|
---|
682 | */
|
---|
683 | ssize_t xplra_multi_set_byte_array(int bufferID, size_t datarefID,
|
---|
684 | const void* value, size_t length,
|
---|
685 | size_t offset);
|
---|
686 |
|
---|
687 | /*----------------------------------------------------------------------------*/
|
---|
688 |
|
---|
689 | /**
|
---|
690 | * Get the contents of the byte array with the given ID.
|
---|
691 | *
|
---|
692 | * @param length the amount of data. If 0, it is assumed to be the
|
---|
693 | * length of the data in the buffer minus the offset.
|
---|
694 | * @param offset the offset within the buffer to get the data from
|
---|
695 | *
|
---|
696 | * @return the number of data items retrieved, or -1 on error.
|
---|
697 | */
|
---|
698 | ssize_t xplra_multi_get_byte_array(void* value,
|
---|
699 | size_t length, size_t offset,
|
---|
700 | int bufferID, size_t datarefID);
|
---|
701 |
|
---|
702 | /*----------------------------------------------------------------------------*/
|
---|
703 |
|
---|
704 | /**
|
---|
705 | * Get a pointer to the byte array with the given ID.
|
---|
706 | *
|
---|
707 | * @param offset the offset within the buffer.
|
---|
708 | *
|
---|
709 | * @return the pointer on success, 0 on error.
|
---|
710 | */
|
---|
711 | const uint8_t* xplra_multi_get_byte_array_ptr(int bufferID, size_t datarefID,
|
---|
712 | size_t offset);
|
---|
713 |
|
---|
714 | /*----------------------------------------------------------------------------*/
|
---|
715 |
|
---|
716 | /**
|
---|
717 | * Set the value of the byte array with the given ID from the given
|
---|
718 | * string. If the string is shorter than the array, the rest will be
|
---|
719 | * filled with 0s.
|
---|
720 | *
|
---|
721 | * @return the number of bytes set, or -1 on error
|
---|
722 | */
|
---|
723 | ssize_t xplra_multi_set_string(int bufferID, size_t datarefID,
|
---|
724 | const char* value, size_t offset);
|
---|
725 |
|
---|
726 | /*----------------------------------------------------------------------------*/
|
---|
727 |
|
---|
728 | /**
|
---|
729 | * Get a pointer as a string pointer to the byte array with the given
|
---|
730 | * ID.
|
---|
731 | *
|
---|
732 | * @return the pointer on success, 0 on error.
|
---|
733 | */
|
---|
734 | const char* xplra_multi_get_string_ptr(int bufferID, size_t datarefID,
|
---|
735 | size_t offset);
|
---|
736 |
|
---|
737 | /*----------------------------------------------------------------------------*/
|
---|
738 |
|
---|
739 | /**
|
---|
740 | * Destroy a multi-dataref buffer for the given connection.
|
---|
741 | *
|
---|
742 | * @param connectionID the ID of the connection for which the buffer
|
---|
743 | * has been created.
|
---|
744 | *
|
---|
745 | * @return 0 on success, -1 on error.
|
---|
746 | */
|
---|
747 | int xplra_multi_destroy_buffer(int connectionID, int bufferID);
|
---|
748 |
|
---|
749 | /*----------------------------------------------------------------------------*/
|
---|
750 | /*----------------------------------------------------------------------------*/
|
---|
751 |
|
---|
752 | /**
|
---|
753 | * Show a message in the simulator window for the given duration.
|
---|
754 | */
|
---|
755 | int xplra_show_message(int connectionID, const char* message, float duration);
|
---|
756 |
|
---|
757 | /*----------------------------------------------------------------------------*/
|
---|
758 | /*----------------------------------------------------------------------------*/
|
---|
759 |
|
---|
760 | /**
|
---|
761 | * Register the given hotkey codes for listening. If there is an
|
---|
762 | * existing set of hotkeys registered, those will be overwritten.
|
---|
763 | */
|
---|
764 | int xplra_register_hotkeys(int connectionID,
|
---|
765 | const uint16_t* codes, size_t length);
|
---|
766 |
|
---|
767 | /*----------------------------------------------------------------------------*/
|
---|
768 |
|
---|
769 | /**
|
---|
770 | * Query the registered hotkeys whether they were pressed.
|
---|
771 | */
|
---|
772 | int xplra_query_hotkeys(int connectionID, uint8_t* states, size_t length);
|
---|
773 |
|
---|
774 | /*----------------------------------------------------------------------------*/
|
---|
775 |
|
---|
776 | /**
|
---|
777 | * Unregister the hotkeys.
|
---|
778 | */
|
---|
779 | int xplra_unregister_hotkeys(int connectionID);
|
---|
780 |
|
---|
781 | /*----------------------------------------------------------------------------*/
|
---|
782 | /*----------------------------------------------------------------------------*/
|
---|
783 |
|
---|
784 | /**
|
---|
785 | * Destroy the connection with the given ID.
|
---|
786 | *
|
---|
787 | * @return 0 on success, -1 on error.
|
---|
788 | */
|
---|
789 | int xplra_disconnect(int connectionID);
|
---|
790 |
|
---|
791 | /*----------------------------------------------------------------------------*/
|
---|
792 |
|
---|
793 | #ifdef __cplusplus
|
---|
794 | } // extern "C"
|
---|
795 | #endif
|
---|
796 |
|
---|
797 | /*----------------------------------------------------------------------------*/
|
---|
798 | #endif // HU_VARADIISTVAN_XPLRA_XPLRA_H
|
---|