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
107 changes: 97 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,64 @@ add_executable(sfr_kinect_sensor_test tests/kinect_sensor_test.cpp src/kinect_se
src/kinect_preview.cpp)
target_include_directories(sfr_kinect_sensor_test PRIVATE src)
add_test(NAME kinect_sensor COMMAND sfr_kinect_sensor_test)
add_executable(sfr_kinect_smoothing_test tests/kinect_smoothing_test.cpp src/kinect_smoothing.cpp)
add_executable(sfr_kinect_smoothing_test tests/kinect_smoothing_test.cpp src/kinect_smoothing.cpp src/nui_transform_smooth.cpp)
target_include_directories(sfr_kinect_smoothing_test PRIVATE src)
add_test(NAME kinect_smoothing COMMAND sfr_kinect_smoothing_test)
add_executable(sfr_kinect_calibration_test tests/kinect_calibration_test.cpp src/kinect_calibration.cpp)
target_include_directories(sfr_kinect_calibration_test PRIVATE src)
add_test(NAME kinect_calibration COMMAND sfr_kinect_calibration_test)
# The title's NuiTransformSmooth (827701A0) done natively, worked by hand.
add_executable(sfr_nui_transform_smooth_test tests/nui_transform_smooth_test.cpp src/nui_transform_smooth.cpp
src/nui_transform_smooth_guest.cpp src/guest_memory.cpp)
target_include_directories(sfr_nui_transform_smooth_test PRIVATE src)
add_test(NAME nui_transform_smooth COMMAND sfr_nui_transform_smooth_test)
if(WIN32)
# The same against the Kinect for Windows SDK 1.8's own NuiTransformSmooth
# (Kinect10.dll, loaded when there; no sensor is started). Skipped (77)
# without the SDK, or when it will not smooth without a sensor.
add_executable(sfr_nui_transform_smooth_sdk_test tests/nui_transform_smooth_sdk_test.cpp src/nui_transform_smooth.cpp)
target_include_directories(sfr_nui_transform_smooth_sdk_test PRIVATE src)
add_test(NAME nui_transform_smooth_sdk COMMAND sfr_nui_transform_smooth_sdk_test)
set_tests_properties(nui_transform_smooth_sdk PROPERTIES SKIP_RETURN_CODE 77)
endif()
# A Kinect v2's camera images and skeleton points in the preview's v1 sizes.
add_executable(sfr_kinect_v2_image_test tests/kinect_v2_image_test.cpp src/kinect_v2_image.cpp)
target_include_directories(sfr_kinect_v2_image_test PRIVATE src)
add_test(NAME kinect_v2_image COMMAND sfr_kinect_v2_image_test)
# Where the Kinect preview window puts its two picture panels.
add_executable(sfr_kinect_preview_layout_test tests/kinect_preview_layout_test.cpp src/kinect_preview_layout.cpp src/kinect_v2_image.cpp)
target_include_directories(sfr_kinect_preview_layout_test PRIVATE src)
add_test(NAME kinect_preview_layout COMMAND sfr_kinect_preview_layout_test)
# A Kinect v2's depth made into a Kinect v1's for the game.
# Its raw recording, and the depth made again from it offline through the same
# view state and synthesis as live (sfr_kinect_depth_resynth).
set(SFR_KINECT_V2_RESYNTH src/kinect_v2_depth.cpp src/kinect_ideal_diagram.cpp src/kinect_v2_image.cpp src/kinect_v2_resynth.cpp src/kinect_record_raw.cpp
src/kinect_record.cpp)
add_executable(sfr_kinect_v2_depth_test tests/kinect_v2_depth_test.cpp ${SFR_KINECT_V2_RESYNTH})
target_include_directories(sfr_kinect_v2_depth_test PRIVATE src)
add_test(NAME kinect_v2_depth COMMAND sfr_kinect_v2_depth_test)
# The Recompiled view's top-down diagram (the preview window and the launcher).
add_executable(sfr_kinect_ideal_diagram_test tests/kinect_ideal_diagram_test.cpp src/kinect_ideal_diagram.cpp)
target_include_directories(sfr_kinect_ideal_diagram_test PRIVATE src)
add_test(NAME kinect_ideal_diagram COMMAND sfr_kinect_ideal_diagram_test)
# Recording a real Kinect (v1 or v2) and the race's detector answers to CSV,
# and the alone-or-both steadiness summary (docs/kinect-sensor.md).
add_executable(sfr_kinect_record_test tests/kinect_record_test.cpp src/kinect_record.cpp src/kinect_race_record.cpp src/kinect_nui_record.cpp)
target_include_directories(sfr_kinect_record_test PRIVATE src)
add_test(NAME kinect_record COMMAND sfr_kinect_record_test)
add_executable(sfr_kinect_record_summary tests/kinect_record_summary.cpp src/kinect_record.cpp)
target_include_directories(sfr_kinect_record_summary PRIVATE src)
# The depth images given to the game, recorded (SFR_KINECT_RECORD_DEPTH), the
# title's depth view features computed again from them, and a real Kinect
# v1's compared with a Kinect v2's (docs/kinect-sensor.md).
set(SFR_KINECT_DEPTH_TOOLS src/kinect_record_depth.cpp src/kinect_depth_features.cpp src/kinect_depth_compare.cpp
src/kinect_record.cpp src/kinect_race_record.cpp)
add_executable(sfr_kinect_depth_test tests/kinect_depth_test.cpp ${SFR_KINECT_DEPTH_TOOLS})
target_include_directories(sfr_kinect_depth_test PRIVATE src)
add_test(NAME kinect_depth COMMAND sfr_kinect_depth_test)
add_executable(sfr_kinect_depth_features tests/kinect_depth_features.cpp ${SFR_KINECT_DEPTH_TOOLS})
target_include_directories(sfr_kinect_depth_features PRIVATE src)
add_executable(sfr_kinect_depth_compare tests/kinect_depth_compare.cpp ${SFR_KINECT_DEPTH_TOOLS})
target_include_directories(sfr_kinect_depth_compare PRIVATE src)
add_executable(sfr_kinect_depth_resynth tests/kinect_depth_resynth.cpp ${SFR_KINECT_V2_RESYNTH} src/kinect_record_depth.cpp)
target_include_directories(sfr_kinect_depth_resynth PRIVATE src)
add_executable(sfr_nui_menu_players_test tests/nui_menu_players_test.cpp src/nui_skeleton.cpp src/guest_memory.cpp)
target_include_directories(sfr_nui_menu_players_test PRIVATE src)
add_test(NAME nui_menu_players COMMAND sfr_nui_menu_players_test)
Expand Down Expand Up @@ -236,10 +288,12 @@ add_test(NAME nui_race_min_scale COMMAND sfr_nui_race_test 0.1)
set_tests_properties(nui_race_min_scale PROPERTIES ENVIRONMENT "SFR_RACE_LEAN_SCALE=0")
add_test(NAME nui_race_max_scale COMMAND sfr_nui_race_test 3.5)
set_tests_properties(nui_race_max_scale PROPERTIES ENVIRONMENT "SFR_RACE_LEAN_SCALE=99")
add_executable(sfr_nui_race_players_test tests/nui_race_players_test.cpp src/nui_race.cpp src/guest_memory.cpp)
add_executable(sfr_nui_race_players_test tests/nui_race_players_test.cpp src/nui_race.cpp src/guest_memory.cpp
src/kinect_record.cpp src/kinect_race_record.cpp src/kinect_nui_record.cpp)
target_include_directories(sfr_nui_race_players_test PRIVATE tests/race_hook_stub src)
add_test(NAME nui_race_players COMMAND sfr_nui_race_players_test)
add_executable(sfr_nui_race_hooks_test tests/nui_race_hooks_test.cpp src/nui_race.cpp src/guest_memory.cpp)
add_executable(sfr_nui_race_hooks_test tests/nui_race_hooks_test.cpp src/nui_race.cpp src/guest_memory.cpp
src/kinect_record.cpp src/kinect_race_record.cpp src/kinect_nui_record.cpp)
target_include_directories(sfr_nui_race_hooks_test PRIVATE tests/race_hook_stub src)
add_test(NAME nui_race_hooks COMMAND sfr_nui_race_hooks_test)
add_executable(sfr_shader_inputs_test tests/shader_inputs_test.cpp src/shader_inputs.cpp)
Expand Down Expand Up @@ -364,10 +418,13 @@ else()
set(SFR_CAMERA_CAPTURE src/camera_capture.cpp src/camera_capture_none.cpp)
endif()
if(WIN32)
set(SFR_KINECT_SENSOR src/kinect_sensor_win32.cpp src/kinect_v2_win32.cpp src/kinect_smoothing.cpp)
set(SFR_KINECT_SENSOR src/kinect_sensor_win32.cpp src/kinect_v2_win32.cpp src/kinect_v2_image.cpp src/kinect_v2_depth.cpp src/kinect_ideal_diagram.cpp src/kinect_smoothing.cpp
src/nui_transform_smooth.cpp src/kinect_record.cpp src/kinect_race_record.cpp src/kinect_nui_record.cpp src/kinect_record_depth.cpp src/kinect_record_raw.cpp
src/kinect_v2_resynth.cpp)
set(SFR_VOICE src/voice_commands.cpp src/voice_commands_win32.cpp)
else()
set(SFR_KINECT_SENSOR src/kinect_sensor_none.cpp)
set(SFR_KINECT_SENSOR src/kinect_sensor_none.cpp src/kinect_ideal_diagram.cpp src/nui_transform_smooth.cpp src/kinect_record.cpp src/kinect_race_record.cpp src/kinect_nui_record.cpp src/kinect_record_depth.cpp
src/kinect_record_raw.cpp)
set(SFR_VOICE src/voice_commands.cpp src/voice_commands_none.cpp)
endif()
# The Kinect's voice commands, through the host's speech recognizer.
Expand Down Expand Up @@ -566,6 +623,9 @@ add_test(NAME launcher_settings COMMAND sfr_launcher_settings_test)
add_executable(sfr_aspect_settings_test tests/aspect_settings_test.cpp)
target_include_directories(sfr_aspect_settings_test PRIVATE src)
add_test(NAME aspect_settings COMMAND sfr_aspect_settings_test)
add_executable(sfr_consecutive_failures_test tests/consecutive_failures_test.cpp)
target_include_directories(sfr_consecutive_failures_test PRIVATE src)
add_test(NAME consecutive_failures COMMAND sfr_consecutive_failures_test)
add_executable(sfr_launcher_screen_fit_test tests/launcher_screen_fit_test.cpp)
target_include_directories(sfr_launcher_screen_fit_test PRIVATE src)
add_test(NAME launcher_screen_fit COMMAND sfr_launcher_screen_fit_test)
Expand Down Expand Up @@ -646,7 +706,7 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tools/imgui/imgui.cpp")
# The launcher lists the host cameras and controllers.
set(SFR_LAUNCHER_SOURCES src/launcher_main.cpp src/launcher_settings.cpp src/mod_loader.cpp src/input_bindings.cpp src/pad_devices.cpp src/pad_assignment.cpp src/launcher_sound.cpp src/launcher_art.cpp src/sony_gamepad.cpp
${SFR_CAMERA_CAPTURE} src/kinect_sensor.cpp ${SFR_KINECT_SENSOR} ${SFR_VOICE}
src/kinect_preview.cpp src/kinect_preview_window.cpp src/camera_preview_window.cpp src/kinect_calibration.cpp src/camera_debug.cpp src/text_wrap.cpp src/touch_scroll.cpp
src/kinect_preview.cpp src/kinect_preview_window.cpp src/kinect_preview_layout.cpp src/camera_preview_window.cpp src/camera_debug.cpp src/text_wrap.cpp src/touch_scroll.cpp
src/live_connect.cpp
${SFR_IMGUI}/imgui.cpp ${SFR_IMGUI}/imgui_draw.cpp ${SFR_IMGUI}/imgui_tables.cpp ${SFR_IMGUI}/imgui_widgets.cpp)
if(WIN32)
Expand Down Expand Up @@ -1072,6 +1132,31 @@ if(SFR_BUILD_DIAGNOSTIC)
message(FATAL_ERROR "Run scripts/generate_diagnostic.py first; raw output is not safe to execute.")
endif()
file(GLOB SFR_DIAGNOSTIC_SOURCES CONFIGURE_DEPENDS "${SFR_DIAGNOSTIC_DIR}/ppc_recomp.*.cpp")
# The title's depth view (82439998, 82439D80) as generated, copied out of
# those sources into the build directory and run on test images against
# the offline extractor (kinect_depth_features.h): bit for bit.
set(SFR_DEPTH_VIEW_GUEST "${CMAKE_CURRENT_BINARY_DIR}/kinect_depth_view_guest.inc")
add_custom_command(OUTPUT "${SFR_DEPTH_VIEW_GUEST}"
COMMAND ${CMAKE_COMMAND} "-DDIR=${SFR_DIAGNOSTIC_DIR}" "-DOUT=${SFR_DEPTH_VIEW_GUEST}" "-DFUNCTIONS=82439998,82439D80"
-P "${CMAKE_CURRENT_SOURCE_DIR}/tests/extract_guest_functions.cmake"
DEPENDS ${SFR_DIAGNOSTIC_SOURCES} "${CMAKE_CURRENT_SOURCE_DIR}/tests/extract_guest_functions.cmake"
VERBATIM)
add_executable(sfr_kinect_depth_view_guest_test tests/kinect_depth_view_guest_test.cpp src/kinect_depth_features.cpp
"${SFR_DEPTH_VIEW_GUEST}")
set_source_files_properties("${SFR_DEPTH_VIEW_GUEST}" PROPERTIES HEADER_FILE_ONLY TRUE)
target_include_directories(sfr_kinect_depth_view_guest_test PRIVATE src "${CMAKE_CURRENT_BINARY_DIR}" "${SFR_DIAGNOSTIC_DIR}"
tools/XenonRecomp/thirdparty/simde)
# The generated code as the diagnostic compiles it; the extractor as the tools do.
if(MSVC)
set(SFR_DEPTH_VIEW_GUEST_OPTIONS -fno-strict-aliasing -Wno-unused-variable -Wno-unused-value /fp:strict)
else()
set(SFR_DEPTH_VIEW_GUEST_OPTIONS -fno-strict-aliasing -Wno-unused-variable -Wno-unused-value -ffp-model=strict)
endif()
if(CMAKE_SYSTEM_PROCESSOR MATCHES "AMD64|amd64|x86_64")
list(APPEND SFR_DEPTH_VIEW_GUEST_OPTIONS -march=sandybridge)
endif()
set_source_files_properties(tests/kinect_depth_view_guest_test.cpp PROPERTIES COMPILE_OPTIONS "${SFR_DEPTH_VIEW_GUEST_OPTIONS}")
add_test(NAME kinect_depth_view_guest COMMAND sfr_kinect_depth_view_guest_test)
if(ANDROID)
# The game is libmain.so; SDL's activity calls its SDL_main
# (src/android_main.cpp), which sets up and calls the usual main.
Expand Down Expand Up @@ -1127,7 +1212,7 @@ if(SFR_BUILD_DIAGNOSTIC)
${SFR_CAMERA_CAPTURE} ${SFR_POSE_SOURCES})
# A real Kinect (SFR_CAMERA=kinect), through the Kinect for Windows runtime.
target_sources(sfr_cpu_diagnostic PRIVATE src/kinect_sensor.cpp ${SFR_KINECT_SENSOR} ${SFR_VOICE}
src/kinect_preview.cpp src/kinect_preview_window.cpp src/kinect_calibration.cpp)
src/kinect_preview.cpp src/kinect_preview_window.cpp src/kinect_preview_layout.cpp)
if(SFR_POSE_AVAILABLE)
target_link_libraries(sfr_cpu_diagnostic PRIVATE sfr_onnxruntime)
sfr_copy_onnx_dlls(sfr_cpu_diagnostic)
Expand All @@ -1149,6 +1234,8 @@ if(SFR_BUILD_DIAGNOSTIC)
target_link_libraries(sfr_cpu_diagnostic PRIVATE sfr_wait_trace)
target_link_libraries(sfr_cpu_diagnostic PRIVATE sfr_native_timer_resolution)
target_sources(sfr_cpu_diagnostic PRIVATE src/guest_graphics_hooks.cpp src/game_patches.cpp src/nui_hooks.cpp src/nui_race_hooks.cpp src/pause_gesture.cpp)
# The title's NuiTransformSmooth and the SFR_NUI_ANALYSIS_TRACE observations (docs/kinect-sensor.md).
target_sources(sfr_cpu_diagnostic PRIVATE src/nui_smooth_hooks.cpp src/nui_transform_smooth_guest.cpp src/nui_analysis_hooks.cpp)
# The title's heap on o1heap (SFR_HOST_HEAP=1; docs/architecture-migration.md, phase 2).
target_sources(sfr_cpu_diagnostic PRIVATE src/heap_hooks.cpp src/guest_heap.cpp)
target_link_libraries(sfr_cpu_diagnostic PRIVATE sfr_o1heap)
Expand Down
22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -370,15 +370,25 @@ require a sensor or its SDK.
| Kinect for Xbox 360 / Kinect for Windows v1 | SDK 1.8 and a powered USB connection; the Xbox 360 sensor requires the full SDK, while Kinect for Windows v1 can use Runtime 1.8 | Xbox 360 Kinect tested through races on Windows 10 |
| Kinect v2 / Kinect for Xbox One | SDK 2.0, USB 3.0 and a compatible powered PC adapter | Experimental; skeleton tracking is implemented, but hardware gameplay validation is still pending |

Install the matching SDK, connect the sensor, then select **Kinect** in the
launcher's **Motion input > Camera** setting and choose **Open preview** to check tracking.
Both generations use the same option: the runtime tries v1 first, then v2.
Install the matching SDK, connect the sensor, then select **Kinect (Xbox 360)** or
**Kinect v2 (Xbox One)** in the launcher's **Motion input > Camera** setting and choose
**Open preview** to check tracking. Each choice opens its own generation, so with both sensors
plugged in you can pick the v2. An older `settings.ini` with `camera=kinect` and only a v2
connected still works: when no Xbox 360 Kinect opens, the v2 is used and `game.log` says so.
There is no smoothing option any more: the game smooths a real Kinect's skeletons (v1 and v2) once,
with the filter and settings the original game asks its Kinect library for.
A Kinect v2 always hands the game a Kinect v1-style depth image made from its own depth.
As on the console, a Kinect's race input always comes from the game's own detectors: the lean,
crouch and jump read the depth image (crouch and jump the skeleton's hips as well), and the
other gestures and the menus read the skeleton; nothing on the PC stands in for them. If the
depth cannot be opened the game gets none, and `game.log` and the launcher's Kinect preview say why.
Keep your whole body visible
and allow enough space to move.

Kinect v1 can supply skeleton, depth and color data. The current v2 backend
supplies skeletons only, with additional skeleton-based steering and crouch/jump
handling. Physical Kinect input is Windows-only; Linux and Android releases
Kinect v1 can supply skeleton, depth and color data. A Kinect v2 gives the game skeletons and a depth image made
from its own depth;
its color and depth images also appear in the launcher's preview (not yet
verified on hardware). Physical Kinect input is Windows-only; Linux and Android releases
do not provide it.

SDK links, adapter requirements and troubleshooting:
Expand Down
14 changes: 10 additions & 4 deletions README.zh-TW.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,18 @@ Kinect 為選用功能;使用手把或鍵盤遊玩,不需要感測器,也
| Xbox 360 版 Kinect/Kinect for Windows 第一代 | SDK 1.8 與供電 USB 連接;Xbox 360 版需完整 SDK,Kinect for Windows 第一代可用 Runtime 1.8 | 已在 Windows 10 上用 Xbox 360 版 Kinect 實際跑完比賽 |
| Kinect v2/Xbox One 版 Kinect | SDK 2.0、USB 3.0 與相容的 PC 電源轉接器 | 實驗性支援;已實作骨架追蹤,仍待實機遊玩驗證 |

安裝對應 SDK 並連接感測器後,在啟動器的 **體感與攝影機 → 攝影機** 設定選擇 **Kinect**,
再按 **開啟預覽** 確認追蹤狀態。兩代共用同一個選項:程式先嘗試 v1,再嘗試 v2。
安裝對應 SDK 並連接感測器後,在啟動器的 **體感與攝影機 → 攝影機** 設定選擇 **Kinect(Xbox 360)** 或
**Kinect v2(Xbox One)**,再按 **開啟預覽** 確認追蹤狀態。兩個選項各自只開對應的那一代,
兩種感測器都接上時可指定要用 v2。舊的 `settings.ini`(`camera=kinect`)若只接了 v2 仍可使用:
找不到 Xbox 360 版時會改用 v2,`game.log` 會註明。「平滑」選項已移除:遊戲會照原版要求 Kinect 函式庫的濾波器與參數,
把實體 Kinect(v1 與 v2)的骨架平滑一次。
Kinect v2 一律把自己的深度換成 Kinect v1 格式的深度影像交給遊戲。跟主機一樣,Kinect 的比賽輸入
永遠來自遊戲自己的判斷器:傾身、蹲下、跳躍讀深度影像(蹲下與跳躍也讀骨架的髖部),其他動作與選單讀骨架,
電腦端沒有任何替代判定;深度打不開時遊戲就沒有深度,
`game.log` 與 launcher 的 Kinect 預覽會說明原因。
請讓全身進入感測器範圍,並預留足夠的活動空間。

Kinect v1 可提供骨架、深度與彩色影像;目前的 v2 支援只提供骨架,並以骨架補足
轉向與蹲跳判定。實體 Kinect 輸入僅支援 Windows,Linux 與 Android 發行包尚未提供。
Kinect v1 可提供骨架、深度與彩色影像;v2 交給遊戲的有骨架與由自身深度換算的深度影像;v2 的彩色與深度影像會顯示在 launcher 的預覽視窗(尚未實機驗證)。實體 Kinect 輸入僅支援 Windows,Linux 與 Android 發行包尚未提供。

SDK 下載、轉接器需求與疑難排解見 [Kinect 感測器使用說明](docs/kinect-sensor.md)。
若要使用一般攝影機進行體感操作,請看下一節。
Expand Down
Loading
Loading