Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ project(libvirtualhid VERSION 0.0.0
LANGUAGES CXX)

set(PROJECT_LICENSE "MIT")
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ target_include_directories(${PROJECT_NAME}
PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}")

target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_20)
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_23)
set_target_properties(${PROJECT_NAME} PROPERTIES
EXPORT_NAME libvirtualhid
OUTPUT_NAME virtualhid)
Expand Down
42 changes: 36 additions & 6 deletions src/core/runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,12 @@ namespace lvh {

Gamepad::Gamepad(Gamepad &&) noexcept = default;
Gamepad &Gamepad::operator=(Gamepad &&) noexcept = default;
Gamepad::~Gamepad() = default;

Gamepad::~Gamepad() {
if (device_) {
static_cast<void>(close());
}
}

DeviceId Gamepad::device_id() const {
return device_->id;
Expand Down Expand Up @@ -425,7 +430,12 @@ namespace lvh {

Keyboard::Keyboard(Keyboard &&) noexcept = default;
Keyboard &Keyboard::operator=(Keyboard &&) noexcept = default;
Keyboard::~Keyboard() = default;

Keyboard::~Keyboard() {
if (device_) {
static_cast<void>(close());
}
}

DeviceId Keyboard::device_id() const {
return device_->id;
Expand Down Expand Up @@ -531,7 +541,12 @@ namespace lvh {

Mouse::Mouse(Mouse &&) noexcept = default;
Mouse &Mouse::operator=(Mouse &&) noexcept = default;
Mouse::~Mouse() = default;

Mouse::~Mouse() {
if (device_) {
static_cast<void>(close());
}
}

DeviceId Mouse::device_id() const {
return device_->id;
Expand Down Expand Up @@ -641,7 +656,12 @@ namespace lvh {

Touchscreen::Touchscreen(Touchscreen &&) noexcept = default;
Touchscreen &Touchscreen::operator=(Touchscreen &&) noexcept = default;
Touchscreen::~Touchscreen() = default;

Touchscreen::~Touchscreen() {
if (device_) {
static_cast<void>(close());
}
}

DeviceId Touchscreen::device_id() const {
return device_->id;
Expand Down Expand Up @@ -743,7 +763,12 @@ namespace lvh {

Trackpad::Trackpad(Trackpad &&) noexcept = default;
Trackpad &Trackpad::operator=(Trackpad &&) noexcept = default;
Trackpad::~Trackpad() = default;

Trackpad::~Trackpad() {
if (device_) {
static_cast<void>(close());
}
}

DeviceId Trackpad::device_id() const {
return device_->id;
Expand Down Expand Up @@ -862,7 +887,12 @@ namespace lvh {

PenTablet::PenTablet(PenTablet &&) noexcept = default;
PenTablet &PenTablet::operator=(PenTablet &&) noexcept = default;
PenTablet::~PenTablet() = default;

PenTablet::~PenTablet() {
if (device_) {
static_cast<void>(close());
}
}

DeviceId PenTablet::device_id() const {
return device_->id;
Expand Down
4 changes: 2 additions & 2 deletions src/core/types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace lvh {
}

void ButtonSet::set(GamepadButton button, bool pressed) {
const auto mask = 1U << static_cast<std::uint8_t>(button);
const auto mask = 1U << std::to_underlying(button);
if (pressed) {
bits_ |= mask;
} else {
Expand All @@ -59,7 +59,7 @@ namespace lvh {
}

bool ButtonSet::test(GamepadButton button) const {
return (bits_ & (1U << static_cast<std::uint8_t>(button))) != 0;
return (bits_ & (1U << std::to_underlying(button))) != 0;
}

std::uint32_t ButtonSet::raw_bits() const {
Expand Down
12 changes: 6 additions & 6 deletions src/include/libvirtualhid/runtime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ namespace lvh {
Gamepad(detail::RuntimeConstructionToken token, std::shared_ptr<detail::GamepadDevice> device);

/**
* @brief Destroy the gamepad handle.
* @brief Destroy the gamepad handle and close the virtual device if it is still open.
*/
~Gamepad() override;

Expand Down Expand Up @@ -248,7 +248,7 @@ namespace lvh {
Keyboard(detail::RuntimeConstructionToken token, std::shared_ptr<detail::KeyboardDevice> device);

/**
* @brief Destroy the keyboard handle.
* @brief Destroy the keyboard handle and close the virtual device if it is still open.
*/
~Keyboard() override;

Expand Down Expand Up @@ -368,7 +368,7 @@ namespace lvh {
Mouse(detail::RuntimeConstructionToken token, std::shared_ptr<detail::MouseDevice> device);

/**
* @brief Destroy the mouse handle.
* @brief Destroy the mouse handle and close the virtual device if it is still open.
*/
~Mouse() override;

Expand Down Expand Up @@ -509,7 +509,7 @@ namespace lvh {
Touchscreen(detail::RuntimeConstructionToken token, std::shared_ptr<detail::TouchscreenDevice> device);

/**
* @brief Destroy the touchscreen handle.
* @brief Destroy the touchscreen handle and close the virtual device if it is still open.
*/
~Touchscreen() override;

Expand Down Expand Up @@ -613,7 +613,7 @@ namespace lvh {
Trackpad(detail::RuntimeConstructionToken token, std::shared_ptr<detail::TrackpadDevice> device);

/**
* @brief Destroy the trackpad handle.
* @brief Destroy the trackpad handle and close the virtual device if it is still open.
*/
~Trackpad() override;

Expand Down Expand Up @@ -725,7 +725,7 @@ namespace lvh {
PenTablet(detail::RuntimeConstructionToken token, std::shared_ptr<detail::PenTabletDevice> device);

/**
* @brief Destroy the pen tablet handle.
* @brief Destroy the pen tablet handle and close the virtual device if it is still open.
*/
~PenTablet() override;

Expand Down
Loading