From: Alfreda on
I have C++ code (using DefineDosDevice and DeviceIoControl) which controls
the state of the LEDs on "traditional" (PS2) keyboards but this fails for USB
keyboards.

To do the same with USB Keyboards I believe I'll need to use the
HidD_GetFeature and HidD_SetFeature APIs (since Reads and Writes will fail -
Windows locks the USB keyboard device for exclusive use).

I'm new to USB and HID APIs and was hoping that someone could point me at
sample code (or even post some) thats shows HidD_GetFeature and
HidD_SetFeature being used to get / set the state of the LEDs on a USB
Keyboard.

Thanks in advance.
From: Robert Marquardt on
Alfreda wrote:
> I have C++ code (using DefineDosDevice and DeviceIoControl) which controls
> the state of the LEDs on "traditional" (PS2) keyboards but this fails for USB
> keyboards.
>
> To do the same with USB Keyboards I believe I'll need to use the
> HidD_GetFeature and HidD_SetFeature APIs (since Reads and Writes will fail -
> Windows locks the USB keyboard device for exclusive use).
>
> I'm new to USB and HID APIs and was hoping that someone could point me at
> sample code (or even post some) thats shows HidD_GetFeature and
> HidD_SetFeature being used to get / set the state of the LEDs on a USB
> Keyboard.
>
> Thanks in advance.


Forget it. The LEDs are in an output report and not in a feature report.
Output reports can only be written with WriteFile which is as locked as
ReadFile for a keyboard.
From: Alfreda on
Robert,

Thanks for the post. That would explain why my attempts to get things
working have been so unsuccessful! Originally I was pointed to a DirectX API
(IDirectInputDevice8::SendDeviceData) but was told that this was no longer
recommended and to use the HID API instead.

I guess I should investigate the DirectX API again - unless anyone else out
there has any suggestions? I had no idea it would be this difficult....

"Robert Marquardt" wrote:

> Alfreda wrote:
> > I have C++ code (using DefineDosDevice and DeviceIoControl) which controls
> > the state of the LEDs on "traditional" (PS2) keyboards but this fails for USB
> > keyboards.
> >
> > To do the same with USB Keyboards I believe I'll need to use the
> > HidD_GetFeature and HidD_SetFeature APIs (since Reads and Writes will fail -
> > Windows locks the USB keyboard device for exclusive use).
> >
> > I'm new to USB and HID APIs and was hoping that someone could point me at
> > sample code (or even post some) thats shows HidD_GetFeature and
> > HidD_SetFeature being used to get / set the state of the LEDs on a USB
> > Keyboard.
> >
> > Thanks in advance.
>
>
> Forget it. The LEDs are in an output report and not in a feature report.
> Output reports can only be written with WriteFile which is as locked as
> ReadFile for a keyboard.
>