diff options
author | Simon Howard | 2014-03-27 20:50:10 -0400 |
---|---|---|
committer | Simon Howard | 2014-03-27 20:52:09 -0400 |
commit | 8a699c6ebc34dc5dd498c35a53bd88fc06f21a11 (patch) | |
tree | f653f9ea4b0ed33df235d01ec8ee373a3bb3f598 | |
parent | 2b4eb0f8fb8ffca7b4016f6e8f05c124d0ad2afc (diff) | |
download | chocolate-doom-8a699c6ebc34dc5dd498c35a53bd88fc06f21a11.tar.gz chocolate-doom-8a699c6ebc34dc5dd498c35a53bd88fc06f21a11.tar.bz2 chocolate-doom-8a699c6ebc34dc5dd498c35a53bd88fc06f21a11.zip |
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.
-rw-r--r-- | src/doomkeys.h | 1 | ||||
-rw-r--r-- | src/i_video.c | 3 | ||||
-rw-r--r-- | src/m_config.c | 14 | ||||
-rw-r--r-- | textscreen/txt_sdl.c | 1 |
4 files changed, 16 insertions, 3 deletions
diff --git a/src/doomkeys.h b/src/doomkeys.h index 07fe916a..4bc63d08 100644 --- 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) diff --git a/src/i_video.c b/src/i_video.c index d3f674d4..be40128f 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -480,7 +480,8 @@ static int TranslateKey(SDL_keysym *sym) 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; diff --git a/src/m_config.c b/src/m_config.c index 9593de57..b0e201d5 100644 --- a/src/m_config.c +++ b/src/m_config.c @@ -1489,6 +1489,16 @@ static default_t *SearchCollection(default_collection_t *collection, char *name) 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,14 +1509,14 @@ static const int scantokey[128] = '\'', '`', 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, 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 }; diff --git a/textscreen/txt_sdl.c b/textscreen/txt_sdl.c index 895e1da0..4ff24fcf 100644 --- a/textscreen/txt_sdl.c +++ b/textscreen/txt_sdl.c @@ -445,6 +445,7 @@ static int TranslateKey(SDL_keysym *sym) 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; |