mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 17:01:51 +00:00
SDL: Fix "the issue where if you hold down a key and enter the console then release it that the key remains held down until you hit it again outside the console".
git-svn-id: https://svn.eduke32.com/eduke32@4269 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
b2a3aec334
commit
31a8bfebb6
7 changed files with 39 additions and 15 deletions
|
@ -82,14 +82,16 @@ extern void setvsync(int32_t sync);
|
|||
extern char inputdevices;
|
||||
|
||||
// keys
|
||||
#define KEYSTATUSSIZ 256
|
||||
#define KEYFIFOSIZ 64
|
||||
extern char keystatus[256], keyfifo[KEYFIFOSIZ], keyfifoplc, keyfifoend;
|
||||
extern char keystatus[KEYSTATUSSIZ], keyfifo[KEYFIFOSIZ], keyfifoplc, keyfifoend;
|
||||
extern char keyasciififo[KEYFIFOSIZ], keyasciififoplc, keyasciififoend;
|
||||
extern char scantoasc[128], remap[256], key_names[256][24];
|
||||
extern char scantoasc[128], remap[KEYSTATUSSIZ], key_names[256][24];
|
||||
extern int32_t remapinit;
|
||||
|
||||
extern int32_t defaultres[][2];
|
||||
|
||||
extern int32_t GetKey(int32_t key);
|
||||
extern void SetKey(int32_t key, int32_t state);
|
||||
|
||||
// mouse
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
|
||||
// input
|
||||
char inputdevices=0;
|
||||
char keystatus[256], keyfifo[KEYFIFOSIZ], keyfifoplc, keyfifoend;
|
||||
char keystatus[KEYSTATUSSIZ], keyfifo[KEYFIFOSIZ], keyfifoplc, keyfifoend;
|
||||
char keyasciififo[KEYFIFOSIZ], keyasciififoplc, keyasciififoend;
|
||||
char remap[256];
|
||||
char remap[KEYSTATUSSIZ];
|
||||
int32_t remapinit=0;
|
||||
char key_names[256][24];
|
||||
volatile int32_t mousex=0,mousey=0,mouseb=0,mouseabsx=0,mouseabsy=0;
|
||||
|
@ -54,6 +54,10 @@ int32_t defaultres[][2] =
|
|||
};
|
||||
|
||||
|
||||
int32_t GetKey(int32_t key)
|
||||
{
|
||||
return keystatus[remap[key]];
|
||||
}
|
||||
void SetKey(int32_t key, int32_t state)
|
||||
{
|
||||
keystatus[remap[key]] = state;
|
||||
|
|
|
@ -70,8 +70,6 @@ extern char game_executable[BMAX_PATH];
|
|||
extern int32_t fullscreen;
|
||||
extern char default_buildkeys[NUMBUILDKEYS];
|
||||
static char *const keys = default_buildkeys;
|
||||
extern char remap[256];
|
||||
extern int32_t remapinit;
|
||||
static int32_t default_grid=3;
|
||||
extern int32_t AmbienceToggle, MixRate;
|
||||
extern int32_t ParentalLock;
|
||||
|
|
|
@ -1217,7 +1217,7 @@ int32_t OSD_HandleChar(char ch)
|
|||
int32_t OSD_HandleScanCode(int32_t sc, int32_t press)
|
||||
{
|
||||
if ((osdflags & OSD_INITIALIZED) == 0)
|
||||
return sc;
|
||||
return 1;
|
||||
|
||||
if (sc == osdkey)
|
||||
{
|
||||
|
@ -1232,10 +1232,10 @@ int32_t OSD_HandleScanCode(int32_t sc, int32_t press)
|
|||
OSD_CaptureInput(osdscroll == 1);
|
||||
osdscrtime = getticks();
|
||||
}
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
else if ((osdflags & OSD_CAPTURE) == 0)
|
||||
return sc;
|
||||
return 2;
|
||||
|
||||
if (!press)
|
||||
{
|
||||
|
|
|
@ -145,7 +145,7 @@ static inline void RI_ProcessKeyboard(const RAWKEYBOARD *rkbd)
|
|||
|
||||
KeyboardState[VKey] = 1 - (rkbd->Flags & RI_KEY_BREAK);
|
||||
|
||||
if (OSD_HandleScanCode(key, KeyboardState[VKey] != 0))
|
||||
if (OSD_HandleScanCode(key, KeyboardState[VKey] > 0))
|
||||
{
|
||||
SetKey(key, KeyboardState[VKey] != 0);
|
||||
|
||||
|
|
|
@ -2151,12 +2151,22 @@ int32_t handleevents(void)
|
|||
// printf("got key %d, %d\n",ev.key.keysym.scancode,code);
|
||||
|
||||
// hook in the osd
|
||||
if (OSD_HandleScanCode(code, (ev.key.type == SDL_KEYDOWN)) == 0)
|
||||
if ((j = OSD_HandleScanCode(code, (ev.key.type == SDL_KEYDOWN))) <= 0)
|
||||
{
|
||||
if (j == -1) // osdkey
|
||||
for (j = 0; j < KEYSTATUSSIZ; ++j)
|
||||
if (GetKey(j))
|
||||
{
|
||||
SetKey(j, 0);
|
||||
if (keypresscallback)
|
||||
keypresscallback(j, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (ev.key.type == SDL_KEYDOWN)
|
||||
{
|
||||
if (!keystatus[code])
|
||||
if (!GetKey(code))
|
||||
{
|
||||
SetKey(code, 1);
|
||||
if (keypresscallback)
|
||||
|
@ -2240,12 +2250,22 @@ int32_t handleevents(void)
|
|||
// hook in the osd
|
||||
// if (ev.type==SDL_KEYDOWN)
|
||||
// printf("got key SDLK %d (%s), trans 0x%x\n", ev.key.keysym.sym, SDL_GetKeyName(ev.key.keysym.sym), code);
|
||||
if (OSD_HandleScanCode(code, (ev.key.type == SDL_KEYDOWN)) == 0)
|
||||
if ((j = OSD_HandleScanCode(code, (ev.key.type == SDL_KEYDOWN))) <= 0)
|
||||
{
|
||||
if (j == -1) // osdkey
|
||||
for (j = 0; j < KEYSTATUSSIZ; ++j)
|
||||
if (GetKey(j))
|
||||
{
|
||||
SetKey(j, 0);
|
||||
if (keypresscallback)
|
||||
keypresscallback(j, 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (ev.key.type == SDL_KEYDOWN)
|
||||
{
|
||||
if (!keystatus[code])
|
||||
if (!GetKey(code))
|
||||
{
|
||||
SetKey(code, 1);
|
||||
if (keypresscallback)
|
||||
|
|
|
@ -944,7 +944,7 @@ void releaseallbuttons(void)
|
|||
}
|
||||
joyb = joyblast = 0;
|
||||
|
||||
for (i=0; i<256; i++)
|
||||
for (i=0; i<KEYSTATUSSIZ; i++)
|
||||
{
|
||||
//if (!keystatus[i]) continue;
|
||||
//if (OSD_HandleKey(i, 0) != 0) {
|
||||
|
|
Loading…
Reference in a new issue