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

Re: SysRq on titanium powerbook



On Tue, Aug 16, 2005 at 10:51:55AM +1000, Benjamin Herrenschmidt wrote:
> You need to keep track that it's pressed to send appropriate key up as
> well I suppose...

Found another snag with this. Using Fn activates the numeric keypad
emulation of the keyboard, effectively blocking commands p,m,o.
Unfortunately can't use F12 itself here as that is mapped as a button.

Code below uses Alt-F11, but I'm not sure if that is specific enough
as it could be used by normal applications. Any sugestion for a better
key combination to use?

-- 
Martin

	Signed-off-by: Martin Habets <errandir_news@mph.eclipse.co.uk>
---------------------------------------------------------------------------
Index: 2.6/drivers/macintosh/adbhid.c
===================================================================
--- 2.6.orig/drivers/macintosh/adbhid.c	2005-08-15 13:49:27.000000000 +0100
+++ 2.6/drivers/macintosh/adbhid.c	2005-08-16 22:48:15.000000000 +0100
@@ -69,7 +69,9 @@
 #define ADB_KEY_DEL		0x33
 #define ADB_KEY_CMD		0x37
 #define ADB_KEY_CAPSLOCK	0x39
+#define ADB_KEY_LEFTALT		0x3a
 #define ADB_KEY_FN		0x3f
+#define ADB_KEY_F11		0x67
 #define ADB_KEY_FWDEL		0x75
 #define ADB_KEY_POWER_OLD	0x7e
 #define ADB_KEY_POWER		0x7f
@@ -221,6 +223,8 @@
 #define FLAG_FN_KEY_PRESSED	0x00000001
 #define FLAG_POWER_FROM_FN	0x00000002
 #define FLAG_EMU_FWDEL_DOWN	0x00000004
+#define FLAG_LEFTALT_DOWN	0x00000008
+#define FLAG_F11_DOWN		0x00000010
 
 static struct adbhid *adbhid[16];
 
@@ -343,6 +347,31 @@
 				ahid->flags |= FLAG_EMU_FWDEL_DOWN;
 		}
 		break;
+#ifdef CONFIG_MAGIC_SYSRQ
+	case ADB_KEY_LEFTALT:
+		/* Keep track of the Alt key state */
+		if (up_flag) {
+			ahid->flags &= ~FLAG_LEFTALT_DOWN;
+			/* Map Alt+F11 to SysRq. */
+			if (ahid->flags & FLAG_F11_DOWN) {
+				ahid->flags &= ~FLAG_F11_DOWN;
+				keycode = 0x69;
+				break;
+			}
+		} else
+			ahid->flags |= FLAG_LEFTALT_DOWN;
+		break;
+	case ADB_KEY_F11:
+		/* Map Alt+F11 to SysRq. */
+		if (ahid->flags & FLAG_LEFTALT_DOWN) {
+			keycode = 0x69;
+			if (up_flag)
+				ahid->flags &= ~FLAG_F11_DOWN;
+			else
+				ahid->flags |= FLAG_F11_DOWN;
+		}
+		break;
+#endif
 #endif /* CONFIG_PPC_PMAC */
 	}
 



Reply to: