xinput/interop/
winapi-0.3.rs

1use crate::*;
2use winapi::shared::guiddef::GUID;
3use winapi::um::xinput::*;
4
5
6
7struct_mapping! {
8    #[derive(unsafe { AsRef, AsMut, FromInto })]
9    BatteryInformation => XINPUT_BATTERY_INFORMATION {
10        battery_type    => BatteryType,
11        battery_level   => BatteryLevel,
12    }
13
14    #[derive(unsafe { AsRef, AsMut, FromInto })]
15    Capabilities => XINPUT_CAPABILITIES {
16        ty          => Type,
17        sub_type    => SubType,
18        flags       => Flags,
19        gamepad     => Gamepad,
20        vibration   => Vibration,
21    }
22
23    #[derive(unsafe { AsRef, AsMut, FromInto })]
24    Gamepad => XINPUT_GAMEPAD {
25        buttons         => wButtons,
26        left_trigger    => bLeftTrigger,
27        right_trigger   => bRightTrigger,
28        #[renamed] left_thumb_x    => sThumbLX,
29        #[renamed] left_thumb_y    => sThumbLY,
30        #[renamed] right_thumb_x   => sThumbRX,
31        #[renamed] right_thumb_y   => sThumbRY,
32    }
33
34    #[derive(unsafe { AsRef, AsMut, FromInto })]
35    #[renamed] DSoundAudioDeviceGuid => GUID {
36        // fields not individually defined
37    }
38
39    #[derive(unsafe { AsRef, AsMut, FromInto })]
40    Keystroke => XINPUT_KEYSTROKE {
41        virtual_key     => VirtualKey,
42        unicode         => Unicode,
43        flags           => Flags,
44        user_index      => UserIndex,
45        hid_code        => HidCode,
46    }
47
48    #[derive(unsafe { AsRef, AsMut, FromInto })]
49    State => XINPUT_STATE {
50        packet_number   => dwPacketNumber,
51        gamepad         => Gamepad,
52    }
53
54    #[derive(unsafe { AsRef, AsMut, FromInto })]
55    Vibration => XINPUT_VIBRATION {
56        left_motor_speed    => wLeftMotorSpeed,
57        right_motor_speed   => wRightMotorSpeed,
58    }
59}