diff mbox

[1/2] Input: gpio_keys - Also send release events for ABS codes

Message ID 20161101102504.3783-2-paul@crapouillou.net (mailing list archive)
State New, archived
Headers show

Commit Message

Paul Cercueil Nov. 1, 2016, 10:25 a.m. UTC
Right now, the gpio-keys driver is mostly used with EV_KEY event types.
However, this driver (and its devicetree bindings) support specifying
a different input type, like EV_ABS, even though this doesn't work in
practice: "key pressed" events are correctly received and treated, but
"key released" are silently ignored.

With this commit, keys configured as EV_ABS will inject an event with
the value 0 when released.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 drivers/input/keyboard/gpio_keys.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Dmitry Torokhov Nov. 3, 2016, 4:21 p.m. UTC | #1
On Tue, Nov 01, 2016 at 11:25:03AM +0100, Paul Cercueil wrote:
> Right now, the gpio-keys driver is mostly used with EV_KEY event types.
> However, this driver (and its devicetree bindings) support specifying
> a different input type, like EV_ABS, even though this doesn't work in
> practice: "key pressed" events are correctly received and treated, but
> "key released" are silently ignored.
> 
> With this commit, keys configured as EV_ABS will inject an event with
> the value 0 when released.

No, this will break setups like this:

gpio0 - ABS_X - 0
gpio1 - ABS_X - 1
gpio2 - ABS_X - 2
...
gpio7 - ABS_X - 7

- something like a slider built on top of gpios.

> 
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> ---
>  drivers/input/keyboard/gpio_keys.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
> index 2909365..7018c49 100644
> --- a/drivers/input/keyboard/gpio_keys.c
> +++ b/drivers/input/keyboard/gpio_keys.c
> @@ -369,6 +369,8 @@ static void gpio_keys_gpio_report_event(struct gpio_button_data *bdata)
>  	if (type == EV_ABS) {
>  		if (state)
>  			input_event(input, type, button->code, button->value);
> +		else
> +			input_event(input, type, button->code, 0);
>  	} else {
>  		input_event(input, type, button->code, !!state);
>  	}
> -- 
> 2.9.3
> 

Thanks.
Paul Cercueil Nov. 5, 2016, 11:58 a.m. UTC | #2
On 03/11/2016 17:21, Dmitry Torokhov wrote:
> On Tue, Nov 01, 2016 at 11:25:03AM +0100, Paul Cercueil wrote:
>> Right now, the gpio-keys driver is mostly used with EV_KEY event types.
>> However, this driver (and its devicetree bindings) support specifying
>> a different input type, like EV_ABS, even though this doesn't work in
>> practice: "key pressed" events are correctly received and treated, but
>> "key released" are silently ignored.
>>
>> With this commit, keys configured as EV_ABS will inject an event with
>> the value 0 when released.
> No, this will break setups like this:
>
> gpio0 - ABS_X - 0
> gpio1 - ABS_X - 1
> gpio2 - ABS_X - 2
> ...
> gpio7 - ABS_X - 7
>
> - something like a slider built on top of gpios.

So what would you suggest for the implementation of a hat / d-pad on top 
of GPIOs?

Thanks,
- Paul
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Dmitry Torokhov Nov. 9, 2016, 12:09 a.m. UTC | #3
On Sat, Nov 05, 2016 at 12:58:00PM +0100, Paul Cercueil wrote:
> On 03/11/2016 17:21, Dmitry Torokhov wrote:
> >On Tue, Nov 01, 2016 at 11:25:03AM +0100, Paul Cercueil wrote:
> >>Right now, the gpio-keys driver is mostly used with EV_KEY event types.
> >>However, this driver (and its devicetree bindings) support specifying
> >>a different input type, like EV_ABS, even though this doesn't work in
> >>practice: "key pressed" events are correctly received and treated, but
> >>"key released" are silently ignored.
> >>
> >>With this commit, keys configured as EV_ABS will inject an event with
> >>the value 0 when released.
> >No, this will break setups like this:
> >
> >gpio0 - ABS_X - 0
> >gpio1 - ABS_X - 1
> >gpio2 - ABS_X - 2
> >...
> >gpio7 - ABS_X - 7
> >
> >- something like a slider built on top of gpios.
> 
> So what would you suggest for the implementation of a hat / d-pad on
> top of GPIOs?

Maybe we should allow specifying "release" value for ABS GPIOs.

Thanks.
diff mbox

Patch

diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 2909365..7018c49 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -369,6 +369,8 @@  static void gpio_keys_gpio_report_event(struct gpio_button_data *bdata)
 	if (type == EV_ABS) {
 		if (state)
 			input_event(input, type, button->code, button->value);
+		else
+			input_event(input, type, button->code, 0);
 	} else {
 		input_event(input, type, button->code, !!state);
 	}