From patchwork Sun Apr 10 15:03:11 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Stein X-Patchwork-Id: 696571 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p3AF3ChH026989 for ; Sun, 10 Apr 2011 15:03:12 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753540Ab1DJPDL (ORCPT ); Sun, 10 Apr 2011 11:03:11 -0400 Received: from jack.hrz.tu-chemnitz.de ([134.109.132.46]:46399 "EHLO jack.hrz.tu-chemnitz.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753467Ab1DJPDL (ORCPT ); Sun, 10 Apr 2011 11:03:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tu-chemnitz.de; s=dkim2010; h=Message-Id:Date:Subject:Cc:To:From; bh=V0p0L1A2N7VHXYF27oeOv8eI6HHUaz3SPbs3wDCL/HA=; b=hhwacul60RBe3LTzMgozo5/ymKBV8oyI70970QggeWPDgWXKtT0HYrm8e9hev+Gr1Ra2f0bMGZspyzmV0vzYUfafUM2399W2O3htZmNbdE6VZrj+lu7ABA/lNEzNIZPhKcDHYlQgKYMYe8LyTinzme9zNzXAdwfuzGY4yMZf+ac=; Received: from 77-64-193-225.dynamic.primacom.net ([77.64.193.225] helo=kongar.lan.local) by jack.hrz.tu-chemnitz.de with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.74) (envelope-from ) id 1Q8wAO-0007L8-NP; Sun, 10 Apr 2011 17:03:09 +0200 From: Alexander Stein To: linux-input@vger.kernel.org Cc: Dmitry Torokhov , Alexander Stein Subject: [PATCH] gpio_keys: Add support for EV_ABS Date: Sun, 10 Apr 2011 17:03:11 +0200 Message-Id: <1302447791-9284-1-git-send-email-alexander.stein@informatik.tu-chemnitz.de> X-Mailer: git-send-email 1.7.4.1 X-Spam-Score: -0.9 (/) X-Spam-Report: --- Textanalyse SpamAssassin 3.3.1 (-0.9 Punkte) Fragen an/questions to: Postmaster TU Chemnitz * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.1 TVD_RCVD_IP TVD_RCVD_IP --- Ende Textanalyse X-Scan-Signature: bd263acef5c49e825d8b5debdb1b160d Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sun, 10 Apr 2011 15:03:12 +0000 (UTC) With this patch you can setup a group of GPIOs representing a specific position on an EV_ABS axis. Signed-off-by: Alexander Stein --- 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;