All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] gpio_keys.c: Send also event when EV_ABS axis button is released
@ 2025-02-01 16:20 Marian Flor
  2025-02-03 14:00 ` Dmitry Torokhov
  0 siblings, 1 reply; 2+ messages in thread
From: Marian Flor @ 2025-02-01 16:20 UTC (permalink / raw)
  To: dmitry.torokhov; +Cc: linux-input, linux-kernel

The input EV_ABS does not emit an event when the axis button is
released.  It appears to libevdev as held, even when the axis
button is physically released.  This behavior is also opposing
to the devicetree documentation for gpio-keys.  Change the code
to additionally emit a zero valued event on axis button release.

Signed-off-by: Marian Flor <marian.flor@posteo.net>
---
v2: No changes in patch itself, v2 got a commit description.

 drivers/input/keyboard/gpio_keys.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 5eef66516e37..20a0327e8f9a 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -373,12 +373,10 @@ static void gpio_keys_gpio_report_event(struct gpio_button_data *bdata)
 		return;
 	}
 
-	if (type == EV_ABS) {
-		if (state)
-			input_event(input, type, button->code, button->value);
-	} else {
+	if (type == EV_ABS)
+		input_event(input, type, button->code, state ? button->value : 0);
+	else
 		input_event(input, type, *bdata->code, state);
-	}
 }
 
 static void gpio_keys_debounce_event(struct gpio_button_data *bdata)
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] gpio_keys.c: Send also event when EV_ABS axis button is released
  2025-02-01 16:20 [PATCH v2] gpio_keys.c: Send also event when EV_ABS axis button is released Marian Flor
@ 2025-02-03 14:00 ` Dmitry Torokhov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2025-02-03 14:00 UTC (permalink / raw)
  To: Marian Flor; +Cc: linux-input, linux-kernel

Hi Marian,

On Sat, Feb 01, 2025 at 04:20:15PM +0000, Marian Flor wrote:
> The input EV_ABS does not emit an event when the axis button is
> released.  It appears to libevdev as held, even when the axis
> button is physically released.  This behavior is also opposing
> to the devicetree documentation for gpio-keys.  Change the code
> to additionally emit a zero valued event on axis button release.

This unfortunately will not work: if you have several GPIOs with
progression of values, such as:

GPIO1: EV_ABS/ABS_X/0
GPIO2: EV_ABS/ABS_X/1
GPIO3: EV_ABS/ABS_X/2
GPIO4: EV_ABS/ABS_X/3

You do not want the values to bounce to 0 as they transition from let's
say 1->2.

The "return to 0 as resting point" behavior was originally only supposed
to be valid for the polled variant of gpio keys, but commit fbfb9a60d5d0
("dt-bindings: input: Convert gpio-keys bindings to schema") changed it
without updating the driver. It was an oversight.

To properly implement this behavior you need to scan all other GPIOs
with the same type and code and see if any of them are still active.

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-02-03 14:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-01 16:20 [PATCH v2] gpio_keys.c: Send also event when EV_ABS axis button is released Marian Flor
2025-02-03 14:00 ` Dmitry Torokhov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.