Corsair Strafe RGB Mk. 2 Automatic Backlight
This project uses a Raspberry Pi Pico to control the RGB lighting on a Corsair Strafe RGB Mk. 2 keyboard while passing through key events from the keyboard to the host device.
The Raspberry Pi Pico uses the ADC to determine the ambient brightness using an attached light dependent resistor, then sends the RGB control signals to the keyboard to provide either dim white light when the ambient environment is bright or a bright white light when the ambient environment is dark.
The Raspberry Pi Pico also reads keyboard input from the keyboard, processes it, and sends it to the connected host device. The Strafe Mk. 2 keyboard sends individual key up/down signals, and media control signals. The processing will take these presses and update a single NKRO keyboard key bitmap signal and HID Consumer Control interface for the media key inputs.
The project has the lighting color, brightness, and threshold ambient brightness for the two states hardcoded. If you want to change these, you will need to modify them directly in the source. While it would be possible to make the lighting settings user-configurable over USB, it will require significant work to do so. Since this keyboard is deployed in a professional setting, the simple solid white lighting with increased brightness when it is dark was chosen.
The project also hardcodes the VID and PID of the Strafe Mk. 2 keyboard so that it will only accept that keyboard model connected to the device. This is partly because there are multiple NKRO protocols, so determining which one is in use by an arbitrary keyboard plugged into the Pico would be difficult. The other major reason is that RGB lighting protocols are proprietary and vary from vendor to vendor and often from model to model even within the same vendor or brand. If another keyboard is plugged in, even if USB keyboard inputs are passed through, the Pico would serve no additional purpose with a keyboard that does not obey the exact same RGB protocol as the Strafe Mk. 2.
For an unknown reason, forwarding the standard indicator LED status HID reports for determining the state of the caps/num/scroll lock keys does not work, so the indicator LEDs do not update correctly.
The project may serve as a proof-of-concept for someone who is more ambitious and wants to make the lighting settings more user-configurable or to see an example of capturing and forwarding USB keyboard events with a Raspberry Pi Pico.