source: xplra/src/client/c/hu/varadiistvan/xplra/xplra.h@ 70:7882bccb87a0

Last change on this file since 70:7882bccb87a0 was 70:7882bccb87a0, checked in by István Váradi <ivaradi@…>, 11 years ago

Added the description of the C API

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