[PATCH] sysrq for ibook

Joerg Dorchain joerg at dorchain.net
Thu Jan 20 21:26:33 EST 2005


Hi,

I am somehow missing the sysrq-feature with the iBook keyboard. As there
is no F13=sysrq on it, IMHO it might be an idea to emulate it via Fn+esc.

Bye,

Joerg

--- adbhid.c.sysrq	2005-01-19 18:57:30.000000000 +0100
+++ adbhid.c	2005-01-19 20:09:15.873421184 +0100
@@ -67,13 +67,16 @@
 
 /* Some special keys */
 #define ADB_KEY_DEL		0x33
+#define ADB_KEY_ESC		0x35
 #define ADB_KEY_CMD		0x37
 #define ADB_KEY_CAPSLOCK	0x39
 #define ADB_KEY_FN		0x3f
+#define ADB_KEY_SYSRQ		0x69
 #define ADB_KEY_FWDEL		0x75
 #define ADB_KEY_POWER_OLD	0x7e
 #define ADB_KEY_POWER		0x7f
 
+
 u8 adb_to_linux_keycodes[128] = {
 	/* 0x00 */ KEY_A, 		/*  30 */
 	/* 0x01 */ KEY_S, 		/*  31 */
@@ -221,6 +224,7 @@
 #define FLAG_FN_KEY_PRESSED	0x00000001
 #define FLAG_POWER_FROM_FN	0x00000002
 #define FLAG_EMU_FWDEL_DOWN	0x00000004
+#define FLAG_EMU_SYSRQ_DOWN	0x00000008
 
 static struct adbhid *adbhid[16];
 
@@ -329,6 +333,12 @@
 				keycode = ADB_KEY_FWDEL;
 				break;
 			}
+			/* Emulate Fn+esc = sysreq */
+			if (ahid->flags & FLAG_EMU_SYSRQ_DOWN) {
+				ahid->flags &= ~FLAG_EMU_SYSRQ_DOWN;
+				keycode = ADB_KEY_SYSRQ;
+				break;
+			}
 		} else
 			ahid->flags |= FLAG_FN_KEY_PRESSED;
 		/* Swallow the key press */
@@ -343,6 +353,23 @@
 				ahid->flags |= FLAG_EMU_FWDEL_DOWN;
 		}
 		break;
+	case ADB_KEY_ESC:
+		/* Emulate Fn+esc = left alt+sysreq */
+		if (ahid->flags & FLAG_FN_KEY_PRESSED) {
+			keycode = ADB_KEY_SYSRQ;
+			input_regs(&ahid->input, regs);
+			if (up_flag) {
+				ahid->flags &= ~FLAG_EMU_SYSRQ_DOWN;
+				/* Warning: Hack to avoid twisted fingers ...*/
+				input_report_key(&ahid->input, KEY_LEFTALT, 0);
+			} else {
+				ahid->flags |= FLAG_EMU_SYSRQ_DOWN;
+				/* Warning: Hack to avoid twisted fingers ...*/
+				input_report_key(&ahid->input, KEY_LEFTALT, 1);
+			}
+			input_sync(&ahid->input);
+		}
+		break;
 #endif /* CONFIG_PPC_PMAC */
 	}
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.ozlabs.org/pipermail/linuxppc-dev/attachments/20050120/b3452357/attachment.pgp>


More information about the Linuxppc-dev mailing list