diff options
author | Simon Howard | 2007-07-29 23:41:12 +0000 |
---|---|---|
committer | Simon Howard | 2007-07-29 23:41:12 +0000 |
commit | e4681dd485de5a393070e3fcb91505116405cc1d (patch) | |
tree | 63443c3d1671a6e3febfac62c20092917c32d034 /textscreen/txt_sdl.c | |
parent | b361695b7aa13dc89149e7394e273b204394ef79 (diff) | |
download | chocolate-doom-e4681dd485de5a393070e3fcb91505116405cc1d.tar.gz chocolate-doom-e4681dd485de5a393070e3fcb91505116405cc1d.tar.bz2 chocolate-doom-e4681dd485de5a393070e3fcb91505116405cc1d.zip |
Allow more than the standard three mouse buttons to be defined through
setup (hopefully)
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 939
Diffstat (limited to 'textscreen/txt_sdl.c')
-rw-r--r-- | textscreen/txt_sdl.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/textscreen/txt_sdl.c b/textscreen/txt_sdl.c index 7a0e3ba8..73a69569 100644 --- a/textscreen/txt_sdl.c +++ b/textscreen/txt_sdl.c @@ -322,6 +322,24 @@ static int TranslateKey(SDL_keysym *sym) } } +// Convert an SDL button index to textscreen button index. +// +// Note special cases because 2 == mid in SDL, 3 == mid in textscreen/setup + +static int SDLButtonToTXTButton(int button) +{ + switch (button) + { + case SDL_BUTTON_LEFT: + return TXT_MOUSE_LEFT; + case SDL_BUTTON_RIGHT: + return TXT_MOUSE_RIGHT; + case SDL_BUTTON_MIDDLE: + return TXT_MOUSE_MIDDLE; + default: + return TXT_MOUSE_BASE + button - 1; + } +} signed int TXT_GetChar(void) { @@ -345,12 +363,10 @@ signed int TXT_GetChar(void) switch (ev.type) { case SDL_MOUSEBUTTONDOWN: - if (ev.button.button == SDL_BUTTON_LEFT) - return TXT_MOUSE_LEFT; - else if (ev.button.button == SDL_BUTTON_RIGHT) - return TXT_MOUSE_RIGHT; - else if (ev.button.button == SDL_BUTTON_MIDDLE) - return TXT_MOUSE_MIDDLE; + if (ev.button.button < TXT_MAX_MOUSE_BUTTONS) + { + return SDLButtonToTXTButton(ev.button.button); + } break; case SDL_KEYDOWN: |