Port-mac68k archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

PowerBook and ADB keyboard impovements



Hi,

Attached are patches that add support for raw keyboard mode (useful in X11) 
and the ability to emulate function keys 1 through to 8 on a standard or 
PowerBook keyboard.

The config option EMULFKEYS cannot be used togther with ALTXBUTTONS as there 
would be a key clash.

See attached:


I'd like to commit these in a week if there are no objections.


Best regards,

Nat
--- a/sys/arch/mac68k/dev/akbd.c	Tue May 12 13:07:52 2026 +0000
+++ b/sys/arch/mac68k/dev/akbd.c	Sun May 17 02:45:17 2026 +1000
@@ -468,8 +468,8 @@
 int
 akbd_ioctl(void *v, u_long cmd, void *data, int flag, struct lwp *l)
 {
-#ifdef notyet
-	struct akbd_softc *ksc = v;
+#ifdef WSDISPLAY_COMPAT_RAWKBD
+	struct akbd_softc *ksc = (struct akbd_softc *) v;
 #endif
 
 	switch (cmd) {
@@ -497,6 +497,11 @@
 		/* comes in as msec, goes out as ticks; volume ignored */
 #undef d
 		return (0);
+#ifdef WSDISPLAY_COMPAT_RAWKBD
+	case WSKBDIO_SETMODE:
+		ksc->sc_rawkbd = *(int *)data == WSKBD_RAW;
+		return (0);
+#endif
 	}
 	/* kbdioctl(...); */
 
@@ -526,6 +531,26 @@
 
 	if (adb_polling)
 		polledkey = key;
+#ifdef WSDISPLAY_COMPAT_RAWKBD
+	else if (sc->sc_rawkbd) {
+		char cbuf[2];
+		int s;
+		int j = 0;
+		int c = keyboard[ADBK_KEYVAL(key)][3];
+
+		if (c == 0)			/* XXX */
+			return (0);
+
+		if (c & 0x80)
+			cbuf[j++] = 0xe0;
+
+		cbuf[j++] = (c & 0x7f) | (ADBK_PRESS(key)? 0 : 0x80);
+
+		s = spltty();
+		wskbd_rawinput(sc->sc_wskbddev, cbuf, j);
+		splx(s);
+	}
+#endif
 	else
 		wskbd_input(sc->sc_wskbddev, type, val);
 
--- a/sys/arch/mac68k/dev/akbdvar.h	Tue May 12 13:07:52 2026 +0000
+++ b/sys/arch/mac68k/dev/akbdvar.h	Sun May 17 02:45:17 2026 +1000
@@ -46,6 +46,10 @@
 
 	u_int8_t	sc_leds;	/* current LED state */
 	device_t	sc_wskbddev;
+
+#ifdef WSDISPLAY_COMPAT_RAWKBD
+	int sc_rawkbd;
+#endif
 };
 
 /* LED register bits, inverse of actual register value */
--- a/sys/arch/mac68k/include/keyboard.h	Tue May 12 13:07:52 2026 +0000
+++ b/sys/arch/mac68k/include/keyboard.h	Sun May 17 02:45:17 2026 +1000
@@ -72,137 +81,137 @@
 				 (((key) & 0x7f) == ADBK_OPTION))
 
 #ifndef KEYBOARD_ARRAY
-extern unsigned char keyboard[128][3];
+extern unsigned char keyboard[128][4];
 #else
-unsigned char keyboard[128][3] = {
-		/* Scan code      Normal     Shifted     Controlled */
-	{	/*   0x00, */       'a',       'A',         0x01 },
-	{	/*   0x01, */       's',       'S',         0x13 },
-	{	/*   0x02, */       'd',       'D',         0x04 },
-	{	/*   0x03, */       'f',       'F',         0x06 },
-	{	/*   0x04, */       'h',       'H',         0x08 },
-	{	/*   0x05, */       'g',       'G',         0x07 },
-	{	/*   0x06, */       'z',       'Z',         0x1A },
-	{	/*   0x07, */       'x',       'X',         0x18 },
-	{	/*   0x08, */       'c',       'C',         0x03 },
-	{	/*   0x09, */       'v',       'V',         0x16 },
-	{	/*   0x0A, */      0x00,      0x00,         0x00 },
-	{	/*   0x0B, */       'b',       'B',         0x02 },
-	{	/*   0x0C, */       'q',       'Q',         0x11 },
-	{	/*   0x0D, */       'w',       'W',         0x17 },
-	{	/*   0x0E, */       'e',       'E',         0x05 },
-	{	/*   0x0F, */       'r',       'R',         0x12 },
-	{	/*   0x10, */       'y',       'Y',         0x19 },
-	{	/*   0x11, */       't',       'T',         0x14 },
-	{	/*   0x12, */       '1',       '!',         0x00 },
-	{	/*   0x13, */       '2',       '@',         0x00 },
-	{	/*   0x14, */       '3',       '#',         0x00 },
-	{	/*   0x15, */       '4',       '$',         0x00 },
-	{	/*   0x16, */       '6',       '^',         0x1E },
-	{	/*   0x17, */       '5',       '%',         0x00 },
-	{	/*   0x18, */       '=',       '+',         0x00 },
-	{	/*   0x19, */       '9',       '(',         0x00 },
-	{	/*   0x1A, */       '7',       '&',         0x00 },
-	{	/*   0x1B, */       '-',       '_',         0x1F },
-	{	/*   0x1C, */       '8',       '*',         0x00 },
-	{	/*   0x1D, */       '0',       ')',         0x00 },
-	{	/*   0x1E, */       ']',       '}',         0x1D },
-	{	/*   0x1F, */       'o',       'O',         0x0F },
-	{	/*   0x20, */       'u',       'U',         0x15 },
-	{	/*   0x21, */       '[',       '{',         0x1B },
-	{	/*   0x22, */       'i',       'I',         0x09 },
-	{	/*   0x23, */       'p',       'P',         0x10 },
-	{	/*   0x24, */      0x0D,      0x0D,         0x0D },
-	{	/*   0x25, */       'l',       'L',         0x0C },
-	{	/*   0x26, */       'j',       'J',         0x0A },
-	{	/*   0x27, */      '\'',       '"',         0x00 },
-	{	/*   0x28, */       'k',       'K',         0x0B },
-	{	/*   0x29, */       ';',       ':',         0x00 },
-	{	/*   0x2A, */      '\\',       '|',         0x1C },
-	{	/*   0x2B, */       ',',       '<',         0x00 },
-	{	/*   0x2C, */       '/',       '?',         0x00 },
-	{	/*   0x2D, */       'n',       'N',         0x0E },
-	{	/*   0x2E, */       'm',       'M',         0x0D },
-	{	/*   0x2F, */       '.',       '>',         0x00 },
-	{	/*   0x30, */      0x09,      0x09,         0x09 },
-	{	/*   0x31, */       ' ',       ' ',         0x00 },
-	{	/*   0x32, */       '`',       '~',         0x00 },
-	{	/*   0x33, */      0x7F,      0x7F,         0x7F }, /* Delete */
-	{	/*   0x34, */      0x00,      0x00,         0x00 },
-	{	/*   0x35, */      0x1B,      0x1B,         0x1B },
-	{	/*   0x36, */      0x00,      0x00,         0x00 },
-	{	/*   0x37, */      0x00,      0x00,         0x00 },
-	{	/*   0x38, */      0x00,      0x00,         0x00 },
-	{	/*   0x39, */      0x00,      0x00,         0x00 },
-	{	/*   0x3A, */      0x00,      0x00,         0x00 },
-	{	/*   0x3B, */       'h',      0x00,         0x00 },  /* Left */
-	{	/*   0x3C, */       'l',      0x00,         0x00 },  /* Right */
-	{	/*   0x3D, */       'j',      0x00,         0x00 },  /* Down */
-	{	/*   0x3E, */       'k',      0x00,         0x00 },  /* Up */
-	{	/*   0x3F, */      0x00,      0x00,         0x00 },
-	{	/*   0x40, */      0x00,      0x00,         0x00 },
-	{	/*   0x41, */       '.',       '.',         0x00 },
-	{	/*   0x42, */      0x00,      0x00,         0x00 },
-	{	/*   0x43, */       '*',       '*',         0x00 },
-	{	/*   0x44, */      0x00,      0x00,         0x00 },
-	{	/*   0x45, */       '+',       '+',         0x00 },
-	{	/*   0x46, */      0x00,      0x00,         0x00 },
-	{	/*   0x47, */      0x00,      0x00,         0x00 },
-	{	/*   0x48, */      0x00,      0x00,         0x00 },
-	{	/*   0x49, */      0x00,      0x00,         0x00 },
-	{	/*   0x4A, */      0x00,      0x00,         0x00 },
-	{	/*   0x4B, */       '/',       '/',         0x00 },
-	{	/*   0x4C, */      0x0D,      0x0D,         0x0D },
-	{	/*   0x4D, */      0x00,      0x00,         0x00 },
-	{	/*   0x4E, */       '-',       '-',         0x00 },
-	{	/*   0x4F, */      0x00,      0x00,         0x00 },
-	{	/*   0x50, */      0x00,      0x00,         0x00 },
-	{	/*   0x51, */       '=',       '=',         0x00 },
-	{	/*   0x52, */       '0',       '0',         0x00 },
-	{	/*   0x53, */       '1',       '1',         0x00 },
-	{	/*   0x54, */       '2',       '2',         0x00 },
-	{	/*   0x55, */       '3',       '3',         0x00 },
-	{	/*   0x56, */       '4',       '4',         0x00 },
-	{	/*   0x57, */       '5',       '5',         0x00 },
-	{	/*   0x58, */       '6',       '6',         0x00 },
-	{	/*   0x59, */       '7',       '7',         0x00 },
-	{	/*   0x5A, */      0x00,      0x00,         0x00 },
-	{	/*   0x5B, */       '8',       '8',         0x00 },
-	{	/*   0x5C, */       '9',       '9',         0x00 },
-	{	/*   0x5D, */      0x00,      0x00,         0x00 },
-	{	/*   0x5E, */      0x00,      0x00,         0x00 },
-	{	/*   0x5F, */      0x00,      0x00,         0x00 },
-	{	/*   0x60, */      0x00,      0x00,         0x00 },
-	{	/*   0x61, */      0x00,      0x00,         0x00 },
-	{	/*   0x62, */      0x00,      0x00,         0x00 },
-	{	/*   0x63, */      0x00,      0x00,         0x00 },
-	{	/*   0x64, */      0x00,      0x00,         0x00 },
-	{	/*   0x65, */      0x00,      0x00,         0x00 },
-	{	/*   0x66, */      0x00,      0x00,         0x00 },
-	{	/*   0x67, */      0x00,      0x00,         0x00 },
-	{	/*   0x68, */      0x00,      0x00,         0x00 },
-	{	/*   0x69, */      0x00,      0x00,         0x00 },
-	{	/*   0x6A, */      0x00,      0x00,         0x00 },
-	{	/*   0x6B, */      0x00,      0x00,         0x00 },
-	{	/*   0x6C, */      0x00,      0x00,         0x00 },
-	{	/*   0x6D, */      0x00,      0x00,         0x00 },
-	{	/*   0x6E, */      0x00,      0x00,         0x00 },
-	{	/*   0x6F, */      0x00,      0x00,         0x00 },
-	{	/*   0x70, */      0x00,      0x00,         0x00 },
-	{	/*   0x71, */      0x00,      0x00,         0x00 },
-	{	/*   0x72, */      0x00,      0x00,         0x00 },
-	{	/*   0x73, */      0x00,      0x00,         0x00 },
-	{	/*   0x74, */      0x00,      0x00,         0x00 },
-	{	/*   0x75, */      0x00,      0x00,         0x00 },
-	{	/*   0x76, */      0x00,      0x00,         0x00 },
-	{	/*   0x77, */      0x00,      0x00,         0x00 },
-	{	/*   0x78, */      0x00,      0x00,         0x00 },
-	{	/*   0x79, */      0x00,      0x00,         0x00 },
-	{	/*   0x7A, */      0x00,      0x00,         0x00 },
-	{	/*   0x7B, */      0x00,      0x00,         0x00 },
-	{	/*   0x7C, */      0x00,      0x00,         0x00 },
-	{	/*   0x7D, */      0x00,      0x00,         0x00 },
-	{	/*   0x7E, */      0x00,      0x00,         0x00 },
-	{	/*   0x7F, */      0x00,      0x00,         0x00 }
+unsigned char keyboard[128][4] = {
+	  /* Scan code      Normal     Shifted     Controlled   XT */
+	{ /*   0x00, */       'a',       'A',         0x01,	 30 },
+	{ /*   0x01, */       's',       'S',         0x13,	 31 },
+	{ /*   0x02, */       'd',       'D',         0x04,	 32 },
+	{ /*   0x03, */       'f',       'F',         0x06,	 33 },
+	{ /*   0x04, */       'h',       'H',         0x08,	 35 },
+	{ /*   0x05, */       'g',       'G',         0x07,	 34 },
+	{ /*   0x06, */       'z',       'Z',         0x1A,	 44 },
+	{ /*   0x07, */       'x',       'X',         0x18,	 45 },
+	{ /*   0x08, */       'c',       'C',         0x03,	 46 },
+	{ /*   0x09, */       'v',       'V',         0x16,	 47 },
+	{ /*   0x0A, */      0x00,      0x00,         0x00,	 86 },
+	{ /*   0x0B, */       'b',       'B',         0x02,	 48 },
+	{ /*   0x0C, */       'q',       'Q',         0x11,	 16 },
+	{ /*   0x0D, */       'w',       'W',         0x17,	 17 },
+	{ /*   0x0E, */       'e',       'E',         0x05,	 18 },
+	{ /*   0x0F, */       'r',       'R',         0x12,	 19 },
+	{ /*   0x10, */       'y',       'Y',         0x19,	 21 },
+	{ /*   0x11, */       't',       'T',         0x14,	 20 },
+	{ /*   0x12, */       '1',       '!',         0x00,	  2 },
+	{ /*   0x13, */       '2',       '@',         0x00,	  3 },
+	{ /*   0x14, */       '3',       '#',         0x00,	  4 },
+	{ /*   0x15, */       '4',       '$',         0x00,	  5 },
+	{ /*   0x16, */       '6',       '^',         0x1E,	  7 },
+	{ /*   0x17, */       '5',       '%',         0x00,	  6 },
+	{ /*   0x18, */       '=',       '+',         0x00,	 13 },
+	{ /*   0x19, */       '9',       '(',         0x00,	 10 },
+	{ /*   0x1A, */       '7',       '&',         0x00,	  8 },
+	{ /*   0x1B, */       '-',       '_',         0x1F,	 12 },
+	{ /*   0x1C, */       '8',       '*',         0x00,	  9 },
+	{ /*   0x1D, */       '0',       ')',         0x00,	 11 },
+	{ /*   0x1E, */       ']',       '}',         0x1D,	 27 },
+	{ /*   0x1F, */       'o',       'O',         0x0F,	 24 },
+	{ /*   0x20, */       'u',       'U',         0x15,	 22 },
+	{ /*   0x21, */       '[',       '{',         0x1B,	 26 },
+	{ /*   0x22, */       'i',       'I',         0x09,	 23 },
+	{ /*   0x23, */       'p',       'P',         0x10,	 25 },
+	{ /*   0x24, */      0x0D,      0x0D,         0x0D,	 28 },
+	{ /*   0x25, */       'l',       'L',         0x0C,	 38 },
+	{ /*   0x26, */       'j',       'J',         0x0A,	 36 },
+	{ /*   0x27, */       '\'',      '"',         0x00,	 40 },
+	{ /*   0x28, */       'k',       'K',         0x0B,	 37 },
+	{ /*   0x29, */       ';',       ':',         0x00,	 39 },
+	{ /*   0x2A, */      '\\',       '|',         0x1C,	 43 },
+	{ /*   0x2B, */       ',',       '<',         0x00,	 51 },
+	{ /*   0x2C, */       '/',       '?',         0x00,	 53 },
+	{ /*   0x2D, */       'n',       'N',         0x0E,	 49 },
+	{ /*   0x2E, */       'm',       'M',         0x0D,	 50 },
+	{ /*   0x2F, */       '.',       '>',         0x00,	 52 },
+	{ /*   0x30, */      0x09,      0x09,         0x09,	 15 },
+	{ /*   0x31, */       ' ',       ' ',         0x00,	 57 },
+	{ /*   0x32, */       '`',       '~',         0x00,	 41 },
+	{ /*   0x33, */      0x7F,      0x7F,         0x7F,	211 }, /* Delete */
+	{ /*   0x34, */      0x00,      0x00,         0x00,	105 }, /* MODE/KP_Enter */
+	{ /*   0x35, */      0x1B,      0x1B,         0x1B,	  1 },
+	{ /*   0x36, */      0x00,      0x00,         0x00,	 29 },
+	{ /*   0x37, */      0x00,      0x00,         0x00,	219 },
+	{ /*   0x38, */      0x00,      0x00,         0x00,	 42 },
+	{ /*   0x39, */      0x00,      0x00,         0x00,	 58 },
+	{ /*   0x3A, */      0x00,      0x00,         0x00,	 56 }, /* L Alt */
+	{ /*   0x3B, */       'h',      0x00,         0x00,	203 },  /* Left */
+	{ /*   0x3C, */       'l',      0x00,         0x00,	205 },  /* Right */
+	{ /*   0x3D, */       'j',      0x00,         0x00,	208 },  /* Down */
+	{ /*   0x3E, */       'k',      0x00,         0x00,	200 },  /* Up */
+	{ /*   0x3F, */      0x00,      0x00,         0x00,	  0 }, /* Fn */
+	{ /*   0x40, */      0x00,      0x00,         0x00,	  0 },
+	{ /*   0x41, */       '.',       '.',         0x00,	 83 },
+	{ /*   0x42, */      0x00,      0x00,         0x00,	  0 },
+	{ /*   0x43, */       '*',       '*',         0x00,	 55 },
+	{ /*   0x44, */      0x00,      0x00,         0x00,	  0 },
+	{ /*   0x45, */       '+',       '+',         0x00,	 78 },
+	{ /*   0x46, */      0x00,      0x00,         0x00,	  0 },
+	{ /*   0x47, */      0x00,      0x00,         0x00,	 69 },
+	{ /*   0x48, */      0x00,      0x00,         0x00,	  0 },
+	{ /*   0x49, */      0x00,      0x00,         0x00,	  0 },
+	{ /*   0x4A, */      0x00,      0x00,         0x00,	  0 },
+	{ /*   0x4B, */       '/',       '/',         0x00,	181 },
+	{ /*   0x4C, */      0x0D,      0x0D,         0x0D,	156 },
+	{ /*   0x4D, */      0x00,      0x00,         0x00,	  0 },
+	{ /*   0x4E, */       '-',       '-',         0x00,	 74 },
+	{ /*   0x4F, */      0x00,      0x00,         0x00,	  0 },
+	{ /*   0x50, */      0x00,      0x00,         0x00,	  0 },
+	{ /*   0x51, */       '=',       '=',         0x00,	118 },
+	{ /*   0x52, */       '0',       '0',         0x00,	 82 },
+	{ /*   0x53, */       '1',       '1',         0x00,	 79 },
+	{ /*   0x54, */       '2',       '2',         0x00,	 80 },
+	{ /*   0x55, */       '3',       '3',         0x00,	 81 },
+	{ /*   0x56, */       '4',       '4',         0x00,	 75 },
+	{ /*   0x57, */       '5',       '5',         0x00,	 76 },
+	{ /*   0x58, */       '6',       '6',         0x00,	 77 },
+	{ /*   0x59, */       '7',       '7',         0x00,	 71 },
+	{ /*   0x5A, */      0x00,      0x00,         0x00,	  0 },
+	{ /*   0x5B, */       '8',       '8',         0x00,	 72 },
+	{ /*   0x5C, */       '9',       '9',         0x00,	 73 },
+	{ /*   0x5D, */      0x00,      0x00,         0x00,	125 },
+	{ /*   0x5E, */      0x00,      0x00,         0x00,	115 },
+	{ /*   0x5F, */      0x00,      0x00,         0x00,	 51 },
+	{ /*   0x60, */      0x00,      0x00,         0x00,	 63 }, /* F5 */
+	{ /*   0x61, */      0x00,      0x00,         0x00,	 64 }, /* F6 */
+	{ /*   0x62, */      0x00,      0x00,         0x00,	 65 }, /* F7 */
+	{ /*   0x63, */      0x00,      0x00,         0x00,	 61 }, /* F3 */
+	{ /*   0x64, */      0x00,      0x00,         0x00,	 66 }, /* F8 */
+	{ /*   0x65, */      0x00,      0x00,         0x00,	 67 }, /* F9 */
+	{ /*   0x66, */      0x00,      0x00,         0x00,	123 },
+	{ /*   0x67, */      0x00,      0x00,         0x00,	 87 }, /* F11 */
+	{ /*   0x68, */      0x00,      0x00,         0x00,	112 },
+	{ /*   0x69, */      0x00,      0x00,         0x00,	  0 },
+	{ /*   0x6A, */      0x00,      0x00,         0x00,	156 },
+	{ /*   0x6B, */      0x00,      0x00,         0x00,	  0 },
+	{ /*   0x6C, */      0x00,      0x00,         0x00,	  0 },
+	{ /*   0x6D, */      0x00,      0x00,         0x00,	 68 }, /* F10 */
+	{ /*   0x6E, */      0x00,      0x00,         0x00,	  0 },
+	{ /*   0x6F, */      0x00,      0x00,         0x00,	 88 }, /* F12 */
+	{ /*   0x70, */      0x00,      0x00,         0x00,	  0 },
+	{ /*   0x71, */      0x00,      0x00,         0x00,	  0 },
+	{ /*   0x72, */      0x00,      0x00,         0x00,	  0 },
+	{ /*   0x73, */      0x00,      0x00,         0x00,	199 },
+	{ /*   0x74, */      0x00,      0x00,         0x00,	201 },
+	{ /*   0x75, */      0x00,      0x00,         0x00,	  0 },
+	{ /*   0x76, */      0x00,      0x00,         0x00,	 62 }, /* F4 */
+	{ /*   0x77, */      0x00,      0x00,         0x00,	207 },
+	{ /*   0x78, */      0x00,      0x00,         0x00,	 60 }, /* F2 */
+	{ /*   0x79, */      0x00,      0x00,         0x00,	209 },
+	{ /*   0x7A, */      0x00,      0x00,         0x00,	 59 }, /* F1 */
+	{ /*   0x7B, */      0x00,      0x00,         0x00,	  0 },
+	{ /*   0x7C, */      0x00,      0x00,         0x00,	  0 },
+	{ /*   0x7D, */      0x00,      0x00,         0x00,	  0 },
+	{ /*   0x7E, */      0x00,      0x00,         0x00,	  0 },
+	{ /*   0x7F, */      0x00,      0x00,         0x00,	  0 } /* pwr */
 };
 #endif /* KEYBOARD_ARRAY */
diff -r 313a5cb65658 share/man/man4/akbd.4
--- a/share/man/man4/akbd.4	Tue May 12 13:07:52 2026 +0000
+++ b/share/man/man4/akbd.4	Sun May 17 03:12:40 2026 +1000
@@ -28,7 +28,7 @@
 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd January 20, 2025
+.Dd May 17, 2026
 .Dt AKBD 4
 .Os
 .
@@ -42,6 +42,7 @@
 .Pp
 .Cd "options ALTXBUTTONS"
 .Cd "options CAPS_IS_CONTROL"
+.Cd "options EMULFKEYS
 .Cd "options FORCE_FUNCTION_KEYS"
 .
 .Sh DESCRIPTION
@@ -76,6 +77,41 @@
 .Tn ADB Ap s
 strange emulation of a mechanically-locked key.
 .
+.It Cd "options EMULFKEYS"
+.
+On mac68k especially PowerBooks that do not have function keys or on a
+standard keyboard this emulates function keys 1-8.
+To map
+.Sm off
+.Ao Option Ac \&+ Aq 1 ,
+.Sm on
+.Sm off
+.Ao Option Ac \&+ Aq 2 ,
+.Sm on
+.Sm off
+.Ao Option Ac \&+ Aq 3 ,
+.Sm on
+.Sm off
+.Ao Option Ac \&+ Aq 4 ,
+.Sm on
+.Sm off
+.Ao Option Ac \&+ Aq 5 ,
+.Sm on
+.Sm off
+.Ao Option Ac \&+ Aq 6 ,
+.Sm on
+.Sm off
+.Ao Option Ac \&+ Aq 7 ,
+.Sm on
+.Sm off
+.Ao Option Ac \&+ Aq 8 ,
+.Sm on
+to function keys 1 through to 8
+respectively.
+.Pp
+This cannot be used in conjunction with
+.Cd "options ALTXBUTTONS"
+.
 .It Cd options FORCE_FUNCTION_KEYS
 .
 On macppc PowerBooks, several function keys double as
--- a/sys/arch/mac68k/dev/aed.c	Tue May 12 13:07:52 2026 +0000
+++ b/sys/arch/mac68k/dev/aed.c	Sun May 17 02:45:17 2026 +1000
@@ -57,6 +57,10 @@
 #define BRIGHTNESS_MIN	0
 #define BRIGHTNESS_STEP	4
 
+#if defined(ALTXBUTTONS) && defined(EMULFKEYS)
+#error "options ALTXBUTTONS" and "options EMULFKEYS" cannot be used together.
+#endif
+
 /*
  * Function declarations.
  */
@@ -187,6 +191,10 @@
 	case ADBADDR_KBD:
 		if (aed_sc->sc_options & AED_MSEMUL) {
 			rv = aed_emulate_mouse(&new_event);
+			if (rv == 2) {
+				memcpy(event, &new_event, sizeof(new_event));
+				rv = 0;
+			}
 		} else
 			aed_dokeyupdown(&new_event);
 		break;
@@ -233,6 +241,9 @@
 			aed_handoff(&new_event);
 		}
 	} else if (emulmodkey_down) {
+#if defined(EMULFKEYS)
+		int fkey = 0;
+#endif
 		switch(event->u.k.key) {
 #ifdef ALTXBUTTONS
 		case ADBK_KEYDOWN(ADBK_1):
@@ -325,6 +336,80 @@
 			/* ctrl, shift, cmd */
 			aed_dokeyupdown(event);
 			break;
+#if defined(EMULFKEYS)
+		case ADBK_KEYDOWN(ADBK_1):
+			if (!fkey)
+				fkey = ADBK_F1;
+		case ADBK_KEYDOWN(ADBK_2):
+			if (!fkey)
+				fkey = ADBK_F2;
+		case ADBK_KEYDOWN(ADBK_3):
+			if (!fkey)
+				fkey = ADBK_F3;
+		case ADBK_KEYDOWN(ADBK_4):
+			if (!fkey)
+				fkey = ADBK_F4;
+		case ADBK_KEYDOWN(ADBK_5):
+			if (!fkey)
+				fkey = ADBK_F5;
+		case ADBK_KEYDOWN(ADBK_6):
+			if (!fkey)
+				fkey = ADBK_F6;
+		case ADBK_KEYDOWN(ADBK_7):
+			if (!fkey)
+				fkey = ADBK_F7;
+		case ADBK_KEYDOWN(ADBK_8):
+			if (!fkey)
+				fkey = ADBK_F8;
+
+			result = 2;
+			/* key down */
+			new_event = *event;
+
+			/* send FKEY-down */
+			new_event.u.k.key = ADBK_KEYDOWN(fkey);
+			new_event.bytes[0] = new_event.u.k.key;
+			microtime(&new_event.timestamp);
+			aed_dokeyupdown(&new_event);
+			memcpy(event, &new_event, sizeof(new_event));
+			break;
+		case ADBK_KEYUP(ADBK_1):
+			if (!fkey)
+				fkey = ADBK_F1;
+		case ADBK_KEYUP(ADBK_2):
+			if (!fkey)
+				fkey = ADBK_F2;
+		case ADBK_KEYUP(ADBK_3):
+			if (!fkey)
+				fkey = ADBK_F3;
+		case ADBK_KEYUP(ADBK_4):
+			if (!fkey)
+				fkey = ADBK_F4;
+		case ADBK_KEYUP(ADBK_5):
+			if (!fkey)
+				fkey = ADBK_F5;
+		case ADBK_KEYUP(ADBK_6):
+			if (!fkey)
+				fkey = ADBK_F6;
+		case ADBK_KEYUP(ADBK_7):
+			if (!fkey)
+				fkey = ADBK_F7;
+		case ADBK_KEYUP(ADBK_8):
+			if (!fkey)
+				fkey = ADBK_F8;
+
+			result = 2;
+			/* key up */
+			new_event = *event;
+
+			/* send FKEY-up */
+			new_event.u.k.key = ADBK_KEYUP(fkey);
+			new_event.bytes[0] = new_event.u.k.key;
+			microtime(&new_event.timestamp);
+			aed_dokeyupdown(&new_event);
+			memcpy(event, &new_event, sizeof(new_event));
+			break;
+#endif
 		default:
 			if (event->u.k.key & 0x80)
 				/* ignore keyup */
--- a/sys/arch/mac68k/dev/akbdmap.h	Tue May 12 13:07:52 2026 +0000
+++ b/sys/arch/mac68k/dev/akbdmap.h	Sun May 17 02:45:17 2026 +1000
@@ -90,7 +90,11 @@
     KC(52),			KS_KP_Enter,    /* Pretend this is alt-R ? */
     KC(53),			KS_Escape,
     KC(54),			KS_Control_L,
+#ifdef EMULFKEYS
+    KC(55),  KS_Cmd,		KS_Mode_switch,		/* Command */
+#else
     KC(55),  KS_Cmd,				/* Command */
+#endif
     KC(56),			KS_Shift_L,
     KC(57),			KS_Caps_Lock,
     KC(58),  KS_Cmd1,				/* Option */
--- a/sys/arch/mac68k/include/keyboard.h	Tue May 12 13:07:52 2026 +0000
+++ b/sys/arch/mac68k/include/keyboard.h	Sun May 17 02:45:17 2026 +1000
@@ -62,6 +62,15 @@
 #define ADBK_9		0x19
 #define ADBK_0		0x1D
 
+#define ADBK_F1		0x7A
+#define ADBK_F2		0x78
+#define ADBK_F3		0x63
+#define ADBK_F4		0x76
+#define ADBK_F5		0x60
+#define ADBK_F6		0x61
+#define ADBK_F7		0x62
+#define ADBK_F8		0x64
+
 #define ADBK_KEYVAL(key)	((key) & 0x7f)
 #define ADBK_PRESS(key)		(((key) & 0x80) == 0)
 #define ADBK_KEYDOWN(key)	(key)


Home | Main Index | Thread Index | Old Index