Files
Nebula-OS/Bigscreen/CMakeLists.txt
T
andrew 61c448eb00 Add SDL3-based controller input service
Integrate SDL3 controller support and wire it into the InputRouter.

- Add ControllerInputService (src/ControllerInputService.{h,cpp}) to discover, poll and translate SDL3 gamepad events into InputRouter actions, with axis repeat handling and debouncing.
- Update CMakeLists to find or fetch SDL3, add the new source files to the target, link the SDL3 target, and copy runtime DLLs on Windows.
- Add triggerAction(Action) to InputRouter and use it from existing keyboard handling to centralize action dispatch.
- Instantiate ControllerInputService in main so controllers feed the InputRouter.
- Update QML views (ShellWindow, HomeView, LibraryView, SettingsView) to use numeric action IDs and add small UI/status text and navigation tweaks for controller-driven flows.

These changes enable gamepad/controller input for Bigscreen via SDL3 and adapt UI code to handle the mapped actions.
2026-05-23 21:47:15 +12:00

109 lines
3.0 KiB
CMake

cmake_minimum_required(VERSION 3.21)
project(NebulaBigscreen VERSION 0.1.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
find_package(Qt6 6.5 REQUIRED COMPONENTS Quick Gui)
find_package(SDL3 CONFIG QUIET)
if(NOT SDL3_FOUND)
include(FetchContent)
set(SDL_SHARED ON CACHE BOOL "" FORCE)
set(SDL_STATIC OFF CACHE BOOL "" FORCE)
set(SDL_TEST_LIBRARY OFF CACHE BOOL "" FORCE)
set(SDL_TESTS OFF CACHE BOOL "" FORCE)
set(SDL_EXAMPLES OFF CACHE BOOL "" FORCE)
FetchContent_Declare(SDL3
URL https://github.com/libsdl-org/SDL/releases/download/release-3.2.30/SDL3-3.2.30.tar.gz
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
)
FetchContent_MakeAvailable(SDL3)
endif()
if(TARGET SDL3::SDL3)
set(BIGSCREEN_SDL_TARGET SDL3::SDL3)
elseif(TARGET SDL3::SDL3-shared)
set(BIGSCREEN_SDL_TARGET SDL3::SDL3-shared)
else()
message(FATAL_ERROR "SDL3 target was not found after package lookup/fetch")
endif()
qt_standard_project_setup(REQUIRES 6.5)
qt_policy(SET QTP0004 NEW)
set(BIGSCREEN_QML_FILES
qml/Main.qml
qml/ShellWindow.qml
qml/Theme.qml
qml/components/NebulaBackground.qml
qml/components/TopBar.qml
qml/components/AppTile.qml
qml/components/TileRail.qml
qml/components/PowerOverlay.qml
qml/views/HomeView.qml
qml/views/LibraryView.qml
qml/views/SettingsView.qml
)
set_source_files_properties(qml/Theme.qml PROPERTIES QT_QML_SINGLETON_TYPE TRUE)
qt_add_executable(nebula-bigscreen
src/main.cpp
src/ControllerInputService.cpp
src/ControllerInputService.h
src/InputRouter.cpp
src/InputRouter.h
)
qt_add_qml_module(nebula-bigscreen
URI Nebula.Bigscreen
VERSION 1.0
QML_FILES ${BIGSCREEN_QML_FILES}
)
target_link_libraries(nebula-bigscreen
PRIVATE
Qt6::Quick
Qt6::Gui
${BIGSCREEN_SDL_TARGET}
)
if(WIN32)
add_custom_command(
TARGET nebula-bigscreen
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_RUNTIME_DLLS:nebula-bigscreen>
$<TARGET_FILE_DIR:nebula-bigscreen>
COMMAND_EXPAND_LISTS
COMMENT "Copying runtime DLLs next to nebula-bigscreen"
)
endif()
if(WIN32)
set_target_properties(nebula-bigscreen PROPERTIES WIN32_EXECUTABLE TRUE)
get_target_property(_qmake_executable Qt6::qmake IMPORTED_LOCATION)
get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY)
find_program(WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${_qt_bin_dir}" REQUIRED)
add_custom_command(
TARGET nebula-bigscreen
POST_BUILD
COMMAND "${WINDEPLOYQT_EXECUTABLE}"
$<$<CONFIG:Debug>:--debug>
$<$<NOT:$<CONFIG:Debug>>:--release>
--qmldir "${CMAKE_CURRENT_SOURCE_DIR}/qml"
"$<TARGET_FILE:nebula-bigscreen>"
COMMENT "Deploying Qt runtime DLLs next to nebula-bigscreen"
)
endif()
install(TARGETS nebula-bigscreen RUNTIME DESTINATION bin)