Combine CONTROL_KeyBinds and CONTROL_MouseBinds

git-svn-id: https://svn.eduke32.com/eduke32@6328 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2017-07-05 05:42:54 +00:00
parent bea9a73047
commit 5ce9e2b208
5 changed files with 16 additions and 40 deletions

View file

@ -322,8 +322,6 @@ void writesettings(void) // save binds and aliases to <cfgname>_m32_settings.cfg
if (fp)
{
Bfprintf(fp,"// this file is automatically generated by %s\n", AppProperName);
Bfprintf(fp,"// these settings take precedence over your main cfg file\n");
Bfprintf(fp,"// do not modify if you lack common sense\n");
OSD_WriteAliases(fp);
OSD_WriteCvars(fp);

View file

@ -653,22 +653,14 @@ void CONFIG_WriteSettings(void) // save binds and aliases to <cfgname>_settings.
if (fp)
{
Bfprintf(fp,"// this file is automatically generated by EDuke32\n");
Bfprintf(fp,"// these settings take precedence over your main cfg file\n");
Bfprintf(fp,"// do not modify if you lack common sense\n");
Bfprintf(fp,"// this file is automatically generated by %s\n", AppProperName);
Bfprintf(fp,"unbindall\n");
for (i=0; i<MAXBOUNDKEYS; i++)
for (i=0; i<MAXBOUNDKEYS+MAXMOUSEBUTTONS; i++)
if (CONTROL_KeyIsBound(i))
Bfprintf(fp,"bind \"%s\"%s \"%s\"\n",CONTROL_KeyBinds[i].key,
CONTROL_KeyBinds[i].repeat?"":" norepeat",CONTROL_KeyBinds[i].cmdstr);
for (i=0; i<MAXMOUSEBUTTONS; i++)
if (CONTROL_MouseIsBound(i))
Bfprintf(fp,"bind \"%s\"%s \"%s\"\n",CONTROL_MouseBinds[i].key,
CONTROL_MouseBinds[i].repeat?"":" norepeat",CONTROL_MouseBinds[i].cmdstr);
OSD_WriteAliases(fp);
if (g_crosshairSum != -1 && g_crosshairSum != DefaultCrosshairColors.r+(DefaultCrosshairColors.g<<8)+(DefaultCrosshairColors.b<<16))

View file

@ -1015,7 +1015,7 @@ static int32_t osdcmd_bind(osdfuncparm_t const * const parm)
OSD_Printf("Current key bindings:\n");
for (i=0; i<MAXBOUNDKEYS; i++)
for (i=0; i<MAXBOUNDKEYS+MAXMOUSEBUTTONS; i++)
if (CONTROL_KeyIsBound(i))
{
j++;
@ -1023,14 +1023,6 @@ static int32_t osdcmd_bind(osdfuncparm_t const * const parm)
CONTROL_KeyBinds[i].cmdstr);
}
for (i=0; i<MAXMOUSEBUTTONS; i++)
if (CONTROL_MouseIsBound(i))
{
j++;
OSD_Printf("%-9s %s\"%s\"\n", CONTROL_MouseBinds[i].key, CONTROL_MouseBinds[i].repeat?"":"norepeat ",
CONTROL_MouseBinds[i].cmdstr);
}
if (j == 0)
OSD_Printf("No binds found.\n");
@ -1051,9 +1043,10 @@ static int32_t osdcmd_bind(osdfuncparm_t const * const parm)
if (parm->numparms < 2)
{
if (CONTROL_MouseBinds[i].cmdstr && CONTROL_MouseBinds[i].key)
OSD_Printf("%-9s %s\"%s\"\n", ConsoleButtons[i], CONTROL_MouseBinds[i].repeat?"":"norepeat ",
CONTROL_MouseBinds[i].cmdstr);
if (CONTROL_KeyBinds[MAXBOUNDKEYS + i].cmdstr && CONTROL_KeyBinds[MAXBOUNDKEYS + i ].key)
OSD_Printf("%-9s %s\"%s\"\n", ConsoleButtons[i], CONTROL_KeyBinds[MAXBOUNDKEYS + i].repeat?"":"norepeat ",
CONTROL_KeyBinds[MAXBOUNDKEYS + i].cmdstr);
else OSD_Printf("%s is unbound\n", ConsoleButtons[i]);
return OSDCMD_OK;
}

View file

@ -186,8 +186,7 @@ typedef struct binding {
} keybind;
// Direct use DEPRECATED:
extern keybind CONTROL_KeyBinds[MAXBOUNDKEYS], CONTROL_MouseBinds[MAXMOUSEBUTTONS];
extern keybind CONTROL_KeyBinds[MAXBOUNDKEYS+MAXMOUSEBUTTONS];
extern int32_t CONTROL_BindsEnabled;
void CONTROL_ClearAllBinds(void);
@ -201,11 +200,6 @@ static inline int32_t CONTROL_KeyIsBound(int32_t i)
return (CONTROL_KeyBinds[i].cmdstr && CONTROL_KeyBinds[i].key);
}
static inline int32_t CONTROL_MouseIsBound(int32_t i)
{
return (CONTROL_MouseBinds[i].cmdstr && CONTROL_MouseBinds[i].key);
}
void CONTROL_ProcessBinds(void);
////////////////////

View file

@ -59,8 +59,7 @@ int32_t CONTROL_Started = FALSE;
static int32_t CONTROL_DoubleClickSpeed;
int32_t CONTROL_OSDInput[CONTROL_NUM_FLAGS];
keybind CONTROL_KeyBinds[MAXBOUNDKEYS];
keybind CONTROL_MouseBinds[MAXMOUSEBUTTONS];
keybind CONTROL_KeyBinds[MAXBOUNDKEYS+MAXMOUSEBUTTONS];
int32_t CONTROL_BindsEnabled = 0;
int32_t CONTROL_SmoothMouse = 0;
@ -83,7 +82,7 @@ void CONTROL_BindKey(int32_t i, const char *cmd, int32_t repeat, const char *key
void CONTROL_BindMouse(int32_t i, const char *cmd, int32_t repeat, const char *keyname)
{
BIND(CONTROL_MouseBinds[i], Bstrdup(cmd), repeat, keyname);
BIND(CONTROL_KeyBinds[MAXBOUNDKEYS + i], Bstrdup(cmd), repeat, keyname);
}
void CONTROL_FreeKeyBind(int32_t i)
@ -93,7 +92,7 @@ void CONTROL_FreeKeyBind(int32_t i)
void CONTROL_FreeMouseBind(int32_t i)
{
BIND(CONTROL_MouseBinds[i], NULL, 0, NULL);
BIND(CONTROL_KeyBinds[MAXBOUNDKEYS + i], NULL, 0, NULL);
}
#ifndef __ANDROID__
@ -708,7 +707,7 @@ static void CONTROL_ButtonFunctionState(int32_t *p1)
do
{
if (!CONTROL_MouseBinds[i].cmdstr)
if (!CONTROL_KeyBinds[MAXBOUNDKEYS + i].cmdstr)
{
j = CONTROL_MouseButtonMapping[i].doubleclicked;
if (j != KEYUNDEFINED)
@ -722,12 +721,12 @@ static void CONTROL_ButtonFunctionState(int32_t *p1)
if (!CONTROL_BindsEnabled)
continue;
if (CONTROL_MouseBinds[i].cmdstr && CONTROL_MouseButtonState[i])
if (CONTROL_KeyBinds[MAXBOUNDKEYS + i].cmdstr && CONTROL_MouseButtonState[i])
{
if (CONTROL_MouseBinds[i].repeat || (CONTROL_MouseBinds[i].laststate == 0))
OSD_Dispatch(CONTROL_MouseBinds[i].cmdstr);
if (CONTROL_KeyBinds[MAXBOUNDKEYS + i].repeat || (CONTROL_KeyBinds[MAXBOUNDKEYS + i].laststate == 0))
OSD_Dispatch(CONTROL_KeyBinds[MAXBOUNDKEYS + i].cmdstr);
}
CONTROL_MouseBinds[i].laststate = CONTROL_MouseButtonState[i];
CONTROL_KeyBinds[MAXBOUNDKEYS + i].laststate = CONTROL_MouseButtonState[i];
}
while (i--);
}