Skip to contentSkip to conversation

ability to change SysRq scancode

PATCH In review federico 2 participants 4 messages Jul 9, 2005 – Jul 12, 2005

Subsystems (3)
lore
Share & tools
lore

federico

author
#0 lore raw

PATCH 1/1 ability to change SysRq scancode

i release this patch because my keyboard ("Mitsumi Electric Apple Extended USB Keyboard" Bus=0003 Vendor=05ac Product=0205 Version=0122) doesn't have a PrintScr key, so cannot send the right scancode, and KEY_SYSRQ needs to be modified.

i hope that i've done in the right way ;)
it's tested by me, and it's working, yeah i'm pressing the SAK with F13 :P

diff linux.orig/lib/Kconfig.debug linux/lib/Kconfig.debug 30a31,40

Quoted 10 lines

config MAGIC_SYSRQ_SCANCODE
int
prompt "Change default scancode of SysRq key" if MAGIC_SYSRQ default 99
depends on MAGIC_SYSRQ
help
If your keyboard hasn't a SysRq key, you can specify another key which should act as SysRq. You can find the scancode on your keyboard with programs like showkey or evtest.

diff linux.orig/include/linux/input.h linux/include/linux/input.h 206a207,210

Quoted 4 lines

#if defined(CONFIG_MAGIC_SYSRQ) && defined(CONFIG_MAGIC_SYSRQ_SCANCODE)
#define KEY_SYSRQ CONFIG_MAGIC_SYSRQ_SCANCODE
#else

207a212,213

Quoted 2 lines

#endif

#1 lore raw
Quoted 6 lines · federico

i release this patch because my keyboard ("Mitsumi Electric Apple Extended USB Keyboard" Bus=0003 Vendor=05ac Product=0205 Version=0122) doesn't have a PrintScr key, so cannot send the right scancode, and KEY_SYSRQ needs to be modified.

i hope that i've done in the right way ;)

diff -uprN please.

Quoted 1 line

it's tested by me, and it's working, yeah i'm pressing the SAK with F13 :P

author
#2 lore raw

Alexey Dobriyan ha scritto:

Quoted 8 lines · federico
Quoted 7 lines

i release this patch because my keyboard ("Mitsumi Electric Apple Extended USB Keyboard" Bus=0003 Vendor=05ac Product=0205 Version=0122) doesn't have a PrintScr key, so cannot send the right scancode, and KEY_SYSRQ needs to be modified.

Quoted 7 lines
Quoted 3 lines

i hope that i've done in the right way ;)

diff -uprN please.

here it is

include/linux/input.h +6 -0
diff -uprN linux.orig/include/linux/input.h linux/include/linux/input.h
@@ -204,7 +204,13 @@ struct input_absinfo {
 #define KEY_KPENTER		96
 #define KEY_RIGHTCTRL		97
 #define KEY_KPSLASH		98
+
+#if defined(CONFIG_MAGIC_SYSRQ) && defined(CONFIG_MAGIC_SYSRQ_SCANCODE)
+#define KEY_SYSRQ		CONFIG_MAGIC_SYSRQ_SCANCODE
+#else
 #define KEY_SYSRQ		99
+#endif
+
 #define KEY_RIGHTALT		100
 #define KEY_LINEFEED		101
 #define KEY_HOME		102
lib/Kconfig.debug +10 -0
diff -uprN linux.orig/lib/Kconfig.debug linux/lib/Kconfig.debug
@@ -28,6 +28,16 @@ config MAGIC_SYSRQ
 	  send a BREAK and then within 5 seconds a command keypress. The
 	  keys are documented in <file:Documentation/sysrq.txt>. Don't say Y
 	  unless you really know what this hack does.
+	  
+config MAGIC_SYSRQ_SCANCODE
+	int
+	prompt "Change default scancode of SysRq key" if MAGIC_SYSRQ
+	default 99
+	depends on MAGIC_SYSRQ
+	help
+	  If your keyboard hasn't a SysRq key, you can specify another key
+	  which should act as SysRq. You can find the scancode on your
+	  keyboard with programs like showkey or evtest.
 
 config LOG_BUF_SHIFT
 	int "Kernel log buffer size (16 => 64KB, 17 => 128KB)" if DEBUG_KERNEL
author
#3 lore raw
In reply to federico

federico ha scritto:

Quoted 9 lines

i release this patch because my keyboard ("Mitsumi Electric Apple Extended USB Keyboard" Bus=0003 Vendor=05ac Product=0205 Version=0122) doesn't have a PrintScr key, so cannot send the right scancode, and KEY_SYSRQ needs to be modified.

i hope that i've done in the right way ;)
it's tested by me, and it's working, yeah i'm pressing the SAK with F13 :P

fixed some typos in Kconfig and cleaned up the code.

this should be that last release of this patch.
it's tested and working (it's nothing else a simple one-line hack)

if someone wants to try please report results :)
ciao!
Federico

drivers/char/keyboard.c +1 -1
diff -uprN linux.orig/drivers/char/keyboard.c linux/drivers/char/keyboard.c
@@ -1081,7 +1087,7 @@ static void kbd_keycode(unsigned int key
 				printk(KERN_WARNING "keyboard.c: can't emulate rawmode for keycode %d\n", keycode);
 
 #ifdef CONFIG_MAGIC_SYSRQ	       /* Handle the SysRq Hack */
-	if (keycode == KEY_SYSRQ && (sysrq_down || (down == 1 && sysrq_alt))) {
+	if (keycode == CONFIG_MAGIC_SYSRQ_KEYCODE && (sysrq_down || (down == 1 && sysrq_alt))) {
 		sysrq_down = down;
 		return;
 	}
lib/Kconfig.debug +12 -0
diff -uprN linux.orig/lib/Kconfig.debug linux/lib/Kconfig.debug
@@ -28,6 +28,16 @@ config MAGIC_SYSRQ
 	  send a BREAK and then within 5 seconds a command keypress. The
 	  keys are documented in <file:Documentation/sysrq.txt>. Don't say Y
 	  unless you really know what this hack does.
+	  
+config MAGIC_SYSRQ_KEYCODE
+	int
+	prompt "Change SysRq key-code" if MAGIC_SYSRQ
+	default 99
+	depends on MAGIC_SYSRQ
+	help
+	  If your keyboard doesn't have a SysRq key (also labeled PrintScr),
+	  you can specify another keycode which should act as SysRq.
+	  Default is 99 (KEY_SYSRQ).
+	  You can find this number using programs like evtest, or (maybe)
+	  showkey.
 

config LOG_BUF_SHIFT
int "Kernel log buffer size (16 => 64KB, 17 => 128KB)" if DEBUG_KERNEL