diff --git a/fallback/windows-nui/src/sensor.cpp b/fallback/windows-nui/src/sensor.cpp index 7e8877f..8589dee 100644 --- a/fallback/windows-nui/src/sensor.cpp +++ b/fallback/windows-nui/src/sensor.cpp @@ -759,18 +759,35 @@ void VirtualKinectSensor::BuildSkeletonFrame(const SourceFrame& src) { } static unsigned hand_calls = 0; - if ((hand_calls++ % 60u) == 0u) { + if ((hand_calls++ % 15u) == 0u) { const NUI_SKELETON_DATA& d0 = frame.SkeletonData[0]; const Vector4& hr = d0.SkeletonPositions[11]; // HAND_R - const Vector4& hl = d0.SkeletonPositions[7]; // HAND_L const Vector4& sc = d0.SkeletonPositions[2]; // SHOULDER_CENTER const Vector4& sr = d0.SkeletonPositions[8]; // SHOULDER_R + // Read the game's live cursor at the SAME instant as the hand, so the pair + // is correlated (2s-apart sampling before was too coarse to solve). + float cx = -1.0f, cy = -1.0f; + HMODULE gk = GetModuleHandleA("gamekdm.dll"); + if (gk != nullptr) { + uint32_t obj = 0; + SafeReadU32(reinterpret_cast(gk) + 0x3d2bb8u, &obj); + if (obj != 0) { + uint32_t inner = 0; + SafeReadU32(obj, &inner); + if (inner != 0) { + uint32_t ux = 0, uy = 0; + SafeReadU32(inner + 0x108u, &ux); + SafeReadU32(inner + 0x10cu, &uy); + std::memcpy(&cx, &ux, sizeof(cx)); + std::memcpy(&cy, &uy, sizeof(cy)); + } + } + } ShimLog( - "hands: HAND_R=(%.2f,%.2f,%.2f) HAND_L=(%.2f,%.2f,%.2f) " - "SH_C=(%.2f,%.2f,%.2f) handR-relSHC=(%.2f,%.2f,%.2f) " - "handR-relSHR=(%.2f,%.2f,%.2f)", - hr.x, hr.y, hr.z, hl.x, hl.y, hl.z, sc.x, sc.y, sc.z, hr.x - sc.x, - hr.y - sc.y, hr.z - sc.z, hr.x - sr.x, hr.y - sr.y, hr.z - sr.z); + "handcur: HAND_R=(%.2f,%.2f,%.2f) SH_C=(%.2f,%.2f) relSHC=(%.2f,%.2f) " + "relSHR=(%.2f,%.2f) CURSOR=(%.0f,%.0f)", + hr.x, hr.y, hr.z, sc.x, sc.y, hr.x - sc.x, hr.y - sc.y, hr.x - sr.x, + hr.y - sr.y, cx, cy); } latest_skeleton_ = frame;