1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// Copyright (c) 2023 xplm-sys developers
// SPDX-FileCopyrightText: 2024 Julia DeMille <me@jdemille.com
//
// SPDX-License-Identifier: Apache-2.0 OR MIT

// Allow C-like conventions
#![allow(non_upper_case_globals, non_camel_case_types, non_snake_case)]

use std::fmt::Debug;

use core::ffi::c_uint;

use bitfield::{bitfield_bitrange, bitfield_debug, bitfield_fields};

include!(concat!(env!("OUT_DIR"), "/bindings.rs"));

bitfield_bitrange! {struct XPLMDataTypeID(c_uint)}
impl XPLMDataTypeID {
    bitfield_fields! {
        c_uint;
        pub int, _ : 0;
        pub float, _ : 1;
        pub double, _ : 2;
        pub float_array, _ : 3;
        pub int_array, _ : 4;
        pub data, _ : 4;
        pub unrecognized_bits, _ : 31, 5;
    }
}

impl Debug for XPLMDataTypeID {
    bitfield_debug! {
        struct XPLMDataTypeID;
        int, _ : 0;
        float, _ : 1;
        double, _ : 2;
        float_array, _ : 3;
        int_array, _ : 4;
        data, _ : 5;
        unrecognized_bits, _ : 31, 6;
    }
}

bitfield_bitrange! {struct XPLMKeyFlags(c_uint)}
impl XPLMKeyFlags {
    bitfield_fields! {
        c_uint;
        pub shift, _ : 0;
        pub option_alt, _ : 1;
        pub ctrl, _ : 2;
        pub down, _ : 3;
        pub up, _ : 4;
        pub unrecognized, _ : 31, 5;
    }
}

impl Debug for XPLMKeyFlags {
    bitfield_debug! {
        struct XPLMKeyFlags;
        shift, _ : 0;
        option_alt, _ : 1;
        ctrl, _ : 2;
        down, _ : 3;
        up, _ : 4;
        unrecognized, _ : 31, 5;
    }
}

bitfield_bitrange! {struct XPLMNavType(c_uint)}
impl XPLMNavType {
    bitfield_fields! {
        c_uint;
        pub airport, _ : 0;
        pub ndb, _ : 1;
        pub vor, _ : 2;
        pub ils, _ : 3;
        pub localizer, _ : 4;
        pub glideslope, _ : 5;
        pub outer_marker, _ : 6;
        pub middle_marker, _ : 7;
        pub inner_marker, _ : 8;
        pub fix, _ : 9;
        pub dme, _ : 10;
        pub lat_lon, _ : 11;
        pub unrecognized, _ : 31, 12;
    }
}

impl Debug for XPLMNavType {
    bitfield_debug! {
        struct XPLMNavType;
        airport, _ : 0;
        ndb, _ : 1;
        vor, _ : 2;
        ils, _ : 3;
        localizer, _ : 4;
        glideslope, _ : 5;
        outer_marker, _ : 6;
        middle_marker, _ : 7;
        inner_marker, _ : 8;
        fix, _ : 9;
        dme, _ : 10;
        lat_lon, _ : 11;
        unrecognized, _ : 31, 12;
    }
}