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
use *;
/// \[[docs.microsoft.com](https://docs.microsoft.com/en-us/windows/win32/api/xinput/nf-xinput-xinputenable)\]
/// XInputEnable
///
/// Meant to be called when an application gains or loses focus
/// (such as via [WM_ACTIVATEAPP](https://docs.microsoft.com/en-us/windows/desktop/winmsg/wm-activateapp)\),
/// to enable or disable XInput for this app.
///
/// "Disabling" xinput with `xinput::enable(false)` will:
/// * Stop all vibration
/// * Cause [xinput::get_state](crate::xinput::get_state) to retrieve neutral data (no buttons held, 0 axises)
///
/// ### Arguments
/// * `enable` - `true` to accept input and allow vibration, `false` to block input and vibration
///
/// ### Example
/// ```rust
/// # use thindx::xinput;
/// # use winapi::shared::minwindef::*;
/// # use winapi::shared::windef::*;
/// # use winapi::um::winuser::*;
/// unsafe extern "system"
/// fn wndproc(hwnd: HWND, msg: u32, wparam: WPARAM, lparam: LPARAM) -> LRESULT {
/// match msg {
/// WM_ACTIVATEAPP => {
/// // assumes this is the only window of this app accepting xinput
/// xinput::enable(wparam as BOOL != FALSE);
/// 0
/// },
/// _ => DefWindowProcW(hwnd, msg, wparam, lparam),
/// }
/// }
/// ```