summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Nagy <robert@cvs.openbsd.org>2022-11-09 10:05:19 +0000
committerRobert Nagy <robert@cvs.openbsd.org>2022-11-09 10:05:19 +0000
commit13f98e113fb16ed4f0c4c050a4c526e84c4bd826 (patch)
treed86836d12065a3279ba7b6001fc90aa237a88bb6
parent7c3d55ee60505232a7ab60d23d4272827bdbe132 (diff)
translate Fn+(1-10,-,=) keys to F1-F12 on M1 laptops with a touchbar
ok kettenis@, miod@
-rw-r--r--sys/arch/arm64/dev/aplhidev.c16
-rw-r--r--sys/dev/hid/hidkbd.c31
-rw-r--r--sys/dev/hid/hidkbdsc.h3
3 files changed, 45 insertions, 5 deletions
diff --git a/sys/arch/arm64/dev/aplhidev.c b/sys/arch/arm64/dev/aplhidev.c
index dc221a0f677..f1c3f5ad0e7 100644
--- a/sys/arch/arm64/dev/aplhidev.c
+++ b/sys/arch/arm64/dev/aplhidev.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: aplhidev.c,v 1.8 2022/10/02 19:00:46 kettenis Exp $ */
+/* $OpenBSD: aplhidev.c,v 1.9 2022/11/09 10:05:18 robert Exp $ */
/*
* Copyright (c) 2021 Mark Kettenis <kettenis@openbsd.org>
* Copyright (c) 2013-2014 joshua stein <jcs@openbsd.org>
@@ -33,6 +33,8 @@
#include <dev/ofw/ofw_gpio.h>
#include <dev/ofw/ofw_pinctrl.h>
+#include <dev/usb/usbdevs.h>
+
#include <dev/wscons/wsconsio.h>
#include <dev/wscons/wskbdvar.h>
#include <dev/wscons/wsksymdef.h>
@@ -526,8 +528,16 @@ aplkbd_attach(struct device *parent, struct device *self, void *aux)
printf("\n");
if (hid_locate(aa->aa_desc, aa->aa_desclen, HID_USAGE2(HUP_APPLE, HUG_FN_KEY),
- 1, hid_input, &kbd->sc_fn, NULL))
- kbd->sc_munge = hidkbd_apple_munge;
+ 1, hid_input, &kbd->sc_fn, NULL)) {
+ switch (sc->sc_hidev->sc_product) {
+ case USB_PRODUCT_APPLE_WELLSPRINGM1_J293:
+ kbd->sc_munge = hidkbd_apple_tb_munge;
+ break;
+ default:
+ kbd->sc_munge = hidkbd_apple_munge;
+ break;
+ }
+ }
if (kbd->sc_console_keyboard) {
extern struct wskbd_mapdata ukbd_keymapdata;
diff --git a/sys/dev/hid/hidkbd.c b/sys/dev/hid/hidkbd.c
index 08e02c4f9c5..c1faded214a 100644
--- a/sys/dev/hid/hidkbd.c
+++ b/sys/dev/hid/hidkbd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hidkbd.c,v 1.7 2022/09/16 16:30:10 robert Exp $ */
+/* $OpenBSD: hidkbd.c,v 1.8 2022/11/09 10:05:18 robert Exp $ */
/* $NetBSD: ukbd.c,v 1.85 2003/03/11 16:44:00 augustss Exp $ */
/*
@@ -108,6 +108,21 @@ const u_int8_t hidkbd_trtab[256] = {
};
#endif /* defined(WSDISPLAY_COMPAT_RAWKBD) */
+static const struct hidkbd_translation apple_tb_trans[] = {
+ { 30, 58 }, /* 1 -> F1 */
+ { 31, 59 }, /* 2 -> F2 */
+ { 32, 60 }, /* 3 -> F3 */
+ { 33, 61 }, /* 4 -> F4 */
+ { 34, 62 }, /* 5 -> F5 */
+ { 35, 63 }, /* 6 -> F6 */
+ { 36, 64 }, /* 7 -> F7 */
+ { 37, 65 }, /* 8 -> F8 */
+ { 38, 66 }, /* 9 -> F9 */
+ { 39, 67 }, /* 0 -> F10 */
+ { 45, 68 }, /* - -> F11 */
+ { 46, 69 } /* = -> F12 */
+};
+
static const struct hidkbd_translation apple_fn_trans[] = {
{ 40, 73 }, /* return -> insert */
{ 42, 76 }, /* backspace -> delete */
@@ -337,6 +352,20 @@ hidkbd_apple_munge(void *vsc, uint8_t *ibuf, u_int ilen)
}
void
+hidkbd_apple_tb_munge(void *vsc, uint8_t *ibuf, u_int ilen)
+{
+ struct hidkbd *kbd = vsc;
+
+ if (!hid_get_data(ibuf, ilen, &kbd->sc_fn))
+ return;
+
+ hidkbd_apple_munge(vsc, ibuf, ilen);
+
+ hidkbd_apple_translate(vsc, ibuf, ilen, apple_tb_trans,
+ nitems(apple_tb_trans));
+}
+
+void
hidkbd_apple_iso_munge(void *vsc, uint8_t *ibuf, u_int ilen)
{
hidkbd_apple_translate(vsc, ibuf, ilen, apple_iso_trans,
diff --git a/sys/dev/hid/hidkbdsc.h b/sys/dev/hid/hidkbdsc.h
index f8efc80fe45..d7128523bc7 100644
--- a/sys/dev/hid/hidkbdsc.h
+++ b/sys/dev/hid/hidkbdsc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: hidkbdsc.h,v 1.2 2022/09/16 16:30:10 robert Exp $ */
+/* $OpenBSD: hidkbdsc.h,v 1.3 2022/11/09 10:05:18 robert Exp $ */
/* $NetBSD: ukbd.c,v 1.85 2003/03/11 16:44:00 augustss Exp $ */
/*
@@ -113,6 +113,7 @@ int hidkbd_ioctl(struct hidkbd *, u_long, caddr_t, int, struct proc *);
int hidkbd_set_leds(struct hidkbd *, int, uint8_t *);
uint8_t hidkbd_translate(const struct hidkbd_translation *, size_t, uint8_t);
void hidkbd_apple_munge(void *, uint8_t *, u_int);
+void hidkbd_apple_tb_munge(void *, uint8_t *, u_int);
void hidkbd_apple_iso_munge(void *, uint8_t *, u_int);
void hidkbd_apple_mba_munge(void *, uint8_t *, u_int);
void hidkbd_apple_iso_mba_munge(void *, uint8_t *, u_int);