File tree Expand file tree Collapse file tree 2 files changed +48
-0
lines changed
Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,29 @@ typedef enum
3838 ACCELEROMETER_DATA_COUNT
3939} ACCELEROMETER_DATA_INDEX;
4040
41+ UINT8 CrosEcGetMotionSensorCount (HANDLE Handle)
42+ {
43+ EC_REQUEST_MOTION_SENSE_DUMP req{};
44+ EC_RESPONSE_MOTION_SENSE_DUMP res{};
45+
46+ req.MaxSensorCount = 0 ;
47+ if (0 == CrosEcSendCommand (
48+ Handle,
49+ EC_CMD_MOTION_SENSE,
50+ 0 ,
51+ &req,
52+ sizeof (req),
53+ &res,
54+ sizeof (res)
55+ )) {
56+ TraceError (" %!FUNC! EC_CMD_MOTION_SENSE_DUMP failed" );
57+ return 0 ;
58+ }
59+
60+ return res.SensorCount ;
61+ }
62+
63+
4164// ------------------------------------------------------------------------------
4265// Function: Initialize
4366//
@@ -57,6 +80,8 @@ AccelerometerDevice::Initialize(
5780 )
5881{
5982 NTSTATUS Status = STATUS_SUCCESS;
83+ UINT8 SensorCount = 0 ;
84+ PComboDevice Context = GetContextFromSensorInstance (SensorInstance);
6085
6186 SENSOR_FunctionEnter ();
6287
@@ -67,6 +92,15 @@ AccelerometerDevice::Initialize(
6792 m_SensorInstance = SensorInstance;
6893 m_Started = FALSE ;
6994
95+ SensorCount = CrosEcGetMotionSensorCount (Context->m_CrosEcHandle );
96+ TraceInformation (" %!FUNC! Found %d Sensors on this device" , SensorCount);
97+ if (SensorCount == 0 )
98+ {
99+ TraceError (" %!FUNC! No Sensors available. Not initializing AccelerometerClient" );
100+ Status = STATUS_NOT_FOUND;
101+ goto Exit;
102+ }
103+
70104 //
71105 // Create Lock
72106 //
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ NTSTATUS ConnectToEc(
4949 _Inout_ HANDLE * Handle
5050);
5151
52+ #define EC_CMD_MOTION_SENSE 0x002B
5253#define EC_CMD_RGBKBD_SET_COLOR 0x013A
5354#define EC_CMD_RGBKBD 0x013B
5455
@@ -93,6 +94,19 @@ typedef struct {
9394 Rgb Colors [CROS_EC_CMD_MAX_KEY_COUNT ];
9495} EC_REQUEST_RGB_KBD_SET_COLOR ;
9596
97+ typedef struct {
98+ UINT8 MaxSensorCount ;
99+ } EC_REQUEST_MOTION_SENSE_DUMP ;
100+
101+ typedef struct {
102+ UINT8 MaxSensorCount ;
103+ UINT8 SensorCount ;
104+ // Need to allocate extra data if you care about this field.
105+ // Right now I only care about the count.
106+ // If this field is not there, the EC just truncates the response.
107+ // UINT8 Sensors[];
108+ } EC_RESPONSE_MOTION_SENSE_DUMP ;
109+
96110#include <poppack.h>
97111
98112int CrosEcSendCommand (
You can’t perform that action at this time.
0 commit comments