Gamepad state normalization, report packing, and output parsing declarations.
More...
#include <cstdint>
#include <vector>
#include <libvirtualhid/types.hpp>
Go to the source code of this file.
|
| namespace | lvh |
| | Public libvirtualhid API namespace.
|
| |
Gamepad state normalization, report packing, and output parsing declarations.
◆ clamp_axis()
| float lvh::reports::clamp_axis |
( |
float | value | ) |
|
Clamp a stick axis value to the normalized range.
- Parameters
-
- Returns
- Clamped axis value in the inclusive range
[-1.0, 1.0].
◆ clamp_trigger()
| float lvh::reports::clamp_trigger |
( |
float | value | ) |
|
Clamp a trigger value to the normalized range.
- Parameters
-
- Returns
- Clamped trigger value in the inclusive range
[0.0, 1.0].
◆ hat_from_buttons()
| std::uint8_t lvh::reports::hat_from_buttons |
( |
const ButtonSet & | buttons | ) |
|
Convert directional pad buttons to a HID hat switch value.
- Parameters
-
| buttons | Button set containing directional pad state. |
- Returns
- HID hat switch value, or
8 for neutral.
◆ normalize_axis()
| std::int16_t lvh::reports::normalize_axis |
( |
float | value | ) |
|
Convert a normalized axis value to a signed HID axis value.
- Parameters
-
| value | Axis value in the inclusive range [-1.0, 1.0]. |
- Returns
- Signed 16-bit HID axis value.
◆ normalize_state()
| GamepadState lvh::reports::normalize_state |
( |
const GamepadState & | state | ) |
|
Normalize all scalar fields in a gamepad state.
- Parameters
-
| state | Gamepad state to normalize. |
- Returns
- Normalized gamepad state.
◆ normalize_trigger()
| std::uint8_t lvh::reports::normalize_trigger |
( |
float | value | ) |
|
Convert a normalized trigger value to an unsigned HID trigger value.
- Parameters
-
| value | Trigger value in the inclusive range [0.0, 1.0]. |
- Returns
- Unsigned 8-bit HID trigger value.
◆ pack_input_report()
Pack a gamepad state into the profile's common input report format.
- Parameters
-
| profile | Device profile used for report identity and size. |
| state | Gamepad state to pack. |
- Returns
- Packed input report bytes.
◆ parse_output_report()
| GamepadOutput lvh::reports::parse_output_report |
( |
const DeviceProfile & | profile, |
|
|
const std::vector< std::uint8_t > & | report ) |
Parse a backend output report into the profile-neutral output model.
- Parameters
-
| profile | Device profile used for report identity and capabilities. |
| report | Raw HID output report bytes. |
- Returns
- Parsed gamepad output. Unrecognized reports are returned as raw reports.
◆ parse_output_reports()
| std::vector< GamepadOutput > lvh::reports::parse_output_reports |
( |
const DeviceProfile & | profile, |
|
|
const std::vector< std::uint8_t > & | report ) |
Parse a backend output report into zero or more profile-neutral output events.
- Parameters
-
| profile | Device profile used for report identity and capabilities. |
| report | Raw HID output report bytes. |
- Returns
- Parsed gamepad outputs. Unrecognized reports are returned as one raw-report event.