mirror of
https://github.com/libratbag/libratbag.git
synced 2026-11-07 23:23:52 +01:00
Add ratbag_resolution_set/get_default
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
@@ -148,6 +148,8 @@ hidpp10drv_read_profile(struct ratbag_profile *profile, unsigned int index)
|
||||
* active profile */
|
||||
if (profile->resolution.modes[i].dpi == xres)
|
||||
profile->resolution.modes[i].is_active = true;
|
||||
if (i == p.default_dpi_mode)
|
||||
profile->resolution.modes[i].is_default = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -187,6 +187,7 @@ struct ratbag_resolution{
|
||||
unsigned int dpi; /**< resolution on dpi */
|
||||
unsigned int hz; /**< report rate in Hz */
|
||||
bool is_active;
|
||||
bool is_default;
|
||||
};
|
||||
|
||||
struct ratbag_profile {
|
||||
|
||||
@@ -787,6 +787,20 @@ ratbag_resolution_set_active(struct ratbag_resolution *resolution)
|
||||
}
|
||||
|
||||
|
||||
LIBRATBAG_EXPORT int
|
||||
ratbag_resolution_is_default(const struct ratbag_resolution *resolution)
|
||||
{
|
||||
return resolution->is_default;
|
||||
}
|
||||
|
||||
LIBRATBAG_EXPORT int
|
||||
ratbag_resolution_set_default(struct ratbag_resolution *resolution)
|
||||
{
|
||||
resolution->is_default = true;
|
||||
/* FIXME: call into the driver */
|
||||
return 0;
|
||||
}
|
||||
|
||||
LIBRATBAG_EXPORT struct ratbag_button*
|
||||
ratbag_profile_get_button_by_index(struct ratbag_profile *profile,
|
||||
unsigned int index)
|
||||
|
||||
@@ -593,9 +593,8 @@ ratbag_resolution_get_report_rate(struct ratbag_resolution *resolution);
|
||||
* Activate the given resolution mode. If the mode is not configured, this
|
||||
* function returns an error and the result is undefined.
|
||||
*
|
||||
* If the profile is the currently active profile, the change takes effect
|
||||
* immediately. Otherwise, the resolution mode will be the active mode when
|
||||
* the device switches to the profile next.
|
||||
* The mode must be one of the current profile, otherwise an error is
|
||||
* returned.
|
||||
*
|
||||
* @param resolution A previously initialized ratbag resolution
|
||||
*
|
||||
@@ -610,8 +609,7 @@ ratbag_resolution_set_active(struct ratbag_resolution *resolution);
|
||||
* Check if the resolution mode is the currently active one.
|
||||
*
|
||||
* If the profile is the currently active profile, the mode is the one
|
||||
* currently active. Otherwise, the resolution mode is the one used when
|
||||
* the device switches to the profile next.
|
||||
* currently active. For profiles not currently active, this always returns 0.
|
||||
*
|
||||
* @param resolution A previously initialized ratbag resolution
|
||||
*
|
||||
@@ -621,6 +619,41 @@ ratbag_resolution_set_active(struct ratbag_resolution *resolution);
|
||||
int
|
||||
ratbag_resolution_is_active(const struct ratbag_resolution *resolution);
|
||||
|
||||
/**
|
||||
* @ingroup resolution
|
||||
*
|
||||
* Set the default resolution mode for the associated profile. When the
|
||||
* device switches to the profile next, this mode will be the active
|
||||
* resolution. If the mode is not configured, this function returns an error
|
||||
* and the result is undefined.
|
||||
*
|
||||
* This only switches the default resolution, not the currently active
|
||||
* resolution. Use ratbag_resolution_set_active() instead.
|
||||
*
|
||||
* @param resolution A previously initialized ratbag resolution
|
||||
*
|
||||
* @return zero on success, non-zero otherwise
|
||||
*/
|
||||
int
|
||||
ratbag_resolution_set_default(struct ratbag_resolution *resolution);
|
||||
|
||||
/**
|
||||
* @ingroup resolution
|
||||
*
|
||||
* Check if the resolution mode is the default one in this profile.
|
||||
*
|
||||
* The default resolution is the one the device selects when switching to
|
||||
* the corresponding profile. It may not be the currently active resolution,
|
||||
* use ratbag_resolution_is_active() instead.
|
||||
*
|
||||
* @param resolution A previously initialized ratbag resolution
|
||||
*
|
||||
* @return Non-zero if the resolution mode is the default one, zero
|
||||
* otherwise.
|
||||
*/
|
||||
int
|
||||
ratbag_resolution_is_default(const struct ratbag_resolution *resolution);
|
||||
|
||||
/**
|
||||
* @ingroup profile
|
||||
*
|
||||
|
||||
@@ -43,8 +43,10 @@ global:
|
||||
ratbag_resolution_get_report_rate;
|
||||
ratbag_resolution_get_user_data;
|
||||
ratbag_resolution_is_active;
|
||||
ratbag_resolution_is_default;
|
||||
ratbag_resolution_ref;
|
||||
ratbag_resolution_set_active;
|
||||
ratbag_resolution_set_default;
|
||||
ratbag_resolution_set_dpi;
|
||||
ratbag_resolution_set_report_rate;
|
||||
ratbag_resolution_set_user_data;
|
||||
|
||||
@@ -330,8 +330,9 @@ ratbag_cmd_info(struct ratbag *ratbag, uint32_t flags, int argc, char **argv)
|
||||
res = ratbag_profile_get_resolution(profile, j);
|
||||
dpi = ratbag_resolution_get_dpi(res);
|
||||
rate = ratbag_resolution_get_report_rate(res);
|
||||
printf(" %d: %ddpi @ %dHz%s\n", i, dpi, rate,
|
||||
ratbag_resolution_is_active(res) ? " (active)" : "");
|
||||
printf(" %d: %ddpi @ %dHz%s%s\n", i, dpi, rate,
|
||||
ratbag_resolution_is_active(res) ? " (active)" : "",
|
||||
ratbag_resolution_is_default(res) ? " (default)" : "");
|
||||
|
||||
ratbag_resolution_unref(res);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user