Re: [PATCH libinput] evdev: check model flags for actual booleans

2016-06-09 Thread Hans de Goede

Hi,

On 09-06-16 02:53, Peter Hutterer wrote:

The hwdb doesn't allow unsetting a property so once we start nesting model
flags it'll become important to be able to be able to unset one as well (by
assigning it to 0).

So rather than checking for existence, check whether the property is actually
set to something resembling a boolean.

Signed-off-by: Peter Hutterer 


patch looks good to me:

Reviewed-by: Hans de Goede 

Regards,

Hans



---
 src/evdev.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/evdev.c b/src/evdev.c
index 0227f51..e0923cd 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1813,10 +1813,12 @@ evdev_read_model_flags(struct evdev_device *device)
};
const struct model_map *m = model_map;
uint32_t model_flags = 0;
+   const char *val;

while (m->property) {
-   if (!!udev_device_get_property_value(device->udev_device,
-m->property)) {
+   val = udev_device_get_property_value(device->udev_device,
+m->property);
+   if (val && !streq(val, "0")) {
log_debug(device->base.seat->libinput,
  "%s: tagged as %s\n",
  evdev_device_get_sysname(device),


___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH libinput] evdev: check model flags for actual booleans

2016-06-08 Thread Vasily Khoruzhick
On Wed, Jun 8, 2016 at 5:53 PM, Peter Hutterer  wrote:
> The hwdb doesn't allow unsetting a property so once we start nesting model
> flags it'll become important to be able to be able to unset one as well (by
> assigning it to 0).
>
> So rather than checking for existence, check whether the property is actually
> set to something resembling a boolean.
>
> Signed-off-by: Peter Hutterer 

Tested-by: Vasily Khoruzhick 

> ---
>  src/evdev.c | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/src/evdev.c b/src/evdev.c
> index 0227f51..e0923cd 100644
> --- a/src/evdev.c
> +++ b/src/evdev.c
> @@ -1813,10 +1813,12 @@ evdev_read_model_flags(struct evdev_device *device)
> };
> const struct model_map *m = model_map;
> uint32_t model_flags = 0;
> +   const char *val;
>
> while (m->property) {
> -   if (!!udev_device_get_property_value(device->udev_device,
> -m->property)) {
> +   val = udev_device_get_property_value(device->udev_device,
> +m->property);
> +   if (val && !streq(val, "0")) {
> log_debug(device->base.seat->libinput,
>   "%s: tagged as %s\n",
>   evdev_device_get_sysname(device),
> --
> 2.7.4
>
> ___
> wayland-devel mailing list
> wayland-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/wayland-devel
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH libinput] evdev: check model flags for actual booleans

2016-06-08 Thread Peter Hutterer
The hwdb doesn't allow unsetting a property so once we start nesting model
flags it'll become important to be able to be able to unset one as well (by
assigning it to 0).

So rather than checking for existence, check whether the property is actually
set to something resembling a boolean.

Signed-off-by: Peter Hutterer 
---
 src/evdev.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/evdev.c b/src/evdev.c
index 0227f51..e0923cd 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1813,10 +1813,12 @@ evdev_read_model_flags(struct evdev_device *device)
};
const struct model_map *m = model_map;
uint32_t model_flags = 0;
+   const char *val;
 
while (m->property) {
-   if (!!udev_device_get_property_value(device->udev_device,
-m->property)) {
+   val = udev_device_get_property_value(device->udev_device,
+m->property);
+   if (val && !streq(val, "0")) {
log_debug(device->base.seat->libinput,
  "%s: tagged as %s\n",
  evdev_device_get_sysname(device),
-- 
2.7.4

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel