linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ike Panhc <ike.pan@canonical.com>
To: platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-input@vger.kernel.org
Cc: Matthew Garrett <mjg@redhat.com>,
	Dmitry Torohov <dmitry.torokhov@gmail.com>
Subject: [PATCH] ideapad: let Fn+F5 also trigger KEY_BLUETOOTH
Date: Tue, 14 Jun 2011 16:28:29 +0800	[thread overview]
Message-ID: <1308040109-12038-1-git-send-email-ike.pan@canonical.com> (raw)

The design for ideapad Fn-F5 key is not only for wifi but for all
radio device including wifi, bluetooth and wwan. Idealy it shall
acts like this:

    wifi on          wifi off         wifi on         wifi off
     bt on   ----->   bt on   ----->   bt off  ----->  bt off

This patch will switch wifi mode every key-push and switch
bluetooth mode every two key-push.

Signed-off-by: Ike Panhc <ike.pan@canonical.com>
---
 drivers/platform/x86/ideapad-laptop.c |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
index bfdda33..e92ab14 100644
--- a/drivers/platform/x86/ideapad-laptop.c
+++ b/drivers/platform/x86/ideapad-laptop.c
@@ -328,6 +328,7 @@ static void ideapad_platform_exit(struct ideapad_private *priv)
 static const struct key_entry ideapad_keymap[] = {
 	{ KE_KEY, 0x06, { KEY_SWITCHVIDEOMODE } },
 	{ KE_KEY, 0x0D, { KEY_WLAN } },
+	{ KE_KEY, 0x0D, { KEY_BLUETOOTH } },
 	{ KE_END, 0 },
 };
 
@@ -379,7 +380,22 @@ static void __devexit ideapad_input_exit(struct ideapad_private *priv)
 static void ideapad_input_report(struct ideapad_private *priv,
 				 unsigned long scancode)
 {
-	sparse_keymap_report_event(priv->inputdev, scancode, 1, true);
+	static int bt_event_round;
+
+	if (scancode == 0x0D) {
+		bt_event_round++;
+		if (bt_event_round & 1) {
+			input_report_key(priv->inputdev, KEY_BLUETOOTH, 1);
+			input_sync(priv->inputdev);
+			input_report_key(priv->inputdev, KEY_BLUETOOTH, 0);
+			input_sync(priv->inputdev);
+		}
+		input_report_key(priv->inputdev, KEY_WLAN, 1);
+		input_sync(priv->inputdev);
+		input_report_key(priv->inputdev, KEY_WLAN, 0);
+		input_sync(priv->inputdev);
+	} else
+		sparse_keymap_report_event(priv->inputdev, scancode, 1, true);
 }
 
 /*
-- 
1.7.4.1


             reply	other threads:[~2011-06-14  8:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-14  8:28 Ike Panhc [this message]
2011-06-14  8:29 ` [PATCH] ideapad: let Fn+F5 also trigger KEY_BLUETOOTH Ike Panhc
2011-06-14  9:08   ` David Woodhouse
2011-06-14  9:21 ` Bastien Nocera
2011-06-14 21:52   ` Joey Lee

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=1308040109-12038-1-git-send-email-ike.pan@canonical.com \
    --to=ike.pan@canonical.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjg@redhat.com \
    --cc=platform-driver-x86@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).