fix(windows-nui): honor TITLE_SETS protocol - report skeleton POSITION_ONLY until app selects its ID, then TRACKED (fixes game never locking skeleton)

This commit is contained in:
kinect-bot committed 2026-11-25 23:59:10 -05:00
1 parent 0dfeedb2a0
commit 1ff8ecf2d1
1 file changed
+27 -8
+27 -8
View File
@@ -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;
}
}