240 lines
9.0 KiB
C
240 lines
9.0 KiB
C
#ifndef FALLBACK_WINDOWS_NUI_NUI_ABI_H
|
|
#define FALLBACK_WINDOWS_NUI_NUI_ABI_H
|
|
|
|
// Clean-room declaration of the Kinect for Windows 1.8 NUI ABI surface.
|
|
//
|
|
// CLEAN-ROOM PROVENANCE: every type, enum value, struct field order, and packing
|
|
// rule below is reproduced SOLELY from public Microsoft Kinect for Windows SDK 1.8
|
|
// header knowledge (NuiApi.h / NuiSkeleton.h / NuiImageCamera.h / NuiSensor.h) as
|
|
// distilled into .omo/design/nui-contracts.md. No GPL-licensed third-party source
|
|
// (e.g. KinectFaker) was read or copied. These declarations are ABI/interoperability
|
|
// facts required for a drop-in replacement of the real Kinect10.dll; all synthesis
|
|
// logic lives in the shared core (core/mapping, core/synth) and the src/ files here.
|
|
//
|
|
// ALIGNMENT: the real NUI headers use DEFAULT (natural) struct alignment, NOT
|
|
// #pragma pack(1). MinGW-w64 targets the Microsoft x86/x64 struct-layout ABI, so
|
|
// leaving these structs at default alignment reproduces the MSVC layout bit-for-bit.
|
|
// (This is distinct from core/contract/contract.h, which is pack(1) on purpose for
|
|
// the cross-language IPC region.)
|
|
|
|
#include <windows.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
// NUI Vector4: homogeneous 3D point, x/y/z metres, w normally 1.0 (NuiSkeleton.h).
|
|
typedef struct _Vector4 {
|
|
FLOAT x;
|
|
FLOAT y;
|
|
FLOAT z;
|
|
FLOAT w;
|
|
} Vector4;
|
|
|
|
#define NUI_SKELETON_COUNT 6
|
|
#define NUI_SKELETON_POSITION_COUNT 20
|
|
#define NUI_SKELETON_MAX_TRACKED_COUNT 2
|
|
|
|
// Packed depth word bit layout (NuiImageCamera.h), nui-contracts.md §2.2.
|
|
#define NUI_IMAGE_PLAYER_INDEX_SHIFT 3
|
|
#define NUI_IMAGE_PLAYER_INDEX_MASK ((1 << NUI_IMAGE_PLAYER_INDEX_SHIFT) - 1)
|
|
#define NUI_IMAGE_DEPTH_MINIMUM (800 << NUI_IMAGE_PLAYER_INDEX_SHIFT)
|
|
#define NUI_IMAGE_DEPTH_MAXIMUM (4000 << NUI_IMAGE_PLAYER_INDEX_SHIFT)
|
|
#define NUI_IMAGE_DEPTH_NO_VALUE 0
|
|
|
|
// NuiInitialize subsystem flags (NuiApi.h).
|
|
#define NUI_INITIALIZE_FLAG_USES_AUDIO 0x10000000
|
|
#define NUI_INITIALIZE_FLAG_USES_DEPTH_AND_PLAYER_INDEX 0x00000001
|
|
#define NUI_INITIALIZE_FLAG_USES_COLOR 0x00000002
|
|
#define NUI_INITIALIZE_FLAG_USES_SKELETON 0x00000008
|
|
#define NUI_INITIALIZE_FLAG_USES_DEPTH 0x00000020
|
|
|
|
// NuiSkeletonTrackingEnable flags (NuiApi.h).
|
|
#define NUI_SKELETON_TRACKING_FLAG_SUPPRESS_NO_FRAME_DATA 0x00000001
|
|
#define NUI_SKELETON_TRACKING_FLAG_TITLE_SETS_TRACKED_SKELETONS 0x00000002
|
|
#define NUI_SKELETON_TRACKING_FLAG_ENABLE_SEATED_SUPPORT 0x00000004
|
|
#define NUI_SKELETON_TRACKING_FLAG_ENABLE_IN_NEAR_RANGE 0x00000008
|
|
|
|
// NUI_SKELETON_FRAME.dwFlags / per-skeleton quality flags (NuiSkeleton.h).
|
|
#define NUI_SKELETON_FRAME_FLAG_SEATED_SUPPORT_ENABLED 0x00000001
|
|
#define NUI_SKELETON_QUALITY_CLIPPED_RIGHT 0x00000001
|
|
#define NUI_SKELETON_QUALITY_CLIPPED_LEFT 0x00000002
|
|
#define NUI_SKELETON_QUALITY_CLIPPED_TOP 0x00000004
|
|
#define NUI_SKELETON_QUALITY_CLIPPED_BOTTOM 0x00000008
|
|
|
|
// HRESULT values the NUI API returns beyond the standard ones (NuiApi.h).
|
|
#ifndef E_NUI_FRAME_NO_DATA
|
|
#define E_NUI_DEVICE_NOT_CONNECTED ((HRESULT)0x83010001L)
|
|
#define E_NUI_DEVICE_NOT_READY ((HRESULT)0x83010002L)
|
|
#define E_NUI_ALREADY_INITIALIZED ((HRESULT)0x83010003L)
|
|
#define E_NUI_NO_MORE_ITEMS ((HRESULT)0x83010004L)
|
|
#define E_NUI_FRAME_NO_DATA ((HRESULT)0x83010005L)
|
|
#define E_NUI_STREAM_NOT_ENABLED ((HRESULT)0x83010006L)
|
|
#define E_NUI_DATABASE_NOT_FOUND ((HRESULT)0x8301000DL)
|
|
#define E_NUI_DATABASE_VERSION_MISMATCH ((HRESULT)0x8301000EL)
|
|
#define E_NUI_NOTCONNECTED ((HRESULT)0x83010001L)
|
|
#endif
|
|
|
|
// NUI_IMAGE_TYPE (NuiImageCamera.h).
|
|
typedef enum _NUI_IMAGE_TYPE {
|
|
NUI_IMAGE_TYPE_DEPTH_AND_PLAYER_INDEX = 0,
|
|
NUI_IMAGE_TYPE_COLOR = 1,
|
|
NUI_IMAGE_TYPE_COLOR_YUV = 2,
|
|
NUI_IMAGE_TYPE_COLOR_RAW_YUV = 3,
|
|
NUI_IMAGE_TYPE_DEPTH = 4,
|
|
NUI_IMAGE_TYPE_COLOR_INFRARED = 5,
|
|
NUI_IMAGE_TYPE_COLOR_RAW_BAYER = 6,
|
|
} NUI_IMAGE_TYPE;
|
|
|
|
// NUI_IMAGE_RESOLUTION (NuiImageCamera.h).
|
|
typedef enum _NUI_IMAGE_RESOLUTION {
|
|
NUI_IMAGE_RESOLUTION_INVALID = -1,
|
|
NUI_IMAGE_RESOLUTION_80x60 = 0,
|
|
NUI_IMAGE_RESOLUTION_320x240 = 1,
|
|
NUI_IMAGE_RESOLUTION_640x480 = 2,
|
|
NUI_IMAGE_RESOLUTION_1280x960 = 3,
|
|
} NUI_IMAGE_RESOLUTION;
|
|
|
|
// NUI_IMAGE_DIGITAL_ZOOM (NuiImageCamera.h).
|
|
typedef enum _NUI_IMAGE_DIGITAL_ZOOM {
|
|
NUI_IMAGE_DIGITAL_ZOOM_1X = 0,
|
|
} NUI_IMAGE_DIGITAL_ZOOM;
|
|
|
|
// NUI_SKELETON_POSITION_INDEX (NuiSkeleton.h). Values 0..19 in this exact order;
|
|
// this order matches core/contract SkeletonFrame.joints[] by construction.
|
|
typedef enum _NUI_SKELETON_POSITION_INDEX {
|
|
NUI_SKELETON_POSITION_HIP_CENTER = 0,
|
|
NUI_SKELETON_POSITION_SPINE = 1,
|
|
NUI_SKELETON_POSITION_SHOULDER_CENTER = 2,
|
|
NUI_SKELETON_POSITION_HEAD = 3,
|
|
NUI_SKELETON_POSITION_SHOULDER_LEFT = 4,
|
|
NUI_SKELETON_POSITION_ELBOW_LEFT = 5,
|
|
NUI_SKELETON_POSITION_WRIST_LEFT = 6,
|
|
NUI_SKELETON_POSITION_HAND_LEFT = 7,
|
|
NUI_SKELETON_POSITION_SHOULDER_RIGHT = 8,
|
|
NUI_SKELETON_POSITION_ELBOW_RIGHT = 9,
|
|
NUI_SKELETON_POSITION_WRIST_RIGHT = 10,
|
|
NUI_SKELETON_POSITION_HAND_RIGHT = 11,
|
|
NUI_SKELETON_POSITION_HIP_LEFT = 12,
|
|
NUI_SKELETON_POSITION_KNEE_LEFT = 13,
|
|
NUI_SKELETON_POSITION_ANKLE_LEFT = 14,
|
|
NUI_SKELETON_POSITION_FOOT_LEFT = 15,
|
|
NUI_SKELETON_POSITION_HIP_RIGHT = 16,
|
|
NUI_SKELETON_POSITION_KNEE_RIGHT = 17,
|
|
NUI_SKELETON_POSITION_ANKLE_RIGHT = 18,
|
|
NUI_SKELETON_POSITION_FOOT_RIGHT = 19,
|
|
} NUI_SKELETON_POSITION_INDEX;
|
|
|
|
// NUI_SKELETON_TRACKING_STATE (per-skeleton, NuiSkeleton.h).
|
|
typedef enum _NUI_SKELETON_TRACKING_STATE {
|
|
NUI_SKELETON_NOT_TRACKED = 0,
|
|
NUI_SKELETON_POSITION_ONLY = 1,
|
|
NUI_SKELETON_TRACKED = 2,
|
|
} NUI_SKELETON_TRACKING_STATE;
|
|
|
|
// NUI_SKELETON_POSITION_TRACKING_STATE (per-joint, NuiSkeleton.h). Matches
|
|
// core/contract JointTrackingState values.
|
|
typedef enum _NUI_SKELETON_POSITION_TRACKING_STATE {
|
|
NUI_SKELETON_POSITION_NOT_TRACKED = 0,
|
|
NUI_SKELETON_POSITION_INFERRED = 1,
|
|
NUI_SKELETON_POSITION_TRACKED = 2,
|
|
} NUI_SKELETON_POSITION_TRACKING_STATE;
|
|
|
|
// NUI_SKELETON_DATA (NuiSkeleton.h). Default alignment; 12-byte header of DWORDs,
|
|
// then Position, then the position array, then the per-joint state array, then
|
|
// dwQualityFlags.
|
|
typedef struct _NUI_SKELETON_DATA {
|
|
NUI_SKELETON_TRACKING_STATE eTrackingState;
|
|
DWORD dwTrackingID;
|
|
DWORD dwEnrollmentIndex;
|
|
DWORD dwUserIndex;
|
|
Vector4 Position;
|
|
Vector4 SkeletonPositions[NUI_SKELETON_POSITION_COUNT];
|
|
NUI_SKELETON_POSITION_TRACKING_STATE
|
|
eSkeletonPositionTrackingState[NUI_SKELETON_POSITION_COUNT];
|
|
DWORD dwQualityFlags;
|
|
} NUI_SKELETON_DATA;
|
|
|
|
// NUI_SKELETON_FRAME (NuiSkeleton.h).
|
|
typedef struct _NUI_SKELETON_FRAME {
|
|
LARGE_INTEGER liTimeStamp;
|
|
DWORD dwFrameNumber;
|
|
DWORD dwFlags;
|
|
Vector4 vFloorClipPlane;
|
|
Vector4 vNormalToGravity;
|
|
NUI_SKELETON_DATA SkeletonData[NUI_SKELETON_COUNT];
|
|
} NUI_SKELETON_FRAME;
|
|
|
|
// NUI_TRANSFORM_SMOOTH_PARAMETERS (NuiSkeleton.h), nui-contracts.md §1.6.
|
|
typedef struct _NUI_TRANSFORM_SMOOTH_PARAMETERS {
|
|
FLOAT fSmoothing;
|
|
FLOAT fCorrection;
|
|
FLOAT fPrediction;
|
|
FLOAT fJitterRadius;
|
|
FLOAT fMaxDeviationRadius;
|
|
} NUI_TRANSFORM_SMOOTH_PARAMETERS;
|
|
|
|
// NUI_LOCKED_RECT (NuiImageCamera.h), nui-contracts.md §3.5.
|
|
typedef struct _NUI_LOCKED_RECT {
|
|
INT Pitch;
|
|
INT size;
|
|
BYTE* pBits;
|
|
} NUI_LOCKED_RECT;
|
|
|
|
// NUI_SURFACE_DESC (NuiImageCamera.h).
|
|
typedef struct _NUI_SURFACE_DESC {
|
|
UINT Width;
|
|
UINT Height;
|
|
} NUI_SURFACE_DESC;
|
|
|
|
// NUI_IMAGE_VIEW_AREA (NuiImageCamera.h).
|
|
typedef struct _NUI_IMAGE_VIEW_AREA {
|
|
NUI_IMAGE_DIGITAL_ZOOM eDigitalZoom;
|
|
LONG lCenterX;
|
|
LONG lCenterY;
|
|
} NUI_IMAGE_VIEW_AREA;
|
|
|
|
// Forward declaration of the frame-texture COM interface.
|
|
struct INuiFrameTexture;
|
|
|
|
// NUI_IMAGE_FRAME (NuiImageCamera.h), nui-contracts.md §3.5.
|
|
typedef struct _NUI_IMAGE_FRAME {
|
|
LARGE_INTEGER liTimeStamp;
|
|
DWORD dwFrameNumber;
|
|
NUI_IMAGE_TYPE eImageType;
|
|
NUI_IMAGE_RESOLUTION eResolution;
|
|
struct INuiFrameTexture* pFrameTexture;
|
|
DWORD dwFrameFlags;
|
|
NUI_IMAGE_VIEW_AREA ViewArea;
|
|
} NUI_IMAGE_FRAME;
|
|
|
|
// NUI_DEPTH_IMAGE_PIXEL (unpacked depth, NuiImageCamera.h), nui-contracts.md §2.2.
|
|
typedef struct _NUI_DEPTH_IMAGE_PIXEL {
|
|
USHORT playerIndex;
|
|
USHORT depth;
|
|
} NUI_DEPTH_IMAGE_PIXEL;
|
|
|
|
// Device-status callback signature (NuiApi.h): called on connect/disconnect.
|
|
typedef void(CALLBACK* NuiStatusProc)(HRESULT hrStatus,
|
|
const OLECHAR* instanceName,
|
|
const OLECHAR* uniqueDeviceName,
|
|
void* pUserData);
|
|
|
|
#ifdef __cplusplus
|
|
} // extern "C"
|
|
|
|
// Architecture-independent layout pins (no pointer members): these sizes are
|
|
// identical under MSVC x86/x64 and MinGW x86/x64 and must match the real NUI
|
|
// structs bit-for-bit. A drift fails the cross-build rather than the game.
|
|
static_assert(sizeof(Vector4) == 16, "Vector4 ABI size");
|
|
static_assert(sizeof(NUI_SKELETON_DATA) == 436, "NUI_SKELETON_DATA ABI size");
|
|
static_assert(sizeof(NUI_SKELETON_FRAME) == 2664, "NUI_SKELETON_FRAME ABI size");
|
|
static_assert(sizeof(NUI_TRANSFORM_SMOOTH_PARAMETERS) == 20,
|
|
"NUI_TRANSFORM_SMOOTH_PARAMETERS ABI size");
|
|
static_assert(sizeof(NUI_SURFACE_DESC) == 8, "NUI_SURFACE_DESC ABI size");
|
|
static_assert(sizeof(NUI_IMAGE_VIEW_AREA) == 12, "NUI_IMAGE_VIEW_AREA ABI size");
|
|
static_assert(sizeof(NUI_DEPTH_IMAGE_PIXEL) == 4, "NUI_DEPTH_IMAGE_PIXEL ABI size");
|
|
#endif
|
|
|
|
#endif // FALLBACK_WINDOWS_NUI_NUI_ABI_H
|