xinput/structures/
vibration.rs

1use bytemuck::{Pod, Zeroable};
2
3
4
5/// \[[microsoft.com](https://learn.microsoft.com/en-us/windows/win32/api/xinput/ns-xinput-xinput_vibration)\]
6/// XINPUT_VIBRATION
7///
8/// Specifies motor speed levels for the vibration function of a controller.
9#[derive(Clone, Copy, Debug)]
10#[derive(Default, Pod, Zeroable)]
11#[repr(C)] pub struct Vibration {
12    /// Speed of the left, lower-frequency (heavier?) rumble motor.
13    ///
14    /// | Value | Rumble    |
15    /// | ----- | --------- |
16    /// | 0     | None      |
17    /// | 65535 | 100%      |
18    pub left_motor_speed:   u16,
19
20    /// Speed of the right, higher-frequency (lighter?) rumble motor.
21    ///
22    /// | Value | Rumble    |
23    /// | ----- | --------- |
24    /// | 0     | None      |
25    /// | 65535 | 100%      |
26    pub right_motor_speed:  u16,
27}
28
29impl From<()        > for Vibration { fn from(_:      ()        ) -> Self { Self { left_motor_speed: 0, right_motor_speed: 0 } } }
30impl From<(u16, u16)> for Vibration { fn from((l, r): (u16, u16)) -> Self { Self { left_motor_speed: l, right_motor_speed: r } } }
31impl From<[u16; 2]  > for Vibration { fn from([l, r]: [u16; 2]  ) -> Self { Self { left_motor_speed: l, right_motor_speed: r } } }
32
33impl AsRef<Self> for Vibration { fn as_ref(&    self) -> &    Self { self } }
34impl AsMut<Self> for Vibration { fn as_mut(&mut self) -> &mut Self { self } }
35
36#[test] fn test_traits_for_coverage() {
37    let _vibration = Vibration::default();
38    let _vibration = Vibration::zeroed();
39    let _vibration = _vibration.clone();
40    dbg!(_vibration);
41}
42
43//#cpp2rust XINPUT_VIBRATION            = xinput::Vibration