From 1ff8ecf2d10870eac709575db3780175127a7cf3 Mon Sep 17 00:00:00 2001 From: kinect-bot Date: Wed, 25 Nov 2026 23:59:10 -0500 Subject: [PATCH] fix(windows-nui): honor TITLE_SETS protocol - report skeleton POSITION_ONLY until app selects its ID, then TRACKED (fixes game never locking skeleton) --- fallback/windows-nui/src/sensor.cpp | 35 ++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/fallback/windows-nui/src/sensor.cpp b/fallback/windows-nui/src/sensor.cpp index 23fa6f6..28f941a 100644 --- a/fallback/windows-nui/src/sensor.cpp +++ b/fallback/windows-nui/src/sensor.cpp @@ -582,20 +582,39 @@ void VirtualKinectSensor::BuildSkeletonFrame(const SourceFrame& src) { if (src.has_player) { NUI_SKELETON_DATA& data = frame.SkeletonData[0]; - data.eTrackingState = NUI_SKELETON_TRACKED; - data.dwTrackingID = src.meta.skeleton.skeleton_tracking_id; + const DWORD id = src.meta.skeleton.skeleton_tracking_id; + data.dwTrackingID = id; data.dwEnrollmentIndex = 0; data.dwUserIndex = 0; data.dwQualityFlags = src.meta.skeleton.quality_flags; const contract::Vector4& hip = src.meta.skeleton.joints[NUI_SKELETON_POSITION_HIP_CENTER].position; data.Position = {hip.x, hip.y, hip.z, hip.w}; - for (std::size_t j = 0; j < contract::kJointCount; ++j) { - const contract::JointData& joint = src.meta.skeleton.joints[j]; - data.SkeletonPositions[j] = {joint.position.x, joint.position.y, - joint.position.z, joint.position.w}; - data.eSkeletonPositionTrackingState[j] = - MapJointState(joint.tracking_state); + + // TITLE_SETS_TRACKED_SKELETONS protocol: the app first sees skeletons as + // POSITION_ONLY (center of mass + ID only), picks IDs, and promotes them to + // full tracking via NuiSkeletonSetTrackedSkeletons. If we report TRACKED + // before the app selects our ID, the game's selection scan finds no + // position-only candidate, locks nobody ([0,0]) and never draws. So only + // emit full joints once the app has selected our ID. + const bool title_sets = + (skeleton_flags_ & + NUI_SKELETON_TRACKING_FLAG_TITLE_SETS_TRACKED_SKELETONS) != 0; + const bool selected = + requested_tracked_ids_[0] == id || requested_tracked_ids_[1] == id; + + if (!title_sets || selected) { + data.eTrackingState = NUI_SKELETON_TRACKED; + for (std::size_t j = 0; j < contract::kJointCount; ++j) { + const contract::JointData& joint = src.meta.skeleton.joints[j]; + data.SkeletonPositions[j] = {joint.position.x, joint.position.y, + joint.position.z, joint.position.w}; + data.eSkeletonPositionTrackingState[j] = + MapJointState(joint.tracking_state); + } + } else { + // Discovery phase: center-of-mass only, joints stay NOT_TRACKED. + data.eTrackingState = NUI_SKELETON_POSITION_ONLY; } }