aboutsummaryrefslogtreecommitdiffstats
path: root/LibOVR/Src/OVR_OSX_HIDDevice.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'LibOVR/Src/OVR_OSX_HIDDevice.cpp')
-rw-r--r--LibOVR/Src/OVR_OSX_HIDDevice.cpp39
1 files changed, 28 insertions, 11 deletions
diff --git a/LibOVR/Src/OVR_OSX_HIDDevice.cpp b/LibOVR/Src/OVR_OSX_HIDDevice.cpp
index e93cf67..38b1b3e 100644
--- a/LibOVR/Src/OVR_OSX_HIDDevice.cpp
+++ b/LibOVR/Src/OVR_OSX_HIDDevice.cpp
@@ -5,11 +5,22 @@ Created : February 26, 2013
Authors : Lee Cooper
Copyright : Copyright 2013 Oculus VR, Inc. All Rights reserved.
-
-Use of this software is subject to the terms of the Oculus license
-agreement provided at the time of installation or download, or which
+
+Licensed under the Oculus VR SDK License Version 2.0 (the "License");
+you may not use the Oculus VR SDK except in compliance with the License,
+which is provided at the time of installation or download, or which
otherwise accompanies this software in either electronic or hard copy form.
+You may obtain a copy of the License at
+
+http://www.oculusvr.com/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, the Oculus VR SDK
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
*************************************************************************************/
#include "OVR_OSX_HIDDevice.h"
@@ -360,7 +371,7 @@ bool HIDDeviceManager::Enumerate(HIDEnumerateVisitor* enumVisitor)
initSerialNumber(hidDev, &devDesc);
// Look for the device to check if it is already opened.
- Ptr<DeviceCreateDesc> existingDevice = DevManager->FindHIDDevice(devDesc);
+ Ptr<DeviceCreateDesc> existingDevice = DevManager->FindHIDDevice(devDesc, true);
// if device exists and it is opened then most likely the CreateHIDFile
// will fail; therefore, we just set Enumerated to 'true' and continue.
if (existingDevice && existingDevice->pDevice)
@@ -368,11 +379,17 @@ bool HIDDeviceManager::Enumerate(HIDEnumerateVisitor* enumVisitor)
existingDevice->Enumerated = true;
continue;
}
-
- // Construct minimal device that the visitor callback can get feature reports from.
- OSX::HIDDevice device(this, hidDev);
-
- enumVisitor->Visit(device, devDesc);
+
+ // open the device temporarily for startup communication
+ if (IOHIDDeviceOpen(hidDev, kIOHIDOptionsTypeSeizeDevice) == kIOReturnSuccess)
+ {
+ // Construct minimal device that the visitor callback can get feature reports from.
+ OSX::HIDDevice device(this, hidDev);
+
+ enumVisitor->Visit(device, devDesc);
+
+ IOHIDDeviceClose(hidDev, kIOHIDOptionsTypeSeizeDevice);
+ }
}
}
@@ -543,7 +560,7 @@ void HIDDevice::deviceAddedCallback(io_iterator_t iterator)
{
LogText("OVR::OSX::HIDDevice - Reopened device : %s", DevDesc.Path.ToCStr());
- Ptr<DeviceCreateDesc> existingHIDDev = HIDManager->DevManager->FindHIDDevice(DevDesc);
+ Ptr<DeviceCreateDesc> existingHIDDev = HIDManager->DevManager->FindHIDDevice(DevDesc, true);
if (existingHIDDev && existingHIDDev->pDevice)
{
HIDManager->DevManager->CallOnDeviceAdded(existingHIDDev);
@@ -775,7 +792,7 @@ void HIDDevice::deviceRemovedCallback()
{
Ptr<HIDDevice> _this(this); // prevent from release
- Ptr<DeviceCreateDesc> existingHIDDev = HIDManager->DevManager->FindHIDDevice(DevDesc);
+ Ptr<DeviceCreateDesc> existingHIDDev = HIDManager->DevManager->FindHIDDevice(DevDesc, true);
if (existingHIDDev && existingHIDDev->pDevice)
{
HIDManager->DevManager->CallOnDeviceRemoved(existingHIDDev);