# \[PATCH\] ideapad: let Fn+F5 also trigger KEY\_BLUETOOTH

- Subsystems: THE REST, X86 PLATFORM DRIVERS
- Maintainers: Linus Torvalds, Hans de Goede, Ilpo Järvinen
- List: linux-input
- 5 messages, 4 authors
- Page: https://ratatoskr.run/linux-input/2011/06/3728996/t

## \[PATCH\] ideapad: let Fn+F5 also trigger KEY\_BLUETOOTH

- From: Ike Panhc \<hidden\>
- Date: 2011-06-14 08:28:40 
- Message: https://ratatoskr.run/linux-input/2011/06/3728996.md

```text
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 <redacted>
---
 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

```

## Re: \[PATCH\] ideapad: let Fn+F5 also trigger KEY\_BLUETOOTH

- From: Ike Panhc \<hidden\>
- Date: 2011-06-14 08:30:02 
- Message: https://ratatoskr.run/linux-input/2011/06/3728997.md

```text
On 06/14/2011 04:28 PM, Ike Panhc wrote:
> 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.

This maybe is disputed. 

The problem is that now Fn+F5 only turns on/off wifi and leave bluetooth alone.
According to the design this hotkey shall change the status of all radio
devices, including wifi, bluetooth and wwan.

On machine with wifi and bluetooth, it will turn on/off wifi and bluetooth in
order. On machine with wifi, it will switch wifi mode on every event.

I think it is better to solve this in driver not in user space application 
because on some other platforms, the KEY_WLAN and KEY_BLUETOOTH are separate.

I do not have a clear idea how to deal with wwan interface such as it shall be
exclusive or inclusive with wifi.

Please reply for any opinion.
```

## Re: \[PATCH\] ideapad: let Fn+F5 also trigger KEY\_BLUETOOTH

- From: David Woodhouse \<dwmw2@infradead.org\>
- Date: 2011-06-14 09:08:26 
- Message: https://ratatoskr.run/linux-input/2011/06/3729013.md

```text
On Tue, 2011-06-14 at 16:29 +0800, Ike Panhc wrote:
> I think it is better to solve this in driver not in user space application 
> because on some other platforms, the KEY_WLAN and KEY_BLUETOOTH are separate.

I think it's better to do it in userspace. It's not as if it's hard to
define another KEY_ and just tell the truth about what happened. Let
userspace work out what to do with it.

-- 
David Woodhouse                            Open Source Technology Centre
David.Woodhouse@intel.com                              Intel Corporation
```

## Re: \[PATCH\] ideapad: let Fn+F5 also trigger KEY\_BLUETOOTH

- From: Bastien Nocera \<hadess@hadess.net\>
- Date: 2011-06-14 09:22:12 
- Message: https://ratatoskr.run/linux-input/2011/06/3729023.md

```text
On Tue, 2011-06-14 at 16:28 +0800, Ike Panhc wrote:
> 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.

If that's what you want to achieve, then the key should be KEY_RFKILL.
That's what the key is there for.

```

## Re: \[PATCH\] ideapad: let Fn+F5 also trigger KEY\_BLUETOOTH

- From: Joey Lee \<hidden\>
- Date: 2011-06-14 21:52:15 
- Message: https://ratatoskr.run/linux-input/2011/06/3729269.md

```text
Hi Ike, 

於 二，2011-06-14 於 10:21 +0100，Bastien Nocera 提到：
> On Tue, 2011-06-14 at 16:28 +0800, Ike Panhc wrote:
> > 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.
> 
> If that's what you want to achieve, then the key should be KEY_RFKILL.
> That's what the key is there for.
> 

I also agree push the wifi key logic to userland application has more
flexibility.

Highly suggest you can use urfkill daemon:
http://www.google.com.tw/search?sourceid=chrome&ie=UTF-8&q=urfkill

It support KEY_WIRELESS, KEY_BLUETOOTH and KEY_RFKILL, and you can setup
the wifi key rule on urfkill daemon. 
Please feel free send patch to Gary Lin [ref], he can merge
your key rule for ideapad.


Thank's
Joey Lee


--
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
```
