![]() |
libvirtualhid 24
Cross-platform C++ library for virtual HID devices.
|
Caches a full gamepad state and resubmits it after partial updates. More...
#include <src/include/libvirtualhid/gamepad_adapter.hpp>
Public Member Functions | |
| OperationStatus | clear_battery () |
| Clear battery metadata and submit the full cached state. | |
| OperationStatus | clear_motion () |
| Clear motion data and submit the full cached state. | |
| OperationStatus | clear_touchpad_contact (std::size_t index) |
| Clear one touchpad contact and submit the full cached state. | |
| OperationStatus | close () |
| Close the owned gamepad. | |
| OperationStatus | dispatch_output (const GamepadOutput &output) |
| Dispatch an output event to the owned gamepad callback. | |
| Gamepad * | gamepad () |
| Get the owned gamepad handle. | |
| const Gamepad * | gamepad () const |
| Get the owned gamepad handle. | |
| GamepadStateAdapter (const GamepadStateAdapter &)=delete | |
| Copy construction is disabled because the adapter owns the gamepad handle. | |
| GamepadStateAdapter (GamepadStateAdapter &&other) noexcept | |
| Move construct an adapter. | |
| GamepadStateAdapter (std::unique_ptr< Gamepad > gamepad) | |
| Construct an adapter around a created gamepad handle. | |
| bool | is_open () const |
| Check whether the owned gamepad is open. | |
| GamepadStateAdapter & | operator= (const GamepadStateAdapter &)=delete |
| Copy assignment is disabled because the adapter owns the gamepad handle. | |
| GamepadStateAdapter & | operator= (GamepadStateAdapter &&other) noexcept |
| Move assign an adapter. | |
| OperationStatus | set_acceleration (std::optional< Vector3 > acceleration) |
| Update accelerometer data and submit the full cached state. | |
| OperationStatus | set_battery (GamepadBattery battery) |
| Update battery metadata and submit the full cached state. | |
| OperationStatus | set_button (GamepadButton button, bool pressed) |
| Update one logical button and submit the full cached state. | |
| OperationStatus | set_gyroscope (std::optional< Vector3 > gyroscope) |
| Update gyroscope data and submit the full cached state. | |
| OperationStatus | set_left_stick (Stick stick) |
| Update the left stick and submit the full cached state. | |
| OperationStatus | set_left_trigger (float value) |
| Update the left trigger and submit the full cached state. | |
| OperationStatus | set_motion (Vector3 acceleration, Vector3 gyroscope) |
| Update accelerometer and gyroscope data and submit the full cached state. | |
| void | set_output_callback (const OutputCallback &callback) |
| Register a callback for backend output events. | |
| OperationStatus | set_right_stick (Stick stick) |
| Update the right stick and submit the full cached state. | |
| OperationStatus | set_right_trigger (float value) |
| Update the right trigger and submit the full cached state. | |
| OperationStatus | set_state (const GamepadState &state) |
| Replace and submit the cached full gamepad state. | |
| OperationStatus | set_touchpad_contact (std::size_t index, GamepadTouchContact contact) |
| Update one touchpad contact and submit the full cached state. | |
| const GamepadState & | state () const |
| Get the cached full gamepad state. | |
| OperationStatus | submit () |
| Submit the cached full gamepad state. | |
| const GamepadProfileSupport & | support () const |
| Get profile support flags captured at creation time. | |
| ~GamepadStateAdapter () | |
| Destroy the adapter and close the owned gamepad if still open. | |
Static Public Member Functions | |
| static GamepadAdapterCreationResult | create (Runtime &runtime, const CreateGamepadOptions &options) |
| Create a gamepad and wrap it in a state adapter. | |
Caches a full gamepad state and resubmits it after partial updates.
|
noexcept |
Move construct an adapter.
| other | Adapter to move from. |
|
explicit |
Construct an adapter around a created gamepad handle.
| gamepad | Gamepad handle owned by the adapter. |
| OperationStatus lvh::GamepadStateAdapter::clear_battery | ( | ) |
Clear battery metadata and submit the full cached state.
| OperationStatus lvh::GamepadStateAdapter::clear_motion | ( | ) |
Clear motion data and submit the full cached state.
| OperationStatus lvh::GamepadStateAdapter::clear_touchpad_contact | ( | std::size_t | index | ) |
Clear one touchpad contact and submit the full cached state.
| index | Touchpad contact slot. |
| OperationStatus lvh::GamepadStateAdapter::close | ( | ) |
Close the owned gamepad.
|
static |
| OperationStatus lvh::GamepadStateAdapter::dispatch_output | ( | const GamepadOutput & | output | ) |
Dispatch an output event to the owned gamepad callback.
| output | Output event. |
| Gamepad * lvh::GamepadStateAdapter::gamepad | ( | ) |
Get the owned gamepad handle.
nullptr after move. | const Gamepad * lvh::GamepadStateAdapter::gamepad | ( | ) | const |
Get the owned gamepad handle.
nullptr after move. | bool lvh::GamepadStateAdapter::is_open | ( | ) | const |
Check whether the owned gamepad is open.
true when the owned gamepad can accept operations.
|
delete |
Copy assignment is disabled because the adapter owns the gamepad handle.
|
noexcept |
Move assign an adapter.
| other | Adapter to move from. |
| OperationStatus lvh::GamepadStateAdapter::set_acceleration | ( | std::optional< Vector3 > | acceleration | ) |
Update accelerometer data and submit the full cached state.
| acceleration | Accelerometer data, or std::nullopt to clear it. |
| OperationStatus lvh::GamepadStateAdapter::set_battery | ( | GamepadBattery | battery | ) |
Update battery metadata and submit the full cached state.
| battery | Battery metadata. |
| OperationStatus lvh::GamepadStateAdapter::set_button | ( | GamepadButton | button, |
| bool | pressed ) |
Update one logical button and submit the full cached state.
| button | Logical button to update. |
| pressed | Whether the button is pressed. |
| OperationStatus lvh::GamepadStateAdapter::set_gyroscope | ( | std::optional< Vector3 > | gyroscope | ) |
Update gyroscope data and submit the full cached state.
| gyroscope | Gyroscope data, or std::nullopt to clear it. |
| OperationStatus lvh::GamepadStateAdapter::set_left_stick | ( | Stick | stick | ) |
Update the left stick and submit the full cached state.
| stick | Left stick state. |
| OperationStatus lvh::GamepadStateAdapter::set_left_trigger | ( | float | value | ) |
Update the left trigger and submit the full cached state.
| value | Normalized left trigger value. |
| OperationStatus lvh::GamepadStateAdapter::set_motion | ( | Vector3 | acceleration, |
| Vector3 | gyroscope ) |
Update accelerometer and gyroscope data and submit the full cached state.
| acceleration | Accelerometer data. |
| gyroscope | Gyroscope data. |
| void lvh::GamepadStateAdapter::set_output_callback | ( | const OutputCallback & | callback | ) |
Register a callback for backend output events.
| callback | Output callback copied into the owned gamepad. |
| OperationStatus lvh::GamepadStateAdapter::set_right_stick | ( | Stick | stick | ) |
Update the right stick and submit the full cached state.
| stick | Right stick state. |
| OperationStatus lvh::GamepadStateAdapter::set_right_trigger | ( | float | value | ) |
Update the right trigger and submit the full cached state.
| value | Normalized right trigger value. |
| OperationStatus lvh::GamepadStateAdapter::set_state | ( | const GamepadState & | state | ) |
Replace and submit the cached full gamepad state.
| state | New full gamepad state. |
| OperationStatus lvh::GamepadStateAdapter::set_touchpad_contact | ( | std::size_t | index, |
| GamepadTouchContact | contact ) |
Update one touchpad contact and submit the full cached state.
| index | Touchpad contact slot. |
| contact | Touchpad contact state. |
| const GamepadState & lvh::GamepadStateAdapter::state | ( | ) | const |
Get the cached full gamepad state.
| OperationStatus lvh::GamepadStateAdapter::submit | ( | ) |
Submit the cached full gamepad state.
| const GamepadProfileSupport & lvh::GamepadStateAdapter::support | ( | ) | const |
Get profile support flags captured at creation time.