mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-29 18:20:09 +01:00
quirks: add quirks_get_double()
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
0021f9e7a8
commit
1cc9f44e93
3 changed files with 34 additions and 0 deletions
20
src/quirks.c
20
src/quirks.c
|
|
@ -54,6 +54,7 @@ enum property_type {
|
|||
PT_BOOL,
|
||||
PT_DIMENSION,
|
||||
PT_RANGE,
|
||||
PT_DOUBLE,
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -74,6 +75,7 @@ struct property {
|
|||
char *s;
|
||||
struct quirk_dimensions dim;
|
||||
struct quirk_range range;
|
||||
double d;
|
||||
} value;
|
||||
};
|
||||
|
||||
|
|
@ -1434,6 +1436,24 @@ quirks_get_uint32(struct quirks *q, enum quirk which, uint32_t *val)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
quirks_get_double(struct quirks *q, enum quirk which, double *val)
|
||||
{
|
||||
struct property *p;
|
||||
|
||||
if (!q)
|
||||
return false;
|
||||
|
||||
p = quirk_find_prop(q, which);
|
||||
if (!p)
|
||||
return false;
|
||||
|
||||
assert(p->type == PT_DOUBLE);
|
||||
*val = p->value.d;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
quirks_get_string(struct quirks *q, enum quirk which, char **val)
|
||||
{
|
||||
|
|
|
|||
13
src/quirks.h
13
src/quirks.h
|
|
@ -216,6 +216,19 @@ quirks_get_int32(struct quirks *q,
|
|||
enum quirk which,
|
||||
int32_t *val);
|
||||
|
||||
/**
|
||||
* Get the value of the given quirk, as double.
|
||||
* This function will assert if the quirk type does not match the
|
||||
* requested type. If the quirk is not set for this device, val is
|
||||
* unchanged.
|
||||
*
|
||||
* @return true if the quirk value is valid, false otherwise.
|
||||
*/
|
||||
bool
|
||||
quirks_get_double(struct quirks *q,
|
||||
enum quirk which,
|
||||
double *val);
|
||||
|
||||
/**
|
||||
* Get the value of the given quirk, as string.
|
||||
* This function will assert if the quirk type does not match the
|
||||
|
|
|
|||
|
|
@ -630,6 +630,7 @@ tools_list_device_quirks(struct quirks_context *ctx,
|
|||
struct quirk_range r;
|
||||
uint32_t v;
|
||||
char *s;
|
||||
double d;
|
||||
|
||||
if (!quirks_has_quirk(quirks, *q))
|
||||
continue;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue