ref: 8a699c6ebc34dc5dd498c35a53bd88fc06f21a11
parent: 2b4eb0f8fb8ffca7b4016f6e8f05c124d0ad2afc
author: Simon Howard <[email protected]>
date: Thu Mar 27 16:50:10 EDT 2014
Define a keyboard scan code for PrintScreen. There is no real scan code for the PrintScreen key under DOS, but it is convenient to be able to bind it as a screenshot key. Define a "fake" scancode (126) to represent PrintScreen so that it can be represented as a key binding in configuration files. Also add some comments/notes to the scantokey[] lookup table. This fixes #369.
--- a/src/doomkeys.h
+++ b/src/doomkeys.h
@@ -69,6 +69,7 @@
#define KEY_CAPSLOCK (0x80+0x3a)
#define KEY_NUMLOCK (0x80+0x45)
#define KEY_SCRLCK (0x80+0x46)
+#define KEY_PRTSCR (0x80+0x59)
#define KEY_HOME (0x80+0x47)
#define KEY_END (0x80+0x4f)
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -480,7 +480,8 @@
case SDLK_F10: return KEY_F10;
case SDLK_F11: return KEY_F11;
case SDLK_F12: return KEY_F12;
-
+ case SDLK_PRINT: return KEY_PRTSCR;
+
case SDLK_BACKSPACE: return KEY_BACKSPACE;
case SDLK_DELETE: return KEY_DEL;
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -1489,6 +1489,16 @@
return NULL;
}
+// Mapping from DOS keyboard scan code to internal key code (as defined
+// in doomkey.h). I think I (fraggle) reused this from somewhere else
+// but I can't find where. Anyway, notes:
+// * KEY_PAUSE is wrong - it's in the KEY_NUMLOCK spot. This shouldn't
+// matter in terms of Vanilla compatibility because neither of
+// those were valid for key bindings.
+// * There is no proper scan code for PrintScreen (on DOS machines it
+// sends an interrupt). So I added a fake scan code of 126 for it.
+// The presence of this is important so we can bind PrintScreen as
+// a screenshot key.
static const int scantokey[128] =
{
0 , 27, '1', '2', '3', '4', '5', '6',
@@ -1499,7 +1509,7 @@
'\'', '`', KEY_RSHIFT,'\\', 'z', 'x', 'c', 'v',
'b', 'n', 'm', ',', '.', '/', KEY_RSHIFT,KEYP_MULTIPLY,
KEY_RALT, ' ', KEY_CAPSLOCK,KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5,
- KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_PAUSE,KEY_SCRLCK,KEY_HOME,
+ KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, /*KEY_NUMLOCK?*/KEY_PAUSE,KEY_SCRLCK,KEY_HOME,
KEY_UPARROW,KEY_PGUP,KEY_MINUS,KEY_LEFTARROW,KEYP_5,KEY_RIGHTARROW,KEYP_PLUS,KEY_END,
KEY_DOWNARROW,KEY_PGDN,KEY_INS,KEY_DEL,0, 0, 0, KEY_F11,
KEY_F12, 0, 0, 0, 0, 0, 0, 0,
@@ -1506,7 +1516,7 @@
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0
+ 0, 0, 0, 0, 0, 0, KEY_PRTSCR, 0
};
--- a/textscreen/txt_sdl.c
+++ b/textscreen/txt_sdl.c
@@ -445,6 +445,7 @@
case SDLK_F10: return KEY_F10;
case SDLK_F11: return KEY_F11;
case SDLK_F12: return KEY_F12;
+ case SDLK_PRINT: return KEY_PRTSCR;
case SDLK_BACKSPACE: return KEY_BACKSPACE;
case SDLK_DELETE: return KEY_DEL;