Re: [PATCH libinput] Added missing button range for pad on CTH-680

2017-02-12 Thread Hans de Goede

Hi,

On 13-02-17 07:57, Peter Hutterer wrote:

From: Sakse Dalum 

This device has BTN_LEFT, BTN_RIGHT, BTN_FORWARD and BTN_BACK, add the
missing range to the pad init function.

https://bugs.freedesktop.org/show_bug.cgi?id=99785

Signed-off-by: Peter Hutterer 


Patch looks good to me:

Reviewed-by: Hans de Goede 

Regards,

Hans




---
 src/evdev-tablet-pad.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/evdev-tablet-pad.c b/src/evdev-tablet-pad.c
index bed43b6..6be53b5 100644
--- a/src/evdev-tablet-pad.c
+++ b/src/evdev-tablet-pad.c
@@ -542,6 +542,11 @@ pad_init_buttons(struct pad_dispatch *pad,
pad->button_map[code] = map++;
}

+   for (code = BTN_LEFT; code < BTN_LEFT + 7; code++) {
+   if (libevdev_has_event_code(device->evdev, EV_KEY, code))
+   pad->button_map[code] = map++;
+   }
+
pad->nbuttons = map;
 }



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


[PATCH libinput] Added missing button range for pad on CTH-680

2017-02-12 Thread Peter Hutterer
From: Sakse Dalum 

This device has BTN_LEFT, BTN_RIGHT, BTN_FORWARD and BTN_BACK, add the
missing range to the pad init function.

https://bugs.freedesktop.org/show_bug.cgi?id=99785

Signed-off-by: Peter Hutterer 
---
 src/evdev-tablet-pad.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/evdev-tablet-pad.c b/src/evdev-tablet-pad.c
index bed43b6..6be53b5 100644
--- a/src/evdev-tablet-pad.c
+++ b/src/evdev-tablet-pad.c
@@ -542,6 +542,11 @@ pad_init_buttons(struct pad_dispatch *pad,
pad->button_map[code] = map++;
}
 
+   for (code = BTN_LEFT; code < BTN_LEFT + 7; code++) {
+   if (libevdev_has_event_code(device->evdev, EV_KEY, code))
+   pad->button_map[code] = map++;
+   }
+
pad->nbuttons = map;
 }
 
-- 
2.11.1

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


[PATCH libinput] tools: hide key codes by default

2017-02-12 Thread Peter Hutterer
libinput-debug-events prints keycodes as they come in. This makes it dangerous
to be run by users (especially in the background) because it will leak
sensitive information as it is typed. Obfuscate the base set of keycodes
by default, require a --show-keycodes switch to show it.

The few times we actually need the keycodes, we can run the switch in the
debugging tool.

This does not affect keys outside of the main block on the keyboard (F-keys,
multimedia keys).

Signed-off-by: Peter Hutterer 
---
 tools/event-debug.c | 19 +++
 tools/shared.c  |  7 +++
 tools/shared.h  |  3 +++
 3 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/tools/event-debug.c b/tools/event-debug.c
index 779b54a..9022e39 100644
--- a/tools/event-debug.c
+++ b/tools/event-debug.c
@@ -267,20 +267,31 @@ print_device_notify(struct libinput_event *ev)
 }
 
 static void
-print_key_event(struct libinput_event *ev)
+print_key_event(struct libinput *li, struct libinput_event *ev)
 {
struct libinput_event_keyboard *k = 
libinput_event_get_keyboard_event(ev);
+   struct tools_context *context;
+   struct tools_options *options;
enum libinput_key_state state;
uint32_t key;
const char *keyname;
 
+   context = libinput_get_user_data(li);
+   options = >options;
+
print_event_time(libinput_event_keyboard_get_time(k));
state = libinput_event_keyboard_get_key_state(k);
 
key = libinput_event_keyboard_get_key(k);
-   keyname = libevdev_event_code_get_name(EV_KEY, key);
+   if (!options->show_keycodes &&
+   (key >= KEY_ESC && key < KEY_ZENKAKUHANKAKU)) {
+   keyname = "***";
+   } else {
+   keyname = libevdev_event_code_get_name(EV_KEY, key);
+   keyname = keyname ? keyname : "???";
+   }
printf("%s (%d) %s\n",
-  keyname ? keyname : "???",
+  keyname,
   key,
   state == LIBINPUT_KEY_STATE_PRESSED ? "pressed" : "released");
 }
@@ -754,7 +765,7 @@ handle_and_print_events(struct libinput *li)
  );
break;
case LIBINPUT_EVENT_KEYBOARD_KEY:
-   print_key_event(ev);
+   print_key_event(li, ev);
break;
case LIBINPUT_EVENT_POINTER_MOTION:
print_motion_event(ev);
diff --git a/tools/shared.c b/tools/shared.c
index 05fb118..1019184 100644
--- a/tools/shared.c
+++ b/tools/shared.c
@@ -62,6 +62,7 @@ enum options {
OPT_SCROLL_BUTTON,
OPT_SPEED,
OPT_PROFILE,
+   OPT_SHOW_KEYCODES,
 };
 
 LIBINPUT_ATTRIBUTE_PRINTF(3, 0)
@@ -103,6 +104,7 @@ tools_usage(void)
   "--set-profile=[adaptive|flat] set pointer acceleration 
profile\n"
   "--set-speed= set pointer acceleration speed (allowed 
range [-1, 1]) \n"
   "--set-tap-map=[lrm|lmr] ... set button mapping for tapping\n"
+  "--show-keycodes show all key codes while typing\n"
   "\n"
   "These options apply to all applicable devices, if a feature\n"
   "is not explicitly specified it is left at each device's 
default.\n"
@@ -137,6 +139,7 @@ tools_init_context(struct tools_context *context)
options->seat = "seat0";
options->speed = 0.0;
options->profile = LIBINPUT_CONFIG_ACCEL_PROFILE_NONE;
+   options->show_keycodes = false;
 }
 
 int
@@ -173,6 +176,7 @@ tools_parse_args(int argc, char **argv, struct 
tools_context *context)
{ "set-profile", 1, 0, OPT_PROFILE },
{ "set-tap-map", 1, 0, OPT_TAP_MAP },
{ "set-speed", 1, 0, OPT_SPEED },
+   { "show-keycodes", 0, 0, OPT_SHOW_KEYCODES },
{ 0, 0, 0, 0}
};
 
@@ -337,6 +341,9 @@ tools_parse_args(int argc, char **argv, struct 
tools_context *context)
return 1;
}
break;
+   case OPT_SHOW_KEYCODES:
+   options->show_keycodes = true;
+   break;
default:
tools_usage();
return 1;
diff --git a/tools/shared.h b/tools/shared.h
index 17fdf37..9b1a988 100644
--- a/tools/shared.h
+++ b/tools/shared.h
@@ -24,6 +24,8 @@
 #ifndef _SHARED_H_
 #define _SHARED_H_
 
+#include 
+
 #include 
 
 enum tools_backend {
@@ -36,6 +38,7 @@ struct tools_options {
const char *device; /* if backend is BACKEND_DEVICE */
const char *seat; /* if backend is BACKEND_UDEV */
int grab; /* EVIOCGRAB */
+   bool show_keycodes; /* show keycodes */
 
int verbose;
int tapping;
-- 
2.9.3

___
wayland-devel mailing list

Re: [PATCH libinput 1/2] touchpad: add a hwdb quirk for (external) touchpad/keyboard combos

2017-02-12 Thread Peter Hutterer
On Fri, Feb 10, 2017 at 11:04:00AM +0100, Hans de Goede wrote:
> Hi,
> 
> Series looks good, but patch 1/2 introduces
> tp_is_tpkb_combo_below() and patch 2/2 then moves it around
> to avoid doing a forward declaration, it would be better IMHO
> if patch 1/2 simply defined it in the place where 2/2 puts it.
> 
> With that fixed:
> 
> Reviewed-by: Hans de Goede 

fixed, thanks!

Cheers,
   Peter

> On 10-02-17 06:45, Peter Hutterer wrote:
> > Specify the layout of the combo so we know when to initialize palm 
> > detection.
> > 
> > This allows us to drop palm detection on external touchpads otherwise,
> > replacing the wacom-specific check with something more generic..
> > 
> > Signed-off-by: Peter Hutterer 
> > ---
> >  src/evdev-mt-touchpad.c| 19 +--
> >  src/libinput-util.c| 24 
> >  src/libinput-util.h|  7 +++
> >  test/test-touchpad.c   |  4 
> >  udev/90-libinput-model-quirks.hwdb |  7 +++
> >  udev/parse_hwdb.py |  7 ++-
> >  6 files changed, 65 insertions(+), 3 deletions(-)
> > 
> > diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
> > index c5eeeac..f8c5cc6 100644
> > --- a/src/evdev-mt-touchpad.c
> > +++ b/src/evdev-mt-touchpad.c
> > @@ -2192,6 +2192,21 @@ tp_init_dwt(struct tp_dispatch *tp,
> > return;
> >  }
> > 
> > +static inline bool
> > +tp_is_tpkb_combo_below(struct evdev_device *device)
> > +{
> > +   const char *prop;
> > +   enum tpkbcombo_layout layout = TPKBCOMBO_LAYOUT_UNKNOWN;
> > +
> > +   prop = udev_device_get_property_value(device->udev_device,
> > + "LIBINPUT_ATTR_TPKBCOMBO_LAYOUT");
> > +   if (!prop)
> > +   return false;
> > +
> > +   return parse_tpkbcombo_layout_poperty(prop, ) &&
> > +   layout == TPKBCOMBO_LAYOUT_BELOW;
> > +}
> > +
> >  static void
> >  tp_init_palmdetect(struct tp_dispatch *tp,
> >struct evdev_device *device)
> > @@ -2203,8 +2218,8 @@ tp_init_palmdetect(struct tp_dispatch *tp,
> > tp->palm.right_edge = INT_MAX;
> > tp->palm.left_edge = INT_MIN;
> > 
> > -   /* Wacom doesn't have internal touchpads */
> > -   if (device->model_flags & EVDEV_MODEL_WACOM_TOUCHPAD)
> > +   if (device->tags & EVDEV_TAG_EXTERNAL_TOUCHPAD &&
> > +   !tp_is_tpkb_combo_below(device))
> > return;
> > 
> > evdev_device_get_size(device, , );
> > diff --git a/src/libinput-util.c b/src/libinput-util.c
> > index d75955c..351bbe4 100644
> > --- a/src/libinput-util.c
> > +++ b/src/libinput-util.c
> > @@ -336,6 +336,30 @@ parse_switch_reliability_property(const char *prop,
> >  }
> > 
> >  /**
> > + * Parses a string with the allowed values: "below"
> > + * The value refers to the position of the touchpad (relative to the
> > + * keyboard, i.e. your average laptop would be 'below')
> > + *
> > + * @param prop The value of the property
> > + * @param layout The layout
> > + * @return true on success, false otherwise
> > + */
> > +bool
> > +parse_tpkbcombo_layout_poperty(const char *prop,
> > +  enum tpkbcombo_layout *layout)
> > +{
> > +   if (!prop)
> > +   return false;
> > +
> > +   if (streq(prop, "below")) {
> > +   *layout = TPKBCOMBO_LAYOUT_BELOW;
> > +   return true;
> > +   }
> > +
> > +   return false;
> > +}
> > +
> > +/**
> >   * Return the next word in a string pointed to by state before the first
> >   * separator character. Call repeatedly to tokenize a whole string.
> >   *
> > diff --git a/src/libinput-util.h b/src/libinput-util.h
> > index 00ece58..d86ff12 100644
> > --- a/src/libinput-util.h
> > +++ b/src/libinput-util.h
> > @@ -379,6 +379,13 @@ double parse_trackpoint_accel_property(const char 
> > *prop);
> >  bool parse_dimension_property(const char *prop, size_t *width, size_t 
> > *height);
> >  bool parse_calibration_property(const char *prop, float calibration[6]);
> > 
> > +enum tpkbcombo_layout {
> > +   TPKBCOMBO_LAYOUT_UNKNOWN,
> > +   TPKBCOMBO_LAYOUT_BELOW,
> > +};
> > +bool parse_tpkbcombo_layout_poperty(const char *prop,
> > +   enum tpkbcombo_layout *layout);
> > +
> >  enum switch_reliability {
> > RELIABILITY_UNKNOWN,
> > RELIABILITY_RELIABLE,
> > diff --git a/test/test-touchpad.c b/test/test-touchpad.c
> > index aca9f7b..4656443 100644
> > --- a/test/test-touchpad.c
> > +++ b/test/test-touchpad.c
> > @@ -933,11 +933,15 @@ touchpad_has_palm_detect_size(struct litest_device 
> > *dev)
> >  {
> > double width, height;
> > unsigned int vendor;
> > +   unsigned int bustype;
> > int rc;
> > 
> > vendor = libinput_device_get_id_vendor(dev->libinput_device);
> > +   bustype = libevdev_get_id_bustype(dev->evdev);
> > if (vendor == VENDOR_ID_WACOM)
> > return 0;
> > +   if (bustype == BUS_BLUETOOTH)
> > +   return 0;
> > if (vendor ==