333 std::unique_ptr<Gamepad> gamepad_;
357 explicit operator bool()
const {
Caches a full gamepad state and resubmits it after partial updates.
Definition gamepad_adapter.hpp:105
OperationStatus set_right_stick(Stick stick)
Update the right stick and submit the full cached state.
OperationStatus set_acceleration(std::optional< Vector3 > acceleration)
Update accelerometer data and submit the full cached state.
OperationStatus set_touchpad_contact(std::size_t index, GamepadTouchContact contact)
Update one touchpad contact and submit the full cached state.
OperationStatus close()
Close the owned gamepad.
GamepadStateAdapter(GamepadStateAdapter &&other) noexcept
Move construct an adapter.
OperationStatus set_right_trigger(float value)
Update the right trigger and submit the full cached state.
OperationStatus clear_motion()
Clear motion data and submit the full cached state.
OperationStatus set_state(const GamepadState &state)
Replace and submit the cached full gamepad state.
OperationStatus clear_touchpad_contact(std::size_t index)
Clear one touchpad contact and submit the full cached state.
const Gamepad * gamepad() const
Get the owned gamepad handle.
OperationStatus clear_battery()
Clear battery metadata and submit the full cached state.
OperationStatus submit()
Submit the cached full gamepad state.
OperationStatus set_left_trigger(float value)
Update the left trigger and submit the full cached state.
OperationStatus set_button(GamepadButton button, bool pressed)
Update one logical button and submit the full cached state.
GamepadStateAdapter & operator=(const GamepadStateAdapter &)=delete
Copy assignment is disabled because the adapter owns the gamepad handle.
OperationStatus set_battery(GamepadBattery battery)
Update battery metadata and submit the full cached state.
GamepadStateAdapter(const GamepadStateAdapter &)=delete
Copy construction is disabled because the adapter owns the gamepad handle.
void set_output_callback(const OutputCallback &callback)
Register a callback for backend output events.
OperationStatus set_left_stick(Stick stick)
Update the left stick and submit the full cached state.
~GamepadStateAdapter()
Destroy the adapter and close the owned gamepad if still open.
OperationStatus set_motion(Vector3 acceleration, Vector3 gyroscope)
Update accelerometer and gyroscope data and submit the full cached state.
OperationStatus set_gyroscope(std::optional< Vector3 > gyroscope)
Update gyroscope data and submit the full cached state.
const GamepadState & state() const
Get the cached full gamepad state.
Gamepad * gamepad()
Get the owned gamepad handle.
GamepadStateAdapter & operator=(GamepadStateAdapter &&other) noexcept
Move assign an adapter.
static GamepadAdapterCreationResult create(Runtime &runtime, const CreateGamepadOptions &options)
Create a gamepad and wrap it in a state adapter.
GamepadStateAdapter(std::unique_ptr< Gamepad > gamepad)
Construct an adapter around a created gamepad handle.
OperationStatus dispatch_output(const GamepadOutput &output)
Dispatch an output event to the owned gamepad callback.
const GamepadProfileSupport & support() const
Get profile support flags captured at creation time.
bool is_open() const
Check whether the owned gamepad is open.
Virtual gamepad device handle.
Definition runtime.hpp:88
Result status with an error category and human-readable message.
Definition types.hpp:41
bool ok() const
Check whether the operation succeeded.
Runtime that owns backend state and creates virtual devices.
Definition runtime.hpp:939
Public libvirtualhid API namespace.
Definition gamepad_adapter.hpp:17
std::function< void(const GamepadOutput &)> OutputCallback
Callback invoked when a gamepad receives output from the backend.
Definition types.hpp:982
GamepadOutputKind
Output report categories delivered by a gamepad backend.
Definition types.hpp:896
@ button
Mouse button transition.
@ other
Other platform-specific device path.
bool supports_gamepad_output(const DeviceProfile &profile, GamepadOutputKind output_kind)
Check whether a gamepad profile can emit an output category.
bool supports_gamepad_button(const DeviceProfile &profile, GamepadButton button)
Check whether a gamepad profile can expose a logical button.
GamepadButton
Logical gamepad buttons accepted by the common gamepad state model.
Definition types.hpp:494
GamepadProfileSupport gamepad_profile_support(const DeviceProfile &profile)
Get portable support flags for a gamepad profile.
Runtime and virtual device handle declarations.
Full gamepad creation request.
Definition types.hpp:399
Descriptor and identity data used to create a virtual device.
Definition types.hpp:274
Result returned by gamepad adapter creation.
Definition gamepad_adapter.hpp:341
std::unique_ptr< GamepadStateAdapter > adapter
Created adapter when creation succeeds.
Definition gamepad_adapter.hpp:350
OperationStatus status
Creation status.
Definition gamepad_adapter.hpp:345
Gamepad battery charge metadata.
Definition types.hpp:613
Normalized gamepad output event delivered to the consumer.
Definition types.hpp:907
Profile support summary for portable gamepad adapter code.
Definition gamepad_adapter.hpp:22
bool supports_motion
Whether the profile exposes motion sensor input.
Definition gamepad_adapter.hpp:46
bool supports_rgb_led
Whether the profile supports RGB LED output.
Definition gamepad_adapter.hpp:36
bool supports_touchpad_button
Whether the profile exposes a touchpad click button.
Definition gamepad_adapter.hpp:66
bool supports_adaptive_triggers
Whether the profile supports adaptive trigger output.
Definition gamepad_adapter.hpp:41
bool supports_battery
Whether the profile exposes battery state input.
Definition gamepad_adapter.hpp:56
std::uint8_t supported_rear_paddle_count
Number of rear paddle buttons exposed by the profile.
Definition gamepad_adapter.hpp:71
bool supports_rumble
Whether the profile supports main rumble output.
Definition gamepad_adapter.hpp:26
bool supports_trigger_rumble
Whether the profile supports independent trigger rumble output.
Definition gamepad_adapter.hpp:31
bool supports_touchpad
Whether the profile exposes touchpad contact input.
Definition gamepad_adapter.hpp:51
bool supports_misc1_button
Whether the profile exposes the miscellaneous profile-specific button.
Definition gamepad_adapter.hpp:61
Common gamepad input state accepted by libvirtualhid.
Definition types.hpp:653
Normalized two-axis stick state.
Definition types.hpp:565
Normalized three-axis sensor state.
Definition types.hpp:580
Core public types for libvirtualhid.