hidpp10: store the number of dpi_modes/buttons in the profile

Makes it easier to iterate through the profile without relying on global
variables.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer
2015-08-26 08:55:25 +10:00
parent cab9169e6f
commit 1d80ea4898
2 changed files with 5 additions and 0 deletions

View File

@@ -422,6 +422,7 @@ hidpp10_get_profile(struct hidpp10_device *dev, int8_t number, struct hidpp10_pr
profile.default_dpi_mode = p->default_dpi_mode;
profile.refresh_rate = p->usb_refresh_rate ? 1000/p->usb_refresh_rate : 0;
profile.num_dpi_modes = PROFILE_NUM_DPI_MODES;
for (i = 0; i < PROFILE_NUM_DPI_MODES; i++) {
uint8_t *be; /* in big endian */
struct _hidpp10_dpi_mode *dpi = &p->dpi_modes[i];
@@ -437,6 +438,7 @@ hidpp10_get_profile(struct hidpp10_device *dev, int8_t number, struct hidpp10_pr
profile.dpi_modes[i].led[3] = dpi->led4 == 0x2;
}
profile.num_buttons = PROFILE_NUM_BUTTONS;
for (i = 0; i < PROFILE_NUM_BUTTONS; i++) {
union _hidpp10_button_binding *b = &p->buttons[i];
union hidpp10_buttons *button = &profile.buttons[i];

View File

@@ -130,6 +130,8 @@ struct hidpp10_profile {
uint16_t yres;
bool led[4];
} dpi_modes[5];
size_t num_dpi_modes;
bool angle_correction;
uint8_t default_dpi_mode;
uint16_t refresh_rate;
@@ -156,6 +158,7 @@ struct hidpp10_profile {
uint8_t type;
} disabled;
} buttons[PROFILE_NUM_BUTTONS];
size_t num_buttons;
};
int