From 94e0842a06f0aa948def2d204be2bae60684fd4e Mon Sep 17 00:00:00 2001 From: Thomas Hindoe Paaboel Andersen Date: Thu, 28 Sep 2017 00:18:09 +0200 Subject: [PATCH] G300: add support LEDs --- data/gnome/logitech-g300.svg | 57 +++++++++++++++++++++++++++++++++--- src/driver-logitech-g300.c | 42 ++++++++++++++++++++++++-- 2 files changed, 92 insertions(+), 7 deletions(-) diff --git a/data/gnome/logitech-g300.svg b/data/gnome/logitech-g300.svg index 2e4fa3fa..4945e6a1 100644 --- a/data/gnome/logitech-g300.svg +++ b/data/gnome/logitech-g300.svg @@ -25,9 +25,9 @@ borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" - inkscape:zoom="1" - inkscape:cx="482.11115" - inkscape:cy="144.0202" + inkscape:zoom="2.8284271" + inkscape:cx="253.02787" + inkscape:cy="140.76165" inkscape:document-units="px" inkscape:current-layer="Buttons" inkscape:document-rotation="0" @@ -41,7 +41,7 @@ showborder="true" inkscape:guide-bbox="true" units="px" - inkscape:snap-global="true" + inkscape:snap-global="false" inkscape:measure-start="200.26,379.645" inkscape:measure-end="199.294,334.274"> + + + + + + + + + + + profile; + struct ratbag_device *device = profile->device; + struct logitech_g300_data *drv_data = device->drv_data; + struct logitech_g300_profile_data *pdata; + struct logitech_g300_profile_report *profile_report; + + pdata = &drv_data->profile_data[profile->index]; + profile_report = &pdata->report; + + led->type = RATBAG_LED_TYPE_SIDE; + led->mode = RATBAG_LED_ON; + led->color.red = profile_report->led_red * 255; + led->color.green = profile_report->led_green * 255; + led->color.blue = profile_report->led_blue * 255; +} + static int logitech_g300_test_hidraw(struct ratbag_device *device) { @@ -439,6 +461,8 @@ logitech_g300_write_profile(struct ratbag_profile *profile) struct logitech_g300_profile_data *pdata; struct logitech_g300_profile_report *report; struct ratbag_button *button; + struct ratbag_led *led; + uint8_t *buf; unsigned int hz, i; int rc; @@ -479,6 +503,17 @@ logitech_g300_write_profile(struct ratbag_profile *profile) } } + list_for_each(led, &profile->leds, link) { + if (!led->dirty) + continue; + + /* Clamp the 8 bit colors to 1 bit */ + report->led_red = led->color.red > 127; + report->led_green = led->color.green > 127; + report->led_blue = led->color.blue > 127; + } + + buf = (uint8_t*)report; rc = ratbag_hidraw_raw_request(device, report->id, @@ -533,4 +568,5 @@ struct ratbag_driver logitech_g300_driver = { .commit = logitech_g300_commit, .set_active_profile = logitech_g300_set_active_profile, .read_button = logitech_g300_read_button, + .read_led = logitech_g300_read_led, };