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
74 changes: 44 additions & 30 deletions .github/workflows/cmake-single-platform.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,53 @@
# This starter workflow is for a CMake project running on a single platform. There is a different starter workflow if you need cross-platform coverage.
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml
name: CMake on a single platform
name: Build and test

on:
push:
branches: [ "main" ]
branches: [main]
pull_request:
branches: [ "main" ]
branches: [main]

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
permissions:
contents: read

jobs:
build:
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ubuntu-latest

name: ${{ matrix.component }}
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
include:
- component: daemon
gadget: 'OFF'
packages: libdbus-1-dev libsystemd-dev
- component: qt
gadget: 'ON'
packages: libdbus-1-dev libsystemd-dev qt6-base-dev qt6-declarative-dev libx11-dev libxtst-dev
steps:
- uses: actions/checkout@v4

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}

- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

- name: Test
working-directory: ${{github.workspace}}/build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C ${{env.BUILD_TYPE}}

- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends -y build-essential cmake ninja-build pkg-config ${{ matrix.packages }}
- name: Configure
run: >-
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
-DBUILD_DAEMON=ON -DBUILD_GADGET=${{ matrix.gadget }} -DBUILD_TESTS=ON
- name: Build
run: cmake --build build --parallel 2
- name: Test
run: ctest --test-dir build --output-on-failure --no-tests=error
- name: Verify installed executables
run: |
prefix="$RUNNER_TEMP/openwheel"
cmake --install build --prefix "$prefix"
test -x "$prefix/bin/asus_wheel"
if [ '${{ matrix.gadget }}' = 'ON' ]; then
test -x "$prefix/bin/openwheel-gadget"
ldd "$prefix/bin/openwheel-gadget" > "$RUNNER_TEMP/gadget-libraries.txt"
if grep -F 'not found' "$RUNNER_TEMP/gadget-libraries.txt"; then
exit 1
fi
fi
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ CMakeCache.txt
CMakeFiles/
cmake_install.cmake
Makefile
*.cmake

# Compiled binaries
*.o
*.so
*.a
openwheel-gadget
asus_wheel
/bin/openwheel-gadget
/bin/asus_wheel

# Qt/QML compiled files
*.qmlc
Expand Down
29 changes: 9 additions & 20 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ OpenWheel uses CMake as its build system with support for:
- C11 compiler (for openwheel-daemon)
- C++20 compiler (for openwheel-gadget)
- pkg-config
- DBus development libraries
- D-Bus development libraries (for openwheel-daemon)

### For Gadget Component
- Qt5 (5.15+) or Qt6
- Qt modules: Core, Gui, Widgets, Qml, Quick, DBus
- Qt6 with Core, Gui, Widgets, Qml, Quick, QuickControls2 and DBus
- Qt6 Test module when `BUILD_TESTS=ON`

### Optional
- KDE Frameworks 6 (for enhanced features)
Expand Down Expand Up @@ -107,11 +107,12 @@ ctest -j$(nproc)

### Available Tests

- `check_build_outputs` - Verifies build completed successfully
- `daemon_executable_exists` - Checks daemon binary exists (if built)
- `gadget_executable_exists` - Checks gadget binary exists (if built)
- `version_test` - Validates project version
- `config_summary` - Displays build configuration
- `hid_report` tests HID decoding and button/rotation ordering (daemon builds).
- `test_rotation` tests the Qt rotation handler (gadget builds).
- `daemon_executable_exists` and `gadget_executable_exists` check the requested build artifacts.

The daemon-only build and tests require no Qt dependencies.
Configure with `cmake -S . -B build-daemon -DBUILD_GADGET=OFF`.

## Installation

Expand Down Expand Up @@ -221,18 +222,6 @@ sudo pacman -S qt6-base qt6-declarative
sudo pacman -S libx11 libxtst
```

### Qt Version Issues

If both Qt5 and Qt6 are installed and you want to use a specific version:

```bash
# Force Qt6
cmake -DQT_VERSION_MAJOR=6 ..

# Force Qt5
cmake -DQT_VERSION_MAJOR=5 ..
```

### Build Warnings

To enable additional compiler warnings:
Expand Down
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)

# Include standard CMake modules
include(GNUInstallDirs)
include(CTest)
if(BUILD_TESTS)
enable_testing()
endif()

# Add subdirectories
if(BUILD_DAEMON)
Expand All @@ -34,7 +36,6 @@ endif()

# Enable testing
if(BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
message(STATUS "Testing enabled")
endif()
Expand All @@ -47,4 +48,4 @@ message(STATUS " Build daemon: ${BUILD_DAEMON}")
message(STATUS " Build gadget: ${BUILD_GADGET}")
message(STATUS " Build tests: ${BUILD_TESTS}")
message(STATUS " Install prefix: ${CMAKE_INSTALL_PREFIX}")
message(STATUS "")
message(STATUS "")
57 changes: 13 additions & 44 deletions openwheel-daemon/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,58 +1,27 @@
cmake_minimum_required(VERSION 3.16)
project(openwheel-daemon C)

set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)

# Find required packages
find_package(PkgConfig REQUIRED)
pkg_check_modules(DBUS dbus-1)

if(NOT DBUS_FOUND)
message(WARNING "DBus not found - daemon will not be built")
return()
endif()
pkg_check_modules(DBUS REQUIRED IMPORTED_TARGET dbus-1)

# Source files
set(DAEMON_SRCS
hidreader.c
helpers.c
report.c
)

set(DAEMON_HEADERS
openwheel.h
helpers.h
report.h
)

# Create executable
add_executable(asus_wheel ${DAEMON_SRCS} ${DAEMON_HEADERS})

# Include directories
target_include_directories(asus_wheel PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${DBUS_INCLUDE_DIRS}
)

# Link libraries
target_link_libraries(asus_wheel PRIVATE
${DBUS_LIBRARIES}
)

# Compile options
target_compile_options(asus_wheel PRIVATE
${DBUS_CFLAGS_OTHER}
-Wall
-Wextra
)

# Installation
install(TARGETS asus_wheel
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT daemon
)

# Install headers (for development)
install(FILES ${DAEMON_HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openwheel
COMPONENT daemon-dev
)
target_compile_features(asus_wheel PRIVATE c_std_11)
target_compile_options(asus_wheel PRIVATE -Wall -Wextra)
target_link_libraries(asus_wheel PRIVATE PkgConfig::DBUS)

if(ENABLE_INSTALL)
install(TARGETS asus_wheel
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT daemon)
install(FILES ${DAEMON_HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openwheel COMPONENT daemon-dev)
endif()
15 changes: 9 additions & 6 deletions openwheel-daemon/helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ int find_hidraw_device(char *device_path, size_t path_size) {
// Iterate through the hidrawX directories
while ((entry = readdir(dp)) != NULL) {
if (entry->d_type == DT_LNK) {
char sysfs_device_path[BUFFER_SIZE];
char sysfs_device_path[sizeof(SYSFS_HIDRAW_PATH) +
sizeof(entry->d_name) + sizeof("/device/product")];
char file_content[BUFFER_SIZE];

// Try USB path first: device/product
Expand All @@ -175,9 +176,9 @@ int find_hidraw_device(char *device_path, size_t path_size) {

if (read_sysfs_file(sysfs_device_path, file_content, sizeof(file_content)) == 0) {
if (strstr(file_content, DEVICE_NAME)) {
snprintf(device_path, path_size, "/dev/%s", entry->d_name);
int length = snprintf(device_path, path_size, "/dev/%s", entry->d_name);
closedir(dp);
return 0;
return length >= 0 && (size_t)length < path_size ? 0 : -1;
}
}

Expand All @@ -190,9 +191,9 @@ int find_hidraw_device(char *device_path, size_t path_size) {
while (fgets(file_content, sizeof(file_content), fp) != NULL) {
if (strstr(file_content, DEVICE_NAME)) {
fclose(fp);
snprintf(device_path, path_size, "/dev/%s", entry->d_name);
int length = snprintf(device_path, path_size, "/dev/%s", entry->d_name);
closedir(dp);
return 0;
return length >= 0 && (size_t)length < path_size ? 0 : -1;
}
}
fclose(fp);
Expand Down Expand Up @@ -233,6 +234,7 @@ void send_notification(const char *summary, const char *body) {

if (msg == NULL) {
fprintf(stderr, "Message Null\n");
dbus_connection_unref(conn);
return;
}

Expand Down Expand Up @@ -268,4 +270,5 @@ void send_notification(const char *summary, const char *body) {

dbus_connection_flush(conn);
dbus_message_unref(msg);
}
dbus_connection_unref(conn);
}
Loading