215 lines
6.6 KiB
C++
215 lines
6.6 KiB
C++
#include <windows.h>
|
|
|
|
#include "coordmap.h"
|
|
#include "nui_abi.h"
|
|
#include "nui_interfaces.h"
|
|
#include "sensor.h"
|
|
#include "sensor_com.h"
|
|
#include "shim_log.h"
|
|
|
|
using namespace nui_shim;
|
|
|
|
namespace {
|
|
NuiStatusProc g_status_callback = nullptr;
|
|
void* g_status_user_data = nullptr;
|
|
}
|
|
|
|
extern "C" {
|
|
|
|
HRESULT WINAPI NuiGetSensorCount(int* pCount) {
|
|
if (pCount == nullptr) {
|
|
return E_POINTER;
|
|
}
|
|
*pCount = 1;
|
|
ShimLog("NuiGetSensorCount -> 1");
|
|
return S_OK;
|
|
}
|
|
|
|
HRESULT WINAPI NuiCreateSensorByIndex(int index, INuiSensor** ppNuiSensor) {
|
|
if (ppNuiSensor == nullptr) {
|
|
return E_POINTER;
|
|
}
|
|
if (index != 0) {
|
|
return E_NUI_DEVICE_NOT_CONNECTED;
|
|
}
|
|
*ppNuiSensor = new NuiSensorCom(EnsureGlobalSensor());
|
|
ShimLog("NuiCreateSensorByIndex(%d) -> sensor", index);
|
|
return S_OK;
|
|
}
|
|
|
|
HRESULT WINAPI NuiCreateSensorById(const OLECHAR*, INuiSensor** ppNuiSensor) {
|
|
if (ppNuiSensor == nullptr) {
|
|
return E_POINTER;
|
|
}
|
|
*ppNuiSensor = new NuiSensorCom(EnsureGlobalSensor());
|
|
return S_OK;
|
|
}
|
|
|
|
HRESULT WINAPI NuiInitialize(DWORD dwFlags) {
|
|
return EnsureGlobalSensor()->Initialize(dwFlags);
|
|
}
|
|
|
|
void WINAPI NuiShutdown(void) {
|
|
if (VirtualKinectSensor* sensor = GlobalSensor()) {
|
|
sensor->Shutdown();
|
|
}
|
|
}
|
|
|
|
HRESULT WINAPI NuiSetDeviceStatusCallback(NuiStatusProc callback,
|
|
void* pUserData) {
|
|
g_status_callback = callback;
|
|
g_status_user_data = pUserData;
|
|
if (callback != nullptr) {
|
|
callback(S_OK, L"VirtualKinect0", L"VirtualKinect0", pUserData);
|
|
}
|
|
return S_OK;
|
|
}
|
|
|
|
HRESULT WINAPI NuiSkeletonTrackingEnable(HANDLE hNextFrameEvent, DWORD dwFlags) {
|
|
return EnsureGlobalSensor()->SkeletonTrackingEnable(hNextFrameEvent, dwFlags);
|
|
}
|
|
|
|
HRESULT WINAPI NuiSkeletonTrackingDisable(void) {
|
|
return EnsureGlobalSensor()->SkeletonTrackingDisable();
|
|
}
|
|
|
|
HRESULT WINAPI NuiSkeletonGetNextFrame(DWORD dwMillisecondsToWait,
|
|
NUI_SKELETON_FRAME* pSkeletonFrame) {
|
|
return EnsureGlobalSensor()->SkeletonGetNextFrame(dwMillisecondsToWait,
|
|
pSkeletonFrame);
|
|
}
|
|
|
|
HRESULT WINAPI NuiSkeletonSetTrackedSkeletons(DWORD*) { return S_OK; }
|
|
|
|
HRESULT WINAPI NuiTransformSmooth(
|
|
NUI_SKELETON_FRAME* pSkeletonFrame,
|
|
const NUI_TRANSFORM_SMOOTH_PARAMETERS* pSmoothingParams) {
|
|
if (pSkeletonFrame == nullptr) {
|
|
return E_POINTER;
|
|
}
|
|
TransformSmooth(pSkeletonFrame, pSmoothingParams);
|
|
return S_OK;
|
|
}
|
|
|
|
HRESULT WINAPI NuiImageStreamOpen(NUI_IMAGE_TYPE eImageType,
|
|
NUI_IMAGE_RESOLUTION eResolution,
|
|
DWORD dwImageFrameFlags,
|
|
DWORD dwFrameLimit,
|
|
HANDLE hNextFrameEvent,
|
|
HANDLE* phStreamHandle) {
|
|
return EnsureGlobalSensor()->ImageStreamOpen(eImageType, eResolution,
|
|
dwImageFrameFlags, dwFrameLimit,
|
|
hNextFrameEvent, phStreamHandle);
|
|
}
|
|
|
|
HRESULT WINAPI NuiImageStreamGetNextFrame(HANDLE hStream,
|
|
DWORD dwMillisecondsToWait,
|
|
const NUI_IMAGE_FRAME** ppcImageFrame) {
|
|
return EnsureGlobalSensor()->ImageStreamGetNextFrame(
|
|
hStream, dwMillisecondsToWait, ppcImageFrame);
|
|
}
|
|
|
|
HRESULT WINAPI NuiImageStreamReleaseFrame(HANDLE hStream,
|
|
const NUI_IMAGE_FRAME* pImageFrame) {
|
|
return EnsureGlobalSensor()->ImageStreamReleaseFrame(hStream, pImageFrame);
|
|
}
|
|
|
|
HRESULT WINAPI NuiImageStreamSetImageFrameFlags(HANDLE, DWORD) { return S_OK; }
|
|
|
|
HRESULT WINAPI NuiImageStreamGetImageFrameFlags(HANDLE,
|
|
DWORD* pdwImageFrameFlags) {
|
|
if (pdwImageFrameFlags == nullptr) {
|
|
return E_POINTER;
|
|
}
|
|
*pdwImageFrameFlags = 0;
|
|
return S_OK;
|
|
}
|
|
|
|
HRESULT WINAPI NuiCameraElevationSetAngle(LONG) { return S_OK; }
|
|
|
|
HRESULT WINAPI NuiCameraElevationGetAngle(LONG* plAngleDegrees) {
|
|
if (plAngleDegrees == nullptr) {
|
|
return E_POINTER;
|
|
}
|
|
*plAngleDegrees = 0;
|
|
return S_OK;
|
|
}
|
|
|
|
HRESULT WINAPI NuiImageGetColorPixelCoordinatesFromDepthPixel(
|
|
NUI_IMAGE_RESOLUTION eColorResolution,
|
|
const NUI_IMAGE_VIEW_AREA*,
|
|
LONG lDepthX,
|
|
LONG lDepthY,
|
|
USHORT,
|
|
LONG* plColorX,
|
|
LONG* plColorY) {
|
|
return ColorCoordinatesFromDepthPixel(eColorResolution, lDepthX, lDepthY,
|
|
plColorX, plColorY);
|
|
}
|
|
|
|
Vector4 WINAPI NuiTransformDepthImageToSkeleton(LONG lDepthX,
|
|
LONG lDepthY,
|
|
USHORT usDepthValue) {
|
|
return TransformDepthImageToSkeleton(lDepthX, lDepthY, usDepthValue);
|
|
}
|
|
|
|
HRESULT WINAPI NuiSetFrameEndEvent(HANDLE, DWORD) { return S_OK; }
|
|
|
|
HRESULT WINAPI NuiImageGetColorPixelCoordinatesFromDepthPixelAtResolution(
|
|
NUI_IMAGE_RESOLUTION eColorResolution,
|
|
NUI_IMAGE_RESOLUTION,
|
|
const NUI_IMAGE_VIEW_AREA*,
|
|
LONG lDepthX,
|
|
LONG lDepthY,
|
|
USHORT,
|
|
LONG* plColorX,
|
|
LONG* plColorY) {
|
|
return ColorCoordinatesFromDepthPixel(eColorResolution, lDepthX, lDepthY,
|
|
plColorX, plColorY);
|
|
}
|
|
|
|
// Audio is not synthesized; report no audio source so the game skips it rather
|
|
// than dereferencing a bogus INuiAudioBeam. ppDmo is INuiAudioBeam**.
|
|
HRESULT WINAPI NuiGetAudioSource(void** ppDmo) {
|
|
if (ppDmo != nullptr) {
|
|
*ppDmo = nullptr;
|
|
}
|
|
return E_NUI_DEVICE_NOT_CONNECTED;
|
|
}
|
|
|
|
// Bone orientations are derived by the game from joint positions when needed;
|
|
// the real export exists so a by-ordinal import (ordinal 27) resolves.
|
|
HRESULT WINAPI NuiSkeletonCalculateBoneOrientations(const NUI_SKELETON_DATA*,
|
|
void*) {
|
|
return S_OK;
|
|
}
|
|
|
|
// Undocumented 1.8 exports (ordinals 28/29): present so a by-ordinal import
|
|
// resolves at load; DEA does not drive these. Signatures match arg counts only.
|
|
HRESULT WINAPI NuiCreateCoordinateMapperFromParameters(ULONG, void*, void**) {
|
|
return E_NOTIMPL;
|
|
}
|
|
|
|
HRESULT WINAPI NuiCreateDepthFilter(void**) { return E_NOTIMPL; }
|
|
|
|
// Ordinal 1 in the real DLL is NONAME; stubbed so the slot exists.
|
|
void* WINAPI KinectShimReserved1(void) { return nullptr; }
|
|
|
|
}
|
|
|
|
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD reason, LPVOID) {
|
|
switch (reason) {
|
|
case DLL_PROCESS_ATTACH:
|
|
nui_shim::ShimModuleHandle() = hinstDLL;
|
|
DisableThreadLibraryCalls(hinstDLL);
|
|
nui_shim::ShimLog("DllMain PROCESS_ATTACH (Kinect10 shim loaded)");
|
|
break;
|
|
case DLL_PROCESS_DETACH:
|
|
DestroyGlobalSensor();
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
return TRUE;
|
|
}
|