From f0417a95350bb4a9832fe7c6170e040f323363c8 Mon Sep 17 00:00:00 2001 From: Thomas Hindoe Paaboel Andersen Date: Sun, 28 Feb 2016 04:17:59 +0100 Subject: [PATCH] hidpp10: Add definition for buttons on the G9 --- src/hidpp10.c | 5 +++-- src/hidpp10.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/hidpp10.c b/src/hidpp10.c index 5cd7c687..bd3ec605 100644 --- a/src/hidpp10.c +++ b/src/hidpp10.c @@ -635,7 +635,7 @@ struct _hidpp10_profile_9 { uint8_t default_dpi_mode; uint8_t unknown2[2]; uint8_t usb_refresh_rate; - union _hidpp10_button_binding buttons[10]; + union _hidpp10_button_binding buttons[PROFILE_NUM_BUTTONS_G9]; uint8_t unknown3[3]; union _hidpp10_profile_metadata metadata; } __attribute__((packed)); @@ -1437,6 +1437,7 @@ hidpp10_get_profile(struct hidpp10_device *dev, int8_t number, struct hidpp10_pr break; default: hidpp_log_error(&dev->base, "This should never happen, complain to your maintainer.\n"); + return -EINVAL; } profile = &dev->profiles[number]; @@ -1484,7 +1485,7 @@ hidpp10_get_profile(struct hidpp10_device *dev, int8_t number, struct hidpp10_pr hidpp10_fill_dpi_modes_8(dev, profile, p9->dpi_modes, PROFILE_NUM_DPI_MODES); hidpp10_profile_parse_names(dev, profile, number, &p9->metadata); - hidpp10_fill_buttons(dev, profile, buttons, 10); + hidpp10_fill_buttons(dev, profile, buttons, PROFILE_NUM_BUTTONS_G9); break; default: hidpp_log_error(&dev->base, "This should never happen, complain to your maintainer.\n"); diff --git a/src/hidpp10.h b/src/hidpp10.h index 473367f6..a9801849 100644 --- a/src/hidpp10.h +++ b/src/hidpp10.h @@ -365,6 +365,7 @@ hidpp10_get_battery_mileage(struct hidpp10_device *dev, /* 0x0F: Profile queries */ /* -------------------------------------------------------------------------- */ #define PROFILE_NUM_BUTTONS 13 +#define PROFILE_NUM_BUTTONS_G9 10 #define PROFILE_NUM_DPI_MODES 5 #define PROFILE_BUTTON_TYPE_BUTTON 0x81 #define PROFILE_BUTTON_TYPE_KEYS 0x82