- backend update fromGZDoom.

most importantly this addresses issues with key down/key up events being sent in the same tic not having an effect on game actions that require a key being held down.
This commit is contained in:
Christoph Oelckers 2021-11-21 10:19:52 +01:00
parent 1228cb6044
commit b7c7328cdd
13 changed files with 55 additions and 15 deletions

View file

@ -686,6 +686,17 @@ void ReadBindings(int lump, bool override)
FKeyBindings* dest = &Bindings;
int key;
if (sc.Compare("unbind"))
{
sc.MustGetString();
if (override)
{
// This is only for games to clear unsuitable base defaults, not for mods.
dest->UnbindKey(sc.String);
}
continue;
}
// bind destination is optional and is the same as the console command
if (sc.Compare("bind"))
{
@ -722,7 +733,18 @@ void ReadBindings(int lump, bool override)
void C_SetDefaultKeys(const char* baseconfig)
{
auto lump = fileSystem.CheckNumForFullName("engine/commonbinds.txt");
if (lump >= 0) ReadBindings(lump, true);
if (lump >= 0)
{
// Bail out if a mod tries to override this. Main game resources are allowed to do this, though.
auto fileno2 = fileSystem.GetFileContainer(lump);
if (fileno2 > fileSystem.GetMaxIwadNum())
{
I_FatalError("File %s is overriding core lump %s.",
fileSystem.GetResourceFileFullName(fileno2), "engine/commonbinds.txt");
}
ReadBindings(lump, true);
}
int lastlump = 0;
while ((lump = fileSystem.FindLumpFullName(baseconfig, &lastlump)) != -1)

View file

@ -67,11 +67,21 @@ CVAR(Bool, m_filter, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
void D_ProcessEvents (void)
{
event_t *ev;
FixedBitArray<NUM_KEYS> keywasdown;
TArray<event_t> delayedevents;
keywasdown.Zero();
while (eventtail != eventhead)
{
ev = &events[eventtail];
event_t *ev = &events[eventtail];
eventtail = (eventtail + 1) & (MAXEVENTS - 1);
if (ev->type == EV_KeyUp && keywasdown[ev->data1])
{
delayedevents.Push(*ev);
continue;
}
if (ev->type == EV_None)
continue;
if (ev->type == EV_DeviceChange)
@ -85,7 +95,12 @@ void D_ProcessEvents (void)
continue; // menu ate the event
}
G_Responder (ev);
if (G_Responder(ev) && ev->type == EV_KeyDown) keywasdown.Set(ev->data1);
}
for (auto& ev: delayedevents)
{
D_PostEvent(&ev);
}
}

View file

@ -42,7 +42,7 @@
//
//==========================================================================
struct GrpInfo
struct GrpHeader
{
uint32_t Magic[3];
uint32_t NumLumps;
@ -95,7 +95,7 @@ FGrpFile::FGrpFile(const char *filename, FileReader &file)
bool FGrpFile::Open(bool quiet, LumpFilterInfo*)
{
GrpInfo header;
GrpHeader header;
Reader.Read(&header, sizeof(header));
NumLumps = LittleLong(header.NumLumps);
@ -105,7 +105,7 @@ bool FGrpFile::Open(bool quiet, LumpFilterInfo*)
Lumps.Resize(NumLumps);
int Position = sizeof(GrpInfo) + NumLumps * sizeof(GrpLump);
int Position = sizeof(GrpHeader) + NumLumps * sizeof(GrpLump);
for(uint32_t i = 0; i < NumLumps; i++)
{

View file

@ -67,6 +67,7 @@ void I_InitGraphics ()
#ifdef __APPLE__
SDL_SetHint(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, "0");
#endif // __APPLE__
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
if (SDL_InitSubSystem (SDL_INIT_VIDEO) < 0)
{

View file

@ -22,7 +22,7 @@
#include "v_video.h"
#include "m_png.h"
#include "templates.h"
#include "r_videoscale.h"
#include "i_time.h"
#include "v_text.h"

View file

@ -20,7 +20,7 @@
**
*/
#include "templates.h"
#include "c_cvars.h"
#include "hw_material.h"
#include "hw_cvars.h"

View file

@ -23,7 +23,7 @@
#include "polyrenderer/backend/poly_renderstate.h"
#include "polyrenderer/backend/poly_framebuffer.h"
#include "polyrenderer/backend/poly_hwtexture.h"
#include "templates.h"
#include "hw_skydome.h"
#include "hw_viewpointuniforms.h"
#include "hw_lightbuffer.h"

View file

@ -21,7 +21,7 @@
*/
#include <stddef.h>
#include "templates.h"
#include "filesystem.h"
#include "v_video.h"

View file

@ -21,7 +21,7 @@
*/
#include <stddef.h>
#include "templates.h"
#include "filesystem.h"
#include "v_video.h"

View file

@ -21,7 +21,7 @@
*/
#include <stddef.h>
#include "templates.h"
#include "poly_thread.h"
#include "screen_scanline_setup.h"
#include <cmath>

View file

@ -21,7 +21,6 @@
*/
#include <stddef.h>
#include "templates.h"
#include "poly_thread.h"
#include "screen_scanline_setup.h"
#include <cmath>

View file

@ -21,7 +21,6 @@
*/
#include <stddef.h>
#include "templates.h"
#include "filesystem.h"
#include "v_video.h"

View file

@ -866,6 +866,10 @@ FString ExpandEnvVars(const char *searchpathstring)
FString NicePath(const char *path)
{
#ifdef _WIN32
if (*path == '\0')
{
return FString(".");
}
return ExpandEnvVars(path);
#else
if (path == NULL || *path == '\0')