mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paul Cercueil <paul@crapouillou.net>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Laxman Dewangan <ldewangan@nvidia.com>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Maarten ter Huurne <maarten@treewalker.org>,
	Paul Cercueil <paul@crapouillou.net>
Subject: [PATCH 2/2] Input: gpio_keys - Set ABS params when using axes
Date: Tue,  1 Nov 2016 11:25:04 +0100	[thread overview]
Message-ID: <20161101102504.3783-3-paul@crapouillou.net> (raw)
In-Reply-To: <20161101102504.3783-1-paul@crapouillou.net>

The gpio-keys supports the EV_ABS event type, but does not actually
configure the input device to work with that mode.

This patch configures the axis corresponding to button->code as being
in the range [-1,+1]. This makes it possible to use gpio-keys to
implement a hat (using the ABS_HAT0X /ABS_HAT0Y axes, with two GPIOs
each with values -1/+1).

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

diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 7018c49..1f2850a 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -540,6 +540,9 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
 
 	input_set_capability(input, button->type ?: EV_KEY, button->code);
 
+	if (button->type == EV_ABS)
+		input_set_abs_params(input, button->code, -1, 1, 0, 0);
+
 	/*
 	 * Install custom action to cancel release timer and
 	 * workqueue item.
-- 
2.9.3

  parent reply	other threads:[~2016-11-01 10:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-01 10:25 [PATCH 0/2] Make gpio-keys usable as a hat Paul Cercueil
2016-11-01 10:25 ` [PATCH 1/2] Input: gpio_keys - Also send release events for ABS codes Paul Cercueil
2016-11-03 16:21   ` Dmitry Torokhov
2016-11-05 11:58     ` Paul Cercueil
2016-11-09  0:09       ` Dmitry Torokhov
2016-11-01 10:25 ` Paul Cercueil [this message]
2016-11-03 16:24   ` [PATCH 2/2] Input: gpio_keys - Set ABS params when using axes Dmitry Torokhov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161101102504.3783-3-paul@crapouillou.net \
    --to=paul@crapouillou.net \
    --cc=dmitry.torokhov@gmail.com \
    --cc=ldewangan@nvidia.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten@treewalker.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®