source: xplra/src/client/c/hu/varadiistvan/xplra/xplra.h@ 111:9c29a0b10ea6

Last change on this file since 111:9c29a0b10ea6 was 111:9c29a0b10ea6, checked in by István Váradi <ivaradi@…>, 17 months ago

The C client API can connect over TCP

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