Skip to content

Commit 28887e0

Browse files
committed
Add HingeAngle sensor client
Expose the EC-calculated lid hinge angle (0-360 degrees) to Windows via GUID_SensorType_HingeAngle / PKEY_SensorData_HingeAngle. The EC already computes this from base+lid accelerometers and stores it at EC_MEMMAP_ACC_DATA. The sensor is auto-detected when both base and lid accelerometers are present. Signed-off-by: Daniel Schaefer <dhs@frame.work>
1 parent afd390e commit 28887e0

4 files changed

Lines changed: 497 additions & 1 deletion

File tree

FrameworkSensors/Clients.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,3 +261,27 @@ typedef class _SimpleDeviceOrientationDevice : public _ComboDevice
261261
NTSTATUS UpdateCachedThreshold();
262262

263263
} SimpleDeviceOrientationDevice, *PSimpleDeviceOrientationDevice;
264+
265+
266+
267+
//
268+
// Hinge Angle ----------------------------------------------------------------
269+
//
270+
typedef class _HingeAngleDevice : public _ComboDevice
271+
{
272+
private:
273+
typedef struct _HingeAngleSample
274+
{
275+
FLOAT Angle;
276+
} HingeAngleSample;
277+
278+
HingeAngleSample m_CachedThresholds;
279+
HingeAngleSample m_CachedData;
280+
HingeAngleSample m_LastSample;
281+
282+
public:
283+
NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj);
284+
NTSTATUS GetData(_In_ HANDLE Device);
285+
NTSTATUS UpdateCachedThreshold();
286+
287+
} HingeAngleDevice, *PHingeAngleDevice;

FrameworkSensors/Device.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
typedef enum {
3030
SENSOR_KIND_ACCELEROMETER,
31+
SENSOR_KIND_HINGEANGLE,
3132
SENSOR_KIND_ALS,
3233
} SensorKind;
3334

@@ -60,6 +61,7 @@ void AllocateDeviceAtIndex(
6061
switch (SensorKinds[Index])
6162
{
6263
case SENSOR_KIND_ACCELEROMETER: *ppDevice = new(*ppDevice) AccelerometerDevice; break;
64+
case SENSOR_KIND_HINGEANGLE: *ppDevice = new(*ppDevice) HingeAngleDevice; break;
6365
case SENSOR_KIND_ALS: *ppDevice = new(*ppDevice) AlsDevice; break;
6466
default: break;
6567
}
@@ -221,6 +223,11 @@ OnPrepareHardware(
221223
SensorSizes[SensorInstanceCount] = sizeof(AccelerometerDevice);
222224
SensorKinds[SensorInstanceCount] = SENSOR_KIND_ACCELEROMETER;
223225
SensorInstanceCount++;
226+
227+
TraceInformation("COMBO %!FUNC! Detected hinge angle (base+lid accels present)");
228+
SensorSizes[SensorInstanceCount] = sizeof(HingeAngleDevice);
229+
SensorKinds[SensorInstanceCount] = SENSOR_KIND_HINGEANGLE;
230+
SensorInstanceCount++;
224231
}
225232
}
226233
}

FrameworkSensors/FrameworkSensors.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
8181
</ImportGroup>
8282
<ItemGroup Label="WrappedTaskItems">
83-
<ClCompile Include="AlsClient.cpp; Clients.cpp; device.cpp; driver.cpp; EcCommunication.cpp; SimpleDeviceOrientationClient.cpp; AccelerometerClient.cpp; ">
83+
<ClCompile Include="AlsClient.cpp; Clients.cpp; device.cpp; driver.cpp; EcCommunication.cpp; SimpleDeviceOrientationClient.cpp; AccelerometerClient.cpp; HingeAngleClient.cpp; ">
8484
<WppEnabled>true</WppEnabled>
8585
<WppDllMacro>true</WppDllMacro>
8686
<WppModuleName>FrameworkSensors</WppModuleName>

0 commit comments

Comments
 (0)