xinput/constants/
xuser.rs

1//! \[~~microsoft.com~~\]
2//! XUSER_\*
3
4#[cfg(doc)] use crate::*;
5
6/// \[~~microsoft.com~~\]
7/// XUSER_INDEX_ANY                                                                                                 <br>
8/// Pass to [`get_keystroke`] to get [`Keystroke`]s for any/all connected gamepads rather than a specific gamepad.  <br>
9/// (The gamepad which send the keystroke can be determined with [`Keystroke::user_index`].)                        <br>
10///                                                                                                                 <br>
11pub const INDEX_ANY : u32 = 0xFF;
12
13/// \[~~microsoft.com~~\]
14/// XUSER_MAX_COUNT (4)
15/// &mdash;
16/// The maximum number of unique gamepads/users supported by XInput.
17/// <br>
18/// All user indicies will be less than this (excluding the magic value, [`xuser::INDEX_ANY`].)
19pub const MAX_COUNT : u32 = 4;
20
21
22
23/// Iterator over valid user indicies (<code>0 .. [xuser::MAX_COUNT]</code>)
24pub fn iter() -> impl Iterator<Item = u32> { (0 .. MAX_COUNT).into_iter() }
25
26/// Iterator over a wide range of invalid user indicies for testing purpouses.  Does **not** include [`xuser::INDEX_ANY`].
27/// Includes *every* user index from 4 ..= 254, 256, 512, ..., 0x8000_0000
28#[cfg_attr(not(test), allow(dead_code))]
29pub(crate) fn invalids() -> impl Iterator<Item = u32> {
30    (4 ..= 254).chain((8 .. 32).map(|pow| 1<<pow))
31}
32
33
34//#cpp2rust XUSER_INDEX_ANY     = xinput::xuser::INDEX_ANY
35//#cpp2rust XUSER_MAX_COUNT     = xinput::xuser::MAX_COUNT