void IN_MotionSensor_Init(void) { //Carl: Don't initialize has* here to false, because they can also be set by command line parameters // *** Oculus Sensor Initialization OVR::System::Init(OVR::Log::ConfigureDefaultLog(OVR::LogMask_All)); // Create DeviceManager and first available HMDDevice from it. // Sensor object is created from the HMD, to ensure that it is on the // correct device. pManager = *DeviceManager::Create(); // We'll handle it's messages in this case. //pManager->SetMessageHandler(this); // Release Sensor/HMD in case this is a retry. pSensor.Clear(); pHMD.Clear(); pHMD = *pManager->EnumerateDevices<HMDDevice>().CreateDevice(); if (pHMD) { pSensor = *pHMD->GetSensor(); } else { // If we didn't detect an HMD, try to create the sensor directly. // This is useful for debugging sensor interaction; it is not needed in // a shipping app. pSensor = *pManager->EnumerateDevices<SensorDevice>().CreateDevice(); } if (!pHMD && !pSensor) common->Warning("Oculus Rift not detected.\n"); else if (!pHMD) common->Warning("Oculus Sensor detected; HMD Display not detected.\n"); else if (!pSensor) common->Warning("Oculus HMD Display detected; Sensor not detected.\n"); //else if (HMDInfo.DisplayDeviceName[0] == '\0') // common->Printf("Oculus Sensor detected; HMD display EDID not detected.\n"); if (pSensor) { SFusion.AttachToSensor(pSensor); SFusion.SetPredictionEnabled(true); hasOculusRift = true; hasHMD = true; } if (!pSensor) LoadVR920(); hasHMD = hasHMD || hasVR920Tracker; //Hillcrest libfreespace stuff LPDWORD dwThreadId=0; struct freespace_message message; int numIds; int rc; int i; // Initialize the freespace library rc = freespace_init(); if (rc != FREESPACE_SUCCESS) { common->Warning("Hillcrest Initialization error. rc=%d\n", rc); return; } /** --- START EXAMPLE INITIALIZATION OF DEVICE -- **/ rc = freespace_getDeviceList(&device, 1, &numIds); if (numIds == 0) { common->Warning("MotionSensor: Didn't find any devices.\n"); return; } rc = freespace_openDevice(device); if (rc != FREESPACE_SUCCESS) { common->Warning("MotionSensor: Error opening device: %d\n", rc); return; } rc = freespace_flush(device); if (rc != FREESPACE_SUCCESS) { common->Warning("MotionSensor: Error flushing device: %d\n", rc); return; } memset(&message, 0, sizeof(message)); message.messageType = FREESPACE_MESSAGE_DATAMODECONTROLV2REQUEST; message.dataModeControlV2Request.packetSelect = 2; message.dataModeControlV2Request.modeAndStatus |= 0 << 1; rc = freespace_sendMessage(device, &message); if (rc != FREESPACE_SUCCESS) { common->Warning("freespaceInputThread: Could not send message: %d.\n", rc); } CreateThread(NULL, //Choose default security 0, //Default stack size (LPTHREAD_START_ROUTINE)&IN_MotionSensor_Thread, //Routine to execute (LPVOID) &i, //Thread parameter 0, //Immediately run the thread dwThreadId //Thread Id ); hasHillcrest = true; hasHMD = true; }