From 5ce9e2b208d2d4a3e7706a12de230dd6862a3487 Mon Sep 17 00:00:00 2001 From: terminx Date: Wed, 5 Jul 2017 05:42:54 +0000 Subject: [PATCH] Combine CONTROL_KeyBinds and CONTROL_MouseBinds git-svn-id: https://svn.eduke32.com/eduke32@6328 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/build/src/config.cpp | 2 -- source/duke3d/src/config.cpp | 12 ++---------- source/duke3d/src/osdcmds.cpp | 17 +++++------------ source/mact/include/control.h | 8 +------- source/mact/src/control.cpp | 17 ++++++++--------- 5 files changed, 16 insertions(+), 40 deletions(-) diff --git a/source/build/src/config.cpp b/source/build/src/config.cpp index 951d05efc..ddf8204ba 100644 --- a/source/build/src/config.cpp +++ b/source/build/src/config.cpp @@ -322,8 +322,6 @@ void writesettings(void) // save binds and aliases to _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); diff --git a/source/duke3d/src/config.cpp b/source/duke3d/src/config.cpp index c2cc8a527..45a6e3aea 100644 --- a/source/duke3d/src/config.cpp +++ b/source/duke3d/src/config.cpp @@ -653,22 +653,14 @@ void CONFIG_WriteSettings(void) // save binds and aliases to _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; inumparms < 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; } diff --git a/source/mact/include/control.h b/source/mact/include/control.h index 283af14ac..8f140eb3e 100644 --- a/source/mact/include/control.h +++ b/source/mact/include/control.h @@ -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); //////////////////// diff --git a/source/mact/src/control.cpp b/source/mact/src/control.cpp index fed6bf362..021dadba9 100644 --- a/source/mact/src/control.cpp +++ b/source/mact/src/control.cpp @@ -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--); }