Download presentation
Presentation is loading. Please wait.
1
Dan Polivy Lead Program Manager Microsoft Corporation PC25
8
User System
10
interface ILocation : IUnknown { HRESULT RegisterForReport( ILocationEvents* pEvents, REFIID reportType, ULONG dwRequestedReportInterval); HRESULT GetReport( REFIID reportType, ILocationReport** ppLocationReport); // other functions }; interface ILocationEvents : IUnknown { HRESULT OnLocationChanged( REFIID reportType, ILocationReport* pNewReport); HRESULT OnStatusChanged( REFIID reportType, LOCATION_REPORT_STATUS newStatus); };
12
interface ILatLongReport : ILocationReport { HRESULT GetLatitude(DOUBLE* latitude); HRESULT GetLongitude(DOUBLE* longitude); HRESULT GetAltitude(DOUBLE* altitude); HRESULT GetAltitudeError(DOUBLE* altitudeError); HRESULT GetErrorRadius(DOUBLE* errorRadius); }; interface ICivicAddressReport : ILocationReport { HRESULT GetAddressLine1(BSTR* pbstrAddress1); HRESULT GetAddressLine2(BSTR* pbstrAddress2); HRESULT GetCity(BSTR* pbstrCity); HRESULT GetStateProvince(BSTR* pbstrState); HRESULT GetPostalCode(BSTR* pbstrPostalCode); HRESULT GetCountryRegion(BSTR* pbstrCountry); };
21
#include HRESULT hr; CComPtr pSensorManager; pSensorManager.CoCreateInstance(CLSID_SensorManager); CComPtr pALSCollection; CComPtr pALSSensor; // Get all the ALS sensors on the system pSensorManager->GetSensorsByType(SENSOR_TYPE_AMBIENT_LIGHT, &pALSCollection); hr = pSensorManager->RequestPermissions( 0, // Owner window pALSCollection, // Collection of sensors requiring permissions TRUE); // Modal flag if(SUCCEEDED(hr)) { pALSCollection->GetAt(0, &pALSSensor); }
22
STDMETHODIMP CALSEventSink::OnDataUpdated( ISensor* pSensor, ISensorDataReport* pNewData) { PROPVARIANT lightLevel; PropVariantInit(&lightLevel); // Get the sensor reading from the ISensorDataReport object pNewData->GetSensorValue(SENSOR_DATA_TYPE_LIGHT_LEVEL_LUX, &lightLevel); // Extract the float value from the PROPVARIANT object float luxValue = V_FLOAT(lightLevel); // Normalize the light sensor data double lightNormalized = ::pow(luxValue, 0.4) / 100.0; // Handle UI changes based on the normalized LUX data // which ranges from 0.0 - 1.0 for a lux range of // 0 lux to 100,000 lux, this method represents such a // handler that would be implemented in your application UpdateUI(lightNormalized); PropVariantClear(&lightLevel); return S_OK; }
30
Please fill out your evaluation for this session at: This session will be available as a recording at: www.microsoftpdc.com
32
© 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.