Steam Input as the primary guest-input path (optional, SDK-gated)
Add SteamInputSource: initializes SteamAPI + Steam Input, loads a bundled action manifest via SetInputActionManifestFilePath (no partner-backend config needed), and reads the GameControls action set into CoopPadState -- falling back to XInput per slot, and to pure XInput if Steam isn't available, so the host always runs. Enabled automatically when the Steamworks SDK is vendored at third_party/steamworks_sdk/ (auto-detected by CMake; gitignored and never committed -- the build is XInput-only without it). Stages steam_api64.dll + the manifest next to the host and builds coop_steam_input_probe (a console smoke test). Verified: the probe initializes against the live Steam client and enumerates controllers; the host degrades gracefully when launched standalone. All 5 tests pass. Reading actual controller state needs a pad bound through Steam Input for the running (donor) appid, which XInput otherwise covers. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -37,3 +37,50 @@ target_link_libraries(coop_host PRIVATE
|
||||
ole32)
|
||||
|
||||
set_target_properties(coop_host PROPERTIES OUTPUT_NAME "coop_host")
|
||||
|
||||
# Optional Steam Input: enabled automatically when the Steamworks SDK is vendored
|
||||
# under third_party/steamworks_sdk (it isn't redistributable, so it's gitignored
|
||||
# and never committed). Without it, the host builds XInput-only.
|
||||
set(COOP_STEAM_SDK_DIR "${CMAKE_SOURCE_DIR}/third_party/steamworks_sdk/sdk")
|
||||
if(EXISTS "${COOP_STEAM_SDK_DIR}/public/steam/steam_api.h")
|
||||
message(STATUS "Steamworks SDK found -> Steam Input enabled")
|
||||
target_sources(coop_host PRIVATE src/input/steam_input_source.cpp)
|
||||
target_compile_definitions(coop_host PRIVATE COOP_WITH_STEAM)
|
||||
target_include_directories(coop_host SYSTEM PRIVATE "${COOP_STEAM_SDK_DIR}/public")
|
||||
# The SDK headers trip /W4 (strncpy, non-UTF-8 bytes); silence for this TU only.
|
||||
set_source_files_properties(src/input/steam_input_source.cpp PROPERTIES
|
||||
COMPILE_OPTIONS "/wd4996;/wd4828")
|
||||
target_link_libraries(coop_host PRIVATE
|
||||
"${COOP_STEAM_SDK_DIR}/redistributable_bin/win64/steam_api64.lib")
|
||||
# Stage steam_api64.dll + the action manifest next to coop_host.exe.
|
||||
add_custom_command(TARGET coop_host POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${COOP_STEAM_SDK_DIR}/redistributable_bin/win64/steam_api64.dll"
|
||||
"$<TARGET_FILE_DIR:coop_host>/steam_api64.dll"
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/assets/steam_input_actions.vdf"
|
||||
"$<TARGET_FILE_DIR:coop_host>/steam_input_actions.vdf"
|
||||
VERBATIM)
|
||||
|
||||
# Console smoke test for Steam Input (reuses the shipping source). Not a ctest
|
||||
# (needs Steam running + an appid); run manually from bin/<config>/.
|
||||
add_executable(coop_steam_input_probe
|
||||
${CMAKE_SOURCE_DIR}/tools/steam_input_probe/main.cpp
|
||||
src/input/steam_input_source.cpp
|
||||
src/input/xinput_source.cpp)
|
||||
target_include_directories(coop_steam_input_probe PRIVATE src)
|
||||
target_include_directories(coop_steam_input_probe SYSTEM PRIVATE "${COOP_STEAM_SDK_DIR}/public")
|
||||
target_compile_definitions(coop_steam_input_probe PRIVATE COOP_WITH_STEAM)
|
||||
set_source_files_properties(src/input/steam_input_source.cpp PROPERTIES COMPILE_OPTIONS "/wd4996;/wd4828")
|
||||
target_link_libraries(coop_steam_input_probe PRIVATE
|
||||
coop_common
|
||||
xinput
|
||||
"${COOP_STEAM_SDK_DIR}/redistributable_bin/win64/steam_api64.lib")
|
||||
add_custom_command(TARGET coop_steam_input_probe POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${COOP_STEAM_SDK_DIR}/redistributable_bin/win64/steam_api64.dll"
|
||||
"$<TARGET_FILE_DIR:coop_steam_input_probe>/steam_api64.dll"
|
||||
VERBATIM)
|
||||
else()
|
||||
message(STATUS "Steamworks SDK not found -> Steam Input disabled (XInput only)")
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user