[PATCH libinput 14/15] tablet: add support for libinput_tool_has_button

Peter Hutterer peter.hutterer at who-t.net
Sun Feb 22 18:39:26 PST 2015


On Sun, Feb 22, 2015 at 07:48:03PM -0500, Lyude wrote:
> On Wed, 2015-02-18 at 15:45 +1000, Peter Hutterer wrote:
> > The mouse like devices have LMR, SIDE and EXTRA.
> > PENCIL (which is the Wacom Inking) and the eraser have no buttons.
> > AIRBRUSH has only one button, all other pens have two.
> > 
> > Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> > ---
[...]
> > diff --git a/src/libinput.c b/src/libinput.c
> > index 7c90f37..3a8c07f 100644
> > --- a/src/libinput.c
> > +++ b/src/libinput.c
> > @@ -677,6 +677,17 @@ libinput_tool_has_axis(struct libinput_tool *tool,
> >  	return bit_is_set(tool->axis_caps, axis);
> >  }
> >  
> > +LIBINPUT_EXPORT int
> > +libinput_tool_has_button(struct libinput_tool *tool,
> > +			 uint32_t code)
> > +{
> > +	if (NCHARS(code) > sizeof(tool->buttons))
> > +		return 0;
> > +
> > +	return bit_is_set(tool->buttons, code);
> > +}
> > +
> > +
> Everything looks great, although you've got an extra bit of whitespace
> right here :).

Ah, thanks. Already fixed locally now that I found how to hook up
git-stripspace :)

fwiw:
$ git config filter.trimWhitespace.clean git-stripspace
$ echo "*.c" filter=trimWhitespace >> .git/info/attributes
$ echo "*.h" filter=trimWhitespace >> .git/info/attributes

Cheers,
   Peter

> 
> >  LIBINPUT_EXPORT void
> >  libinput_tool_set_user_data(struct libinput_tool *tool,
> >  			    void *user_data)
> > diff --git a/src/libinput.h b/src/libinput.h
> > index 461925a..36c0931 100644
> > --- a/src/libinput.h
> > +++ b/src/libinput.h
> > @@ -1222,6 +1222,21 @@ libinput_tool_has_axis(struct libinput_tool *tool,
> >  /**
> >   * @ingroup event_tablet
> >   *
> > + * Check if a tablet tool has a button with the
> > + * passed-in code (see linux/input.h).
> > + *
> > + * @param tool A tablet tool
> > + * @param code button code to check for
> > + *
> > + * @return 1 if the tool supports this button code, 0 if it does not
> > + */
> > +int
> > +libinput_tool_has_button(struct libinput_tool *tool,
> > +		         uint32_t code);
> > +
> > +/**
> > + * @ingroup event_tablet
> > + *
> >   * Decrement the ref count of tool by one. When the ref count of tool reaches 0,
> >   * the memory allocated for tool will be freed.
> >   *
> > diff --git a/src/libinput.sym b/src/libinput.sym
> > index b31c231..c4b5344 100644
> > --- a/src/libinput.sym
> > +++ b/src/libinput.sym
> > @@ -155,6 +155,7 @@ LIBINPUT_TABLET_SUPPORT {
> >  	libinput_tool_get_serial;
> >  	libinput_tool_get_type;
> >  	libinput_tool_get_user_data;
> > +	libinput_tool_has_button;
> >  	libinput_tool_has_axis;
> >  	libinput_tool_ref;
> >  	libinput_tool_set_user_data;
> 




More information about the wayland-devel mailing list