From nobody Thu Nov 07 20:38:54 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 4Xkv723h6Cz5cZZZ; Thu, 07 Nov 2024 20:38:54 +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 4Xkv722lGrz3ww2; Thu, 7 Nov 2024 20:38:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731011934; 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=uMZFnrVknnmbSCi4rUJ146B75tUqLYpMkc31JFJ0IcQ=; b=rmoS4C/P/e5c4v5yhglEXSQ/rTDUIcF2VJL/aGqXoUePpa6zpmZUaqtRMABXd/OR0bMq5/ uIwIVrWcrFCsvCDoPTwllhvoCzCZCZ7zPQK9ou4aC9SlU6AeXWilTX19K+RXmox16I9MXJ nmxTJ1xGOgqM+VJNrQGA9shom4DMkp2dXbq1YgmoU8Z10qsC0j/1zsCqaxgEseRNomwarc s1N0P72En2UKmWtEhLAx7nU6JBU9cJqV7f+kpJK31JZLpOJtIdbUukRcUi7KCgkHmd4QPY rS1o3d9SwHabGblVlvFFiE/B9PIe+Y8QOpSK+AC1XJRDMQZJyXBG0YlQulAeJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731011934; 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=uMZFnrVknnmbSCi4rUJ146B75tUqLYpMkc31JFJ0IcQ=; b=m1eVNf0wQdiihn0l4Pz9flqmn5OS82ME8MqUzP3OUDsxFvi/A2NOUk5IgI1Y1mbNXQ130p VtlOjxJBiuPm97+QvGmZeYundcFqW+K9eicFVeGqBTQyIk/x6utyiZlrJMYboYreCXQzda UJKnB2Ux+B7tPILlSAeQEQNB3Y3ObZseDu++kqryiajeniyRWI+tQQD74xLB9z0NShSNek jYaMhEmjL0T+Xwzy2xbj6mID6ipcXn4NbuUgX88hYRVl6amYG6umA3mwcmN/WCNM8XPwT/ 4rUJcyIYLXFJ3R62oxW8StteerlXhy+RVCDw2P3w+hbGSBu9LFs/zrQSPaj5lg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1731011934; a=rsa-sha256; cv=none; b=OjhIfdHVReza59gyvaNXSY98rspYxKpmQyVhFcVDbxm7KGlf1CJjrymuWA4xOwN5tQ85II 26oEB1+wgRB6+Y5qoSo6P58Gmc1uXUyfLMR89JPoeT7YHGVQkGd36LE1UJnDSZ2uA0IRLW qcQNzkA8q1IohqHVZRRuTeWctcQ1nsst0HP/tQDKYqnweGSbFZDSh/3ZgHHVFgJ7Xv/EKF a1mEYlBlMWf2irQc8GL2UHKyJhdFJZdkfRtHenuMJOBVGjrDP1b7DPWZKBVJqydwE6Tp4c jz78+WpsnNBt5+7ETic1+7RsZc/CnmEOH47MMgmmf8LsX+EgF7ygOex1fUAThg== 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 4Xkv7223l6z118q; Thu, 7 Nov 2024 20:38:54 +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 4A7Kcskr019886; Thu, 7 Nov 2024 20:38:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4A7KcsDC019883; Thu, 7 Nov 2024 20:38:54 GMT (envelope-from git) Date: Thu, 7 Nov 2024 20:38:54 GMT Message-Id: <202411072038.4A7KcsDC019883@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 541e7a98b762 - main - 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/main X-Git-Reftype: branch X-Git-Commit: 541e7a98b762916cd951a64dd7e77efd51dfa8dc Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=541e7a98b762916cd951a64dd7e77efd51dfa8dc commit 541e7a98b762916cd951a64dd7e77efd51dfa8dc Author: Frank Hilgendorf AuthorDate: 2024-11-01 19:37:38 +0000 Commit: Mark Johnston CommitDate: 2024-11-07 20:38:38 +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 --- 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 61c7686da957..9a2f6a41c499 100644 --- a/sys/dev/usb/usbdevs +++ b/sys/dev/usb/usbdevs @@ -1141,10 +1141,38 @@ product AOX USB101 0x0008 Ethernet 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 @@ -1173,6 +1201,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 @@ -1193,6 +1225,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