After reading various posts on this forum, I decided to use the non-ATL approach to support the SpaceNavigator from my C++ application. When the device is connected, everything works fine.
On some computers, where the SpaceNavigator is not currently connected, the initialization hangs for about 5 seconds - obviously an annoying delay for our users. I have narrowed it down to the CreateInstance method which is where the 5 second delay happens. This is a snippet from my code:
Code: Select all
// Initialize COM
HRESULT hr = CoInitializeEx(0, COINIT_APARTMENTTHREADED);
if (!SUCCEEDED(hr))
return;
// Create the device object
ISimpleDevicePtr device;
hr = device.CreateInstance(__uuidof(Device)); // THIS TAKES ABOUT 5 SECONDS!
if (!SUCCEEDED(hr))
return;
// Get the interfaces to the sensor and the keyboard
sensor_ = device->Sensor;
keyboard_ = device->Keyboard;
// Associate a configuration with this device (not sure what this does)
device->LoadPreferences(bstr_t("Remo 3D"));
// Connect to the driver
device->Connect();
Regards,
Andreas Ekstrand