Skip to content

Commit 25e602f

Browse files
committed
SensorsComboDriver: Add orientation sensor
Just copied from accel and renamed. Signed-off-by: Daniel Schaefer <dhs@frame.work>
1 parent 1e52459 commit 25e602f

5 files changed

Lines changed: 542 additions & 1 deletion

File tree

SensorsComboDriver/Clients.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,3 +228,30 @@ typedef class _LinearAccelerometerDevice : public _ComboDevice
228228
NTSTATUS UpdateCachedThreshold();
229229

230230
} LinearAccelerometerDevice, *PLinearAccelerometerDevice;
231+
232+
233+
234+
//
235+
// Simple Device Orientation --------------------------------------------------
236+
//
237+
typedef class _SimpleDeviceOrientationDevice : public _ComboDevice
238+
{
239+
private:
240+
241+
typedef struct _SimpleDeviceOrientationSample
242+
{
243+
VEC3D Axis;
244+
BOOL Shake;
245+
} SimpleDeviceOrientationSample, *PSimpleDeviceOrientationSample;
246+
247+
SimpleDeviceOrientationSample m_CachedThresholds;
248+
SimpleDeviceOrientationSample m_CachedData;
249+
SimpleDeviceOrientationSample m_LastSample;
250+
251+
public:
252+
253+
NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj);
254+
NTSTATUS GetData();
255+
NTSTATUS UpdateCachedThreshold();
256+
257+
} SimpleDeviceOrientationDevice, *PSimpleDeviceOrientationDevice;

SensorsComboDriver/Device.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
enum Device
2323
{
2424
Device_Als = 0,
25+
Device_SimpleDeviceOrientation,
2526
Device_LinearAccelerometer,
2627
// Keep this last
2728
Device_Count
@@ -37,6 +38,7 @@ inline size_t GetDeviceSizeAtIndex(
3738
switch (static_cast<Device>(Index))
3839
{
3940
case Device_Als: result = sizeof(AlsDevice); break;
41+
case Device_SimpleDeviceOrientation:result = sizeof(SimpleDeviceOrientationDevice); break;
4042
case Device_LinearAccelerometer: result = sizeof(LinearAccelerometerDevice); break;
4143
default: break; // invalid
4244
}
@@ -51,6 +53,7 @@ void AllocateDeviceAtIndex(
5153
switch (static_cast<Device>(Index))
5254
{
5355
case Device_Als: *ppDevice = new(*ppDevice) AlsDevice; break;
56+
case Device_SimpleDeviceOrientation:*ppDevice = new(*ppDevice) SimpleDeviceOrientationDevice; break;
5457
case Device_LinearAccelerometer: *ppDevice = new(*ppDevice) LinearAccelerometerDevice; break;
5558

5659
default: break; // invalid (let driver fail)

SensorsComboDriver/SensorsComboDriver.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
7777
</ImportGroup>
7878
<ItemGroup Label="WrappedTaskItems">
79-
<ClCompile Include="AlsClient.cpp; Clients.cpp; device.cpp; driver.cpp; linearaccelerometerclient.cpp; ">
79+
<ClCompile Include="AlsClient.cpp; Clients.cpp; device.cpp; driver.cpp; SimpleDeviceOrientationClient.cpp; linearaccelerometerclient.cpp; ">
8080
<WppEnabled>true</WppEnabled>
8181
<WppDllMacro>true</WppDllMacro>
8282
<WppModuleName>SensorsComboDriver</WppModuleName>

SensorsComboDriver/SensorsComboDriver.vcxproj.Filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
<ClCompile Include="driver.cpp">
3232
<Filter>Source Files</Filter>
3333
</ClCompile>
34+
<ClCompile Include="SimpleDeviceOrientationClient.cpp">
35+
<Filter>Source Files</Filter>
36+
</ClCompile>
3437
<ClCompile Include="linearaccelerometerclient.cpp">
3538
<Filter>Source Files</Filter>
3639
</ClCompile>

0 commit comments

Comments
 (0)