Skip to content

Commit 54b2393

Browse files
Add Doxygen config, submodule, and API docs
Add Doxygen/Read the Docs plumbing and document the public API. - Add .readthedocs.yaml and docs/Doxyfile to configure Read the Docs and Doxygen. - Add third-party/doxyconfig as a git submodule and update .gitmodules and .gitignore. - Wire docs submodule into CMake (top-level BUILD_DOCS option) so docs can be built when top-level. - Document public headers: add Doxygen-style comments and API surface annotations to include/libvirtualhid/*.hpp (libvirtualhid.hpp, profiles.hpp, report.hpp, runtime.hpp, types.hpp). - Update README to mention the new docs directory and the doxyconfig submodule. These changes enable building hosted documentation (Read the Docs) and provide inline API documentation for consumers of the public headers.
1 parent a339c18 commit 54b2393

12 files changed

Lines changed: 771 additions & 49 deletions

File tree

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,9 @@
44
# CMake
55
build/
66
cmake-build-*/
7+
8+
# Local temp directories
9+
.tmp/
10+
11+
# doxyconfig
12+
docs/doxyconfig*

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
[submodule "third-party/doxyconfig"]
2+
path = third-party/doxyconfig
3+
url = https://github.com/LizardByte/doxyconfig.git
4+
branch = master
15
[submodule "third-party/googletest"]
26
path = third-party/googletest
37
url = https://github.com/google/googletest.git

.readthedocs.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
# .readthedocs.yaml
3+
# Read the Docs configuration file
4+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
5+
6+
version: 2
7+
8+
build:
9+
os: ubuntu-24.04
10+
tools:
11+
python: "miniconda-latest"
12+
commands:
13+
- |
14+
if [ -f readthedocs_build.sh ]; then
15+
doxyconfig_dir="."
16+
else
17+
doxyconfig_dir="./third-party/doxyconfig"
18+
fi
19+
chmod +x "${doxyconfig_dir}/readthedocs_build.sh"
20+
export DOXYCONFIG_DIR="${doxyconfig_dir}"
21+
"${doxyconfig_dir}/readthedocs_build.sh"
22+
23+
# using conda, we can get newer doxygen and graphviz than ubuntu provide
24+
# https://github.com/readthedocs/readthedocs.org/issues/8151#issuecomment-890359661
25+
conda:
26+
environment: third-party/doxyconfig/environment.yml
27+
28+
submodules:
29+
include: all
30+
recursive: true

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
2727
#
2828
# Project optional configuration
2929
#
30-
option(BUILD_DOCS "Build documentation" OFF)
30+
option(BUILD_DOCS "Build documentation" ${LIBVIRTUALHID_IS_TOP_LEVEL})
3131
option(BUILD_TESTS "Build tests" ${LIBVIRTUALHID_IS_TOP_LEVEL})
3232
option(BUILD_EXAMPLES "Build examples" ${LIBVIRTUALHID_IS_TOP_LEVEL})
3333

@@ -64,6 +64,10 @@ add_subdirectory(src)
6464
# Examples, tests, and docs are top-level only
6565
#
6666
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
67+
if(BUILD_DOCS)
68+
add_subdirectory(third-party/doxyconfig docs)
69+
endif()
70+
6771
if(BUILD_EXAMPLES)
6872
add_subdirectory(examples)
6973
endif()

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ consumers:
191191
- Put all submodules under `third-party`.
192192
- Add GoogleTest as a submodule at `third-party/googletest`; do not download it
193193
during configure.
194+
- Add the LizardByte Doxygen configuration as a submodule at
195+
`third-party/doxyconfig` and use it for local docs and Read the Docs builds.
194196
- Expose `libvirtualhid::libvirtualhid` as the main CMake target.
195197
- Keep the public headers under `include/libvirtualhid` and the implementation
196198
split into shared core code plus platform-specific backends.
@@ -215,6 +217,8 @@ profiles/ Built-in gamepad profiles
215217
examples/ Minimal consumers and platform smoke tests
216218
tests/ Unit and integration tests
217219
cmake/ Package config and helper modules
220+
docs/ Project Doxygen configuration
221+
third-party/doxyconfig/ LizardByte Doxygen configuration submodule
218222
third-party/googletest/ GoogleTest submodule
219223
```
220224

@@ -228,6 +232,8 @@ third-party/googletest/ GoogleTest submodule
228232
- Add a fake in-memory backend so API tests can run on every platform.
229233
- Add GoogleTest as a submodule under `third-party/googletest` and wire tests
230234
using the same top-level-only pattern as `tray` and `libdisplaydevice`.
235+
- Add Doxygen documentation wiring with `third-party/doxyconfig`, a project
236+
`docs/Doxyfile`, and Read the Docs configuration.
231237
- Add CI using the `libdisplaydevice` workflow pattern for Linux GCC, Linux
232238
Clang, macOS, Windows MinGW/UCRT64, and Windows MSVC configure/build/test
233239
coverage.

docs/Doxyfile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# This file describes the settings to be used by the documentation system
2+
# doxygen (www.doxygen.org) for a project.
3+
#
4+
# All text after a double hash (##) is considered a comment and is placed in
5+
# front of the TAG it is preceding.
6+
#
7+
# All text after a single hash (#) is considered a comment and will be ignored.
8+
# The format is:
9+
# TAG = value [value, ...]
10+
# For lists, items can also be appended using:
11+
# TAG += value [value, ...]
12+
# Values that contain spaces should be placed between quotes (\" \").
13+
#
14+
# Note:
15+
#
16+
# Use doxygen to compare the used configuration file with the template
17+
# configuration file:
18+
# doxygen -x [configFile]
19+
# Use doxygen to compare the used configuration file with the template
20+
# configuration file without replacing the environment variables or CMake type
21+
# replacement variables:
22+
# doxygen -x_noenv [configFile]
23+
24+
# project metadata
25+
DOCSET_BUNDLE_ID = dev.lizardbyte.libvirtualhid
26+
DOCSET_PUBLISHER_ID = dev.lizardbyte.libvirtualhid.documentation
27+
PROJECT_BRIEF = "Cross-platform C++ library for virtual HID devices."
28+
PROJECT_NAME = libvirtualhid
29+
30+
# project specific settings
31+
DOT_GRAPH_MAX_NODES = 50
32+
INCLUDE_PATH =
33+
WARN_IF_UNDOCUMENTED = YES
34+
35+
# files and directories to process
36+
USE_MDFILE_AS_MAINPAGE = ../README.md
37+
INPUT = ../README.md \
38+
../third-party/doxyconfig/docs/source_code.md \
39+
../include

include/libvirtualhid/libvirtualhid.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#pragma once
22

3+
/**
4+
* @file libvirtualhid/libvirtualhid.hpp
5+
* @brief Aggregate include for the libvirtualhid public C++ API.
6+
*/
7+
38
#include <libvirtualhid/profiles.hpp>
49
#include <libvirtualhid/report.hpp>
510
#include <libvirtualhid/runtime.hpp>

include/libvirtualhid/profiles.hpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,61 @@
77

88
namespace lvh::profiles {
99

10+
/**
11+
* @brief Create the generic HID gamepad profile.
12+
*
13+
* @return Generic gamepad device profile.
14+
*/
1015
DeviceProfile generic_gamepad();
16+
17+
/**
18+
* @brief Create the Xbox 360-compatible gamepad profile.
19+
*
20+
* @return Xbox 360-compatible device profile.
21+
*/
1122
DeviceProfile xbox_360();
23+
24+
/**
25+
* @brief Create the Xbox One-compatible gamepad profile.
26+
*
27+
* @return Xbox One-compatible device profile.
28+
*/
1229
DeviceProfile xbox_one();
30+
31+
/**
32+
* @brief Create the Xbox Series-compatible gamepad profile.
33+
*
34+
* @return Xbox Series-compatible device profile.
35+
*/
1336
DeviceProfile xbox_series();
37+
38+
/**
39+
* @brief Create the PlayStation DualSense-compatible gamepad profile.
40+
*
41+
* @return DualSense-compatible device profile.
42+
*/
1443
DeviceProfile dualsense();
44+
45+
/**
46+
* @brief Create the Nintendo Switch Pro-compatible gamepad profile.
47+
*
48+
* @return Switch Pro-compatible device profile.
49+
*/
1550
DeviceProfile switch_pro();
1651

52+
/**
53+
* @brief Look up a built-in gamepad profile by kind.
54+
*
55+
* @param kind Built-in gamepad profile kind.
56+
* @return Matching profile, or `std::nullopt` when the kind is unknown.
57+
*/
1758
std::optional<DeviceProfile> gamepad_profile(GamepadProfileKind kind);
59+
60+
/**
61+
* @brief Get every built-in gamepad profile.
62+
*
63+
* @return Built-in gamepad profiles.
64+
*/
1865
std::vector<DeviceProfile> built_in_gamepad_profiles();
1966

2067
} // namespace lvh::profiles

include/libvirtualhid/report.hpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,61 @@
77

88
namespace lvh::reports {
99

10+
/**
11+
* @brief Clamp a stick axis value to the normalized range.
12+
*
13+
* @param value Axis value.
14+
* @return Clamped axis value in the inclusive range `[-1.0, 1.0]`.
15+
*/
1016
float clamp_axis(float value);
17+
18+
/**
19+
* @brief Clamp a trigger value to the normalized range.
20+
*
21+
* @param value Trigger value.
22+
* @return Clamped trigger value in the inclusive range `[0.0, 1.0]`.
23+
*/
1124
float clamp_trigger(float value);
25+
26+
/**
27+
* @brief Convert a normalized axis value to a signed HID axis value.
28+
*
29+
* @param value Axis value in the inclusive range `[-1.0, 1.0]`.
30+
* @return Signed 16-bit HID axis value.
31+
*/
1232
std::int16_t normalize_axis(float value);
33+
34+
/**
35+
* @brief Convert a normalized trigger value to an unsigned HID trigger value.
36+
*
37+
* @param value Trigger value in the inclusive range `[0.0, 1.0]`.
38+
* @return Unsigned 8-bit HID trigger value.
39+
*/
1340
std::uint8_t normalize_trigger(float value);
41+
42+
/**
43+
* @brief Normalize all scalar fields in a gamepad state.
44+
*
45+
* @param state Gamepad state to normalize.
46+
* @return Normalized gamepad state.
47+
*/
1448
GamepadState normalize_state(const GamepadState& state);
49+
50+
/**
51+
* @brief Convert directional pad buttons to a HID hat switch value.
52+
*
53+
* @param buttons Button set containing directional pad state.
54+
* @return HID hat switch value, or `8` for neutral.
55+
*/
1556
std::uint8_t hat_from_buttons(const ButtonSet& buttons);
57+
58+
/**
59+
* @brief Pack a gamepad state into the profile's common input report format.
60+
*
61+
* @param profile Device profile used for report identity and size.
62+
* @param state Gamepad state to pack.
63+
* @return Packed input report bytes.
64+
*/
1665
std::vector<std::uint8_t> pack_input_report(const DeviceProfile& profile, const GamepadState& state);
1766

1867
} // namespace lvh::reports

0 commit comments

Comments
 (0)