claw-keyboard
Use claw-keyboard to discover and control USB keyboards that support the vendor HID protocol (UsagePage 0xFF60, Usage 0x61). Tested with LUXSWH R68pro. Supports RGB backlight, custom per-key LEDs, macros, key remapping, profile tuning, KLE layout rendering, and multi-keyboard management.
Quick start
- -
claw-keyboard discover — scan for connected keyboards - INLINECODE4 — show keyboard details (rows, cols, firmware, mode, RGB state)
- INLINECODE5 — set backlight to red
- INLINECODE6 — set brightness (0-255)
- INLINECODE7 — set lighting effect mode (0-20)
- INLINECODE8 — persist current settings to flash
Device selection
When multiple keyboards are connected, use --device <path> to target a specific one. Run discover to list available paths.
RGB control
- -
claw-keyboard rgb status — show current brightness, effect, speed, color - INLINECODE12 — set color by name (red, green, blue, cyan, purple, orange, yellow, white) or hue value (0-255)
- INLINECODE13 — set LED brightness
- INLINECODE14 — set lighting effect mode (0 = rainbow, 1 = solid, 2-20 = animations)
- INLINECODE15 — set animation speed (0 = slowest, 5 = fastest)
- INLINECODE16 — write current config to flash (avoid frequent calls — flash has limited write cycles)
Custom LED control
- -
claw-keyboard led on <row> <col> — turn on a single LED at row/col position - INLINECODE18 — turn off a single LED
- INLINECODE19 — turn off all LEDs
- INLINECODE20 — list currently lit LED positions
- INLINECODE21 — start onboard LED effect sync (keyboard reports LED data to PC)
- INLINECODE22 — stop onboard LED effect sync
Key mapping
- -
claw-keyboard keymap read — dump current key layout (all layers) - INLINECODE24 — show number of supported layers
- INLINECODE25 — read the 2-byte HID key value at a position
- INLINECODE26 — set a single key (4-digit hex, e.g.
0029 = Escape). Requires user confirmation — this changes a physical key binding on the keyboard. - INLINECODE28 — write complete keymap from hex file. Requires user confirmation — this overwrites all key bindings.
Macro management
- -
claw-keyboard macro list — show macro count, storage usage, and parsed macros - INLINECODE30 — erase all macros. Requires user confirmation — this deletes all macros permanently.
- INLINECODE31 — hex dump of raw macro storage data
- INLINECODE32 — configure macros from action strings (replaces all existing macros). Requires user confirmation.
- Action format:
tap:<keycode>,
press:<keycode>,
release:<keycode>,
delay:<ms> separated by commas
- Example:
claw-keyboard macro set "press:0xE0,tap:0x06,release:0xE0" (Ctrl+C)
Profile parameters
- -
claw-keyboard profile get — read profile parameters (debounce, TAP layer, sleep, power-down) - INLINECODE39 — configure profile parameters (use
--debounce, --tap, --sleep, --powerdown flags)
KLE layout tools
- -
claw-keyboard kle info <file.json> — show parsed KLE layout summary - INLINECODE45 — render KLE JSON layout to SVG
Other
- -
claw-keyboard reset — factory reset keyboard. Requires explicit user confirmation — this permanently erases all settings, key mappings, and macros from the keyboard, restoring it to factory defaults. Only run when the user explicitly requests a factory reset.
Safety
The following commands modify keyboard hardware state and should only be run with explicit user confirmation. Never run these autonomously:
- -
reset — factory reset (irreversible, erases everything) - INLINECODE48 /
macro set — erases or replaces all macros - INLINECODE50 /
keymap write — changes key bindings - INLINECODE52 — writes to flash (limited write cycles)
Read-only commands (discover, info, rgb status, keymap read, macro list, profile get, kle info) are always safe to run.
Notes
- - The tool auto-discovers keyboards by scanning for HID interfaces with UsagePage
0xFF60 and Usage 0x61, then verifying via a challenge-response handshake. - Not all keyboards expose the vendor HID interface. If
discover finds nothing, the keyboard may not support this protocol. - On macOS, you may need to grant HID access permission to the terminal application in System Settings > Privacy & Security > Input Monitoring.
- On Linux, you may need udev rules to access USB HID devices without root. Create
/etc/udev/rules.d/99-claw-keyboard.rules with SUBSYSTEM=="hidraw", ATTRS{idVendor}=="1a86", MODE="0666" and run sudo udevadm control --reload-rules. - SHA256 checksums for all binaries are available in the
SHA256SUMS file on the GitHub Releases page. Verify after downloading: shasum -a 256 -c SHA256SUMS. - Use
--json flag for machine-readable output.
技能名称: claw-keyboard
详细描述:
claw-keyboard
使用 claw-keyboard 来发现和控制支持厂商 HID 协议(UsagePage 0xFF60,Usage 0x61)的 USB 键盘。已在 LUXSWH R68pro 上测试通过。支持 RGB 背光、自定义单键 LED、宏、按键重映射、配置文件调优、KLE 布局渲染以及多键盘管理。
快速开始
- - claw-keyboard discover — 扫描已连接的键盘
- claw-keyboard info — 显示键盘详细信息(行数、列数、固件版本、模式、RGB 状态)
- claw-keyboard rgb color red — 将背光设置为红色
- claw-keyboard rgb brightness 128 — 设置亮度(0-255)
- claw-keyboard rgb effect 1 — 设置灯光效果模式(0-20)
- claw-keyboard rgb save — 将当前设置持久化保存到闪存
设备选择
当连接了多个键盘时,使用 --device <路径> 来指定目标设备。运行 discover 可列出可用路径。
RGB 控制
- - claw-keyboard rgb status — 显示当前亮度、效果、速度、颜色
- claw-keyboard rgb color <名称|色相> — 通过名称(red、green、blue、cyan、purple、orange、yellow、white)或色相值(0-255)设置颜色
- claw-keyboard rgb brightness <0-255> — 设置 LED 亮度
- claw-keyboard rgb effect <0-20> — 设置灯光效果模式(0 = 彩虹,1 = 常亮,2-20 = 动画)
- claw-keyboard rgb speed <0-5> — 设置动画速度(0 = 最慢,5 = 最快)
- claw-keyboard rgb save — 将当前配置写入闪存(避免频繁调用——闪存写入次数有限)
自定义 LED 控制
- - claw-keyboard led on <行> <列> — 打开指定行/列位置的单个 LED
- claw-keyboard led off <行> <列> — 关闭单个 LED
- claw-keyboard led clear — 关闭所有 LED
- claw-keyboard led list — 列出当前点亮的 LED 位置
- claw-keyboard led sync-start — 启动板载 LED 效果同步(键盘向 PC 报告 LED 数据)
- claw-keyboard led sync-stop — 停止板载 LED 效果同步
按键映射
- - claw-keyboard keymap read — 导出当前按键布局(所有层)
- claw-keyboard keymap layers — 显示支持的层数
- claw-keyboard keymap get <层> <行> <列> — 读取指定位置的 2 字节 HID 键值
- claw-keyboard keymap set <层> <行> <列> <键值> — 设置单个按键(4 位十六进制,例如 0029 = Escape)。需要用户确认——这会更改键盘上的物理按键绑定。
- claw-keyboard keymap write <文件> — 从十六进制文件写入完整的按键映射。需要用户确认——这会覆盖所有按键绑定。
宏管理
- - claw-keyboard macro list — 显示宏数量、存储使用情况及解析后的宏
- claw-keyboard macro clear — 清除所有宏。需要用户确认——这会永久删除所有宏。
- claw-keyboard macro dump — 原始宏存储数据的十六进制转储
- claw-keyboard macro set <动作> [<动作>...] — 通过动作字符串配置宏(替换所有现有宏)。需要用户确认。
- 动作格式:tap:<键码>、press:<键码>、release:<键码>、delay:<毫秒>,用逗号分隔
- 示例:claw-keyboard macro set press:0xE0,tap:0x06,release:0xE0(Ctrl+C)
配置文件参数
- - claw-keyboard profile get — 读取配置文件参数(去抖、TAP 层、休眠、断电)
- claw-keyboard profile set — 配置配置文件参数(使用 --debounce、--tap、--sleep、--powerdown 标志)
KLE 布局工具
- - claw-keyboard kle info — 显示解析后的 KLE 布局摘要
- claw-keyboard kle render — 将 KLE JSON 布局渲染为 SVG
其他
- - claw-keyboard reset — 恢复键盘出厂设置。需要用户明确确认——这会从键盘永久擦除所有设置、按键映射和宏,将其恢复为出厂默认值。仅在用户明确要求恢复出厂设置时运行。
安全性
以下命令会修改键盘硬件状态,只能在用户明确确认后运行。切勿自动运行这些命令:
- - reset — 恢复出厂设置(不可逆,擦除所有内容)
- macro clear / macro set — 擦除或替换所有宏
- keymap set / keymap write — 更改按键绑定
- rgb save — 写入闪存(写入次数有限)
只读命令(discover、info、rgb status、keymap read、macro list、profile get、kle info)始终安全可运行。
注意事项
- - 该工具通过扫描 UsagePage 为 0xFF60、Usage 为 0x61 的 HID 接口自动发现键盘,然后通过挑战-响应握手进行验证。
- 并非所有键盘都暴露了厂商 HID 接口。如果 discover 未找到任何设备,则键盘可能不支持此协议。
- 在 macOS 上,您可能需要在系统设置 > 隐私与安全性 > 输入监控中为终端应用授予 HID 访问权限。
- 在 Linux 上,您可能需要 udev 规则才能无需 root 权限访问 USB HID 设备。创建 /etc/udev/rules.d/99-claw-keyboard.rules,内容为 SUBSYSTEM==hidraw, ATTRS{idVendor}==1a86, MODE=0666,然后运行 sudo udevadm control --reload-rules。
- 所有二进制文件的 SHA256 校验和可在 GitHub Releases 页面的 SHA256SUMS 文件中获取。下载后验证:shasum -a 256 -c SHA256SUMS。
- 使用 --json 标志可输出机器可读的结果。