From 18f4e13b59737951518bd03413a4d68c6099df62 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 25 Aug 2015 10:53:25 +1000 Subject: [PATCH] hidpp10: add set_led_status Only enabled for 4 leds and I'm not even sure they're the same on all devices. Still, works on the G500s so that's a good enough start. Signed-off-by: Peter Hutterer --- src/hidpp10.c | 20 ++++++++++++++++++++ src/hidpp10.h | 4 ++++ 2 files changed, 24 insertions(+) diff --git a/src/hidpp10.c b/src/hidpp10.c index b31236f7..a2d4bbea 100644 --- a/src/hidpp10.c +++ b/src/hidpp10.c @@ -328,6 +328,26 @@ hidpp10_get_led_status(struct ratbag_device *device, return 0; } +int +hidpp10_set_led_status(struct ratbag_device *device, + struct hidpp10_device *dev, + const bool led[4]) +{ + unsigned idx = dev->index; + union hidpp10_message led_status = CMD_LED_STATUS(idx, SET_REGISTER_REQ); + int res; + + + /* each led is 4-bits, 0x1 == off, 0x2 == on */ + led_status.msg.parameters[0] |= led[0] ? 0x02 : 0x01; /* running man logo */ + led_status.msg.parameters[0] |= led[1] ? 0x20 : 0x10; /* lowest */ + led_status.msg.parameters[1] |= led[2] ? 0x02 : 0x01; /* middle */ + led_status.msg.parameters[1] |= led[3] ? 0x20 : 0x10; /* highest */ + + res = hidpp10_request_command(device, &led_status); + return res; +} + /* -------------------------------------------------------------------------- */ /* 0x61: Optical Sensor Settings */ /* -------------------------------------------------------------------------- */ diff --git a/src/hidpp10.h b/src/hidpp10.h index cbb06015..cc200811 100644 --- a/src/hidpp10.h +++ b/src/hidpp10.h @@ -80,6 +80,10 @@ int hidpp10_get_led_status(struct ratbag_device *device, struct hidpp10_device *dev, bool led[4]); +int +hidpp10_set_led_status(struct ratbag_device *device, + struct hidpp10_device *dev, + const bool led[4]); /* -------------------------------------------------------------------------- */ /* 0x63: Current Resolution */