mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-11 07:11:39 +00:00
mouse binds
git-svn-id: https://svn.eduke32.com/eduke32@826 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
71292bb5f1
commit
95eed1cd2b
6 changed files with 79 additions and 12 deletions
|
@ -854,6 +854,10 @@ void CONFIG_WriteBinds(void) // save binds and aliases to disk
|
|||
if (boundkeys[i].key && *boundkeys[i].name)
|
||||
fprintf(fp,"bind %s%s \"%s\"\n",boundkeys[i].key,boundkeys[i].repeat?"":" norepeat",boundkeys[i].name);
|
||||
|
||||
for (i=0;i<MAXMOUSEBUTTONS;i++)
|
||||
if (mousebind[i].key && *mousebind[i].name)
|
||||
fprintf(fp,"bind %s%s \"%s\"\n",mousebind[i].key,mousebind[i].repeat?"":" norepeat",mousebind[i].name);
|
||||
|
||||
for (symb=symbols; symb!=NULL; symb=symb->next)
|
||||
if (symb->func == (void *)OSD_ALIAS)
|
||||
fprintf(fp,"alias %s \"%s\"\n", symb->name, symb->help);
|
||||
|
|
|
@ -1024,6 +1024,7 @@ typedef struct {
|
|||
} keydef;
|
||||
|
||||
extern keydef keynames[];
|
||||
extern char *mousenames[];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -258,6 +258,8 @@ keydef keynames[]=
|
|||
{0,0}
|
||||
};
|
||||
|
||||
char *mousenames[] = { "mouse1", "mouse2", "mouse3", "mouse4", "mouse5", "mouse6" };
|
||||
|
||||
enum
|
||||
{
|
||||
T_EOF = -2,
|
||||
|
|
|
@ -57,6 +57,7 @@ static int32 CONTROL_DoubleClickSpeed;
|
|||
|
||||
int extinput[CONTROL_NUM_FLAGS];
|
||||
keybind boundkeys[MAXBOUNDKEYS];
|
||||
keybind mousebind[MAXMOUSEBUTTONS];
|
||||
|
||||
void CONTROL_GetMouseDelta(void)
|
||||
{
|
||||
|
@ -732,13 +733,25 @@ void CONTROL_ButtonFunctionState(int32 *p1)
|
|||
|
||||
for (i=0; i<CONTROL_NumMouseButtons; i++)
|
||||
{
|
||||
j = CONTROL_MouseButtonMapping[i].doubleclicked;
|
||||
if (j != KEYUNDEFINED)
|
||||
p1[j] |= CONTROL_MouseButtonClickedState[i];
|
||||
if (mousebind[i].name[0] && CONTROL_MouseButtonState[i])
|
||||
{
|
||||
if (mousebind[i].repeat || (mousebind[i].laststate == 0))
|
||||
OSD_Dispatch(mousebind[i].name);
|
||||
// if (!boundkeys[i].repeat)
|
||||
// KB_ClearKeyDown(i);
|
||||
}
|
||||
mousebind[i].laststate = CONTROL_MouseButtonState[i];
|
||||
|
||||
j = CONTROL_MouseButtonMapping[i].singleclicked;
|
||||
if (j != KEYUNDEFINED)
|
||||
p1[j] |= CONTROL_MouseButtonState[i];
|
||||
if (!mousebind[i].name[0])
|
||||
{
|
||||
j = CONTROL_MouseButtonMapping[i].doubleclicked;
|
||||
if (j != KEYUNDEFINED)
|
||||
p1[j] |= CONTROL_MouseButtonClickedState[i];
|
||||
|
||||
j = CONTROL_MouseButtonMapping[i].singleclicked;
|
||||
if (j != KEYUNDEFINED)
|
||||
p1[j] |= CONTROL_MouseButtonState[i];
|
||||
}
|
||||
}
|
||||
|
||||
for (i=0; i<CONTROL_NumJoyButtons; i++)
|
||||
|
|
|
@ -223,6 +223,7 @@ typedef struct binding {
|
|||
} keybind;
|
||||
|
||||
extern keybind boundkeys[MAXBOUNDKEYS];
|
||||
extern keybind mousebind[6]; // FIXME
|
||||
|
||||
void CONTROL_ProcessBinds(void);
|
||||
|
||||
|
|
|
@ -932,21 +932,53 @@ static int osdcmd_bind(const osdfuncparm_t *parm)
|
|||
if (parm->numparms==1&&!Bstrcasecmp(parm->parms[0],"showkeys"))
|
||||
{
|
||||
for (i=0;keynames[i].name;i++)OSD_Printf("%s\n",keynames[i].name);
|
||||
for (i=0;i<MAXMOUSEBUTTONS;i++)OSD_Printf("%s\n",mousenames[i]);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
if (parm->numparms==0)
|
||||
{
|
||||
OSD_Printf("Keybindings:\n");
|
||||
for (i=0;i<MAXBOUNDKEYS;i++)if (*boundkeys[i].name)
|
||||
for (i=0;i<MAXBOUNDKEYS;i++)
|
||||
if (*boundkeys[i].name)
|
||||
OSD_Printf("%-11s = %s\n",boundkeys[i].key,boundkeys[i].name);
|
||||
for (i=0;i<MAXMOUSEBUTTONS;i++)
|
||||
if (*mousebind[i].name)
|
||||
OSD_Printf("%-11s = %s\n",mousebind[i].key,mousebind[i].name);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
for (i=0;keynames[i].name;i++)
|
||||
if (!Bstrcasecmp(parm->parms[0],keynames[i].name))
|
||||
break;
|
||||
if (!keynames[i].name) return OSDCMD_SHOWHELP;
|
||||
|
||||
if (!keynames[i].name)
|
||||
{
|
||||
for (i=0;i<MAXMOUSEBUTTONS;i++)
|
||||
if (!Bstrcasecmp(parm->parms[0],mousenames[i]))
|
||||
break;
|
||||
if (i >= MAXMOUSEBUTTONS)
|
||||
return OSDCMD_SHOWHELP;
|
||||
|
||||
if (parm->numparms < 2)
|
||||
{
|
||||
OSD_Printf("%-11s = %s\n",mousenames[i], mousebind[i].name);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
j = 1;
|
||||
if (parm->numparms >= 2 && !Bstrcasecmp(parm->parms[j],"norepeat"))
|
||||
{
|
||||
mousebind[i].repeat = 0;
|
||||
j++;
|
||||
}
|
||||
else mousebind[i].repeat = 1;
|
||||
Bstrncpy(mousebind[i].name,parm->parms[j], MAXBINDSTRINGLENGTH-1);
|
||||
mousebind[i].key=mousenames[i];
|
||||
if (!osdexecscript)
|
||||
OSD_Printf("%s\n",parm->raw);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
if (parm->numparms < 2)
|
||||
{
|
||||
|
@ -974,8 +1006,12 @@ static int osdcmd_unbindall(const osdfuncparm_t *parm)
|
|||
|
||||
UNREFERENCED_PARAMETER(parm);
|
||||
|
||||
for (i=0;i<MAXBOUNDKEYS;i++)if (*boundkeys[i].name)
|
||||
boundkeys[i].name[0] = 0;
|
||||
for (i=0;i<MAXBOUNDKEYS;i++)
|
||||
if (*boundkeys[i].name)
|
||||
boundkeys[i].name[0] = 0;
|
||||
for (i=0;i<MAXMOUSEBUTTONS;i++)
|
||||
if (*mousebind[i].name)
|
||||
mousebind[i].name[0] = 0;
|
||||
OSD_Printf("unbound all keys\n");
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
@ -988,8 +1024,18 @@ static int osdcmd_unbind(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;
|
||||
|
||||
if (!keynames[i].name)
|
||||
{
|
||||
for (i=0;i<MAXMOUSEBUTTONS;i++)
|
||||
if (!Bstrcasecmp(parm->parms[0],mousenames[i]))
|
||||
break;
|
||||
if (i >= MAXMOUSEBUTTONS)
|
||||
return OSDCMD_SHOWHELP;
|
||||
mousebind[i].repeat = 0;
|
||||
mousebind[i].name[0] = 0;
|
||||
OSD_Printf("unbound %s\n",mousebind[i].name);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
boundkeys[keynames[i].id].repeat = 0;
|
||||
boundkeys[keynames[i].id].name[0] = 0;
|
||||
OSD_Printf("unbound key %s\n",keynames[i].name);
|
||||
|
|
Loading…
Reference in a new issue