mirror of
https://github.com/libratbag/libratbag.git
synced 2026-11-07 23:23:52 +01:00
drivers: make .write_resolution_dpi() takes the resolution, not the profile
This allows to set whichever resolution we want within the profile. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
This commit is contained in:
@@ -453,11 +453,13 @@ etekcity_write_button(struct ratbag_button *button,
|
||||
}
|
||||
|
||||
static int
|
||||
etekcity_write_resolution_dpi(struct ratbag_profile *profile, int dpi)
|
||||
etekcity_write_resolution_dpi(struct ratbag_resolution *resolution, int dpi)
|
||||
{
|
||||
struct ratbag_profile *profile = resolution->profile;
|
||||
struct ratbag_device *device = profile->device;
|
||||
struct etekcity_data *drv_data = ratbag_get_drv_data(device);
|
||||
struct etekcity_settings_report *settings_report;
|
||||
unsigned int index;
|
||||
uint8_t *buf;
|
||||
int rc;
|
||||
|
||||
@@ -466,12 +468,14 @@ etekcity_write_resolution_dpi(struct ratbag_profile *profile, int dpi)
|
||||
|
||||
settings_report = &drv_data->settings[profile->index];
|
||||
|
||||
/* FIXME: we should be able to say which dpi setting we change */
|
||||
/* retrieve which resolution is asked to be changed */
|
||||
index = resolution - profile->resolution.modes;
|
||||
|
||||
/* FIXME: allow both x and y dpi to be set */
|
||||
settings_report->x_sensitivity = 0x0a;
|
||||
settings_report->y_sensitivity = 0x0a;
|
||||
settings_report->xres[settings_report->current_dpi] = dpi / 50;
|
||||
settings_report->yres[settings_report->current_dpi] = dpi / 50;
|
||||
settings_report->xres[index] = dpi / 50;
|
||||
settings_report->yres[index] = dpi / 50;
|
||||
|
||||
buf = (uint8_t*)settings_report;
|
||||
etekcity_set_config_profile(device, profile->index, ETEKCITY_CONFIG_SETTINGS);
|
||||
|
||||
@@ -222,8 +222,9 @@ hidpp20drv_read_resolution_dpi(struct ratbag_profile *profile)
|
||||
}
|
||||
|
||||
static int
|
||||
hidpp20drv_write_resolution_dpi(struct ratbag_profile *profile, int dpi)
|
||||
hidpp20drv_write_resolution_dpi(struct ratbag_resolution *resolution, int dpi)
|
||||
{
|
||||
struct ratbag_profile *profile = resolution->profile;
|
||||
struct ratbag_device *device = profile->device;
|
||||
struct hidpp20drv_data *drv_data = ratbag_get_drv_data(device);
|
||||
struct hidpp20_sensor *sensor;
|
||||
|
||||
@@ -173,7 +173,7 @@ struct ratbag_driver {
|
||||
*
|
||||
* Mandatory if the driver exports RATBAG_CAP_SWITCHABLE_RESOLUTION.
|
||||
*/
|
||||
int (*write_resolution_dpi)(struct ratbag_profile *profile, int dpi);
|
||||
int (*write_resolution_dpi)(struct ratbag_resolution *resolution, int dpi);
|
||||
|
||||
/* private */
|
||||
struct list link;
|
||||
|
||||
@@ -751,7 +751,7 @@ ratbag_resolution_set_dpi(struct ratbag_resolution *resolution,
|
||||
resolution->dpi = dpi;
|
||||
|
||||
assert(profile->device->driver->write_resolution_dpi);
|
||||
return profile->device->driver->write_resolution_dpi(profile, dpi);
|
||||
return profile->device->driver->write_resolution_dpi(resolution, dpi);
|
||||
}
|
||||
|
||||
LIBRATBAG_EXPORT int
|
||||
|
||||
Reference in New Issue
Block a user