roccat-kone-pure: migrate to profile-oriented API

This commit is contained in:
Yaroslav Chvanov
2022-01-31 19:56:25 +03:00
committed by Ilya guterman
parent 7f0d058b66
commit ee54001032

View File

@@ -603,9 +603,9 @@ roccat_write_macro(struct ratbag_button *button,
}
static int
roccat_write_button(struct ratbag_button *button,
const struct ratbag_button_action *action)
roccat_write_button(struct ratbag_button *button)
{
const struct ratbag_button_action *action = &button->action;
struct ratbag_profile *profile = button->profile;
struct ratbag_device *device = profile->device;
struct roccat_data *drv_data = ratbag_get_drv_data(device);
@@ -639,8 +639,7 @@ roccat_write_button(struct ratbag_button *button,
}
static int
roccat_write_resolution_dpi(struct ratbag_resolution *resolution,
int dpi_x, int dpi_y)
roccat_write_resolution(struct ratbag_resolution *resolution)
{
struct ratbag_profile *profile = resolution->profile;
struct ratbag_device *device = profile->device;
@@ -649,7 +648,10 @@ roccat_write_resolution_dpi(struct ratbag_resolution *resolution,
uint8_t *buf;
int rc;
if (dpi_x < 100 || dpi_x > 5000 || dpi_x % 50)
const unsigned int dpi_x = resolution->dpi_x;
const unsigned int dpi_y = resolution->dpi_y;
if (dpi_x < 200 || dpi_x > 8200 || dpi_x % 50)
return -EINVAL;
if (dpi_y < 100 || dpi_y > 5000 || dpi_y % 50)
return -EINVAL;
@@ -833,13 +835,50 @@ roccat_remove(struct ratbag_device *device)
free(ratbag_get_drv_data(device));
}
static int
roccat_commit(struct ratbag_device *device)
{
int rc = 0;
struct ratbag_button *button = NULL;
struct ratbag_profile *profile = NULL;
struct ratbag_resolution *resolution = NULL;
ratbag_device_for_each_profile(device, profile) {
if (!profile->dirty)
continue;
rc = roccat_write_profile(profile);
if (rc)
return rc;
ratbag_profile_for_each_resolution(profile, resolution) {
if (!resolution->dirty)
continue;
rc = roccat_write_resolution(resolution);
if (rc)
return rc;
}
ratbag_profile_for_each_button(profile, button) {
if (!button->dirty)
continue;
rc = roccat_write_button(button);
if (rc)
return rc;
}
}
return 0;
}
struct ratbag_driver roccat_kone_pure_driver = {
.name = "Roccat Kone Pure",
.id = "roccat-kone-pure",
.probe = roccat_probe,
.remove = roccat_remove,
.write_profile = roccat_write_profile,
.commit = roccat_commit,
.set_active_profile = roccat_set_current_profile,
.write_button = roccat_write_button,
.write_resolution_dpi = roccat_write_resolution_dpi,
};