summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2016-05-26 10:05:10 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2016-06-22 11:57:07 +1000
commit6583f4bb53fbb26183d6035e51f6db7db6e801ca (patch)
tree6aa22c728652cfb9d92bab1e687729a4fb433c03 /tools
parent8aa5576adb66618b984259ace7bcb955141221e2 (diff)
pad: Add a new API for modes and mode groups
Move mode control to libinput. This reduces some flexibility on what we can do with modes but makes it a lot easier for anyone to implement modes correctly and have the LEDs apply appropriately, etc. Let's go with the option to make the 95% use-case easy. Note: whether the mode is actually used is up to the caller, e.g. under Windows and OS X the mode only applies to the rings/strips, not the buttons. A tablet pad has 1 or more mode groups, all buttons/ring/strips are assigned to a mode group. That group has a numeric mode index and is hooked to the LEDs. libinput will switch the LEDs accordingly. The mode group is a separate object. This allows for better APIs when it comes to: * checking whether a button/ring/strip is part of a mode group * checking whether a button will trigger a mode transition and in the future potentially: * checking which mode transition will happen * setting which button should change the mode transition * changing what type of mode transition should happen. * moving a button from one mode group to the other This patch adds the basic scaffolding, without any real implementation. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Proofread-by: Yong Bakos <ybakos@humanoriented.com> Reviewed-by: Jason Gerecke <jason.gerecke@wacom.com> Reviewed-by: Carlos Garnacho <carlosg@gnome.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/event-debug.c61
-rw-r--r--tools/event-gui.c1
2 files changed, 52 insertions, 10 deletions
diff --git a/tools/event-debug.c b/tools/event-debug.c
index a5608d2b..70f4268f 100644
--- a/tools/event-debug.c
+++ b/tools/event-debug.c
@@ -130,6 +130,9 @@ print_event_header(struct libinput_event *ev)
case LIBINPUT_EVENT_TABLET_PAD_STRIP:
type = "TABLET_PAD_STRIP";
break;
+ case LIBINPUT_EVENT_TABLET_PAD_MODE:
+ type = "TABLET_PAD_MODE";
+ break;
}
printf("%-7s %-16s ", libinput_device_get_sysname(dev), type);
@@ -232,16 +235,18 @@ print_device_notify(struct libinput_event *ev)
if (libinput_device_has_capability(dev,
LIBINPUT_DEVICE_CAP_TABLET_PAD)) {
- int nbuttons, nstrips, nrings;
+ int nbuttons, nstrips, nrings, ngroups;
nbuttons = libinput_device_tablet_pad_get_num_buttons(dev);
nstrips = libinput_device_tablet_pad_get_num_strips(dev);
nrings = libinput_device_tablet_pad_get_num_rings(dev);
+ ngroups = libinput_device_tablet_pad_get_num_mode_groups(dev);
- printf(" buttons:%d strips:%d rings:%d",
+ printf(" buttons:%d strips:%d rings:%d mode groups:%d",
nbuttons,
nstrips,
- nrings);
+ nrings,
+ ngroups);
}
printf("\n");
@@ -604,14 +609,25 @@ static void
print_tablet_pad_button_event(struct libinput_event *ev)
{
struct libinput_event_tablet_pad *p = libinput_event_get_tablet_pad_event(ev);
+ struct libinput_tablet_pad_mode_group *group;
enum libinput_button_state state;
+ unsigned int button, mode;
print_event_time(libinput_event_tablet_pad_get_time(p));
+ button = libinput_event_tablet_pad_get_button_number(p),
state = libinput_event_tablet_pad_get_button_state(p);
- printf("%3d %s\n",
- libinput_event_tablet_pad_get_button_number(p),
- state == LIBINPUT_BUTTON_STATE_PRESSED ? "pressed" : "released");
+ mode = libinput_event_tablet_pad_get_mode(p);
+ printf("%3d %s (mode %d)",
+ button,
+ state == LIBINPUT_BUTTON_STATE_PRESSED ? "pressed" : "released",
+ mode);
+
+ group = libinput_event_tablet_pad_get_mode_group(p);
+ if (libinput_tablet_pad_mode_group_button_is_toggle(group, button))
+ printf(" <mode toggle>");
+
+ printf("\n");
}
static void
@@ -619,6 +635,7 @@ print_tablet_pad_ring_event(struct libinput_event *ev)
{
struct libinput_event_tablet_pad *p = libinput_event_get_tablet_pad_event(ev);
const char *source = "<invalid>";
+ unsigned int mode;
print_event_time(libinput_event_tablet_pad_get_time(p));
@@ -631,10 +648,12 @@ print_tablet_pad_ring_event(struct libinput_event *ev)
break;
}
- printf("ring %d position %.2f (source %s)\n",
+ mode = libinput_event_tablet_pad_get_mode(p);
+ printf("ring %d position %.2f (source %s) (mode %d)\n",
libinput_event_tablet_pad_get_ring_number(p),
libinput_event_tablet_pad_get_ring_position(p),
- source);
+ source,
+ mode);
}
static void
@@ -642,6 +661,7 @@ print_tablet_pad_strip_event(struct libinput_event *ev)
{
struct libinput_event_tablet_pad *p = libinput_event_get_tablet_pad_event(ev);
const char *source = "<invalid>";
+ unsigned int mode;
print_event_time(libinput_event_tablet_pad_get_time(p));
@@ -654,10 +674,28 @@ print_tablet_pad_strip_event(struct libinput_event *ev)
break;
}
- printf("strip %d position %.2f (source %s)\n",
+ mode = libinput_event_tablet_pad_get_mode(p);
+ printf("strip %d position %.2f (source %s) (mode %d)\n",
libinput_event_tablet_pad_get_strip_number(p),
libinput_event_tablet_pad_get_strip_position(p),
- source);
+ source,
+ mode);
+}
+
+static void
+print_tablet_pad_mode_event(struct libinput_event *ev)
+{
+ struct libinput_event_tablet_pad *p = libinput_event_get_tablet_pad_event(ev);
+ struct libinput_tablet_pad_mode_group *group;
+ unsigned int mode;
+
+ print_event_time(libinput_event_tablet_pad_get_time(p));
+
+ group = libinput_event_tablet_pad_get_mode_group(p);
+ mode = libinput_event_tablet_pad_get_mode(p);
+ printf("group %d mode %d\n",
+ libinput_tablet_pad_mode_group_get_index(group),
+ mode);
}
static int
@@ -748,6 +786,9 @@ handle_and_print_events(struct libinput *li)
case LIBINPUT_EVENT_TABLET_PAD_STRIP:
print_tablet_pad_strip_event(ev);
break;
+ case LIBINPUT_EVENT_TABLET_PAD_MODE:
+ print_tablet_pad_mode_event(ev);
+ break;
}
libinput_event_destroy(ev);
diff --git a/tools/event-gui.c b/tools/event-gui.c
index 605f00a3..5eeea1ed 100644
--- a/tools/event-gui.c
+++ b/tools/event-gui.c
@@ -843,6 +843,7 @@ handle_event_libinput(GIOChannel *source, GIOCondition condition, gpointer data)
case LIBINPUT_EVENT_TABLET_PAD_BUTTON:
case LIBINPUT_EVENT_TABLET_PAD_RING:
case LIBINPUT_EVENT_TABLET_PAD_STRIP:
+ case LIBINPUT_EVENT_TABLET_PAD_MODE:
break;
}