/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
RefPtr<ISensorCollection> collection; if (FAILED(manager->GetSensorsByType(SENSOR_TYPE_ACCELEROMETER_3D,
getter_AddRefs(collection)))) { return;
}
ULONG count = 0;
collection->GetCount(&count); if (!count) { return;
}
RefPtr<ISensor> sensor;
collection->GetAt(0, getter_AddRefs(sensor)); if (!sensor) { return;
}
// Set report interval to 100ms if possible. // Default value depends on drivers.
RefPtr<IPortableDeviceValues> values; if (SUCCEEDED(CoCreateInstance(
CLSID_PortableDeviceValues, nullptr, CLSCTX_INPROC_SERVER,
IID_IPortableDeviceValues, getter_AddRefs(values)))) { if (SUCCEEDED(values->SetUnsignedIntegerValue(
SENSOR_PROPERTY_CURRENT_REPORT_INTERVAL, DEFAULT_SENSOR_POLL))) {
RefPtr<IPortableDeviceValues> returns;
sensor->SetProperties(values, getter_AddRefs(returns));
}
}
RefPtr<SensorEvent> event = new SensorEvent();
RefPtr<ISensorEvents> sensorEvents; if (FAILED(event->QueryInterface(IID_ISensorEvents,
getter_AddRefs(sensorEvents)))) { return;
}
if (FAILED(sensor->SetEventSink(sensorEvents))) { return;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.