Share via


NuiSetDeviceStatusCallback

Kinect for Windows 1.5, 1.6, 1.7, 1.8

Sets a callback function that gets notified when the sensor connection status changes.

Syntax

void NuiSetDeviceStatusCallback(
         NuiStatusProc callback,
         void *pUserData
)

Parameters

  • callback
    Type: NuiStatusProc
    Pointer to the callback function.
  • pUserData
    Type: void
    Pointer to optional context data that will be passed to the callback.

Return Value

None.

Remarks

Use this method to handle the case of a user connecting or disconnecting a Kinect sensor. This requires the following steps.

  1. Set the callback function by calling NuiSetDeviceStatusCallback.

      MyApplication *pThis = NULL;
      NuiSetDeviceStatusCallback( &StatusProc, pThis );
    
    
  2. Implement the callback function, which receives the instance name and unique device name of the Kinect sensor.

      void CALLBACK StatusProc( HRESULT hrStatus, const OLECHAR* instanceName, const OLECHAR* uniqueDeviceName, void* pUserData)
      {      
        if ( SUCCEEDED( hrStatus ) )      
        {          
          // Initialize the Kinect sensor identified by the instanceName parameter.      
        }      
        else      
        {          
          // Uninitialize the Kinect sensor identified by the instanceName parameter.        
        }
      }
    
    

Requirements

Header: Declared in NuiSensor.h; however, include NuiApi.h in your project.