From cdecb6ebecf69f084e90d6b20dd7230f2d3f3ba5 Mon Sep 17 00:00:00 2001 From: Simon W Date: Thu, 18 Jan 2024 10:04:05 +0100 Subject: [PATCH] Initial fix for not resetting rgb on all connected devices #60 (#67) Fixes #60 --- src/wooting-rgb-sdk.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/wooting-rgb-sdk.c b/src/wooting-rgb-sdk.c index 2008be2..3a95f82 100644 --- a/src/wooting-rgb-sdk.c +++ b/src/wooting-rgb-sdk.c @@ -108,12 +108,19 @@ bool wooting_rgb_reset_rgb() { } bool wooting_rgb_close() { - if (wooting_rgb_reset_rgb()) { - wooting_usb_disconnect(false); - return true; - } else { - return false; + bool result = false; + + for (uint8_t i = 0; i < wooting_usb_device_count(); i++) { + if (wooting_usb_select_device(i)) { + result |= wooting_rgb_reset_rgb(); + } } + + // The disconnect call disconnects all devices, so we do it after we've + // attempted to reset rgb on all of them + wooting_usb_disconnect(false); + + return result; } bool wooting_rgb_reset() { return wooting_rgb_close(); }