DEADSOFTWARE

4123c071937eac0ee8baab22982c4c38b065b393
[flatwaifu.git] / src / keyb.c
1 /*
2 Copyright (C) Prikol Software 1996-1997
3 Copyright (C) Aleksey Volynskov 1996-1997
4 Copyright (C) <ARembo@gmail.com> 2011
6 This file is part of the Doom2D:Rembo project.
8 Doom2D:Rembo is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License version 2 as
10 published by the Free Software Foundation.
12 Doom2D:Rembo is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, see <http://www.gnu.org/licenses/> or
19 write to the Free Software Foundation, Inc.,
20 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 */
23 #include "keyb.h"
24 #include "error.h"
25 #include <SDL.h>
27 // стандартная функция обработки клавиш
28 key_f def_key_proc;
30 // массив клавиш: 0 - отпущена, иначе - нажата
31 unsigned char *keys = NULL;
33 static key_f *key_proc = NULL;
36 void K_init()
37 {
38 keys = SDL_GetKeyState(NULL);
39 }
41 void K_done()
42 {
44 }
45 // установить функцию обработки клавиш
46 void K_setkeyproc(key_f *k)
47 {
48 key_proc = k;
49 }
51 void updatee_keys()
52 {
53 SDL_Event event;
54 while (SDL_PollEvent (&event)) {
55 /*
56 if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_RETURN && event.key.keysym.mod & KMOD_LALT) {
57 V_toggle();
58 }
59 else */
60 if (event.type == SDL_KEYDOWN || event.type == SDL_KEYUP) {
61 if (event.type == SDL_KEYDOWN && key_proc!=NULL)
62 key_proc(event.key.keysym.sym, event.type == SDL_KEYDOWN);
63 }
64 else if (event.type == SDL_QUIT) {
65 ERR_quit();
66 }
67 }
68 }