1
0
forked from drath/libratbag

hidpp20: add new profile layout (0x04)

Signed-off-by: Filipe Laíns <lains@archlinux.org>
This commit is contained in:
Filipe Laíns
2019-07-29 08:49:49 +01:00
committed by Peter Hutterer
parent 22a6ac1c7e
commit a8b4d9c6f3
2 changed files with 24 additions and 3 deletions

View File

@@ -1463,6 +1463,7 @@ int hidpp20_adjustable_report_rate_get_report_rate_list(struct hidpp20_device *d
#define HIDPP20_ONBOARD_PROFILES_PROFILE_TYPE_G402 0x01
#define HIDPP20_ONBOARD_PROFILES_PROFILE_TYPE_G303 0x02
#define HIDPP20_ONBOARD_PROFILES_PROFILE_TYPE_G900 0x03
#define HIDPP20_ONBOARD_PROFILES_PROFILE_TYPE_G903_HERO 0x04
#define HIDPP20_ONBOARD_PROFILES_MACRO_TYPE_G402 0x01
#define HIDPP20_USER_PROFILES_G402 0x0000
@@ -1481,7 +1482,9 @@ union hidpp20_internal_profile {
struct hidpp20_color profile_color;
uint8_t power_mode;
uint8_t angle_snapping;
uint8_t reserved[14];
uint8_t reserved[10];
uint16_t powersave_timeout;
uint16_t poweroff_timeout;
union hidpp20_button_binding buttons[16];
union hidpp20_button_binding alternate_buttons[16];
union {
@@ -1489,7 +1492,8 @@ union hidpp20_internal_profile {
uint8_t raw[16 * 3];
} name;
struct hidpp20_internal_led leds[2]; /* G303, g502, g900 only */
uint8_t free[24];
struct hidpp20_internal_led alt_leds[2];
uint8_t free[2];
uint16_t crc;
} __attribute__((packed)) profile;
};
@@ -1878,7 +1882,8 @@ hidpp20_onboard_profiles_validate(struct hidpp20_device *device,
if ((info->profile_format_id != HIDPP20_ONBOARD_PROFILES_PROFILE_TYPE_G402) &&
(info->profile_format_id != HIDPP20_ONBOARD_PROFILES_PROFILE_TYPE_G303) &&
(info->profile_format_id != HIDPP20_ONBOARD_PROFILES_PROFILE_TYPE_G900)) {
(info->profile_format_id != HIDPP20_ONBOARD_PROFILES_PROFILE_TYPE_G900) &&
(info->profile_format_id != HIDPP20_ONBOARD_PROFILES_PROFILE_TYPE_G903_HERO)) {
hidpp_log_error(&device->base,
"Profile layout not supported: 0x%02x.\n",
info->profile_format_id);
@@ -2372,12 +2377,18 @@ hidpp20_onboard_profiles_parse_profile(struct hidpp20_device *device,
profile->default_dpi = pdata->profile.default_dpi;
profile->switched_dpi = pdata->profile.switched_dpi;
profile->powersave_timeout = pdata->profile.powersave_timeout;
profile->poweroff_timeout = pdata->profile.poweroff_timeout;
for (i = 0; i < 5; i++) {
profile->dpi[i] = get_unaligned_le_u16(&data[2 * i + 3]);
}
for (i = 0; i < profiles_list->num_leds; i++)
{
hidpp20_onboard_profiles_read_led(&profile->leds[i], pdata->profile.leds[i]);
hidpp20_onboard_profiles_read_led(&profile->alt_leds[i], pdata->profile.alt_leds[i]);
}
hidpp20_buttons_to_cpu(device, profiles_list, profile, pdata->profile.buttons, profiles_list->num_buttons);
@@ -2552,12 +2563,19 @@ hidpp20_onboard_profiles_write_profile(struct hidpp20_device *device,
pdata->profile.default_dpi = profile->default_dpi;
pdata->profile.switched_dpi = profile->switched_dpi;
pdata->profile.powersave_timeout = profile->powersave_timeout;
pdata->profile.poweroff_timeout = profile->poweroff_timeout;
for (i = 0; i < 5; i++) {
pdata->profile.dpi[i] = hidpp_cpu_to_le_u16(profile->dpi[i]);
}
for (i = 0; i < profiles_list->num_leds; i++)
{
hidpp20_onboard_profiles_write_led(&pdata->profile.leds[i], &profile->leds[i]);
/* we write the current led instead of the stored value */
hidpp20_onboard_profiles_write_led(&pdata->profile.alt_leds[i], &profile->leds[i]);
}
hidpp20_buttons_from_cpu(profile, pdata->profile.buttons, profiles_list->num_buttons);

View File

@@ -692,6 +692,8 @@ struct hidpp20_profile {
uint16_t address;
uint8_t enabled;
char name[16 * 3];
uint16_t powersave_timeout;
uint16_t poweroff_timeout;
unsigned report_rate;
unsigned default_dpi;
unsigned switched_dpi;
@@ -700,6 +702,7 @@ struct hidpp20_profile {
union hidpp20_button_binding buttons[32];
union hidpp20_macro_data *macros[32];
struct hidpp20_led leds[HIDPP20_LED_COUNT];
struct hidpp20_led alt_leds[HIDPP20_LED_COUNT];
};
struct hidpp20_onboard_profiles_info {