forderud / IntelliMouseDriver

Filter drivers for Microsoft Pro IntelliMouse that implements safety checks and exposes a WMI interface
MIT License
1 stars 1 forks source link

HidP_SetUsages #2

Closed forderud closed 1 year ago

forderud commented 1 year ago

HidP_SetUsages

Client code:

#define TAILLIGHT_PAGE      0xFF
#define TAILLIGHT_FEATURE   0x02

status = FireflySetFeature(
    WdfObjectGet_DEVICE_CONTEXT(WdfWmiInstanceGetDevice(WmiInstance)),
    TAILLIGHT_PAGE,
    TAILLIGHT_FEATURE,
    pInfo->TailLit
    );

Implementation:

NTSTATUS
FireflySetFeature(
    IN  PDEVICE_CONTEXT DeviceContext,
    IN  UCHAR           PageId,
    IN  USHORT          FeatureId,
    IN  BOOLEAN         EnableFeature
    )

// Edit the report to reflect the enabled feature
USAGE usage = FeatureId;
ULONG usageLength = 1;

status = HidP_SetUsages(
    HidP_Feature,
    PageId,
    0,
    &usage, // pointer to the usage list
    &usageLength, // number of usages in the usage list
    preparsedData,
    report,
    caps.FeatureReportByteLength
    );
forderud commented 1 year ago

Problem avoided by instead hardcoding the feature report in d0d8d2c73b2db087e6e87f063c62958f03141743.