xplane_sys/
lib.rs

1// Copyright (c) 2023 xplm-sys developers
2// SPDX-FileCopyrightText: 2024 Julia DeMille <me@jdemille.com
3//
4// SPDX-License-Identifier: Apache-2.0 OR MIT
5
6// Allow C-like conventions
7#![allow(non_upper_case_globals, non_camel_case_types, non_snake_case)]
8
9use std::fmt::Debug;
10
11use core::ffi::c_uint;
12
13use bitfield::{bitfield_bitrange, bitfield_debug, bitfield_fields};
14
15include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
16
17bitfield_bitrange! {struct XPLMDataTypeID(c_uint)}
18impl XPLMDataTypeID {
19    bitfield_fields! {
20        c_uint;
21        pub int, _ : 0;
22        pub float, _ : 1;
23        pub double, _ : 2;
24        pub float_array, _ : 3;
25        pub int_array, _ : 4;
26        pub data, _ : 4;
27        pub unrecognized_bits, _ : 31, 5;
28    }
29}
30
31impl Debug for XPLMDataTypeID {
32    bitfield_debug! {
33        struct XPLMDataTypeID;
34        int, _ : 0;
35        float, _ : 1;
36        double, _ : 2;
37        float_array, _ : 3;
38        int_array, _ : 4;
39        data, _ : 5;
40        unrecognized_bits, _ : 31, 6;
41    }
42}
43
44bitfield_bitrange! {struct XPLMKeyFlags(c_uint)}
45impl XPLMKeyFlags {
46    bitfield_fields! {
47        c_uint;
48        pub shift, _ : 0;
49        pub option_alt, _ : 1;
50        pub ctrl, _ : 2;
51        pub down, _ : 3;
52        pub up, _ : 4;
53        pub unrecognized, _ : 31, 5;
54    }
55}
56
57impl Debug for XPLMKeyFlags {
58    bitfield_debug! {
59        struct XPLMKeyFlags;
60        shift, _ : 0;
61        option_alt, _ : 1;
62        ctrl, _ : 2;
63        down, _ : 3;
64        up, _ : 4;
65        unrecognized, _ : 31, 5;
66    }
67}
68
69bitfield_bitrange! {struct XPLMNavType(c_uint)}
70impl XPLMNavType {
71    bitfield_fields! {
72        c_uint;
73        pub airport, _ : 0;
74        pub ndb, _ : 1;
75        pub vor, _ : 2;
76        pub ils, _ : 3;
77        pub localizer, _ : 4;
78        pub glideslope, _ : 5;
79        pub outer_marker, _ : 6;
80        pub middle_marker, _ : 7;
81        pub inner_marker, _ : 8;
82        pub fix, _ : 9;
83        pub dme, _ : 10;
84        pub lat_lon, _ : 11;
85        pub unrecognized, _ : 31, 12;
86    }
87}
88
89impl Debug for XPLMNavType {
90    bitfield_debug! {
91        struct XPLMNavType;
92        airport, _ : 0;
93        ndb, _ : 1;
94        vor, _ : 2;
95        ils, _ : 3;
96        localizer, _ : 4;
97        glideslope, _ : 5;
98        outer_marker, _ : 6;
99        middle_marker, _ : 7;
100        inner_marker, _ : 8;
101        fix, _ : 9;
102        dme, _ : 10;
103        lat_lon, _ : 11;
104        unrecognized, _ : 31, 12;
105    }
106}