Re: [PATCH v2 3/5] Input: hynitron-cst816x: release gesture keys

From: Oleh Kuzhylnyi

Date: Sun Oct 04 2026 - 17:38:43 EST


On Fri Oct 2, 2026 at 2:47 PM CEST, Daniel Golle wrote:
> The gesture key is reported with the value of the touch flag, so it
> stays pressed once the controller stops reporting the gesture code
> while the finger is still down. Report the press on its own and
> release the keys the input core still holds down on the first report
> that carries no gesture code. Keycodes above KEY_MAX are rejected,
> as that release looks the key state up in the input core's key bitmap.
>
> Fixes: c87a819bec86 ("Input: add driver for Hynitron CST816x series")
> Signed-off-by: Daniel Golle <daniel@xxxxxxxxxxxxxx>
> ---
> v2:
> - reject keycodes above KEY_MAX and publish keycodemax only once the
> whole array validates (Sashiko AI review)
>
> static irqreturn_t cst816x_irq_cb(int irq, void *cookie)
> {
> struct cst816x_priv *priv = cookie;
> @@ -181,8 +205,9 @@ static irqreturn_t cst816x_irq_cb(int irq, void *cookie)
>
> if (tch.gest)
> input_report_key(priv->input,
> - priv->keycode[cst816x_gest_idx(tch.gest)],
> - tch.active);
> + priv->keycode[cst816x_gest_idx(tch.gest)], 1);

Tested on CST816S setup, found out a subtle issue: cst816x_gest_idx() maps unhandled
single-click (0x05) and long-press (0x0C) gestures to index 4.

Input subsystem ignores SINGLE_TOUCH (code 0x5) events with tch.active == 0 (t: 0).
Instead, reporting index 4 (single-click 0x05 minus 1) with tch.active == 1 falls into BTN_TOOL_TRIPLETAP linux,keycodes element.

As a result every single touch accompanied by BTN_TOOL_TRIPLETAP:
Event: time 1791148663.331439, type 3 (EV_ABS), code 0 (ABS_X), value 117
Event: time 1791148663.331439, type 3 (EV_ABS), code 1 (ABS_Y), value 124
Event: time 1791148663.331439, type 1 (EV_KEY), code 334 (BTN_TOOL_TRIPLETAP), value 0
Event: time 1791148663.331439, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 1
Event: time 1791148663.331439, -------------- SYN_REPORT ------------
Event: time 1791148663.397477, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 0
Event: time 1791148663.397477, -------------- SYN_REPORT ------------
Event: time 1791148663.409413, type 1 (EV_KEY), code 334 (BTN_TOOL_TRIPLETAP), value 1
Event: time 1791148663.409413, -------------- SYN_REPORT ------------

Interrupts:
cst816x 1-0015: x: 127, y: 124, t: 0, g: 0x5 // Finger down (index 4, tch.active == 1)
cst816x 1-0015: x: 117, y: 124, t: 1, g: 0x0
cst816x 1-0015: x: 117, y: 124, t: 1, g: 0x0
cst816x 1-0015: x: 117, y: 124, t: 0, g: 0x0
cst816x 1-0015: x: 117, y: 124, t: 0, g: 0x5 // Finged up (index 4, tch.active == 1)

I suggest either gate the gesture branch on tch.active so a finger-up
single-click never fires a key, or fix cst816x_gest_idx() to map 0x5/0xC
to their own valid slots so they stop aliasing the TRIPLETAP keycode.

Best regards,
Oleh Kuzhylnyi

> + else
> + cst816x_release_keys(priv);
>
> input_report_key(priv->input, BTN_TOUCH, tch.active);
>