Skip to content

Commit

Permalink
Improve code in keyboard driver
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaGarg8 authored Aug 8, 2024
1 parent 148fe7f commit d29f387
Showing 1 changed file with 12 additions and 25 deletions.
37 changes: 12 additions & 25 deletions 1006-HID-hid-appletb-kbd-add-driver-for-the-keyboard-mode.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
From 8e77827903df3331dd38238a827d611b52446915 Mon Sep 17 00:00:00 2001
From f94e8e0b275b22c94d0cf8277c33185ed405de87 Mon Sep 17 00:00:00 2001
From: Kerem Karabay <[email protected]>
Date: Sun, 5 Mar 2023 18:17:23 +0300
Subject: [PATCH] HID: hid-appletb-kbd: add driver for the keyboard mode of
Subject: [PATCH 2/2] HID: hid-appletb-kbd: add driver for the keyboard mode of
Apple Touch Bars
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Expand All @@ -23,9 +23,9 @@ Signed-off-by: Kerem Karabay <[email protected]>
.../ABI/testing/sysfs-driver-hid-appletb-kbd | 13 +
drivers/hid/Kconfig | 11 +
drivers/hid/Makefile | 1 +
drivers/hid/hid-appletb-kbd.c | 316 ++++++++++++++++++
drivers/hid/hid-appletb-kbd.c | 303 ++++++++++++++++++
drivers/hid/hid-quirks.c | 4 +-
5 files changed, 344 insertions(+), 1 deletion(-)
5 files changed, 331 insertions(+), 1 deletion(-)
create mode 100644 Documentation/ABI/testing/sysfs-driver-hid-appletb-kbd
create mode 100644 drivers/hid/hid-appletb-kbd.c

Expand Down Expand Up @@ -84,10 +84,10 @@ index 1d825a474..d903c9a26 100644
obj-$(CONFIG_HID_AUREAL) += hid-aureal.o
diff --git a/drivers/hid/hid-appletb-kbd.c b/drivers/hid/hid-appletb-kbd.c
new file mode 100644
index 000000000..453d5c7e1
index 000000000..0b6ac8c59
--- /dev/null
+++ b/drivers/hid/hid-appletb-kbd.c
@@ -0,0 +1,316 @@
@@ -0,0 +1,303 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Apple Touch Bar Keyboard Mode Driver
Expand Down Expand Up @@ -149,23 +149,6 @@ index 000000000..453d5c7e1
+ { KE_END, 0 }
+};
+
+static const struct key_entry appletb_kbd_keymap_fn[] = {
+ { KE_KEY, KEY_ESC, { KEY_ESC } },
+ { KE_KEY, KEY_F1, { KEY_F1 } },
+ { KE_KEY, KEY_F2, { KEY_F2 } },
+ { KE_KEY, KEY_F3, { KEY_F3 } },
+ { KE_KEY, KEY_F4, { KEY_F4 } },
+ { KE_KEY, KEY_F5, { KEY_F5 } },
+ { KE_KEY, KEY_F6, { KEY_F6 } },
+ { KE_KEY, KEY_F7, { KEY_F7 } },
+ { KE_KEY, KEY_F8, { KEY_F8 } },
+ { KE_KEY, KEY_F9, { KEY_F9 } },
+ { KE_KEY, KEY_F10, { KEY_F10 } },
+ { KE_KEY, KEY_F11, { KEY_F11 } },
+ { KE_KEY, KEY_F12, { KEY_F12 } },
+ { KE_END, 0 }
+};
+
+static int appletb_kbd_set_mode(struct appletb_kbd *kbd, u8 mode)
+{
+ struct hid_report *report = kbd->mode_field->report;
Expand Down Expand Up @@ -293,8 +276,12 @@ index 000000000..453d5c7e1
+
+ __set_bit(EV_REP, input->evbit);
+
+ sparse_keymap_setup(input, appletb_kbd_keymap_fn, NULL);
+ sparse_keymap_setup(input, appletb_kbd_keymap_spcl, NULL);
+
+ for (int i = KEY_F1; i <= KEY_F12; i++) {
+ input_set_capability(input, EV_KEY, i);
+ }
+
+ return 0;
+}
+
Expand Down Expand Up @@ -427,5 +414,5 @@ index 818d41a35..7c576d654 100644
{ HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_I2C_KEYBOARD) },
{ HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_I2C_TOUCHPAD) },
--
2.43.0
2.39.3 (Apple Git-146)

0 comments on commit d29f387

Please sign in to comment.