mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 10:40:46 +00:00
Better keybinding... still needs some work but seems to be functional
Example: bind w repeat gamefunc_move_forward bind s repeat gamefunc_move_backward bind a repeat gamefunc_strafe_left bind d repeat gamefunc_strafe_right bind space gamefunc_jump bind leftcontrol repeat gamefunc_crouch bind f12 quit git-svn-id: https://svn.eduke32.com/eduke32@808 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
5308a328c5
commit
2fa3153a84
11 changed files with 159 additions and 112 deletions
|
@ -647,7 +647,6 @@ void ExtShowSectorData(short sectnum) //F5
|
|||
{
|
||||
short statnum=0;
|
||||
int x,x2,y;
|
||||
int nexti;
|
||||
int i;
|
||||
int secrets=0;
|
||||
int totalactors1=0,totalactors2=0,totalactors3=0,totalactors4=0;
|
||||
|
@ -665,10 +664,6 @@ void ExtShowSectorData(short sectnum) //F5
|
|||
statnum=0;
|
||||
i = headspritestat[statnum];
|
||||
while (i != -1)
|
||||
{
|
||||
nexti = nextspritestat[i];
|
||||
i = nexti;
|
||||
|
||||
{
|
||||
switch (sprite[i].picnum)
|
||||
{
|
||||
|
@ -715,7 +710,7 @@ void ExtShowSectorData(short sectnum) //F5
|
|||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
i = nextspritestat[i];
|
||||
}
|
||||
|
||||
for (i=0;i<MAXSPRITES;i++) numsprite[i]=0;
|
||||
|
@ -6639,7 +6634,7 @@ static void comlinehelp(void)
|
|||
static void addgamepath(const char *buffer)
|
||||
{
|
||||
struct strllist *s;
|
||||
s = (struct strllist *)calloc(1,sizeof(struct strllist));
|
||||
s = (struct strllist *)Bcalloc(1,sizeof(struct strllist));
|
||||
s->str = strdup(buffer);
|
||||
|
||||
if (CommandPaths)
|
||||
|
@ -6655,7 +6650,7 @@ static void addgamepath(const char *buffer)
|
|||
static void addgroup(const char *buffer)
|
||||
{
|
||||
struct strllist *s;
|
||||
s = (struct strllist *)calloc(1,sizeof(struct strllist));
|
||||
s = (struct strllist *)Bcalloc(1,sizeof(struct strllist));
|
||||
s->str = Bstrdup(buffer);
|
||||
if (Bstrchr(s->str,'.') == 0)
|
||||
Bstrcat(s->str,".grp");
|
||||
|
|
|
@ -311,12 +311,11 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
int length, num, soundsiz;
|
||||
char *filename, *ptr;
|
||||
char *filename1;
|
||||
short ps,pe,vo;
|
||||
volatile char lock;
|
||||
char pr,m;
|
||||
char *filename, *ptr, *filename1;
|
||||
SOUNDOWNER SoundOwner[4];
|
||||
short ps,pe,vo;
|
||||
char pr,m;
|
||||
volatile char lock;
|
||||
} sound_t;
|
||||
|
||||
extern sound_t g_sounds[MAXSOUNDS];
|
||||
|
@ -807,7 +806,8 @@ enum sysstrs {
|
|||
STR_MAPNAME,
|
||||
STR_MAPFILENAME,
|
||||
STR_PLAYERNAME,
|
||||
STR_VERSION
|
||||
STR_VERSION,
|
||||
STR_GAMETYPE
|
||||
};
|
||||
|
||||
// store global game definitions
|
||||
|
@ -1018,9 +1018,6 @@ extern playerdata_t g_player[MAXPLAYERS];
|
|||
#include "funct.h"
|
||||
|
||||
// key bindings stuff
|
||||
#define MAXSCRIPTFILENAMELENGTH 32
|
||||
#define MAXBOUNDKEYS 256
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
int id;
|
||||
|
@ -1028,13 +1025,6 @@ typedef struct {
|
|||
|
||||
extern keydef keynames[];
|
||||
|
||||
typedef struct binding {
|
||||
char *key;
|
||||
char name[MAXSCRIPTFILENAMELENGTH];
|
||||
} keybind;
|
||||
|
||||
extern keybind boundkeys[MAXBOUNDKEYS];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -247,8 +247,6 @@ keydef keynames[]=
|
|||
{0,0}
|
||||
};
|
||||
|
||||
keybind boundkeys[MAXBOUNDKEYS];
|
||||
|
||||
enum
|
||||
{
|
||||
T_EOF = -2,
|
||||
|
@ -603,6 +601,8 @@ void getpackets(void)
|
|||
sampletimer();
|
||||
AudioUpdate();
|
||||
|
||||
CONTROL_ProcessBinds();
|
||||
|
||||
if (ALT_IS_PRESSED && KB_KeyPressed(sc_Enter))
|
||||
{
|
||||
if (setgamemode(!ud.config.ScreenMode,ud.config.ScreenWidth,ud.config.ScreenHeight,ud.config.ScreenBPP))
|
||||
|
@ -7821,12 +7821,6 @@ static void nonsharedkeys(void)
|
|||
int i,ch;
|
||||
int j;
|
||||
|
||||
for (i=0;i<256;i++)
|
||||
if (*boundkeys[i].name&&KB_KeyPressed(i))
|
||||
{
|
||||
load_script(boundkeys[i].name);
|
||||
KB_ClearKeyDown(i);
|
||||
}
|
||||
if (ud.recstat == 2)
|
||||
{
|
||||
ControlInfo noshareinfo;
|
||||
|
@ -8588,7 +8582,7 @@ static void setup_rancid_net(const char *fn)
|
|||
netparamcount = rancid_players;
|
||||
if (rancid_local_port_string[0] == '-')
|
||||
netparamcount++;
|
||||
netparam = (char **)calloc(netparamcount, sizeof(char **));
|
||||
netparam = (char **)Bcalloc(netparamcount, sizeof(char **));
|
||||
|
||||
for (i=0;i<rancid_players;i++)
|
||||
{
|
||||
|
@ -8934,7 +8928,7 @@ static int loaddefinitions_game(const char *fn, int preload)
|
|||
static void addgroup(const char *buffer)
|
||||
{
|
||||
struct strllist *s;
|
||||
s = (struct strllist *)calloc(1,sizeof(struct strllist));
|
||||
s = (struct strllist *)Bcalloc(1,sizeof(struct strllist));
|
||||
s->str = Bstrdup(buffer);
|
||||
if (Bstrchr(s->str,'.') == 0)
|
||||
Bstrcat(s->str,".grp");
|
||||
|
@ -8952,7 +8946,7 @@ static void addgroup(const char *buffer)
|
|||
static void addgamepath(const char *buffer)
|
||||
{
|
||||
struct strllist *s;
|
||||
s = (struct strllist *)calloc(1,sizeof(struct strllist));
|
||||
s = (struct strllist *)Bcalloc(1,sizeof(struct strllist));
|
||||
s->str = strdup(buffer);
|
||||
|
||||
if (CommandPaths)
|
||||
|
@ -9117,7 +9111,7 @@ static void checkcommandline(int argc, const char **argv)
|
|||
g_NoSetup = TRUE;
|
||||
firstnet = i;
|
||||
netparamcount = argc - i - 1;
|
||||
netparam = (char **)calloc(netparamcount, sizeof(char**));
|
||||
netparam = (char **)Bcalloc(netparamcount, sizeof(char**));
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -4973,6 +4973,7 @@ static void AddDefaultDefinitions(void)
|
|||
AddDefinition("STR_MAPFILENAME",STR_MAPFILENAME,LABEL_DEFINE);
|
||||
AddDefinition("STR_PLAYERNAME",STR_PLAYERNAME,LABEL_DEFINE);
|
||||
AddDefinition("STR_VERSION",STR_VERSION,LABEL_DEFINE);
|
||||
AddDefinition("STR_GAMETYPE",STR_GAMETYPE,LABEL_DEFINE);
|
||||
|
||||
AddDefinition("NO",0,LABEL_DEFINE|LABEL_ACTION|LABEL_AI|LABEL_MOVE);
|
||||
|
||||
|
|
|
@ -5147,6 +5147,9 @@ static int parse(void)
|
|||
case STR_VERSION:
|
||||
Bstrcpy(fta_quotes[i],HEAD2);
|
||||
break;
|
||||
case STR_GAMETYPE:
|
||||
Bstrcpy(fta_quotes[i],gametype_names[ud.coop]);
|
||||
break;
|
||||
default:
|
||||
OSD_Printf("%s %d unknown str ID %d %d\n",__FILE__,__LINE__,i,j);
|
||||
}
|
||||
|
@ -5532,7 +5535,11 @@ static int parse(void)
|
|||
{
|
||||
int32 i=0;
|
||||
insptr++;
|
||||
if (ud.config.scripthandle < 0) {insptr++;break;}
|
||||
if (ud.config.scripthandle < 0)
|
||||
{
|
||||
insptr++;
|
||||
break;
|
||||
}
|
||||
switch (tw)
|
||||
{
|
||||
case CON_SAVEGAMEVAR:
|
||||
|
|
|
@ -52,7 +52,7 @@ static int LoadGroupsCache(void)
|
|||
if (scriptfile_getnumber(script, &fmtime)) break; // modification time
|
||||
if (scriptfile_getnumber(script, &fcrcval)) break; // crc checksum
|
||||
|
||||
fg = calloc(1, sizeof(struct grpcache));
|
||||
fg = Bcalloc(1, sizeof(struct grpcache));
|
||||
fg->next = grpcache;
|
||||
grpcache = fg;
|
||||
|
||||
|
@ -110,14 +110,14 @@ int ScanGroups(void)
|
|||
free(fn);
|
||||
if (fg->size == st.st_size && fg->mtime == st.st_mtime)
|
||||
{
|
||||
grp = (struct grpfile *)calloc(1, sizeof(struct grpfile));
|
||||
grp = (struct grpfile *)Bcalloc(1, sizeof(struct grpfile));
|
||||
grp->name = strdup(sidx->name);
|
||||
grp->crcval = fg->crcval;
|
||||
grp->size = fg->size;
|
||||
grp->next = foundgrps;
|
||||
foundgrps = grp;
|
||||
|
||||
fgg = (struct grpcache *)calloc(1, sizeof(struct grpcache));
|
||||
fgg = (struct grpcache *)Bcalloc(1, sizeof(struct grpcache));
|
||||
strcpy(fgg->name, fg->name);
|
||||
fgg->size = fg->size;
|
||||
fgg->mtime = fg->mtime;
|
||||
|
@ -149,14 +149,14 @@ int ScanGroups(void)
|
|||
close(fh);
|
||||
initprintf(" Done\n");
|
||||
|
||||
grp = (struct grpfile *)calloc(1, sizeof(struct grpfile));
|
||||
grp = (struct grpfile *)Bcalloc(1, sizeof(struct grpfile));
|
||||
grp->name = strdup(sidx->name);
|
||||
grp->crcval = crcval;
|
||||
grp->size = st.st_size;
|
||||
grp->next = foundgrps;
|
||||
foundgrps = grp;
|
||||
|
||||
fgg = (struct grpcache *)calloc(1, sizeof(struct grpcache));
|
||||
fgg = (struct grpcache *)Bcalloc(1, sizeof(struct grpcache));
|
||||
strncpy(fgg->name, sidx->name, BMAX_PATH);
|
||||
fgg->size = st.st_size;
|
||||
fgg->mtime = st.st_mtime;
|
||||
|
|
|
@ -2873,7 +2873,7 @@ int MV_Init(int soundcard, int MixRate, int Voices, int numchannels, int sampleb
|
|||
|
||||
// Allocate mix buffer within 1st megabyte
|
||||
// use calloc to clear the memory for the first playback.
|
||||
ptr = (char *)calloc(1,TotalBufferSize + 8); // FIXME: temporarily fixes bounds error somewhere...
|
||||
ptr = (char *)Bcalloc(1,TotalBufferSize + 8); // FIXME: temporarily fixes bounds error somewhere...
|
||||
if (!ptr)
|
||||
{
|
||||
USRHOOKS_FreeMem(MV_Voices);
|
||||
|
|
|
@ -159,10 +159,10 @@ boolean CONTROL_KeyboardFunctionPressed(int32 which)
|
|||
|
||||
if (!CONTROL_Flags[which].used) return false;
|
||||
|
||||
if (CONTROL_KeyMapping[which].key1 != KEYUNDEFINED)
|
||||
if (CONTROL_KeyMapping[which].key1 != KEYUNDEFINED && !boundkeys[CONTROL_KeyMapping[which].key1].name[0])
|
||||
key1 = KB_KeyDown[ CONTROL_KeyMapping[which].key1 ] ? true : false;
|
||||
|
||||
if (CONTROL_KeyMapping[which].key2 != KEYUNDEFINED)
|
||||
if (CONTROL_KeyMapping[which].key2 != KEYUNDEFINED && !boundkeys[CONTROL_KeyMapping[which].key1].name[0])
|
||||
key2 = KB_KeyDown[ CONTROL_KeyMapping[which].key2 ] ? true : false;
|
||||
|
||||
return (key1 | key2);
|
||||
|
@ -786,6 +786,27 @@ void CONTROL_ClearButton( int32 whichbutton )
|
|||
CONTROL_Flags[whichbutton].cleared = true;
|
||||
}
|
||||
|
||||
int extinput[CONTROL_NUM_FLAGS];
|
||||
keybind boundkeys[MAXBOUNDKEYS];
|
||||
|
||||
void CONTROL_ProcessBinds(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0;i<256;i++)
|
||||
{
|
||||
if (boundkeys[i].name[0] && KB_KeyPressed(i))
|
||||
{
|
||||
if (boundkeys[i].repeat || (boundkeys[i].laststate == 0))
|
||||
OSD_Dispatch(boundkeys[i].name);
|
||||
// if (!boundkeys[i].repeat)
|
||||
// KB_ClearKeyDown(i);
|
||||
}
|
||||
boundkeys[i].laststate = KB_KeyPressed(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CONTROL_GetInput( ControlInfo *info )
|
||||
{
|
||||
int32 i, periphs[CONTROL_NUM_FLAGS];
|
||||
|
@ -800,12 +821,15 @@ void CONTROL_GetInput( ControlInfo *info )
|
|||
CONTROL_ButtonHeldState2 = CONTROL_ButtonState2;
|
||||
CONTROL_ButtonState1 = CONTROL_ButtonState2 = 0;
|
||||
|
||||
CONTROL_ProcessBinds();
|
||||
|
||||
for (i=0; i<CONTROL_NUM_FLAGS; i++) {
|
||||
CONTROL_SetFlag(i, CONTROL_KeyboardFunctionPressed(i) | periphs[i]);
|
||||
CONTROL_SetFlag(i, CONTROL_KeyboardFunctionPressed(i) | periphs[i] | extinput[i]);
|
||||
|
||||
if (CONTROL_Flags[i].cleared == false) BUTTONSET(i, CONTROL_Flags[i].active);
|
||||
else if (CONTROL_Flags[i].active == false) CONTROL_Flags[i].cleared = 0;
|
||||
}
|
||||
memset(extinput, 0, sizeof(extinput));
|
||||
}
|
||||
|
||||
void CONTROL_WaitRelease( void )
|
||||
|
|
|
@ -212,6 +212,20 @@ void CONTROL_PrintKeyMap(void);
|
|||
void CONTROL_PrintControlFlag(int32 which);
|
||||
void CONTROL_PrintAxes( void );
|
||||
|
||||
#define MAXBINDSTRINGLENGTH 128
|
||||
#define MAXBOUNDKEYS 256
|
||||
|
||||
typedef struct binding {
|
||||
char *key;
|
||||
char name[MAXBINDSTRINGLENGTH];
|
||||
char repeat;
|
||||
char laststate;
|
||||
} keybind;
|
||||
|
||||
extern keybind boundkeys[MAXBOUNDKEYS];
|
||||
|
||||
void CONTROL_ProcessBinds(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -952,9 +952,18 @@ static int osdcmd_name(const osdfuncparm_t *parm)
|
|||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
extern int extinput[64];
|
||||
|
||||
static int osdcmd_button(const osdfuncparm_t *parm)
|
||||
{
|
||||
char *p = (char *)parm->name+9; // skip "gamefunc_"
|
||||
extinput[CONFIG_FunctionNameToNum(p)] = 1;
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
static int osdcmd_bind(const osdfuncparm_t *parm)
|
||||
{
|
||||
int i;
|
||||
int i, j;
|
||||
|
||||
if (parm->numparms==1&&!Bstrcasecmp(parm->parms[0],"showkeys"))
|
||||
{
|
||||
|
@ -973,8 +982,16 @@ static int osdcmd_bind(const osdfuncparm_t *parm)
|
|||
for (i=0;keynames[i].name;i++)if (!Bstrcasecmp(parm->parms[0],keynames[i].name))break;
|
||||
if (!keynames[i].name) return OSDCMD_SHOWHELP;
|
||||
|
||||
Bstrncpy(boundkeys[keynames[i].id].name,parm->parms[1], MAXSCRIPTFILENAMELENGTH-1);
|
||||
j = 1;
|
||||
if (parm->numparms >= 2 && !Bstrcasecmp(parm->parms[j],"repeat"))
|
||||
{
|
||||
boundkeys[keynames[i].id].repeat = 1;
|
||||
j++;
|
||||
}
|
||||
else boundkeys[keynames[i].id].repeat = 0;
|
||||
Bstrncpy(boundkeys[keynames[i].id].name,parm->parms[j], MAXBINDSTRINGLENGTH-1);
|
||||
boundkeys[keynames[i].id].key=keynames[i].name;
|
||||
OSD_Printf("key %s repeat %d string %s\n",keynames[i].name,boundkeys[keynames[i].id].repeat, boundkeys[keynames[i].id].name);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
|
@ -1034,6 +1051,11 @@ int registerosdcommands(void)
|
|||
OSD_RegisterFunction("vidmode","vidmode [xdim ydim] [bpp] [fullscreen]: immediately change the video mode",osdcmd_vidmode);
|
||||
|
||||
OSD_RegisterFunction("bind","bind <key> <scriptfile>: executes a command script when <key> gets pressed. Type \"bind showkeys\" for a list of keys.", osdcmd_bind);
|
||||
for (i=0;i<NUMGAMEFUNCTIONS;i++)
|
||||
{
|
||||
Bsprintf(tempbuf,"gamefunc_%s",gamefunctions[i]);
|
||||
OSD_RegisterFunction(Bstrdup(tempbuf),"game button",osdcmd_button);
|
||||
}
|
||||
//baselayer_onvideomodechange = onvideomodechange;
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue