forked from drath/libratbag
Add a helper function to init a resolution mode
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
@@ -500,14 +500,16 @@ etekcity_read_profile(struct ratbag_profile *profile, unsigned int index)
|
||||
dpi_list = setting_report->xres;
|
||||
|
||||
for (i = 0; i < ETEKCITY_NUM_DPI; i++) {
|
||||
int dpi, hz;
|
||||
resolution = &profile->resolution.modes[i];
|
||||
resolution->dpi = dpi_list[i] * 50;
|
||||
resolution->hz = report_rate;
|
||||
dpi = dpi_list[i] * 50;
|
||||
hz = report_rate;
|
||||
if (!(setting_report->dpi_mask & (1 << i))) {
|
||||
/* the profile is disabled, overwrite it */
|
||||
resolution->dpi = 0;
|
||||
resolution->hz = 0;
|
||||
}
|
||||
ratbag_resolution_init(profile, i, dpi,hz);
|
||||
resolution->is_active = (i == setting_report->current_dpi);
|
||||
}
|
||||
|
||||
|
||||
@@ -139,9 +139,8 @@ hidpp10drv_read_profile(struct ratbag_profile *profile, unsigned int index)
|
||||
profile->resolution.num_modes = p.num_dpi_modes;
|
||||
for (i = 0; i < p.num_dpi_modes; i++) {
|
||||
/* FIXME: we should expose x/y res separately */
|
||||
profile->resolution.modes[i].dpi = p.dpi_modes[i].xres;
|
||||
profile->resolution.modes[i].hz = p.refresh_rate;
|
||||
profile->resolution.modes[i].is_active = false;
|
||||
ratbag_resolution_init(profile, i, p.dpi_modes[i].xres,
|
||||
p.refresh_rate);
|
||||
if (profile->is_active && profile->resolution.modes[i].dpi == xres)
|
||||
profile->resolution.modes[i].is_active = true;
|
||||
if (i == p.default_dpi_mode)
|
||||
|
||||
@@ -207,9 +207,9 @@ hidpp20drv_read_resolution_dpi(struct ratbag_profile *profile)
|
||||
drv_data->num_sensors = MAX_RESOLUTIONS;
|
||||
profile->resolution.num_modes = drv_data->num_sensors;
|
||||
for (i = 0; i < profile->resolution.num_modes; i++) {
|
||||
profile->resolution.modes[i].dpi = drv_data->sensors[i].dpi;
|
||||
/* FIXME: retrieve the refresh rate */
|
||||
profile->resolution.modes[i].hz = 0;
|
||||
ratbag_resolution_init(profile, i, drv_data->sensors[i].dpi, 0);
|
||||
|
||||
/* FIXME: we mark all resolutions as active because
|
||||
* they are from different sensors */
|
||||
profile->resolution.modes[i].is_active = true;
|
||||
|
||||
@@ -307,6 +307,18 @@ ratbag_button_action_match(const struct ratbag_button_action *action,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void
|
||||
ratbag_resolution_init(struct ratbag_profile *profile, int index, int dpi, int hz)
|
||||
{
|
||||
struct ratbag_resolution *res = &profile->resolution.modes[index];
|
||||
|
||||
res->profile = profile;
|
||||
res->dpi = dpi;
|
||||
res->hz = hz;
|
||||
res->is_active = false;
|
||||
res->is_default = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override the auto-picked hidraw device.
|
||||
*/
|
||||
|
||||
@@ -568,7 +568,7 @@ ratbag_create_profile(struct ratbag_device *device,
|
||||
list_init(&profile->buttons);
|
||||
|
||||
for (i = 0; i < MAX_RESOLUTIONS; i++)
|
||||
profile->resolution.modes[i].profile = profile;
|
||||
ratbag_resolution_init(profile, i, 0, 0);
|
||||
|
||||
assert(device->driver->read_profile);
|
||||
device->driver->read_profile(profile, index);
|
||||
|
||||
Reference in New Issue
Block a user