25 friend class ::lvh::Runtime;
31 struct KeyboardDevice;
33 struct TouchscreenDevice;
34 struct TrackpadDevice;
35 struct PenTabletDevice;
207 std::shared_ptr<detail::GamepadDevice> device_;
327 std::shared_ptr<detail::KeyboardDevice> device_;
468 std::shared_ptr<detail::MouseDevice> device_;
572 std::shared_ptr<detail::TouchscreenDevice> device_;
684 std::shared_ptr<detail::TrackpadDevice> device_;
789 std::shared_ptr<detail::PenTabletDevice> device_;
811 explicit operator bool()
const {
835 explicit operator bool()
const {
859 explicit operator bool()
const {
883 explicit operator bool()
const {
907 explicit operator bool()
const {
931 explicit operator bool()
const {
1107 std::shared_ptr<detail::RuntimeState> state_;
Virtual gamepad device handle.
Definition runtime.hpp:88
Gamepad & operator=(Gamepad &&other) noexcept
Move assign a gamepad handle.
std::size_t submit_count() const
Get the number of successful submit operations.
Gamepad & operator=(const Gamepad &)=delete
Copy assignment is disabled because the handle owns device lifetime.
std::vector< DeviceNode > device_nodes() const override
Get platform-visible nodes associated with the device.
const GamepadMetadata & metadata() const
Get the metadata supplied when the gamepad was created.
~Gamepad() override
Destroy the gamepad handle and close the virtual device if it is still open.
Gamepad(Gamepad &&other) noexcept
Move construct a gamepad handle.
Gamepad(detail::RuntimeConstructionToken token, std::shared_ptr< detail::GamepadDevice > device)
Construct a gamepad handle for Runtime-owned state.
GamepadState last_submitted_state() const
Get the most recently submitted gamepad state.
OperationStatus submit(const GamepadState &state)
Submit the latest gamepad input state.
bool is_open() const override
Check whether the device is open.
std::vector< std::uint8_t > last_input_report() const
Get the most recently packed input report.
DeviceId device_id() const override
Get the device identifier assigned by the runtime.
const DeviceProfile & profile() const override
Get the profile used to create this device.
OperationStatus close() override
Close the virtual device.
OperationStatus dispatch_output(const GamepadOutput &output)
Dispatch an output event to the registered callback.
Gamepad(const Gamepad &)=delete
Copy construction is disabled because the handle owns device lifetime.
void set_output_callback(const OutputCallback &callback)
Register a callback for backend output events.
Virtual keyboard device handle.
Definition runtime.hpp:213
std::vector< DeviceNode > device_nodes() const override
Get platform-visible nodes associated with the device.
OperationStatus type_text(const KeyboardTextEvent &event)
Type UTF-8 text.
const DeviceProfile & profile() const override
Get the profile used to create this device.
OperationStatus close() override
Close the virtual device.
Keyboard(detail::RuntimeConstructionToken token, std::shared_ptr< detail::KeyboardDevice > device)
Construct a keyboard handle for Runtime-owned state.
OperationStatus submit(const KeyboardEvent &event)
Submit a keyboard key transition.
OperationStatus press(KeyboardKeyCode key_code)
Press a keyboard key.
Keyboard(Keyboard &&other) noexcept
Move construct a keyboard handle.
DeviceId device_id() const override
Get the device identifier assigned by the runtime.
KeyboardEvent last_submitted_event() const
Get the most recently submitted keyboard event.
std::size_t submit_count() const
Get the number of successful submit operations.
Keyboard(const Keyboard &)=delete
Copy construction is disabled because the handle owns device lifetime.
~Keyboard() override
Destroy the keyboard handle and close the virtual device if it is still open.
Keyboard & operator=(const Keyboard &)=delete
Copy assignment is disabled because the handle owns device lifetime.
OperationStatus release(KeyboardKeyCode key_code)
Release a keyboard key.
Keyboard & operator=(Keyboard &&other) noexcept
Move assign a keyboard handle.
bool is_open() const override
Check whether the device is open.
Virtual mouse device handle.
Definition runtime.hpp:333
std::size_t submit_count() const
Get the number of successful submit operations.
Mouse(Mouse &&other) noexcept
Move construct a mouse handle.
const DeviceProfile & profile() const override
Get the profile used to create this device.
Mouse(const Mouse &)=delete
Copy construction is disabled because the handle owns device lifetime.
MouseEvent last_submitted_event() const
Get the most recently submitted mouse event.
OperationStatus button(MouseButton button, bool pressed)
Submit a mouse button transition.
OperationStatus submit(const MouseEvent &event)
Submit a mouse event.
OperationStatus move_absolute(std::int32_t x, std::int32_t y, std::int32_t width, std::int32_t height)
Submit absolute pointer movement.
~Mouse() override
Destroy the mouse handle and close the virtual device if it is still open.
DeviceId device_id() const override
Get the device identifier assigned by the runtime.
OperationStatus horizontal_scroll(std::int32_t distance)
Submit high-resolution horizontal scroll.
Mouse(detail::RuntimeConstructionToken token, std::shared_ptr< detail::MouseDevice > device)
Construct a mouse handle for Runtime-owned state.
OperationStatus move_relative(std::int32_t delta_x, std::int32_t delta_y)
Submit relative pointer movement.
std::vector< DeviceNode > device_nodes() const override
Get platform-visible nodes associated with the device.
OperationStatus vertical_scroll(std::int32_t distance)
Submit high-resolution vertical scroll.
Mouse & operator=(const Mouse &)=delete
Copy assignment is disabled because the handle owns device lifetime.
Mouse & operator=(Mouse &&other) noexcept
Move assign a mouse handle.
OperationStatus close() override
Close the virtual device.
bool is_open() const override
Check whether the device is open.
Result status with an error category and human-readable message.
Definition types.hpp:41
bool ok() const
Check whether the operation succeeded.
Virtual pen tablet device handle.
Definition runtime.hpp:690
OperationStatus place_tool(const PenToolState &state)
Place or move the active tablet tool.
PenTablet(const PenTablet &)=delete
Copy construction is disabled because the handle owns device lifetime.
OperationStatus close() override
Close the virtual device.
~PenTablet() override
Destroy the pen tablet handle and close the virtual device if it is still open.
DeviceId device_id() const override
Get the device identifier assigned by the runtime.
bool is_open() const override
Check whether the device is open.
PenTablet(PenTablet &&other) noexcept
Move construct a pen tablet handle.
std::vector< DeviceNode > device_nodes() const override
Get platform-visible nodes associated with the device.
PenTablet & operator=(const PenTablet &)=delete
Copy assignment is disabled because the handle owns device lifetime.
const DeviceProfile & profile() const override
Get the profile used to create this device.
PenTablet & operator=(PenTablet &&other) noexcept
Move assign a pen tablet handle.
PenTablet(detail::RuntimeConstructionToken token, std::shared_ptr< detail::PenTabletDevice > device)
Construct a pen tablet handle for Runtime-owned state.
OperationStatus button(PenButton button, bool pressed)
Submit a tablet button transition.
std::size_t submit_count() const
Get the number of successful submit operations.
PenToolState last_submitted_tool() const
Get the most recently submitted tool state.
Runtime that owns backend state and creates virtual devices.
Definition runtime.hpp:939
static std::unique_ptr< Runtime > create(RuntimeOptions options={})
Create a runtime with the requested options.
Runtime(detail::RuntimeConstructionToken token, RuntimeOptions options)
Construct a runtime for Runtime::create.
GamepadCreationResult create_gamepad(const CreateGamepadOptions &options)
Create a gamepad from full creation options.
GamepadCreationResult create_gamepad(const DeviceProfile &profile)
Create a gamepad from a profile.
KeyboardCreationResult create_keyboard(const CreateKeyboardOptions &options)
Create a keyboard from full creation options.
void close_all()
Close every device owned by the runtime.
TouchscreenCreationResult create_touchscreen(const CreateTouchscreenOptions &options)
Create a touchscreen from full creation options.
const BackendCapabilities & capabilities() const
Get capabilities for the selected backend.
TrackpadCreationResult create_trackpad()
Create a trackpad with the built-in trackpad profile.
Runtime(Runtime &&other) noexcept
Move construct a runtime.
TouchscreenCreationResult create_touchscreen()
Create a touchscreen with the built-in touchscreen profile.
Runtime & operator=(Runtime &&other) noexcept
Move assign a runtime.
std::size_t active_device_count() const
Get the number of open devices owned by the runtime.
MouseCreationResult create_mouse()
Create a mouse with the built-in mouse profile.
TrackpadCreationResult create_trackpad(const CreateTrackpadOptions &options)
Create a trackpad from full creation options.
KeyboardCreationResult create_keyboard()
Create a keyboard with the built-in keyboard profile.
~Runtime()
Destroy the runtime and close any remaining devices.
Runtime(const Runtime &)=delete
Copy construction is disabled because the runtime owns backend state.
PenTabletCreationResult create_pen_tablet()
Create a pen tablet with the built-in pen tablet profile.
Runtime & operator=(const Runtime &)=delete
Copy assignment is disabled because the runtime owns backend state.
PenTabletCreationResult create_pen_tablet(const CreatePenTabletOptions &options)
Create a pen tablet from full creation options.
BackendKind backend_kind() const
Get the backend kind used by this runtime.
MouseCreationResult create_mouse(const CreateMouseOptions &options)
Create a mouse from full creation options.
Virtual touchscreen device handle.
Definition runtime.hpp:474
Touchscreen(Touchscreen &&other) noexcept
Move construct a touchscreen handle.
DeviceId device_id() const override
Get the device identifier assigned by the runtime.
OperationStatus close() override
Close the virtual device.
Touchscreen & operator=(Touchscreen &&other) noexcept
Move assign a touchscreen handle.
Touchscreen & operator=(const Touchscreen &)=delete
Copy assignment is disabled because the handle owns device lifetime.
~Touchscreen() override
Destroy the touchscreen handle and close the virtual device if it is still open.
std::size_t submit_count() const
Get the number of successful submit operations.
OperationStatus place_contact(const TouchContact &contact)
Place or move a touch contact.
bool is_open() const override
Check whether the device is open.
std::vector< DeviceNode > device_nodes() const override
Get platform-visible nodes associated with the device.
OperationStatus release_contact(std::int32_t contact_id)
Release a touch contact.
Touchscreen(const Touchscreen &)=delete
Copy construction is disabled because the handle owns device lifetime.
Touchscreen(detail::RuntimeConstructionToken token, std::shared_ptr< detail::TouchscreenDevice > device)
Construct a touchscreen handle for Runtime-owned state.
TouchContact last_submitted_contact() const
Get the most recently submitted touch contact.
const DeviceProfile & profile() const override
Get the profile used to create this device.
Virtual trackpad device handle.
Definition runtime.hpp:578
OperationStatus button(bool pressed)
Submit a physical trackpad button transition.
Trackpad & operator=(const Trackpad &)=delete
Copy assignment is disabled because the handle owns device lifetime.
bool is_open() const override
Check whether the device is open.
OperationStatus release_contact(std::int32_t contact_id)
Release a trackpad contact.
Trackpad(detail::RuntimeConstructionToken token, std::shared_ptr< detail::TrackpadDevice > device)
Construct a trackpad handle for Runtime-owned state.
std::size_t submit_count() const
Get the number of successful submit operations.
OperationStatus place_contact(const TouchContact &contact)
Place or move a trackpad contact.
Trackpad(Trackpad &&other) noexcept
Move construct a trackpad handle.
~Trackpad() override
Destroy the trackpad handle and close the virtual device if it is still open.
TouchContact last_submitted_contact() const
Get the most recently submitted touch contact.
OperationStatus close() override
Close the virtual device.
Trackpad & operator=(Trackpad &&other) noexcept
Move assign a trackpad handle.
const DeviceProfile & profile() const override
Get the profile used to create this device.
std::vector< DeviceNode > device_nodes() const override
Get platform-visible nodes associated with the device.
DeviceId device_id() const override
Get the device identifier assigned by the runtime.
Trackpad(const Trackpad &)=delete
Copy construction is disabled because the handle owns device lifetime.
Common interface for virtual device handles.
Definition runtime.hpp:42
virtual DeviceId device_id() const =0
Get the device identifier assigned by the runtime.
virtual OperationStatus close()=0
Close the virtual device.
virtual std::vector< DeviceNode > device_nodes() const =0
Get platform-visible nodes associated with the device.
virtual ~VirtualDevice()=default
Destroy the virtual device handle.
virtual const DeviceProfile & profile() const =0
Get the profile used to create this device.
virtual bool is_open() const =0
Check whether the device is open.
Public libvirtualhid API namespace.
Definition profiles.hpp:14
std::uint16_t KeyboardKeyCode
Keyboard key code accepted by the keyboard event model.
Definition types.hpp:701
std::uint64_t DeviceId
Stable identifier assigned to a virtual device instance.
Definition types.hpp:24
std::function< void(const GamepadOutput &)> OutputCallback
Callback invoked when a gamepad receives output from the backend.
Definition types.hpp:965
MouseButton
Mouse buttons accepted by the mouse event model.
Definition types.hpp:731
@ button
Mouse button transition.
@ other
Other platform-specific device path.
BackendKind
Backend implementation selection.
Definition types.hpp:101
PenButton
Pen tablet buttons.
Definition types.hpp:841
Feature set exposed by the selected backend.
Definition types.hpp:119
Full gamepad creation request.
Definition types.hpp:398
Full keyboard creation request.
Definition types.hpp:413
Full mouse creation request.
Definition types.hpp:433
Full pen tablet creation request.
Definition types.hpp:478
Full touchscreen creation request.
Definition types.hpp:448
Full trackpad creation request.
Definition types.hpp:463
Descriptor and identity data used to create a virtual device.
Definition types.hpp:273
Result returned by gamepad creation.
Definition runtime.hpp:795
OperationStatus status
Creation status.
Definition runtime.hpp:799
std::unique_ptr< Gamepad > gamepad
Created gamepad handle when creation succeeds.
Definition runtime.hpp:804
Normalized gamepad output event delivered to the consumer.
Definition types.hpp:900
Common gamepad input state accepted by libvirtualhid.
Definition types.hpp:647
Result returned by keyboard creation.
Definition runtime.hpp:819
OperationStatus status
Creation status.
Definition runtime.hpp:823
std::unique_ptr< Keyboard > keyboard
Created keyboard handle when creation succeeds.
Definition runtime.hpp:828
Keyboard key transition.
Definition types.hpp:706
UTF-8 text input request.
Definition types.hpp:721
Result returned by mouse creation.
Definition runtime.hpp:843
OperationStatus status
Creation status.
Definition runtime.hpp:847
std::unique_ptr< Mouse > mouse
Created mouse handle when creation succeeds.
Definition runtime.hpp:852
Mouse input event.
Definition types.hpp:753
Result returned by pen tablet creation.
Definition runtime.hpp:915
OperationStatus status
Creation status.
Definition runtime.hpp:919
std::unique_ptr< PenTablet > pen_tablet
Created pen tablet handle when creation succeeds.
Definition runtime.hpp:924
Runtime creation options.
Definition types.hpp:109
Result returned by touchscreen creation.
Definition runtime.hpp:867
std::unique_ptr< Touchscreen > touchscreen
Created touchscreen handle when creation succeeds.
Definition runtime.hpp:876
OperationStatus status
Creation status.
Definition runtime.hpp:871
Result returned by trackpad creation.
Definition runtime.hpp:891
OperationStatus status
Creation status.
Definition runtime.hpp:895
std::unique_ptr< Trackpad > trackpad
Created trackpad handle when creation succeeds.
Definition runtime.hpp:900
Token used by Runtime to construct runtime-owned handles.
Definition runtime.hpp:23
Core public types for libvirtualhid.