Capture hid keyboard power button press

I have a Logitech hid keyboard (k400r) running setpoint.exe which enables me to remap the ‘Music, Home, Lock, Power’ buttons. I use Autohotkey to automate my lounge HTPC and was looking at a way to remove setpoint.exe from the equation and capture the key presses myself, not using Autohotkey but a custom small exe.

Using Wireshark I can filter and see all the keypresses (USB URB), even the power button key (once setpoint is uninstalled).

All reports are the “HID keyboards and mice cannot be accessed using the native HID driver as Windows reserves exclusive access to them.”

Is this achievable is any form? Perhaps by replacing the hidusb.sys driver with a generic custom driver, if they exist? Or using libusb-win32 installed as a filter driver?

A project on Github named “LogitechK290FnKeySwap” can toggle the ‘Fn’ key using libusb-win32 (installed as a device filter) & LibUsbDotNet by sending a ‘ControlTransfer’ to the keyboard.

So if the above method is achievable is it possible to capture and respond to any/all of the keyboards special keys? By special keys I mean the icons along F1-F12 & custom ‘Music, Home, Lock, Power’.

Examples:
The ‘Lock’ button sends a Win+L shortcut.
The Icon(F6) button sends a Win+I shortcut.
The Icon(F2) button sends a LControl+LWin+Backspace shortcut.
etc…

I assume these are hardcoded in somehow but hopefully overridable?

Yes, libusb as filter should work - if you can parse the descriptors and HID report to find the endpoints for the keyboard and special keys functions. These should be interrupt endpoints. Then run a continuous reader to get the reports.

I don’t have this keyboard so not sure that the special keys are reported thru a separate “application keys” collection - there is also a “legacy” mapping to scan codes. Use the sniffer to see.

– pa