3 Copyright (C) 2003 Nuno Subtil
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 static const char cvsid
[] =
21 "$Id: input.c,v 1.4 2003/11/30 17:43:55 nsubtil Exp $";
32 #include "oglconsole.h"
34 static char keyboard_map
[SDLK_LAST
];
36 void input_reset(void)
38 memset(keyboard_map
, 0, sizeof(keyboard_map
));
42 processes all events and clears the SDL event queue
44 void input_update(void)
48 while(SDL_PollEvent(&ev
))
50 if (OGLCONSOLE_SDLEvent(&ev
) != 0)
53 if(ev
.type
== SDL_QUIT
)
59 if(ev
.type
== SDL_KEYDOWN
)
61 keyboard_map
[ev
.key
.keysym
.sym
] = 1;
64 if(keyboard_map
[SDLK_LALT
] && keyboard_map
[SDLK_RETURN
])
66 screen_toggle_fullscreen();
67 keyboard_map
[SDLK_LALT
] = 0;
68 keyboard_map
[SDLK_RETURN
] = 0;
72 if(ev
.type
== SDL_KEYUP
)
73 keyboard_map
[ev
.key
.keysym
.sym
] = 0;
78 returns the current state of a key
80 int input_kstate(int ksym
)
82 if(ksym
< 0 || ksym
>= SDLK_LAST
)
84 printf("input_kstate: invalid ksym %d\n", ksym
);
89 return keyboard_map
[ksym
];
95 void input_kclear(int ksym
)
97 if(ksym
< 0 || ksym
>= SDLK_LAST
)
99 printf("input_kclear: invalid ksym %d\n", ksym
);
104 keyboard_map
[ksym
] = 0;