libvirtualhid 18
Cross-platform C++ library for virtual HID devices.
report.hpp
Go to the documentation of this file.
1
5#pragma once
6
7// standard includes
8#include <cstdint>
9#include <vector>
10
11// local includes
13
14namespace lvh::reports {
15
22 float clamp_axis(float value);
23
30 float clamp_trigger(float value);
31
38 std::int16_t normalize_axis(float value);
39
46 std::uint8_t normalize_trigger(float value);
47
55
62 std::uint8_t hat_from_buttons(const ButtonSet &buttons);
63
71 std::vector<std::uint8_t> pack_input_report(const DeviceProfile &profile, const GamepadState &state);
72
80 GamepadOutput parse_output_report(const DeviceProfile &profile, const std::vector<std::uint8_t> &report);
81
89 std::vector<GamepadOutput> parse_output_reports(const DeviceProfile &profile, const std::vector<std::uint8_t> &report);
90
91} // namespace lvh::reports
Compact set of pressed gamepad buttons.
Definition types.hpp:515
std::uint8_t normalize_trigger(float value)
Convert a normalized trigger value to an unsigned HID trigger value.
std::int16_t normalize_axis(float value)
Convert a normalized axis value to a signed HID axis value.
GamepadState normalize_state(const GamepadState &state)
Normalize all scalar fields in a gamepad state.
float clamp_trigger(float value)
Clamp a trigger value to the normalized range.
float clamp_axis(float value)
Clamp a stick axis value to the normalized range.
std::vector< GamepadOutput > 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.
std::vector< std::uint8_t > pack_input_report(const DeviceProfile &profile, const GamepadState &state)
Pack a gamepad state into the profile's common input report format.
GamepadOutput parse_output_report(const DeviceProfile &profile, const std::vector< std::uint8_t > &report)
Parse a backend output report into the profile-neutral output model.
std::uint8_t hat_from_buttons(const ButtonSet &buttons)
Convert directional pad buttons to a HID hat switch value.
Descriptor and identity data used to create a virtual device.
Definition types.hpp:273
Normalized gamepad output event delivered to the consumer.
Definition types.hpp:900
Common gamepad input state accepted by libvirtualhid.
Definition types.hpp:647
Core public types for libvirtualhid.