Skip to content

Fix Clevo keyboard LED mapping for per-key RGB control#76

Open
Dronakurl wants to merge 1 commit intoCalcProgrammer1:masterfrom
Dronakurl:clevo2
Open

Fix Clevo keyboard LED mapping for per-key RGB control#76
Dronakurl wants to merge 1 commit intoCalcProgrammer1:masterfrom
Dronakurl:clevo2

Conversation

@Dronakurl
Copy link

This PR fixes the broken per-key RGB control on Clevo ITE 8291 keyboards found in TUXEDO/Clevo laptops.

Problem

The KeyboardLayoutManager returns LED names with a "Key: " prefix (e.g., "Key: W", "Key: F1") but the hardware value lookup in the Clevo controller was using KeyboardLayoutManager.GetKeyValueAt() which expects bare key names. This mismatch caused incorrect key-to-LED mapping, making per-key RGB lighting non-functional.

When attempting to set colors on individual keys, the wrong key would light up. For example, selecting the W key in OpenRGB would actually light up the I key on the keyboard. The mapping was completely broken.

Solution

Added a GetCorrectHWValue() function that properly maps all 126 keyboard LEDs from their full key names to the correct hardware LED values. The function uses an unordered_map for hash lookup instead of the previous broken approach.

The mapping covers:

  • Standard keyboard keys (F-row, number row, QWERTY, ASDF, ZXCV rows)
  • Modifier keys (Ctrl, Alt, Win, Shift, Caps Lock)
  • Arrow keys (Up/Left/Down/Right Arrow)
  • Numpad keys (Number Pad 0-9, /, *, -, +, ., Enter)
  • Navigation keys (Insert, Delete, Home, End, Page Up/Down)

Hardware Information

This fix was tested on:

  • System: TUXEDO Stellaris 16 Intel Gen6 (SKU: STELLARIS16I06)
  • Motherboard: TUXEDO GM6IXxB_MB2 (board model NB02)
  • Keyboard Controller: ITE 8291 (USB device 048d:600b)
  • Keyboard Layout: ISO QWERTY

Testing

After applying this fix, per-key RGB control works correctly. Each key now maps to its proper hardware LED position, allowing individual key color customization through the OpenRGB UI.

Changes

  • RGBController_ClevoKeyboard.cpp: Added GetCorrectHWValue() function with full key mapping
  • RGBController_ClevoKeyboard.h: Added function declaration
  • ClevoKeyboardDevices.cpp: Reorganized comments for clarity

The KeyboardLayoutManager returns LED names with "Key: " prefix
(e.g., "Key: W") but the hardware value lookup was checking for
just "W", causing all keys to map to hardware LED 0 (Left Ctrl).

Added GetCorrectHWValue() function that properly maps all 126 keys
including:
- Standard keyboard keys (F-row, number row, QWERTY, etc.)
- Arrow keys (Up/Left/Down/Right Arrow)
- Numpad keys (Number Pad 0-9, /, *, -, +, ., Enter)

This fixes per-key RGB control on Clevo ITE 8291 keyboards.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

refactor: remove redundant GetCorrectHWValue function

The Clevo keyboard controller had duplicate hardware LED value
mappings in both clevo_tkl_values array and GetCorrectHWValue().
This removes the ~100 if-statement function and uses
KeyboardLayoutManager.GetKeyValueAt() directly, aligning
with the pattern used by other keyboard controllers.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

Revert "refactor: remove redundant GetCorrectHWValue function"

This reverts commit afe1141.

refactor: replace GetCorrectHWValue if-statements with unordered_map

Replace ~100 if-statements in GetCorrectHWValue() with a static
unordered_map for O(1) hash lookup instead of O(n) string
comparisons. This improves:
- Performance: O(1) vs O(n) lookup
- Maintainability: single map definition vs scattered if-statements
- Readability: compact data structure vs verbose code

The mapping is still required because Clevo hardware LED positions
don't match standard keyboard matrix order.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant