forked from drath/libratbag
profiles: add a per profile capabilities field
Doesn't do much now without the next commit Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
This commit is contained in:
committed by
Peter Hutterer
parent
7c650aeeca
commit
97a927bb7d
@@ -70,6 +70,10 @@ test_read_profile(struct ratbag_profile *profile, unsigned int index)
|
||||
|
||||
profile->is_active = p->active;
|
||||
profile->is_enabled = !p->disabled;
|
||||
|
||||
for (i = 0; i < ARRAY_LENGTH(p->caps) && p->caps[i]; i++) {
|
||||
ratbag_profile_set_cap(profile, p->caps[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
|
||||
@@ -277,6 +277,7 @@ struct ratbag_profile {
|
||||
bool is_active; /**< profile is the currently active one */
|
||||
bool is_enabled;
|
||||
bool dirty; /**< profile changed since last commit */
|
||||
unsigned long capabilities[NLONGS(MAX_CAP)];
|
||||
};
|
||||
|
||||
#define BUTTON_ACTION_NONE \
|
||||
@@ -397,6 +398,15 @@ ratbag_profile_get_drv_data(struct ratbag_profile *profile)
|
||||
return profile->drv_data;
|
||||
}
|
||||
|
||||
static inline void
|
||||
ratbag_profile_set_cap(struct ratbag_profile *profile,
|
||||
enum ratbag_profile_capability cap)
|
||||
{
|
||||
assert(cap <= MAX_CAP);
|
||||
|
||||
long_set_bit(profile->capabilities, cap);
|
||||
}
|
||||
|
||||
static inline int
|
||||
ratbag_button_action_match(const struct ratbag_button_action *action,
|
||||
const struct ratbag_button_action *match)
|
||||
|
||||
@@ -76,6 +76,7 @@ struct ratbag_test_profile {
|
||||
bool active;
|
||||
bool dflt;
|
||||
bool disabled;
|
||||
uint32_t caps[10];
|
||||
};
|
||||
|
||||
struct ratbag_test_device {
|
||||
|
||||
@@ -634,6 +634,16 @@ ratbag_profile_init_leds(struct ratbag_profile *profile, unsigned int count)
|
||||
return 0;
|
||||
}
|
||||
|
||||
LIBRATBAG_EXPORT int
|
||||
ratbag_profile_has_capability(const struct ratbag_profile *profile,
|
||||
enum ratbag_profile_capability cap)
|
||||
{
|
||||
if (cap == RATBAG_PROFILE_CAP_NONE || cap >= MAX_CAP)
|
||||
abort();
|
||||
|
||||
return long_bit_is_set(profile->capabilities, cap);
|
||||
}
|
||||
|
||||
static struct ratbag_profile *
|
||||
ratbag_create_profile(struct ratbag_device *device,
|
||||
unsigned int index,
|
||||
|
||||
@@ -646,6 +646,12 @@ ratbag_device_get_num_buttons(struct ratbag_device *device);
|
||||
unsigned int
|
||||
ratbag_device_get_num_leds(struct ratbag_device *device);
|
||||
|
||||
/**
|
||||
* @ingroup profile
|
||||
*/
|
||||
enum ratbag_profile_capability {
|
||||
RATBAG_PROFILE_CAP_NONE = 0,
|
||||
};
|
||||
/**
|
||||
* @ingroup profile
|
||||
*
|
||||
@@ -671,6 +677,17 @@ ratbag_profile_ref(struct ratbag_profile *profile);
|
||||
struct ratbag_profile *
|
||||
ratbag_profile_unref(struct ratbag_profile *profile);
|
||||
|
||||
/**
|
||||
* @ingroup profile
|
||||
*
|
||||
* Check if a profile has a specific capability.
|
||||
*
|
||||
* @return non-zero if the capability is available, zero otherwise.
|
||||
*/
|
||||
int
|
||||
ratbag_profile_has_capability(const struct ratbag_profile *profile,
|
||||
enum ratbag_profile_capability cap);
|
||||
|
||||
/**
|
||||
* @ingroup profile
|
||||
*
|
||||
|
||||
@@ -62,6 +62,7 @@ global:
|
||||
ratbag_profile_get_num_resolutions;
|
||||
ratbag_profile_get_resolution;
|
||||
ratbag_profile_get_user_data;
|
||||
ratbag_profile_has_capability;
|
||||
ratbag_profile_is_active;
|
||||
ratbag_profile_is_enabled;
|
||||
ratbag_profile_ref;
|
||||
|
||||
Reference in New Issue
Block a user