summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorTobias Heider <tobhe@cvs.openbsd.org>2023-07-09 08:02:15 +0000
committerTobias Heider <tobhe@cvs.openbsd.org>2023-07-09 08:02:15 +0000
commitf53343a733ed594b484375369770d7c12a8f8339 (patch)
tree51347bbe7f8e5cb3c6aba71815b942cfab0b52b3 /sys
parent7a3202921dcddc840df18a25dcc932cf0f714666 (diff)
Add suspend key support in wskbd and make it work on Apple ARM laptops.
feedback and ok miod@
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/hid/hidkbd.c6
-rw-r--r--sys/dev/usb/makemap.awk6
-rw-r--r--sys/dev/wscons/wskbd.c9
-rw-r--r--sys/dev/wscons/wsksymdef.h3
4 files changed, 17 insertions, 7 deletions
diff --git a/sys/dev/hid/hidkbd.c b/sys/dev/hid/hidkbd.c
index c1faded214a..ef57b4f16a3 100644
--- a/sys/dev/hid/hidkbd.c
+++ b/sys/dev/hid/hidkbd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hidkbd.c,v 1.8 2022/11/09 10:05:18 robert Exp $ */
+/* $OpenBSD: hidkbd.c,v 1.9 2023/07/09 08:02:13 tobhe Exp $ */
/* $NetBSD: ukbd.c,v 1.85 2003/03/11 16:44:00 augustss Exp $ */
/*
@@ -144,6 +144,7 @@ static const struct hidkbd_translation apple_fn_trans[] = {
{ 61, 129 }, /* F4 -> audio lower */
{ 62, 128 }, /* F5 -> audio raise */
#else
+ { 63, 102 }, /* F6 -> sleep */
{ 67, 127 }, /* F10 -> audio mute */
{ 68, 129 }, /* F11 -> audio lower */
{ 69, 128 }, /* F12 -> audio raise */
@@ -557,11 +558,12 @@ hidkbd_decode(struct hidkbd *kbd, struct hidkbd_data *ud)
wskbd_rawinput(kbd->sc_wskbddev, cbuf, j);
/*
- * Pass audio and brightness keys to wskbd_input anyway.
+ * Pass audio, brightness and sleep keys to wskbd_input anyway.
*/
for (i = 0; i < nkeys; i++) {
key = ibuf[i];
switch (key & CODEMASK) {
+ case 102:
case 127:
case 128:
case 129:
diff --git a/sys/dev/usb/makemap.awk b/sys/dev/usb/makemap.awk
index 8a258dc9bf7..547f19bfa62 100644
--- a/sys/dev/usb/makemap.awk
+++ b/sys/dev/usb/makemap.awk
@@ -1,5 +1,5 @@
#! /usr/bin/awk -f
-# $OpenBSD: makemap.awk,v 1.15 2020/11/02 19:45:18 tobhe Exp $
+# $OpenBSD: makemap.awk,v 1.16 2023/07/09 08:02:13 tobhe Exp $
#
# Copyright (c) 2005, Miodrag Vallat
#
@@ -31,7 +31,7 @@
#
BEGIN {
- rcsid = "$OpenBSD: makemap.awk,v 1.15 2020/11/02 19:45:18 tobhe Exp $"
+ rcsid = "$OpenBSD: makemap.awk,v 1.16 2023/07/09 08:02:13 tobhe Exp $"
ifdepth = 0
ignore = 0
declk = 0
@@ -329,7 +329,7 @@ $1 == "#define" || $1 == "#undef" {
# the ``menu'' key.
#
if (nmaps++ == 0) {
- # 102 Suspend
+ lines[102] = " KC(102),\tKS_Cmd_Sleep,"
lines[116] = " KC(116),\tKS_Open,"
lines[117] = " KC(117),\tKS_Help,"
lines[118] = " KC(118),\tKS_Props,"
diff --git a/sys/dev/wscons/wskbd.c b/sys/dev/wscons/wskbd.c
index d651f119cb8..23a0744b0df 100644
--- a/sys/dev/wscons/wskbd.c
+++ b/sys/dev/wscons/wskbd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wskbd.c,v 1.114 2022/11/10 12:10:54 matthieu Exp $ */
+/* $OpenBSD: wskbd.c,v 1.115 2023/07/09 08:02:14 tobhe Exp $ */
/* $NetBSD: wskbd.c,v 1.80 2005/05/04 01:52:16 augustss Exp $ */
/*
@@ -1513,6 +1513,13 @@ internal_command(struct wskbd_softc *sc, u_int *type, keysym_t ksym,
if (*type != WSCONS_EVENT_KEY_DOWN)
return (0);
+#ifdef SUSPEND
+ if (ksym == KS_Cmd_Sleep) {
+ request_sleep(SLEEP_SUSPEND);
+ return (1);
+ }
+#endif
+
#ifdef HAVE_SCROLLBACK_SUPPORT
#if NWSDISPLAY > 0
switch (ksym) {
diff --git a/sys/dev/wscons/wsksymdef.h b/sys/dev/wscons/wsksymdef.h
index 881510d1e7b..69cc685d99d 100644
--- a/sys/dev/wscons/wsksymdef.h
+++ b/sys/dev/wscons/wsksymdef.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsksymdef.h,v 1.40 2023/01/23 09:36:40 nicm Exp $ */
+/* $OpenBSD: wsksymdef.h,v 1.41 2023/07/09 08:02:14 tobhe Exp $ */
/* $NetBSD: wsksymdef.h,v 1.34.4.1 2000/07/07 09:49:54 hannken Exp $ */
/*-
@@ -667,6 +667,7 @@
#define KS_Cmd_ScrollBack 0xf42c
#define KS_Cmd_ScrollFwd 0xf42d
#define KS_Cmd_KbdReset 0xf42e
+#define KS_Cmd_Sleep 0xf42f
/*
* Group 5 (internal)