Fix zone 2 placement, add colour correction and white balance

Zone 2 is the light under the thumb wheel, not the DPI button. The scroll-wheel
and logo LEDs have much weaker blue than the thumb-wheel LED, so the plugin now
trims their red and green (measured by eye) and applies an optional gamma curve.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mangavalkandClaude Opus 5.5 committed 2026-11-19 16:05:14 +01:00
1 parent 25f3e31b8f
commit f4eb036a98
3 files changed
+35 -16

No files matched your search

+25 -8
View File
@@ -19,21 +19,36 @@ LightingMode:readonly
forcedColor:readonly
shutdownMode:readonly
shutdownColor:readonly
colorCorrection:readonly
whiteBalance:readonly
*/
export function ControllableParameters() {
return [
{property:"LightingMode", group:"lighting", label:"Lighting Mode", description:"Canvas follows the active effect, Forced uses one fixed colour", type:"combobox", values:["Canvas", "Forced"], default:"Canvas"},
{property:"forcedColor", group:"lighting", label:"Forced Color", min:"0", max:"360", type:"color", default:"#009bde"},
{property:"colorCorrection", group:"lighting", label:"Colour Correction", description:"The LEDs respond linearly, so in-between colours look pale next to a screen. Higher values darken mid-tones and make colours richer", type:"combobox", values:["Off", "Light (1.8)", "Normal (2.2)", "Strong (2.8)"], default:"Normal (2.2)"},
{property:"whiteBalance", group:"lighting", label:"White Balance", description:"The scroll-wheel and logo LEDs have much weaker blue than the thumb-wheel LED, so colours there look pale and warm. Balanced trims their red and green to match (reds and greens get dimmer there)", type:"combobox", values:["Balanced", "Off"], default:"Balanced"},
{property:"shutdownMode", group:"lighting", label:"On Exit", description:"What the mouse shows when SignalRGB closes. 'Save last colours' stores them in the active profile (one storage write), so they survive replugging", type:"combobox", values:["Mouse's own lighting", "Shutdown Color", "Save last colours to mouse"], default:"Mouse's own lighting"},
{property:"shutdownColor", group:"lighting", label:"Shutdown Color", min:"0", max:"360", type:"color", default:"#000000"},
];
}
// Zones: 0 = under the scroll wheel, 1 = palm logo, 2 = DPI button
const vLedNames = ["Scroll Wheel", "DPI Button", "Palm Logo"];
const vLedPositions = [[1, 0], [1, 1], [1, 2]];
// Zones: 0 = under the scroll wheel, 1 = palm logo, 2 = under the thumb wheel (left side)
const vLedNames = ["Scroll Wheel", "Thumb Wheel", "Palm Logo"];
const vLedPositions = [[1, 0], [0, 1], [1, 2]];
const vZoneForLed = [0, 2, 1];
const GAMMA = {"Off": 1, "Light (1.8)": 1.8, "Normal (2.2)": 2.2, "Strong (2.8)": 2.8};
// Per-zone R/G/B scale, measured by eye against the thumb-wheel LED (2026-11-19)
const ZONE_BALANCE = [[0.15, 0.10, 1], [0.15, 0.10, 1], [1, 1, 1]];
function corrected(c, zone) {
const g = GAMMA[colorCorrection] || 1;
const k = whiteBalance === "Off" ? [1, 1, 1] : ZONE_BALANCE[zone];
return c.map((v, i) => Math.round(255 * Math.pow(v / 255, g) * k[i]));
}
const FEAT_LEN = 2053;
const PROFILE_LEN = 733;
const LED_OFFSET = 160;
@@ -98,8 +113,9 @@ export function Shutdown(SystemSuspending) {
}
function setZone(zone, c) {
device.send_report([12, 0xC4, 3, 4, 1, zone, c[0], c[1], c[2]], FEAT_LEN);
sent[zone] = c;
const o = corrected(c, zone);
device.send_report([12, 0xC4, 3, 4, 1, zone, o[0], o[1], o[2]], FEAT_LEN);
sent[zone] = c; // uncorrected, so unchanged canvas colours aren't resent
}
function releaseLeds() {
@@ -158,9 +174,10 @@ function saveToProfile(colors) {
const o = LED_OFFSET + z * LED_ZONE_LEN;
profile[o] = 1; // static
profile[o + 1] = 255; // brightness
profile[o + 2] = colors[z][0];
profile[o + 3] = colors[z][1];
profile[o + 4] = colors[z][2];
const c = corrected(colors[z], z);
profile[o + 2] = c[0];
profile[o + 3] = c[1];
profile[o + 4] = c[2];
}
device.send_report([5, 0, s, checksum(profile, 0, PROFILE_LEN)].concat(profile), FEAT_LEN);
+4 -2
View File
@@ -14,14 +14,16 @@ The plugin streams colours live with a firmware command the vendor app never use
to the LED driver with no storage writes, so it doesn't wear anything out. It handles
110+ updates a second. The `static`/`breathe`/`off` commands below change the stored
profile instead (one storage write each), which survives replugging.
Zones: 0 = under the scroll wheel, 1 = palm logo, 2 = DPI button.
Zones: 0 = under the scroll wheel, 1 = palm logo, 2 = under the thumb wheel.
The scroll-wheel and logo LEDs have much weaker blue than the thumb-wheel LED; the plugin
scales their red to 15% and green to 10% ("White Balance") plus a gamma setting.
```
python rat8.py live ff0000 00ff00 0000ff # RAM only, until release/replug
python rat8.py release # back to the stored lighting
python rat8.py info
python rat8.py static 00aaff # all zones
python rat8.py static ff0000 00ff00 0000ff # scroll palm dpi
python rat8.py static ff0000 00ff00 0000ff # scroll palm thumb
python rat8.py breathe ff00ff -p 3
python rat8.py off
python rat8.py restore profile_backup.json
+6 -6
View File
@@ -13,7 +13,7 @@ HID feature reports, padded to 2053 bytes:
read reply [5, B0, slot, checksum, 733 bytes]
LED block: 3 zones of 191 bytes starting at profile offset 160.
zone 0 = under the scroll wheel, zone 1 = palm logo, zone 2 = DPI button
zone 0 = under the scroll wheel, zone 1 = palm logo, zone 2 = under the thumb wheel
static: [1, brightness, R, G, B]
breathe: [2, 0,0,0,0, period_s lo, hi, 0,0,0,0, 1, brightness, R, G, B]
@@ -34,7 +34,7 @@ FEAT_LEN = 2053
PROFILE_LEN = 733
LED_OFFSET = 160
LED_ZONE_LEN = 191
ZONES = {"scroll": 0, "palm": 1, "dpi": 2}
ZONES = {"scroll": 0, "palm": 1, "thumb": 2}
def checksum(data):
@@ -129,8 +129,8 @@ def zone_colors(args):
if len(cols) == 1:
return {z: cols[0] for z in range(3)}
if len(cols) == 3:
return {ZONES["scroll"]: cols[0], ZONES["palm"]: cols[1], ZONES["dpi"]: cols[2]}
raise SystemExit("give 1 colour (all zones) or 3 colours (scroll palm dpi)")
return {ZONES["scroll"]: cols[0], ZONES["palm"]: cols[1], ZONES["thumb"]: cols[2]}
raise SystemExit("give 1 colour (all zones) or 3 colours (scroll palm thumb)")
def apply(m, args, build):
@@ -152,14 +152,14 @@ def main():
for name, hlp in (("static", "solid colours"), ("breathe", "breathing effect")):
sp = sub.add_parser(name, help=hlp)
sp.add_argument("colors", nargs="+", type=parse_color,
help="RRGGBB, either one for all zones or three: scroll palm dpi")
help="RRGGBB, either one for all zones or three: scroll palm thumb")
sp.add_argument("-b", "--brightness", type=int, default=255)
sp.add_argument("--all-slots", action="store_true", help="write all 4 profiles, not just the active one")
if name == "breathe":
sp.add_argument("-p", "--period", type=int, default=3, help="seconds per breath")
sp = sub.add_parser("live", help="set colours live (RAM only, no storage write; lost on replug)")
sp.add_argument("colors", nargs="+", type=parse_color, help="RRGGBB, one or three: scroll palm dpi")
sp.add_argument("colors", nargs="+", type=parse_color, help="RRGGBB, one or three: scroll palm thumb")
sub.add_parser("release", help="hand the LEDs back to the mouse's own stored lighting")
sp = sub.add_parser("off", help="turn all LEDs off")