[PATCH v2 3/4] HID: apple: simplify logic for swapping only left sided option and command keys

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Aditya Garg <gargaditya08@xxxxxxxx>

In order to swap only left sided option and command keys a separate table
was in use. This commit makes use of the APPLE_FLAG_DONT_TRANSLATE flag to
remove the need of such separate tables.

Signed-off-by: Aditya Garg <gargaditya08@xxxxxxxx>
---
 drivers/hid/hid-apple.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
index ca462e483..c672ffc97 100644
--- a/drivers/hid/hid-apple.c
+++ b/drivers/hid/hid-apple.c
@@ -285,14 +285,8 @@ static const struct apple_key_translation apple_iso_keyboard[] = {
 static const struct apple_key_translation swapped_option_cmd_keys[] = {
 	{ KEY_LEFTALT,	KEY_LEFTMETA },
 	{ KEY_LEFTMETA,	KEY_LEFTALT },
-	{ KEY_RIGHTALT,	KEY_RIGHTMETA },
-	{ KEY_RIGHTMETA, KEY_RIGHTALT },
-	{ }
-};
-
-static const struct apple_key_translation swapped_option_cmd_left_keys[] = {
-	{ KEY_LEFTALT,	KEY_LEFTMETA },
-	{ KEY_LEFTMETA,	KEY_LEFTALT },
+	{ KEY_RIGHTALT,	KEY_RIGHTMETA, APPLE_FLAG_DONT_TRANSLATE },
+	{ KEY_RIGHTMETA, KEY_RIGHTALT, APPLE_FLAG_DONT_TRANSLATE },
 	{ }
 };
 
@@ -399,12 +393,9 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
 	}
 
 	if (swap_opt_cmd) {
-		if (swap_opt_cmd == 2)
-			trans = apple_find_translation(swapped_option_cmd_left_keys, code);
-		else
-			trans = apple_find_translation(swapped_option_cmd_keys, code);
+		trans = apple_find_translation(swapped_option_cmd_keys, code);
 
-		if (trans)
+		if (trans && !(swap_opt_cmd == 2 && trans->flags & APPLE_FLAG_DONT_TRANSLATE))
 			code = trans->to;
 	}
 
-- 
2.43.0






[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux