On Sat, Jul 08, 2023 at 04:06:33PM +0000, Miod Vallat wrote:
> > Now that we have request_sleep() we can add a new internal KS_Cmd_Sleep
> > keycode, map it into the macbook keyboard, catch in wskbd and go to sleep.
> >
> > ok?
>
> > --- sys/dev/usb/ukbdmap.c
> > +++ sys/dev/usb/ukbdmap.c
> > @@ -176,6 +176,7 @@ static const keysym_t ukbd_keydesc_us[] = {
> > KC(127), KS_AudioMute,
> > KC(128), KS_AudioRaise,
> > KC(129), KS_AudioLower,
> > + KC(130), KS_Cmd_Sleep,
> > KC(224), KS_Cmd1, KS_Control_L,
> > KC(225), KS_Shift_L,
> > KC(226), KS_Cmd2, KS_Alt_L,
>
> This file is generated, so the changes would be lost eventually.
>
> You should add this in makemap.awk in the block starting at line 330.
> Also, that block mentions the use of keysym 102 for suspend, rather than
> 130 (which you probably picked randomly), so I would prefer if you
> would use 102, this would allow this feature to also work on more
> systems.
Right, I should have known that. Here is an update with all the fixes
you requested including always returning 1, 102 as id and the awk script.
I will of course commit in two steps but included it all in the same
diff for convenience.
ok?
diff 4cfcaa1dc85fba5c0672ef2787341ee6cc639979 refs/heads/acpi
commit - 4cfcaa1dc85fba5c0672ef2787341ee6cc639979
commit + e5107675c0ac640f66a3461f4efa50b84f735ae0
blob - c1faded214af03befd904994c6b8a9606f6b64c8
blob + a88fa9e3d9d6fa12c84b64b992bb6008398777b1
--- sys/dev/hid/hidkbd.c
+++ sys/dev/hid/hidkbd.c
@@ -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 */
@@ -565,6 +566,7 @@ hidkbd_decode(struct hidkbd *kbd, struct hidkbd_data *
case 127:
case 128:
case 129:
+ case 102:
case 232:
case 233:
wskbd_input(kbd->sc_wskbddev,
blob - 8a258dc9bf71251c002f5edb290c011537943ea6
blob + 6f18b7170d87d3b1239cf8550105e06fb9870bf6
--- sys/dev/usb/makemap.awk
+++ sys/dev/usb/makemap.awk
@@ -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,"
blob - da8a33e47dfe3e1c86990ae4e21914138d4fb785
blob + 918eb8526a7c2d8ad6e52385c83711fe6a6a3a98
--- sys/dev/usb/ukbdmap.c
+++ sys/dev/usb/ukbdmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ukbdmap.c,v 1.47 2023/01/23 09:38:03 nicm Exp $ */
+/* $OpenBSD$ */
/*
* THIS FILE IS AUTOMAGICALLY GENERATED. DO NOT EDIT.
@@ -150,6 +150,7 @@ static const keysym_t ukbd_keydesc_us[] = {
KC(98), KS_KP_Insert, KS_KP_0,
KC(99), KS_KP_Delete, KS_KP_Decimal,
KC(101), KS_Menu,
+ KC(102), KS_Cmd_Sleep,
KC(104), KS_f13,
KC(105), KS_f14,
KC(106), KS_f15,
blob - d651f119cb873b6712d678c866ee2ff0f067edaf
blob + e0fd80a19e348a88a38195f8f56161c697a32cd3
--- sys/dev/wscons/wskbd.c
+++ sys/dev/wscons/wskbd.c
@@ -1513,6 +1513,13 @@ internal_command(struct wskbd_softc *sc, u_int *type,
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) {
blob - 881510d1e7b40edbcc11a228b71d84c2aad63f0f
blob + d3d34cca8297ef03dbc310ac97b44c1759ed7da0
--- sys/dev/wscons/wsksymdef.h
+++ sys/dev/wscons/wsksymdef.h
@@ -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)