I need to change SpacePilot display text dynamically. Do perform this I create my config file and use it in LoadPreferences() function. But then I change some buttons titles in config file during my program runtime. As I understand, I should reload preference page from config file. So I call LoadPreferences() once more, it returns S_OK, but there is no effect until I manually reload preferences file in 3DConnexion Control Pannel.
LoadPreferences() returns S_OK even if I stop driver before the call.
Here is my code, maybe someone can help me to find out what is wrong.
Code: Select all
HRESULT hr;
CComPtr<IUnknown> _3DxDevice;
// Create the device object
hr = _3DxDevice.CoCreateInstance(__uuidof(Device));
if (SUCCEEDED(hr))
{
//CComPtr<ISimpleDevice> _3DxSimpleDevice;
hr = _3DxDevice.QueryInterface(&_3DxSimpleDevice);
if (SUCCEEDED(hr))
{
// Get the interfaces to the sensor and the keyboard;
g3DSensor = _3DxSimpleDevice->Sensor;
g3DKeyboard = _3DxSimpleDevice->Keyboard;
// Associate a configuration with this device
if(PathFileExists(filename.GetString()))
{
_3DxSimpleDevice->LoadPreferences(_T("NameFromEXECUTABLES"));
}
// Connect to the driver
_3DxSimpleDevice->Connect();
_3DxSimpleDevice->get_Type(&type);
}
else
{
return _EMPTY;
}
}
else
return _EMPTY;
return _OK;
But then I modify congif file and want to reload it:
Code: Select all
CComPtr<IDispatch> _3DxDeviceN;
// Get the device object
g3DKeyboard->get_Device(&_3DxDeviceN);
CComPtr<ISimpleDevice> _3DxSimpleDeviceN;
HRESULT hr = _3DxDeviceN.QueryInterface(&_3DxSimpleDeviceN);
if (SUCCEEDED(hr))
{
_3DxSimpleDeviceN->LoadPreferences(_T("NameFromEXECUTABLES"));
}
I've tried to close the driver and call CoCreateInstance again, but my application crashed or hung during the call.
After some experiments I get that LoadPreferences() calls correctly only once.
Thanks for your help!
Maxim.