Re: [RFC libinput] Import buttonset interface

2016-05-03 Thread PrasannaKumar Muralidharan
> simply said, I don't know. It's one of the things where we have to write
> most of the interface, see if it makes sense and then remove the bits that
> we don't actually need. your main target right now is a rotary encoder
> but I do encourage you to think of how to deal with other devices that are
> generic devices (tv remotes, maybe a 3d mouse, dj mixers, etc.) and
> incorporate them. an interface just suitable for a rotary encoder won't get
> merged.

Sure I will think and come up with a patch.
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [RFC libinput] Import buttonset interface

2016-04-22 Thread PrasannaKumar Muralidharan
> fwiw, it's very frowned upon to take someone else's patch, rebase it and
> then send it on as your own when it has very little changes. Please keep
> original authorship while it makes sense and add the author as co-author
> where substantial changes have been made.

I definitely did not intend to claim this as my patch. I will set the
correct author when I send the patch again with modifications.

> tbh, I'm not quite sure what to review here though, without a backend
> implementation this is quite theoretical. I'm assuming you just want a
> quick review to make sure nothing obvious got lost in the rebase?
> If so, yes, looks ok, thanks.

Yes. This is one of things I wanted to understand.

> There are a couple of questions that arose from the
> wacom tablet button switch, specifically:
> * what use do the linux/input.h button codes have in the buttonset
>   interface? We will run similar issues with the evdev button code ranges as
>   we did with the pad, where the button code is meaningless.
> * the various axes are nice to have, but without a user I'm hesitant to
>   merge them - we'll need to know how they could be used first

I am dealing is similar to rotary encoder, buttonset interface is the
required for it. I am not aware of the issue mentioned above. I would
prefer to have some guidance on what should be changed or removed. The
main objective of the patch sent is exactly this - I wanted to know
what I have to do to get the buttonset interface merged.

> * ring and strip are absolute, they are wacom-only axes and until we get a
>   device that needs either, we should leave them out.

Will remove them.

> * the seat button count should be removed, it doesn't make sense for a
>   buttonset device
> * get_(x|y)* does not need an axis argument, I struggle to think of a device
>   that has two x or y axes on the same event node.
>
> Other than that I still think that the general approach with numbered axes
> and axis types makes sense.

Okay. Will change accordingly.

>> This change is compile tested.
>
> That's not a confidence-inspiring statement... :)

Agreed. I will follow up with dial input support and will have a
proper working version by then.

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


[RFC libinput] Import buttonset interface

2016-04-21 Thread PrasannaKumar Muralidharan
From: PrasannaKumar Muralidharan 

Import buttonset interface code from
https://github.com/whot/libinput/tree/wip/buttonbox-interface.

There is no user for buttonset interface as of now. I have taken the
buttonset interface code and removed code related to wacom tablet.
Please review the changes. Once this is reviewed will add dial
input support, add test and send another patch.

This change is compile tested.
---
 src/evdev.c|  74 ++-
 src/evdev.h|  33 +++
 src/libinput-private.h |  31 +++
 src/libinput.c | 482 ++
 src/libinput.h | 563 -
 5 files changed, 1181 insertions(+), 2 deletions(-)

diff --git a/src/evdev.c b/src/evdev.c
index afc4710..cab28ff 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -67,6 +67,7 @@ enum evdev_device_udev_tags {
 EVDEV_UDEV_TAG_ACCELEROMETER = (1 << 7),
 EVDEV_UDEV_TAG_TABLET_PAD = (1 << 8),
 EVDEV_UDEV_TAG_POINTINGSTICK = (1 << 9),
+EVDEV_UDEV_TAG_BUTTONSET = (1 << 10),
 };
 
 struct evdev_udev_tag_match {
@@ -86,6 +87,7 @@ static const struct evdev_udev_tag_match 
evdev_udev_tag_matches[] = {
{"ID_INPUT_JOYSTICK",   EVDEV_UDEV_TAG_JOYSTICK},
{"ID_INPUT_ACCELEROMETER",  EVDEV_UDEV_TAG_ACCELEROMETER},
{"ID_INPUT_POINTINGSTICK",  EVDEV_UDEV_TAG_POINTINGSTICK},
+   {"ID_INPUT_TABLET_BUTTONSET",   EVDEV_UDEV_TAG_BUTTONSET},
 
/* sentinel value */
{ 0 },
@@ -318,6 +320,26 @@ evdev_device_transform_y(struct evdev_device *device,
return scale_axis(device->abs.absinfo_y, y, height);
 }
 
+double
+evdev_device_transform_x_mm(struct evdev_device *device,
+   double mm,
+   uint32_t width)
+{
+   mm *= device->abs.absinfo_x->resolution;
+
+   return evdev_device_transform_x(device, mm, width);
+}
+
+double
+evdev_device_transform_y_mm(struct evdev_device *device,
+   double mm,
+   uint32_t height)
+{
+   mm *= device->abs.absinfo_y->resolution;
+
+   return evdev_device_transform_y(device, mm, height);
+}
+
 static inline void
 normalize_delta(struct evdev_device *device,
const struct device_coords *delta,
@@ -1028,6 +1050,9 @@ struct evdev_dispatch_interface fallback_interface = {
NULL, /* device_suspended */
NULL, /* device_resumed */
NULL, /* post_added */
+   NULL, /* buttonset_to_phys */
+   NULL, /* buttonset_get_num_axes */
+   NULL, /* buttonset_get_axis_type */
 };
 
 static uint32_t
@@ -2086,7 +2111,8 @@ evdev_configure_device(struct evdev_device *device)
 udev_tags & EVDEV_UDEV_TAG_POINTINGSTICK ? " Pointingstick" : 
"",
 udev_tags & EVDEV_UDEV_TAG_JOYSTICK ? " Joystick" : "",
 udev_tags & EVDEV_UDEV_TAG_ACCELEROMETER ? " Accelerometer" : 
"",
-udev_tags & EVDEV_UDEV_TAG_TABLET_PAD ? " TabletPad" : "");
+udev_tags & EVDEV_UDEV_TAG_TABLET_PAD ? " TabletPad" : "",
+udev_tags & EVDEV_UDEV_TAG_BUTTONSET ? " Buttonset" : "");
 
if (udev_tags & EVDEV_UDEV_TAG_ACCELEROMETER) {
log_info(libinput,
@@ -2158,6 +2184,17 @@ evdev_configure_device(struct evdev_device *device)
return device->dispatch == NULL ? -1 : 0;
}
 
+#if 0
+   if (udev_tags & EVDEV_UDEV_TAG_BUTTONSET) {
+   device->dispatch = evdev_buttonset_create(device);
+   device->seat_caps |= EVDEV_DEVICE_BUTTONSET;
+   log_info(libinput,
+"input device '%s', %s is a buttonset\n",
+device->devname, devnode);
+   return device->dispatch == NULL ? -1 : 0;
+   }
+#endif
+
if (udev_tags & EVDEV_UDEV_TAG_TOUCHPAD) {
device->dispatch = evdev_mt_touchpad_create(device);
log_info(libinput,
@@ -2580,6 +2617,8 @@ evdev_device_has_capability(struct evdev_device *device,
return !!(device->seat_caps & EVDEV_DEVICE_TABLET);
case LIBINPUT_DEVICE_CAP_TABLET_PAD:
return !!(device->seat_caps & EVDEV_DEVICE_TABLET_PAD);
+   case LIBINPUT_DEVICE_CAP_BUTTONSET:
+   return !!(device->seat_caps & EVDEV_DEVICE_BUTTONSET);
default:
return 0;
}
@@ -2623,6 +2662,39 @@ evdev_device_has_key(struct evdev_device *device, 
uint32_t code)
return libevdev_has_event_code(device->evdev, EV_KEY, code);
 }
 
+int
+evdev_device_buttonset_has_button(struct evdev_device *device,
+

Re: [RFC libinput] Add dial input device support

2016-02-21 Thread PrasannaKumar Muralidharan
> remember that libinput is a low-level library and doesn't know about how a
> specific device is being used by the layers above it. Hence a value in
> degrees isn't any less useful than a value in miscellaneous units which is
> what the _discrete() API bit is for. If the caller cares about units, it
> uses discrete steps, if it cares about number of rotations, it uses
> degrees.
>
> The only requirement in libinput is that you have a units -> physical
> degrees mapping which is something we used the hwdb for (in the case of
> mouse wheels anyway).

Got it.

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


Re: [RFC libinput] Add dial input device support

2016-02-19 Thread PrasannaKumar Muralidharan
> right. the approach we used for this was to have an API that exports the
> value in degrees and an API for get_value_discrete() or similarly named.
> Look up the libinput_event_pointer*axis* API to get an idea.

For several devices (example dimmers used for controlling lamps) value
in degrees is not useful. Exported value depends on device.

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


Re: [RFC libinput] Add dial input device support

2016-02-19 Thread PrasannaKumar Muralidharan
Hi Andreas,

> Instead of car steering wheels I would rather mention rotaty knobs that are
> common in car infotainment  systems to navigate through menues. Those are
> relative - you never get absolute angles just rotation ticks.
> But is that the type of device you had in mind? Those devices usually have a
> bunch of further buttons.. so buttonset sounds like a good generalization
> for those too.

Yes buttonset interface suits well for dial.

As of now kernel provides REL_DIAL. As of now I am thinking about
rotatory knobs or something like PowerMate device. Other use case is
dimmers used for light / lamps which return absolute value, has some
maximum value. I did not look much to find absolute dial interface
from kernel, so skipping it for now. I guess ABS_WHEEL Is not suitable
for this type of devices.

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


Re: [RFC libinput] Add dial input device support

2016-02-18 Thread PrasannaKumar Muralidharan
Hi Peter,

Thanks for your time in looking at the patch.

> First: yes, implementing support for dial interfaces is within the scope of
> libinput, I think it makes sense to add this. But not quite in this form,
> the various CAP flags are libinput interfaces that denote a specific
> functionality. We should not add one per event group.

Makes sense.

> A while ago we started work on the so-called buttonset interface which is
> a generic interface to support a bunch of devices like yours:
> https://lists.freedesktop.org/archives/wayland-devel/2016-January/026670.html
>
> Since that patchset we've split out the wacom-specific parts so you can
> ignore any strip/ring handling. There is no dial axis atm, but there
> could be.
>
> Have a look at that patchset, the documentation should explain what the
> interface is for, etc. I think adding dial to buttonset and then getting
> that interface ready for merging is the best approach here.

Thanks for the info. Could not find the buttonset interface patch in
master branch yet. Will use buttonset interface and provide a patch
once it is merged. Does that make sense?

> One comment on the API (to save you from scrolling down):
> libinput_event_dial_get_rotation_count() should simply be
> libinput_event_dial_get_rotation() and return the value in degrees. This is
> more flexible than the current one which reads like it's multiples of 360
> degrees?

Certainly not multiple of 360 degree, value need not be in degree.
Dial is relative and returns +1, +2 or -2.
Will change the API based on the buttonset interface API convention.

Thanks and regards,
PrasannaKumar
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel


[RFC libinput] Add dial input device support

2016-02-15 Thread PrasannaKumar Muralidharan
From: PrasannaKumar Muralidharan 

I am implementing dial input device support and would like to get feedback on 
the code that I have implemented so far. Did not implement test cases as of 
now, any pointers on how the test framework works will be helpful.

Smartwatch can use dial input, Car can use steering wheel rotation as input for 
maps may be. But I would like to know if dial input device support is useful 
before proceeding further?

Appreciate positive and negative comments.

---
 src/Makefile.am|  2 ++
 src/evdev-dial.c   | 80 ++
 src/evdev-dial.h   |  6 
 src/evdev.c| 12 
 src/evdev.h|  6 
 src/libinput-private.h |  5 
 src/libinput.c | 74 ++
 src/libinput.h | 46 +
 src/libinput.sym   |  5 
 tools/event-debug.c| 23 +++
 10 files changed, 259 insertions(+)
 create mode 100644 src/evdev-dial.c
 create mode 100644 src/evdev-dial.h

diff --git a/src/Makefile.am b/src/Makefile.am
index 343e75c..20a32a5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -11,6 +11,8 @@ libinput_la_SOURCES = \
libinput-private.h  \
evdev.c \
evdev.h \
+   evdev-dial.c\
+   evdev-dial.h\
evdev-middle-button.c   \
evdev-mt-touchpad.c \
evdev-mt-touchpad.h \
diff --git a/src/evdev-dial.c b/src/evdev-dial.c
new file mode 100644
index 000..2427724
--- /dev/null
+++ b/src/evdev-dial.c
@@ -0,0 +1,80 @@
+#include "config.h"
+
+#include 
+#include 
+#include 
+#include 
+
+#include "evdev-dial.h"
+
+static void
+dial_process(struct evdev_dispatch *dispatch,
+struct evdev_device *device,
+struct input_event *event,
+uint64_t time)
+{
+   struct libinput_device *base = &device->base;
+   dial_notify(base, time, (int16_t)event->value);
+}
+
+/*
+static void
+dial_suspend(struct evdev_dispatch *dispatch,
+struct evdev_device *device)
+{
+
+}
+
+static void
+dial_remove(struct evdev_dispatch *dispatch)
+{
+
+}
+*/
+
+static void
+dial_destroy(struct evdev_dispatch *dispatch)
+{
+   free(dispatch);
+}
+
+/*
+static void
+dial_device_added(struct evdev_device *device,
+ struct evdev_device *added_device)
+{
+
+}
+
+static void
+dial_device_removed(struct evdev_device *device,
+   struct evdev_device *removed_device)
+{
+
+}
+*/
+
+/* TODO: Check whether other callbacks have to be implemented? */
+static struct evdev_dispatch_interface dial_interface = {
+   dial_process,
+   NULL, /* device suspend */
+   NULL, /* device remove */
+   dial_destroy,
+   NULL, /* device added */
+   NULL, /* device removed */
+   NULL, /* device suspended */
+   NULL, /* device resumed */
+   NULL, /* device post added */
+};
+
+struct evdev_dispatch *
+evdev_dial_create(struct evdev_device *device)
+{
+   struct evdev_dispatch *dispatch = zalloc(sizeof(struct evdev_dispatch));
+   if (!dispatch)
+   return NULL;
+
+   dispatch->interface = &dial_interface;
+
+   return dispatch;
+}
diff --git a/src/evdev-dial.h b/src/evdev-dial.h
new file mode 100644
index 000..0e191e7
--- /dev/null
+++ b/src/evdev-dial.h
@@ -0,0 +1,6 @@
+#ifndef EVDEV_DIAL_H
+#define EVDEV_DIAL_H
+
+#include "evdev.h"
+
+#endif /* EVDEV_DIAL_H */
diff --git a/src/evdev.c b/src/evdev.c
index 66673a8..1e044fb 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -63,6 +63,7 @@ enum evdev_device_udev_tags {
 EVDEV_UDEV_TAG_ACCELEROMETER = (1 << 7),
 EVDEV_UDEV_TAG_BUTTONSET = (1 << 8),
 EVDEV_UDEV_TAG_POINTINGSTICK = (1 << 9),
+EVDEV_UDEV_TAG_DIAL = (1 << 10),
 };
 
 struct evdev_udev_tag_match {
@@ -82,6 +83,7 @@ static const struct evdev_udev_tag_match 
evdev_udev_tag_matches[] = {
{"ID_INPUT_JOYSTICK",   EVDEV_UDEV_TAG_JOYSTICK},
{"ID_INPUT_ACCELEROMETER",  EVDEV_UDEV_TAG_ACCELEROMETER},
{"ID_INPUT_POINTINGSTICK",  EVDEV_UDEV_TAG_POINTINGSTICK},
+   {"ID_INPUT_DIAL",   EVDEV_UDEV_TAG_DIAL},
 
/* sentinel value */
{ 0 },
@@ -779,6 +781,7 @@ evdev_need_touch_frame(struct evdev_device *device)
switch (device->pending_event) {
case EVDEV_NONE:
case EVDEV_RELATIVE_MOTION:
+   case EVDEV_RELATIVE_DIAL:
break;
case EVDEV_ABSOLUTE_MT_DOWN:
case EVDEV_ABSOLUTE_MT_MOTION:
@@ -2157,6 +2160,15 @@ evdev_configure_device(struct evdev_device *device)
return -1;
}
 
+   if (udev_tags & EVDEV_UDEV_TAG_DIAL)