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