- pass key events to the event queue.

This commit is contained in:
Christoph Oelckers 2019-11-03 22:46:01 +01:00
parent c7af86bd00
commit 01d5d51f13
4 changed files with 9 additions and 22 deletions

View file

@ -585,6 +585,8 @@ void CPlayerMsg::Send(void)
void CPlayerMsg::ProcessKeys(void) void CPlayerMsg::ProcessKeys(void)
{ {
if (KB_KeyPressed(sc_Escape)) Term();
#if 0
int key = keyGetScan(); int key = keyGetScan();
int ch; int ch;
if (key != 0) if (key != 0)
@ -635,6 +637,7 @@ void CPlayerMsg::ProcessKeys(void)
} }
sub_5A944(key); sub_5A944(key);
} }
#endif
} }
bool CPlayerMsg::IsWhitespaceOnly(const char * const pzString) bool CPlayerMsg::IsWhitespaceOnly(const char * const pzString)

View file

@ -112,8 +112,6 @@ extern char g_keyAsciiFIFO[KEYFIFOSIZ];
extern uint8_t g_keyAsciiPos; extern uint8_t g_keyAsciiPos;
extern uint8_t g_keyAsciiEnd; extern uint8_t g_keyAsciiEnd;
extern uint8_t g_keyFIFOend; extern uint8_t g_keyFIFOend;
extern char g_keyRemapTable[NUMKEYS];
extern char g_keyNameTable[NUMKEYS][24];
extern void keySetState(int32_t key, int32_t state); extern void keySetState(int32_t key, int32_t state);
@ -178,7 +176,6 @@ void uninitinput(void);
void keySetCallback(void (*callback)(int32_t,int32_t)); void keySetCallback(void (*callback)(int32_t,int32_t));
void mouseSetCallback(void (*callback)(int32_t,int32_t)); void mouseSetCallback(void (*callback)(int32_t,int32_t));
void joySetCallback(void (*callback)(int32_t,int32_t)); void joySetCallback(void (*callback)(int32_t,int32_t));
const char *keyGetName(int32_t num);
const char *joyGetName(int32_t what, int32_t num); // what: 0=axis, 1=button, 2=hat const char *joyGetName(int32_t what, int32_t num); // what: 0=axis, 1=button, 2=hat
void joyScanDevices(void); void joyScanDevices(void);

View file

@ -9,6 +9,7 @@
#include "polymost.h" #include "polymost.h"
#include "cache1d.h" #include "cache1d.h"
#include "inputstate.h" #include "inputstate.h"
#include "d_event.h"
#include "../../glbackend/glbackend.h" #include "../../glbackend/glbackend.h"
// video // video
@ -31,8 +32,6 @@ uint8_t g_keyFIFOpos;
uint8_t g_keyFIFOend; uint8_t g_keyFIFOend;
uint8_t g_keyAsciiPos; uint8_t g_keyAsciiPos;
uint8_t g_keyAsciiEnd; uint8_t g_keyAsciiEnd;
char g_keyRemapTable[NUMKEYS];
char g_keyNameTable[NUMKEYS][24];
void (*keypresscallback)(int32_t, int32_t); void (*keypresscallback)(int32_t, int32_t);
@ -40,12 +39,14 @@ void keySetCallback(void (*callback)(int32_t, int32_t)) { keypresscallback = cal
void keySetState(int32_t key, int32_t state) void keySetState(int32_t key, int32_t state)
{ {
inputState.SetKeyStatus(g_keyRemapTable[key], state); inputState.SetKeyStatus(key, state);
//keystatus[g_keyRemapTable[key]] = state; event_t ev = { (uint8_t)(state ? EV_KeyDown : EV_KeyUp), 0, (uint16_t)key };
D_PostEvent(&ev);
if (state) if (state)
{ {
g_keyFIFO[g_keyFIFOend] = g_keyRemapTable[key]; g_keyFIFO[g_keyFIFOend] = key;
g_keyFIFO[(g_keyFIFOend+1)&(KEYFIFOSIZ-1)] = state; g_keyFIFO[(g_keyFIFOend+1)&(KEYFIFOSIZ-1)] = state;
g_keyFIFOend = ((g_keyFIFOend+2)&(KEYFIFOSIZ-1)); g_keyFIFOend = ((g_keyFIFOend+2)&(KEYFIFOSIZ-1));
} }
@ -88,8 +89,6 @@ void keyFlushChars(void)
g_keyAsciiPos = g_keyAsciiEnd = 0; g_keyAsciiPos = g_keyAsciiEnd = 0;
} }
const char *keyGetName(int32_t num) { return ((unsigned)num >= NUMKEYS) ? NULL : g_keyNameTable[num]; }
vec2_t g_mousePos; vec2_t g_mousePos;
vec2_t g_mouseAbs; vec2_t g_mouseAbs;
int32_t g_mouseBits; int32_t g_mouseBits;
@ -263,8 +262,6 @@ int32_t baselayer_init(void)
polymost_initosdfuncs(); polymost_initosdfuncs();
#endif #endif
for (native_t i = 0; i < NUMKEYS; i++) g_keyRemapTable[i] = i;
return 0; return 0;
} }

View file

@ -907,16 +907,6 @@ int32_t initinput(void)
inputdevices = 1 | 2; // keyboard (1) and mouse (2) inputdevices = 1 | 2; // keyboard (1) and mouse (2)
g_mouseGrabbed = 0; g_mouseGrabbed = 0;
memset(g_keyNameTable, 0, sizeof(g_keyNameTable));
for (i = SDL_NUM_SCANCODES - 1; i >= 0; i--)
{
if (!keytranslation[i])
continue;
Bstrncpyz(g_keyNameTable[keytranslation[i]], SDL_GetKeyName(SDL_SCANCODE_TO_KEYCODE(i)), sizeof(g_keyNameTable[0]));
}
if (!SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER)) if (!SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER))
{ {
LoadSDLControllerDB(); LoadSDLControllerDB();