Skip to content

Commit df95be8

Browse files
JohnAZoidbergclaude
andcommitted
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. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c7ef185 commit df95be8

File tree

4 files changed

+497
-1
lines changed

4 files changed

+497
-1
lines changed

FrameworkSensors/Clients.h

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

262262
} SimpleDeviceOrientationDevice, *PSimpleDeviceOrientationDevice;
263+
264+
265+
266+
//
267+
// Hinge Angle ----------------------------------------------------------------
268+
//
269+
typedef class _HingeAngleDevice : public _ComboDevice
270+
{
271+
private:
272+
typedef struct _HingeAngleSample
273+
{
274+
FLOAT Angle;
275+
} HingeAngleSample;
276+
277+
HingeAngleSample m_CachedThresholds;
278+
HingeAngleSample m_CachedData;
279+
HingeAngleSample m_LastSample;
280+
281+
public:
282+
NTSTATUS Initialize(_In_ WDFDEVICE Device, _In_ SENSOROBJECT SensorObj);
283+
NTSTATUS GetData(_In_ HANDLE Device);
284+
NTSTATUS UpdateCachedThreshold();
285+
286+
} 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
}
@@ -255,6 +257,11 @@ OnPrepareHardware(
255257
SensorSizes[SensorInstanceCount] = sizeof(AccelerometerDevice);
256258
SensorKinds[SensorInstanceCount] = SENSOR_KIND_ACCELEROMETER;
257259
SensorInstanceCount++;
260+
261+
TraceInformation("COMBO %!FUNC! Detected hinge angle (base+lid accels present)");
262+
SensorSizes[SensorInstanceCount] = sizeof(HingeAngleDevice);
263+
SensorKinds[SensorInstanceCount] = SENSOR_KIND_HINGEANGLE;
264+
SensorInstanceCount++;
258265
}
259266
}
260267
}

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)