Create HID Control Request with AHK

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Posts: 1
Joined: 10 Apr 2021, 15:12

Create HID Control Request with AHK

10 Apr 2021, 15:31


I have built a small 4 button streamdeck, with an RGB LED under each button. I built it using a raspberry PI Pico and have great success in sending F14-F18 keys and using AHK scripting to do all kind of fun things.

The next step for me is to be able to control the RGB LEDS from Auto Hotkey.

As of now, I do receive so-called "HID control requests" whenever I enable/disable caps/scroll/numlock on any of the attached keyboards of my computer. For your reference, this looks like this in the debug output of my raspberry pico running tinyusb:

Code: Select all

USBD Setup Received 21 09 01 02 00 00 02 00 
  HID control request
  Queue EP 00 with 2 bytes
USBD Xfer Complete on EP 00 with 2 bytes
  HID control complete
DEBUG: tud_hid_set_report_cb triggered
DEBUG: report_id: 1
DEBUG: report_type: 2
DEBUG: bufsize: 2
DEBUG: buffer content:
01 01  - End 
  Queue EP 80 with zlp Status
USBD Xfer Complete on EP 80 with 0 bytes
the buffer content (01 01) reflects the state of the enabled/disabled caps/num/scroll lock LEDS.

So the first thing I tried out to send these from autohotkey was using the keyboardLed script from Lexikos:

I was hoping to expand on the keyboardled script to send "longer" HID control requests, and in this way send the status for all 4 RGB leds to the pico.

The code I used for that is here:
Which is basically his code plus my keyhook added:

Code: Select all

Msgbox, % "kbd = " GetKeyboardIndex("HID\VID_BC05&PID_4004\")-1
KeyboardLED(7, "On", GetKeyboardIndex("HID\VID_BC05&PID_4004\"))

Loop, 10
	KeyboardLED(7, "On", A_Index-1)
Now here come my challenges:
  1. The getkeyboardindex words, it shows up as "4"
  2. The keyboardLED function for this index does NOT trigger anything on my Pico (no USB data, nothing in my debug console)
  3. In the test-loop afterwards, the Caps-Lock led on my LAPTOP KEYBOARD does turn on, but NOTHING on the pico
At this point I am fairly stuck, and I am wondering why the USB HID Control request is never triggered. I am open to any suggestions, also other suggestions that would achieve the same goal (being able to perform actions from AHK using the buttons, and sending data from AHK back to the pico to control the RGB Leds)

BTW, the complete code on the pico (and how to build it) is here:
When I get everything to work the 3D printable models for making you own will become available online as open source as well :shh: .

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 120 guests