From nobody Fri Nov 22 21:24:14 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Xw7QR1GHCz5dP5Q; Fri, 22 Nov 2024 21:24:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Xw7QQ6Vk7z4cn2; Fri, 22 Nov 2024 21:24:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732310654; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=p0XLCyFjMOg/KOOaCIlN+nS7h5ZA3OX8+k+6yqCr4jM=; b=Ea1fmBuTPs3qa4zwBlBVxlcP/QmKq1KDpX6nFVLQL6EhYzfMpiJwGIfalQl8l+gaD/F88+ sbKDBp+JfoIHMuMqBSAzg/Y+3WYKgFWnQvh28YZ/W1I8vTtnlPXfDtf8VQN/U3XFApGKp6 /sgl9fKtDfRBjCl/fKYNlp8xLtXEBAljnXX2E2CpG4o8lqieSvS/WfKmKySzrNpQHanvzR MqWcCANIlSK6Wlej4zdk9fwTVTrsCHmD+Zyo+H+zPUmiCO5LnDww0s/whRcKg3iUvrUb+0 IaV8XeQICUMu2tF2XFZuQ3+mC3xlMFWNxsL1U7vGEExasZ6O244T0213jODVKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732310654; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=p0XLCyFjMOg/KOOaCIlN+nS7h5ZA3OX8+k+6yqCr4jM=; b=MjUT+MfShMHwkMCAYzue+8gBmqJ+qkusOzHPlOYgpKdYPDdGOR1u0Nov80G9JvavFzzrdw YbUoI0+KlLk2AK6HQI8ld0WwaDialM0M6xIqZz8ueXNMG4QOQ3LtD42Mn6XGrRtae97hRB ckamBpkk6mYkWCth2smwzFiUeokTT8W7ZPiX735mTdl7xcAwDBH7OaKvkTq+3CiwrjowoK 4tuMvVBsdlHUwjJ+2o+VDNczsvYGZpEvkXvJqzbQnBgnKCGr2XZNDzlbc6AJySDvCQaFoU V3H4AFnH7PfUr3DUmtN7WoxrCTuUV8usoXeylon996HE2/fPq88krGr8tQtC2A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1732310654; a=rsa-sha256; cv=none; b=YSOXfCGnB6hwkc5Q+8Lajk+juSuSEtX/elnyQY9TJCo70VWn15nM4jtaYKOXyOhwmWWX83 f/aFeij8wRq0x48cFcwJ6vF4wKuPriCYOaTYol+5xRLA16dExita0GJjHjJngmYip9CDF7 OPVlSPuCDeI1zqseEQP2djYMKOdc9w1zMdtXDk4mE9wm3mN/YCDkIyfbvW8QznSPVBbok1 mF6YPI1RyWmvOjIjx62Do2eX2qTSHOecxikJ2hn55ok+daF2uuktEuAQ6IIYmSOrQtIcTx l2dPfJkW1bsWhCn/x2a968CCnf2QeKW4DkVJ/AblZLX/PU+RjZ021AqmyxWmkg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Xw7QQ5qFzzhX3; Fri, 22 Nov 2024 21:24:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4AMLOE6q088440; Fri, 22 Nov 2024 21:24:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4AMLOE5e088437; Fri, 22 Nov 2024 21:24:14 GMT (envelope-from git) Date: Fri, 22 Nov 2024 21:24:14 GMT Message-Id: <202411222124.4AMLOE5e088437@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 3126ebadf9e2 - stable/14 - ukbd: Enable ukbd_apple_swap for all Apple ISO keyboards List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 3126ebadf9e203ee3e7d7dd5bac0c48d74007c16 Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=3126ebadf9e203ee3e7d7dd5bac0c48d74007c16 commit 3126ebadf9e203ee3e7d7dd5bac0c48d74007c16 Author: Frank Hilgendorf AuthorDate: 2024-11-01 19:37:38 +0000 Commit: Mark Johnston CommitDate: 2024-11-22 21:23:47 +0000 ukbd: Enable ukbd_apple_swap for all Apple ISO keyboards Key code swapping between [<>] and [^°] key is enabled for all Apple ISO type keyboards. Before, swapping was enabled when the Eject key was detected in HID usage. This did not correlate well with the swapped keys presence. usbdevs file is extended by several Apple keyboard models to support ISO model identification. Reviewed by: markj MFC after: 2 weeks Pull Request: https://github.com/freebsd/freebsd-src/pull/1506 (cherry picked from commit 541e7a98b762916cd951a64dd7e77efd51dfa8dc) --- sys/dev/usb/input/ukbd.c | 72 ++++++++++++++++++++++++++++++++++++++++++++---- sys/dev/usb/usbdevs | 42 ++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+), 6 deletions(-) diff --git a/sys/dev/usb/input/ukbd.c b/sys/dev/usb/input/ukbd.c index f33ae6e8a620..9ff093628312 100644 --- a/sys/dev/usb/input/ukbd.c +++ b/sys/dev/usb/input/ukbd.c @@ -72,6 +72,8 @@ #include +#include "usbdevs.h" + #ifdef EVDEV_SUPPORT #include #include @@ -173,13 +175,19 @@ struct ukbd_softc { #define UKBD_FLAG_ATTACHED 0x00000010 #define UKBD_FLAG_GONE 0x00000020 -#define UKBD_FLAG_HID_MASK 0x003fffc0 -#define UKBD_FLAG_APPLE_EJECT 0x00000040 -#define UKBD_FLAG_APPLE_FN 0x00000080 -#define UKBD_FLAG_APPLE_SWAP 0x00000100 +/* set in ukbd_attach */ +#define UKBD_FLAG_APPLE_SWAP 0x00000040 +/* set in ukbd_parse_hid */ +#define UKBD_FLAG_APPLE_EJECT 0x00000080 +#define UKBD_FLAG_APPLE_FN 0x00000100 #define UKBD_FLAG_NUMLOCK 0x00080000 #define UKBD_FLAG_CAPSLOCK 0x00100000 #define UKBD_FLAG_SCROLLLOCK 0x00200000 +#define UKBD_FLAG_HID_MASK UKBD_FLAG_APPLE_EJECT | \ + UKBD_FLAG_APPLE_FN | \ + UKBD_FLAG_NUMLOCK | \ + UKBD_FLAG_CAPSLOCK | \ + UKBD_FLAG_SCROLLLOCK int sc_mode; /* input mode (K_XLATE,K_RAW,K_CODE) */ int sc_state; /* shift/lock key state */ @@ -296,6 +304,48 @@ static const uint8_t ukbd_boot_desc[] = { 0xff, 0x00, 0x81, 0x00, 0xc0 }; +static const STRUCT_USB_HOST_ID ukbd_apple_iso_models[] = { + /* PowerBooks Feb 2005, iBooks G4 */ + { USB_VP(USB_VENDOR_APPLE, USB_PRODUCT_APPLE_FOUNTAIN_ISO) }, + /* PowerBooks Oct 2005 */ + { USB_VP(USB_VENDOR_APPLE, USB_PRODUCT_APPLE_GEYSER_ISO) }, + /* Core Duo MacBook & MacBook Pro */ + { USB_VP(USB_VENDOR_APPLE, USB_PRODUCT_APPLE_GEYSER3_ISO) }, + /* Core2 Duo MacBook & MacBook Pro */ + { USB_VP(USB_VENDOR_APPLE, USB_PRODUCT_APPLE_GEYSER4_ISO) }, + { USB_VP(USB_VENDOR_APPLE, USB_PRODUCT_APPLE_GEYSER4_HF_ISO) }, + { USB_VP(USB_VENDOR_APPLE, USB_PRODUCT_APPLE_ALU_MINI_ISO) }, + { USB_VP(USB_VENDOR_APPLE, USB_PRODUCT_APPLE_ALU_ISO) }, + { USB_VP(USB_VENDOR_APPLE, USB_PRODUCT_APPLE_ALU_REVB_ISO) }, + /* MacbookAir, aka wellspring */ + { USB_VP(USB_VENDOR_APPLE, USB_PRODUCT_APPLE_WELLSPRING_ISO) }, + /* MacbookProPenryn, aka wellspring2 */ + { USB_VP(USB_VENDOR_APPLE, USB_PRODUCT_APPLE_WELLSPRING2_ISO) }, + /* Macbook5,1 (unibody), aka wellspring3 */ + { USB_VP(USB_VENDOR_APPLE, USB_PRODUCT_APPLE_WELLSPRING3_ISO) }, + /* MacbookAir3,2 (unibody), aka wellspring4 */ + { USB_VP(USB_VENDOR_APPLE, USB_PRODUCT_APPLE_WELLSPRING4_ISO) }, + /* MacbookAir3,1 (unibody), aka wellspring4 */ + { USB_VP(USB_VENDOR_APPLE, USB_PRODUCT_APPLE_WELLSPRING4A_ISO) }, + /* Macbook8 (unibody, March 2011) */ + { USB_VP(USB_VENDOR_APPLE, USB_PRODUCT_APPLE_WELLSPRING5_ISO) }, + /* Macbook8,2 (unibody) */ + { USB_VP(USB_VENDOR_APPLE, USB_PRODUCT_APPLE_WELLSPRING5A_ISO) }, + /* MacbookAir4,2 (unibody, July 2011) */ + { USB_VP(USB_VENDOR_APPLE, USB_PRODUCT_APPLE_WELLSPRING6_ISO) }, + /* MacbookAir4,1 (unibody, July 2011) */ + { USB_VP(USB_VENDOR_APPLE, USB_PRODUCT_APPLE_WELLSPRING6A_ISO) }, + /* MacbookPro10,1 (unibody, June 2012) */ + { USB_VP(USB_VENDOR_APPLE, USB_PRODUCT_APPLE_WELLSPRING7_ISO) }, + /* MacbookPro10,2 (unibody, October 2012) */ + { USB_VP(USB_VENDOR_APPLE, USB_PRODUCT_APPLE_WELLSPRING7A_ISO) }, + /* MacbookAir6,2 (unibody, June 2013) */ + { USB_VP(USB_VENDOR_APPLE, USB_PRODUCT_APPLE_WELLSPRING8_ISO) }, + /* MacbookPro12,1 */ + { USB_VP(USB_VENDOR_APPLE, USB_PRODUCT_APPLE_WELLSPRING9_ISO) }, +}; + + /* prototypes */ static void ukbd_timeout(void *); static void ukbd_set_leds(struct ukbd_softc *, uint8_t); @@ -1001,8 +1051,7 @@ ukbd_parse_hid(struct ukbd_softc *sc, const uint8_t *ptr, uint32_t len) hid_input, 0, &sc->sc_loc_apple_eject, &flags, &sc->sc_id_apple_eject)) { if (flags & HIO_VARIABLE) - sc->sc_flags |= UKBD_FLAG_APPLE_EJECT | - UKBD_FLAG_APPLE_SWAP; + sc->sc_flags |= UKBD_FLAG_APPLE_EJECT; DPRINTFN(1, "Found Apple eject-key\n"); } if (hid_locate(ptr, len, @@ -1138,6 +1187,17 @@ ukbd_attach(device_t dev) sc->sc_fkeymap[n] = fkey_tab[n]; } + /* check if this is an Apple keyboard with swapped key codes + * apparently, these are the ISO layout models + */ + DPRINTF("uaa vendor: 0x%04x, uaa product 0x%04x\n", uaa->info.idVendor, uaa->info.idProduct ); + if (usbd_lookup_id_by_uaa(ukbd_apple_iso_models, sizeof(ukbd_apple_iso_models), uaa) == 0) { + sc->sc_flags |= UKBD_FLAG_APPLE_SWAP; + DPRINTF("UKBD_FLAG_APPLE_SWAP set\n"); + } else { + DPRINTF("UKBD_FLAG_APPLE_SWAP not set\n"); + } + kbd_set_maps(kbd, &sc->sc_keymap, &sc->sc_accmap, sc->sc_fkeymap, UKBD_NFKEY); diff --git a/sys/dev/usb/usbdevs b/sys/dev/usb/usbdevs index 18176fa516a9..af33b2cdec07 100644 --- a/sys/dev/usb/usbdevs +++ b/sys/dev/usb/usbdevs @@ -1142,10 +1142,38 @@ product APPLE DUMMY 0x0000 Dummy product product APPLE IMAC_KBD 0x0201 USB iMac Keyboard product APPLE KBD 0x0202 USB Keyboard M2452 product APPLE EXT_KBD 0x020c Apple Extended USB Keyboard +/* PowerBooks Feb 2005, iBooks G4 */ +product APPLE FOUNTAIN_ANSI 0x020e Apple Internal Keyboard/Trackpad +product APPLE FOUNTAIN_ISO 0x020f Apple Internal Keyboard/Trackpad +/* 17 inch PowerBook */ +product APPLE GEYSER_17 0x020d Apple Internal Keyboard/Trackpad +/* PowerBooks Oct 2005 */ +product APPLE GEYSER_ANSI 0x0214 Apple Internal Keyboard/Trackpad +product APPLE GEYSER_ISO 0x0215 Apple Internal Keyboard/Trackpad +product APPLE GEYSER_JIS 0x0216 Apple Internal Keyboard/Trackpad +/* Core Duo MacBook & MacBook Pro */ +product APPLE GEYSER3_ANSI 0x0217 Apple Internal Keyboard/Trackpad +product APPLE GEYSER3_ISO 0x0218 Apple Internal Keyboard/Trackpad +product APPLE GEYSER3_JIS 0x0219 Apple Internal Keyboard/Trackpad +/* Core2 Duo MacBook & MacBook Pro */ +product APPLE GEYSER4_ANSI 0x021a Apple Internal Keyboard/Trackpad +product APPLE GEYSER4_ISO 0x021b Apple Internal Keyboard/Trackpad +product APPLE GEYSER4_JIS 0x021c Apple Internal Keyboard/Trackpad +/* External */ +product APPLE ALU_MINI_ANSI 0x021d Apple Keyboard/Trackpad +product APPLE ALU_MINI_ISO 0x021e Apple Keyboard/Trackpad +product APPLE ALU_MINI_JIS 0x021f Apple Keyboard/Trackpad +product APPLE ALU_ANSI 0x0220 Apple Keyboard/Trackpad +product APPLE ALU_ISO 0x0221 Apple Keyboard/Trackpad +product APPLE ALU_JIS 0x0222 Apple Keyboard/Trackpad /* MacbookAir, aka wellspring */ product APPLE WELLSPRING_ANSI 0x0223 Apple Internal Keyboard/Trackpad product APPLE WELLSPRING_ISO 0x0224 Apple Internal Keyboard/Trackpad product APPLE WELLSPRING_JIS 0x0225 Apple Internal Keyboard/Trackpad +/* Core2 Duo MacBook3,1 */ +product APPLE GEYSER4_HF_ANSI 0x0229 Apple Internal Keyboard/Trackpad +product APPLE GEYSER4_HF_ISO 0x022a Apple Internal Keyboard/Trackpad +product APPLE GEYSER4_HF_JIS 0x022b Apple Internal Keyboard/Trackpad /* MacbookProPenryn, aka wellspring2 */ product APPLE WELLSPRING2_ANSI 0x0230 Apple Internal Keyboard/Trackpad product APPLE WELLSPRING2_ISO 0x0231 Apple Internal Keyboard/Trackpad @@ -1174,6 +1202,10 @@ product APPLE WELLSPRING6A_JIS 0x024b Apple Internal Keyboard/Trackpad product APPLE WELLSPRING6_ANSI 0x024c Apple Internal Keyboard/Trackpad product APPLE WELLSPRING6_ISO 0x024d Apple Internal Keyboard/Trackpad product APPLE WELLSPRING6_JIS 0x024e Apple Internal Keyboard/Trackpad +/* External */ +product APPLE ALU_REVB_ANSI 0x024f Apple Keyboard/Trackpad +product APPLE ALU_REVB_ISO 0x0250 Apple Keyboard/Trackpad +product APPLE ALU_REVB_JIS 0x0251 Apple Keyboard/Trackpad /* Macbook8,2 (unibody) */ product APPLE WELLSPRING5A_ANSI 0x0252 Apple Internal Keyboard/Trackpad product APPLE WELLSPRING5A_ISO 0x0253 Apple Internal Keyboard/Trackpad @@ -1194,6 +1226,16 @@ product APPLE WELLSPRING8_JIS 0x0292 Apple Internal Keyboard/Trackpad product APPLE WELLSPRING9_ANSI 0x0272 Apple Internal Keyboard/Trackpad product APPLE WELLSPRING9_ISO 0x0273 Apple Internal Keyboard/Trackpad product APPLE WELLSPRING9_JIS 0x0274 Apple Internal Keyboard/Trackpad +product APPLE WELLSPRINGT2_J140K 0x027a Apple Internal Keyboard/Trackpad +product APPLE WELLSPRINGT2_J132 0x027b Apple Internal Keyboard/Trackpad +product APPLE WELLSPRINGT2_J680 0x027c Apple Internal Keyboard/Trackpad +product APPLE WELLSPRINGT2_J213 0x027d Apple Internal Keyboard/Trackpad +product APPLE WELLSPRINGT2_J214K 0x027e Apple Internal Keyboard/Trackpad +product APPLE WELLSPRINGT2_J223 0x027f Apple Internal Keyboard/Trackpad +product APPLE WELLSPRINGT2_J230K 0x0280 Apple Internal Keyboard/Trackpad +product APPLE WELLSPRINGT2_J152F 0x0340 Apple Internal Keyboard/Trackpad +product APPLE MAGIC_KEYBOARD_2021 0x029c Apple Internal Keyboard/Trackpad +product APPLE MAGIC_KEYBOARD_FINGERPRINT_2021 0x029a Apple Keyboard/Trackpad product APPLE MAGIC_TRACKPAD2 0x0265 Apple Magic Trackpad 2 product APPLE MOUSE 0x0301 Mouse M4848 product APPLE OPTMOUSE 0x0302 Optical mouse