|
7 | 7 |
|
8 | 8 | namespace lvh::reports { |
9 | 9 |
|
| 10 | +/** |
| 11 | + * @brief Clamp a stick axis value to the normalized range. |
| 12 | + * |
| 13 | + * @param value Axis value. |
| 14 | + * @return Clamped axis value in the inclusive range `[-1.0, 1.0]`. |
| 15 | + */ |
10 | 16 | float clamp_axis(float value); |
| 17 | + |
| 18 | +/** |
| 19 | + * @brief Clamp a trigger value to the normalized range. |
| 20 | + * |
| 21 | + * @param value Trigger value. |
| 22 | + * @return Clamped trigger value in the inclusive range `[0.0, 1.0]`. |
| 23 | + */ |
11 | 24 | float clamp_trigger(float value); |
| 25 | + |
| 26 | +/** |
| 27 | + * @brief Convert a normalized axis value to a signed HID axis value. |
| 28 | + * |
| 29 | + * @param value Axis value in the inclusive range `[-1.0, 1.0]`. |
| 30 | + * @return Signed 16-bit HID axis value. |
| 31 | + */ |
12 | 32 | std::int16_t normalize_axis(float value); |
| 33 | + |
| 34 | +/** |
| 35 | + * @brief Convert a normalized trigger value to an unsigned HID trigger value. |
| 36 | + * |
| 37 | + * @param value Trigger value in the inclusive range `[0.0, 1.0]`. |
| 38 | + * @return Unsigned 8-bit HID trigger value. |
| 39 | + */ |
13 | 40 | std::uint8_t normalize_trigger(float value); |
| 41 | + |
| 42 | +/** |
| 43 | + * @brief Normalize all scalar fields in a gamepad state. |
| 44 | + * |
| 45 | + * @param state Gamepad state to normalize. |
| 46 | + * @return Normalized gamepad state. |
| 47 | + */ |
14 | 48 | GamepadState normalize_state(const GamepadState& state); |
| 49 | + |
| 50 | +/** |
| 51 | + * @brief Convert directional pad buttons to a HID hat switch value. |
| 52 | + * |
| 53 | + * @param buttons Button set containing directional pad state. |
| 54 | + * @return HID hat switch value, or `8` for neutral. |
| 55 | + */ |
15 | 56 | std::uint8_t hat_from_buttons(const ButtonSet& buttons); |
| 57 | + |
| 58 | +/** |
| 59 | + * @brief Pack a gamepad state into the profile's common input report format. |
| 60 | + * |
| 61 | + * @param profile Device profile used for report identity and size. |
| 62 | + * @param state Gamepad state to pack. |
| 63 | + * @return Packed input report bytes. |
| 64 | + */ |
16 | 65 | std::vector<std::uint8_t> pack_input_report(const DeviceProfile& profile, const GamepadState& state); |
17 | 66 |
|
18 | 67 | } // namespace lvh::reports |
0 commit comments