linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Stein <alexander.stein@informatik.tu-chemnitz.de>
To: linux-input@vger.kernel.org
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Alexander Stein <alexander.stein@informatik.tu-chemnitz.de>
Subject: [PATCH] gpio_keys: Add support for EV_ABS
Date: Sun, 10 Apr 2011 17:03:11 +0200	[thread overview]
Message-ID: <1302447791-9284-1-git-send-email-alexander.stein@informatik.tu-chemnitz.de> (raw)

With this patch you can setup a group of GPIOs representing a specific
position on an EV_ABS axis.

Signed-off-by: Alexander Stein <alexander.stein@informatik.tu-chemnitz.de>
---
See also the discussion thread beginning at http://www.spinics.net/lists/linux-input/msg14324.html

 drivers/input/keyboard/gpio_keys.c |    7 ++++++-
 include/linux/gpio_keys.h          |    3 ++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index eb30063..f319884 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -324,7 +324,12 @@ static void gpio_keys_report_event(struct gpio_button_data *bdata)
 	unsigned int type = button->type ?: EV_KEY;
 	int state = (gpio_get_value_cansleep(button->gpio) ? 1 : 0) ^ button->active_low;
 
-	input_event(input, type, button->code, !!state);
+	if (type == EV_ABS) {
+		if (state)
+			input_event(input, type, button->code, button->value);
+	} else {
+		input_event(input, type, button->code, !!state);
+	}
 	input_sync(input);
 }
 
diff --git a/include/linux/gpio_keys.h b/include/linux/gpio_keys.h
index dd1a56f..c09d7fb 100644
--- a/include/linux/gpio_keys.h
+++ b/include/linux/gpio_keys.h
@@ -7,7 +7,8 @@ struct gpio_keys_button {
 	int gpio;
 	int active_low;
 	char *desc;
-	int type;		/* input event type (EV_KEY, EV_SW) */
+	int type;		/* input event type (EV_KEY, EV_SW, EV_ABS) */
+	int value;		/* axis value for EV_ABS */
 	int wakeup;		/* configure the button as a wake-up source */
 	int debounce_interval;	/* debounce ticks interval in msecs */
 	bool can_disable;
-- 
1.7.4.1


             reply	other threads:[~2011-04-10 15:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-10 15:03 Alexander Stein [this message]
2011-04-12  6:30 ` [PATCH] gpio_keys: Add support for EV_ABS 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=1302447791-9284-1-git-send-email-alexander.stein@informatik.tu-chemnitz.de \
    --to=alexander.stein@informatik.tu-chemnitz.de \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).