From 45129b2bc88efa65f9a0c5ea175e2a7b6ee7934c Mon Sep 17 00:00:00 2001 From: Ilya Guterman Date: Thu, 1 Dec 2016 01:24:28 +0200 Subject: [PATCH] hidpp20: define internal LED structure --- src/hidpp20.c | 9 ++------- src/hidpp20.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/hidpp20.c b/src/hidpp20.c index 316e2e37..1cbbaf8b 100644 --- a/src/hidpp20.c +++ b/src/hidpp20.c @@ -1653,11 +1653,7 @@ union hidpp20_internal_profile { uint8_t default_dpi; uint8_t switched_dpi; uint16_t dpi[5]; - struct { - uint8_t red; - uint8_t green; - uint8_t blue; - } profile_color; + struct hidpp20_color profile_color; uint8_t power_mode; uint8_t angle_snapping; uint8_t reserved[14]; @@ -1667,8 +1663,7 @@ union hidpp20_internal_profile { char txt[16 * 3]; uint8_t raw[16 * 3]; } name; - uint8_t logo_effect[11]; /* G303 only */ - uint8_t side_effects[11]; /* G303 only */ + struct hidpp20_internal_led leds[2]; /* G303, g502, g900 only */ uint8_t free[24]; uint16_t crc; } __attribute__((packed)) profile; diff --git a/src/hidpp20.h b/src/hidpp20.h index 42f2db6a..e54ba234 100644 --- a/src/hidpp20.h +++ b/src/hidpp20.h @@ -317,6 +317,36 @@ union hidpp20_button_binding { } __attribute__((packed)); _Static_assert(sizeof(union hidpp20_button_binding) == 4, "Invalid size"); +struct hidpp20_color { + uint8_t red; + uint8_t green; + uint8_t blue; +} __attribute__((packed)); +_Static_assert(sizeof(struct hidpp20_color) == 3, "Invalid size"); + +struct hidpp20_internal_led { + uint8_t mode; /* 00 - off; 01 - on; 03 - cycle; 0a - breath */ + struct hidpp20_color color; + union { + struct hidpp20_led_cycle { + uint16_t pad_1; + uint16_t rate; /* 16000 - 20000Hz */ + uint8_t brightness; /* 0 - 100 percent */ + uint16_t pad_2; + } __attribute__((packed)) cycle; + struct hidpp20_led_breath { + uint16_t rate; + uint8_t pad_1; + uint8_t brightness; + uint8_t pad_2; + uint16_t pad_3; + } __attribute__((packed)) breath; + } __attribute__((packed)) effect; +}; +_Static_assert(sizeof(struct hidpp20_led_cycle) == 7, "Invalid size"); +_Static_assert(sizeof(struct hidpp20_led_breath) == 7, "Invalid size"); +_Static_assert(sizeof(struct hidpp20_internal_led) == 11, "Invalid size"); + #define HIDPP20_MACRO_NOOP 0x01 #define HIDPP20_MACRO_DELAY 0x40 #define HIDPP20_MACRO_KEY_PRESS 0x43