- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I want to set the sensitivity for my ALS sensor driver. I can set the value via SensorViewer but I have no access via HECI. I'm able to get sensor data via HECI. I use in my app the sensor property SENSOR_PROPERTY_CHANGE_SENSITIVITY. The type of the value is unknown. See Sensor Properties - Windows drivers | Microsoft Learn
Can you share with me an example how to set the value?
I use this code for the moment and I didn't get any error:
HRESULT SensorManager::SetSensitivity(ISensor* pSensor, ULONG ulSensitivity)
{
assert(pSensor);
HRESULT hr = S_OK;
// Configure sensitivity
// Create an IPortableDeviceValues container to hold the <Data Field,
IPortableDeviceValues* pInSensitivityValues;
hr = ::CoCreateInstance(CLSID_PortableDeviceValues, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pInSensitivityValues));
if (FAILED(hr))
{
//::MessageBox(NULL, _T("Unable to CoCreateInstance() a PortableDeviceValues collection."), _T("HBS C++ Sample"), MB_OK |MB_ICONERROR);
cout << "Unable to CoCreateInstance() a PortableDeviceValues collection." << endl;
return -1;
}
PROPVARIANT pv;
PropVariantInit(&pv);
pv.vt = VT_R8; // COM type for (double)
pv.dblVal = (double)ulSensitivity;
pInSensitivityValues->SetValue(SENSOR_DATA_TYPE_SENSOR_DATA_STATE, &pv);
// create an IPortableDeviceValues container for holding the <SENSOR_PROPERTY_CHANGE_SENSITIVITY, pInSensitivityValues> tuple.
IPortableDeviceValues* pInValues;
hr = ::CoCreateInstance(CLSID_PortableDeviceValues, NULL,CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pInValues));
if (FAILED(hr))
{
//::MessageBox(NULL, _T("Unable to CoCreateInstance() a PortableDeviceValues collection."), _T("HBS C++ Sample"), MB_OK |MB_ICONERROR);
cout << "Unable to CoCreateInstance() a PortableDeviceValues collection." << endl;
return -1;
}
// fill it in
pInValues->SetIPortableDeviceValuesValue(SENSOR_PROPERTY_CHANGE_SENSITIVITY, pInSensitivityValues);
// now actually set the sensitivity
IPortableDeviceValues* pOutValues;
hr = pSensor->SetProperties(pInValues, &pOutValues);
if (FAILED(hr))
{
//::MessageBox(NULL, _T("Unable to SetProperties() for Sensitivity."),_T("HBS C++ Sample"), MB_OK | MB_ICONERROR);
cout << "Unable to set sensitivity" << endl;
return -1;
}
PropVariantClear(&pv);
return hr;
}
Link Copied
0 Replies

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page