diff --git a/source/blood/src/_functio.h b/source/blood/src/_functio.h index cbbd9f2e8..de5b5b2a1 100644 --- a/source/blood/src/_functio.h +++ b/source/blood/src/_functio.h @@ -38,102 +38,6 @@ BEGIN_BLD_NS #ifdef __SETUP__ -static const char * mousedefaults[MAXMOUSEBUTTONS] = - { - "Weapon_Fire", - "Weapon_Special_Fire", - "", - "", - "Previous_Weapon", - "Next_Weapon", - }; - - -static const char * mouseclickeddefaults[MAXMOUSEBUTTONS] = - { - }; - - -static const char * mouseanalogdefaults[MAXMOUSEAXES] = - { - "analog_turning", - "analog_moving", - }; - - -static const char * mousedigitaldefaults[MAXMOUSEDIGITAL] = - { - }; - -static const char * joystickdefaults[MAXJOYBUTTONSANDHATS] = - { - "Fire", - "Strafe", - "Run", - "Open", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "Aim_Down", - "Look_Right", - "Aim_Up", - "Look_Left", - }; - - -static const char * joystickclickeddefaults[MAXJOYBUTTONSANDHATS] = - { - "", - "Inventory", - "Jump", - "Crouch", - }; - - -static const char * joystickanalogdefaults[MAXJOYAXES] = - { - "analog_turning", - "analog_moving", - "analog_strafing", - }; - - -static const char * joystickdigitaldefaults[MAXJOYDIGITAL] = - { - "", - "", - "", - "", - "", - "", - "Run", - }; - #endif #endif diff --git a/source/blood/src/config.cpp b/source/blood/src/config.cpp index 34970fe0a..ec2e348ee 100644 --- a/source/blood/src/config.cpp +++ b/source/blood/src/config.cpp @@ -201,195 +201,11 @@ void CONFIG_SetDefaults(void) Bstrcpy(CommbatMacro[8], "Amateurs!"); Bstrcpy(CommbatMacro[9], "Fool! You are already dead."); - memset(MouseFunctions, -1, sizeof(MouseFunctions)); - memset(MouseDigitalFunctions, -1, sizeof(MouseDigitalFunctions)); - memset(JoystickFunctions, -1, sizeof(JoystickFunctions)); - memset(JoystickDigitalFunctions, -1, sizeof(JoystickDigitalFunctions)); - for (int i=0; i=4) continue; - MouseFunctions[i][1] = CONFIG_FunctionNameToNum(mouseclickeddefaults[i]); - CONTROL_MapButton(MouseFunctions[i][1], i, 1, controldevice_mouse); - } - - for (int i=0; i_settings. { } -void CONFIG_WriteSetup(uint32_t flags) -{ -#if 0 - char buf[128]; - if (!setupread) return; - - if (scripthandle < 0) - scripthandle = SCRIPT_Init(SetupFilename); - - //SCRIPT_PutNumber(scripthandle, "Misc", "Executions", ud.executions, FALSE, FALSE); - - SCRIPT_PutNumber(scripthandle, "Setup", "ConfigVersion", BYTEVERSION, FALSE, FALSE); - SCRIPT_PutNumber(scripthandle, "Setup", "ForceSetup", gSetup.forcesetup, FALSE, FALSE); - SCRIPT_PutNumber(scripthandle, "Setup", "NoAutoLoad", gSetup.noautoload, FALSE, FALSE); - -#ifdef POLYMER - SCRIPT_PutNumber(scripthandle, "Screen Setup", "Polymer", glrendmode == REND_POLYMER, FALSE, FALSE); -#endif - - SCRIPT_PutNumber(scripthandle, "Screen Setup", "ScreenBPP", gSetup.bpp, FALSE, FALSE); - SCRIPT_PutNumber(scripthandle, "Screen Setup", "ScreenHeight", gSetup.ydim, FALSE, FALSE); - SCRIPT_PutNumber(scripthandle, "Screen Setup", "ScreenMode", gSetup.fullscreen, FALSE, FALSE); - SCRIPT_PutNumber(scripthandle, "Screen Setup", "ScreenWidth", gSetup.xdim, FALSE, FALSE); - - //if (g_grpNamePtr && !g_addonNum) - // SCRIPT_PutString(scripthandle, "Setup", "SelectedGRP", g_grpNamePtr); - -#ifdef STARTUP_SETUP_WINDOW - if (gNoSetup == 0) - SCRIPT_PutString(scripthandle, "Setup", "ModDir", &g_modDir[0]); -#endif - // exit early after only updating the values that can be changed from the startup window - if (flags & 1) - { - SCRIPT_Save(scripthandle, SetupFilename); - SCRIPT_Free(scripthandle); - return; - } - - SCRIPT_PutNumber(scripthandle, "Screen Setup", "MaxRefreshFreq", maxrefreshfreq, FALSE, FALSE); - SCRIPT_PutNumber(scripthandle, "Screen Setup", "WindowPosX", windowx, FALSE, FALSE); - SCRIPT_PutNumber(scripthandle, "Screen Setup", "WindowPosY", windowy, FALSE, FALSE); - SCRIPT_PutNumber(scripthandle, "Screen Setup", "WindowPositioning", windowpos, FALSE, FALSE); - - //if (!NAM_WW2GI) - //{ - // SCRIPT_PutNumber(scripthandle, "Screen Setup", "Out",ud.lockout,FALSE,FALSE); - // SCRIPT_PutString(scripthandle, "Screen Setup", "Password",ud.pwlockout); - //} - -#ifdef _WIN32 - SCRIPT_PutNumber(scripthandle, "Updates", "CheckForUpdates", CheckForUpdates, FALSE, FALSE); - SCRIPT_PutNumber(scripthandle, "Updates", "LastUpdateCheck", LastUpdateCheck, FALSE, FALSE); -#endif - - if (in_mouse) - { - for (int i=0; i= (MAXMOUSEBUTTONS-2)) continue; - - if (CONFIG_FunctionNumToName(MouseFunctions[i][1])) - { - Bsprintf(buf, "MouseButtonClicked%d", i); - SCRIPT_PutString(scripthandle, "Controls", buf, CONFIG_FunctionNumToName(MouseFunctions[i][1])); - } - } - - for (int i=0; iArchiveGlobalData(); GameConfig->ArchiveGameData(GameName); + CONFIG_WriteControllerSettings(); GameConfig->WriteConfigFile(); delete GameConfig; GameConfig = nullptr; diff --git a/source/common/gamecontrol.cpp b/source/common/gamecontrol.cpp index 4210a1926..af84d97dd 100644 --- a/source/common/gamecontrol.cpp +++ b/source/common/gamecontrol.cpp @@ -7,6 +7,7 @@ #include "sc_man.h" #include "c_cvars.h" #include "gameconfigfile.h" +#include "gamecvars.h" #include "build.h" struct GameFuncNameDesc @@ -172,6 +173,8 @@ void CONFIG_Init() SetupButtonFunctions(); CONTROL_ClearAssignments(); CONFIG_SetDefaultKeys(cl_defaultconfiguration == 1 ? "demolition/origbinds.txt" : cl_defaultconfiguration == 2 ? "demolition/leftbinds.txt" : "demolition/defbinds.txt"); + CONFIG_InitMouseAndController(); + CONFIG_SetGameControllerDefaultsStandard(); } //========================================================================== @@ -355,6 +358,103 @@ int32_t JoystickAnalogueDead[MAXJOYAXES]; int32_t JoystickAnalogueSaturate[MAXJOYAXES]; int32_t JoystickAnalogueInvert[MAXJOYAXES]; +static const char* mousedefaults[MAXMOUSEBUTTONS] = +{ +"Weapon_Fire", +"Weapon_Special_Fire", +"", +"", +"Previous_Weapon", +"Next_Weapon", +}; + + +static const char* mouseclickeddefaults[MAXMOUSEBUTTONS] = +{ +}; + + +static const char* mouseanalogdefaults[MAXMOUSEAXES] = +{ +"analog_turning", +"analog_moving", +}; + + +static const char* mousedigitaldefaults[MAXMOUSEDIGITAL] = +{ +}; + +static const char* joystickdefaults[MAXJOYBUTTONSANDHATS] = +{ +"Fire", +"Strafe", +"Run", +"Open", +"", +"", +"", +"", +"", +"", +"", +"", +"", +"", +"", +"", +"", +"", +"", +"", +"", +"", +"", +"", +"", +"", +"", +"", +"", +"", +"", +"", +"Aim_Down", +"Look_Right", +"Aim_Up", +"Look_Left", +}; + + +static const char* joystickclickeddefaults[MAXJOYBUTTONSANDHATS] = +{ +"", +"Inventory", +"Jump", +"Crouch", +}; + + +static const char* joystickanalogdefaults[MAXJOYAXES] = +{ +"analog_turning", +"analog_moving", +"analog_strafing", +}; + + +static const char* joystickdigitaldefaults[MAXJOYDIGITAL] = +{ +"", +"", +"", +"", +"", +"", +"Run", +}; + + //========================================================================== // // @@ -410,3 +510,604 @@ const char* CONFIG_AnalogNumToName(int32_t func) return NULL; } +void CONFIG_SetupMouse(void) +{ + const char* val; + FString section = currentGame + ".MouseSettings"; + if (!GameConfig->SetSection(section)) return; + + for (int i = 0; i < MAXMOUSEBUTTONS; i++) + { + section.Format("MouseButton%d", i); + val = GameConfig->GetValueForKey(section); + if (val) + MouseFunctions[i][0] = CONFIG_FunctionNameToNum(val); + + section.Format("MouseButtonClicked%d", i); + val = GameConfig->GetValueForKey(section); + if (val) + MouseFunctions[i][1] = CONFIG_FunctionNameToNum(val); + } + + // map over the axes + for (int i = 0; i < MAXMOUSEAXES; i++) + { + section.Format("MouseAnalogAxes%d", i); + val = GameConfig->GetValueForKey(section); + if (val) + MouseAnalogueAxes[i] = CONFIG_AnalogNameToNum(val); + + section.Format("MouseDigitalAxes%d_0", i); + val = GameConfig->GetValueForKey(section); + if (val) + MouseDigitalFunctions[i][0] = CONFIG_FunctionNameToNum(val); + + section.Format("MouseDigitalAxes%d_1", i); + val = GameConfig->GetValueForKey(section); + if (val) + MouseDigitalFunctions[i][1] = CONFIG_FunctionNameToNum(val); + + section.Format("MouseAnalogScale%d", i); + val = GameConfig->GetValueForKey(section); + if (val) + MouseAnalogueScale[i] = (int32_t)strtoull(val, nullptr, 0); + } + + for (int i = 0; i < MAXMOUSEBUTTONS; i++) + { + CONTROL_MapButton(MouseFunctions[i][0], i, 0, controldevice_mouse); + CONTROL_MapButton(MouseFunctions[i][1], i, 1, controldevice_mouse); + } + for (int i = 0; i < MAXMOUSEAXES; i++) + { + CONTROL_MapAnalogAxis(i, MouseAnalogueAxes[i], controldevice_mouse); + CONTROL_MapDigitalAxis(i, MouseDigitalFunctions[i][0], 0, controldevice_mouse); + CONTROL_MapDigitalAxis(i, MouseDigitalFunctions[i][1], 1, controldevice_mouse); + CONTROL_SetAnalogAxisScale(i, MouseAnalogueScale[i], controldevice_mouse); + } +} + + +void CONFIG_SetupJoystick(void) +{ + const char* val; + FString section = currentGame + ".ControllerSettings"; + if (!GameConfig->SetSection(section)) return; + + for (int i = 0; i < MAXJOYBUTTONSANDHATS; i++) + { + section.Format("ControllerButton%d", i); + val = GameConfig->GetValueForKey(section); + if (val) + JoystickFunctions[i][0] = CONFIG_FunctionNameToNum(val); + + section.Format("ControllerButtonClicked%d", i); + val = GameConfig->GetValueForKey(section); + if (val) + JoystickFunctions[i][1] = CONFIG_FunctionNameToNum(val); + } + + // map over the axes + for (int i = 0; i < MAXJOYAXES; i++) + { + section.Format("ControllerAnalogAxes%d", i); + val = GameConfig->GetValueForKey(section); + if (val) + JoystickAnalogueAxes[i] = CONFIG_AnalogNameToNum(val); + + section.Format("ControllerDigitalAxes%d_0", i); + val = GameConfig->GetValueForKey(section); + if (val) + JoystickDigitalFunctions[i][0] = CONFIG_FunctionNameToNum(val); + + section.Format("ControllerDigitalAxes%d_1", i); + val = GameConfig->GetValueForKey(section); + if (val) + JoystickDigitalFunctions[i][1] = CONFIG_FunctionNameToNum(val); + + section.Format("ControllerAnalogScale%d", i); + val = GameConfig->GetValueForKey(section); + if (val) + JoystickAnalogueScale[i] = (int32_t)strtoull(val, nullptr, 0); + + section.Format("ControllerAnalogInvert%d", i); + val = GameConfig->GetValueForKey(section); + if (val) + JoystickAnalogueInvert[i] = (int32_t)strtoull(val, nullptr, 0); + + section.Format("ControllerAnalogDead%d", i); + val = GameConfig->GetValueForKey(section); + if (val) + JoystickAnalogueDead[i] = (int32_t)strtoull(val, nullptr, 0); + + section.Format("ControllerAnalogSaturate%d", i); + val = GameConfig->GetValueForKey(section); + if (val) + JoystickAnalogueSaturate[i] = (int32_t)strtoull(val, nullptr, 0); + } + + for (int i = 0; i < MAXJOYBUTTONSANDHATS; i++) + { + CONTROL_MapButton(JoystickFunctions[i][0], i, 0, controldevice_joystick); + CONTROL_MapButton(JoystickFunctions[i][1], i, 1, controldevice_joystick); + } + for (int i = 0; i < MAXJOYAXES; i++) + { + CONTROL_MapAnalogAxis(i, JoystickAnalogueAxes[i], controldevice_joystick); + CONTROL_MapDigitalAxis(i, JoystickDigitalFunctions[i][0], 0, controldevice_joystick); + CONTROL_MapDigitalAxis(i, JoystickDigitalFunctions[i][1], 1, controldevice_joystick); + CONTROL_SetAnalogAxisScale(i, JoystickAnalogueScale[i], controldevice_joystick); + CONTROL_SetAnalogAxisInvert(i, JoystickAnalogueInvert[i], controldevice_joystick); + } +} + +static void CONFIG_SetJoystickButtonFunction(int i, int j, int function) +{ + JoystickFunctions[i][j] = function; + CONTROL_MapButton(function, i, j, controldevice_joystick); +} +static void CONFIG_SetJoystickAnalogAxisScale(int i, int scale) +{ + JoystickAnalogueScale[i] = scale; + CONTROL_SetAnalogAxisScale(i, scale, controldevice_joystick); +} +static void CONFIG_SetJoystickAnalogAxisInvert(int i, int invert) +{ + JoystickAnalogueInvert[i] = invert; + CONTROL_SetAnalogAxisInvert(i, invert, controldevice_joystick); +} +static void CONFIG_SetJoystickAnalogAxisDeadSaturate(int i, int dead, int saturate) +{ + JoystickAnalogueDead[i] = dead; + JoystickAnalogueSaturate[i] = saturate; + joySetDeadZone(i, dead, saturate); +} +static void CONFIG_SetJoystickDigitalAxisFunction(int i, int j, int function) +{ + JoystickDigitalFunctions[i][j] = function; + CONTROL_MapDigitalAxis(i, function, j, controldevice_joystick); +} +static void CONFIG_SetJoystickAnalogAxisFunction(int i, int function) +{ + JoystickAnalogueAxes[i] = function; + CONTROL_MapAnalogAxis(i, function, controldevice_joystick); +} + +struct GameControllerButtonSetting +{ + GameControllerButton button; + int function; + + void apply() const + { + CONFIG_SetJoystickButtonFunction(button, 0, function); + } +}; +struct GameControllerAnalogAxisSetting +{ + GameControllerAxis axis; + int function; + + void apply() const + { + CONFIG_SetJoystickAnalogAxisFunction(axis, function); + } +}; +struct GameControllerDigitalAxisSetting +{ + GameControllerAxis axis; + int polarity; + int function; + + void apply() const + { + CONFIG_SetJoystickDigitalAxisFunction(axis, polarity, function); + } +}; + + +void CONFIG_SetGameControllerDefaultsClear() +{ + for (int i = 0; i < MAXJOYBUTTONSANDHATS; i++) + { + CONFIG_SetJoystickButtonFunction(i, 0, -1); + CONFIG_SetJoystickButtonFunction(i, 1, -1); + } + + for (int i = 0; i < MAXJOYAXES; i++) + { + CONFIG_SetJoystickAnalogAxisScale(i, DEFAULTJOYSTICKANALOGUESCALE); + CONFIG_SetJoystickAnalogAxisInvert(i, 0); + CONFIG_SetJoystickAnalogAxisDeadSaturate(i, DEFAULTJOYSTICKANALOGUEDEAD, DEFAULTJOYSTICKANALOGUESATURATE); + + CONFIG_SetJoystickDigitalAxisFunction(i, 0, -1); + CONFIG_SetJoystickDigitalAxisFunction(i, 1, -1); + + CONFIG_SetJoystickAnalogAxisFunction(i, -1); + } +} + +static void CONFIG_SetGameControllerAxesModern() +{ + static GameControllerAnalogAxisSetting const analogAxes[] = + { + { GAMECONTROLLER_AXIS_LEFTX, analog_strafing }, + { GAMECONTROLLER_AXIS_LEFTY, analog_moving }, + { GAMECONTROLLER_AXIS_RIGHTX, analog_turning }, + { GAMECONTROLLER_AXIS_RIGHTY, analog_lookingupanddown }, + }; + + CONFIG_SetJoystickAnalogAxisScale(GAMECONTROLLER_AXIS_RIGHTX, 32768 + 16384); + CONFIG_SetJoystickAnalogAxisScale(GAMECONTROLLER_AXIS_RIGHTY, 32768 + 16384); + + for (auto const& analogAxis : analogAxes) + analogAxis.apply(); +} + +void CONFIG_SetGameControllerDefaultsStandard() +{ + CONFIG_SetGameControllerDefaultsClear(); + CONFIG_SetGameControllerAxesModern(); + + static GameControllerButtonSetting const buttons[] = + { + { GAMECONTROLLER_BUTTON_A, gamefunc_Jump }, + { GAMECONTROLLER_BUTTON_B, gamefunc_Toggle_Crouch }, + { GAMECONTROLLER_BUTTON_BACK, gamefunc_Map }, + { GAMECONTROLLER_BUTTON_LEFTSTICK, gamefunc_Run }, + { GAMECONTROLLER_BUTTON_RIGHTSTICK, gamefunc_Quick_Kick }, + { GAMECONTROLLER_BUTTON_LEFTSHOULDER, gamefunc_Crouch }, + { GAMECONTROLLER_BUTTON_RIGHTSHOULDER, gamefunc_Jump }, + { GAMECONTROLLER_BUTTON_DPAD_UP, gamefunc_Previous_Weapon }, + { GAMECONTROLLER_BUTTON_DPAD_DOWN, gamefunc_Next_Weapon }, + }; + + static GameControllerButtonSetting const buttonsDuke[] = + { + { GAMECONTROLLER_BUTTON_X, gamefunc_Open }, + { GAMECONTROLLER_BUTTON_Y, gamefunc_Inventory }, + { GAMECONTROLLER_BUTTON_DPAD_LEFT, gamefunc_Inventory_Left }, + { GAMECONTROLLER_BUTTON_DPAD_RIGHT, gamefunc_Inventory_Right }, + }; + + static GameControllerButtonSetting const buttonsFury[] = + { + { GAMECONTROLLER_BUTTON_X, gamefunc_Steroids }, // Reload + { GAMECONTROLLER_BUTTON_Y, gamefunc_Open }, + { GAMECONTROLLER_BUTTON_DPAD_LEFT, gamefunc_MedKit }, + { GAMECONTROLLER_BUTTON_DPAD_RIGHT, gamefunc_NightVision }, // Radar + }; + + static GameControllerDigitalAxisSetting const digitalAxes[] = + { + { GAMECONTROLLER_AXIS_TRIGGERLEFT, 1, gamefunc_Alt_Fire }, + { GAMECONTROLLER_AXIS_TRIGGERRIGHT, 1, gamefunc_Fire }, + }; + + for (auto const& button : buttons) + button.apply(); + + /* + if (FURY) + { + for (auto const& button : buttonsFury) + button.apply(); + } + else + */ + { + for (auto const& button : buttonsDuke) + button.apply(); + } + + for (auto const& digitalAxis : digitalAxes) + digitalAxis.apply(); +} + +void CONFIG_SetGameControllerDefaultsPro() +{ + CONFIG_SetGameControllerDefaultsClear(); + CONFIG_SetGameControllerAxesModern(); + + static GameControllerButtonSetting const buttons[] = + { + { GAMECONTROLLER_BUTTON_A, gamefunc_Open }, + { GAMECONTROLLER_BUTTON_B, gamefunc_Third_Person_View }, + { GAMECONTROLLER_BUTTON_Y, gamefunc_Quick_Kick }, + { GAMECONTROLLER_BUTTON_BACK, gamefunc_Map }, + { GAMECONTROLLER_BUTTON_LEFTSTICK, gamefunc_Run }, + { GAMECONTROLLER_BUTTON_RIGHTSTICK, gamefunc_Crouch }, + { GAMECONTROLLER_BUTTON_DPAD_UP, gamefunc_Previous_Weapon }, + { GAMECONTROLLER_BUTTON_DPAD_DOWN, gamefunc_Next_Weapon }, + }; + + static GameControllerButtonSetting const buttonsDuke[] = + { + { GAMECONTROLLER_BUTTON_X, gamefunc_Inventory }, + { GAMECONTROLLER_BUTTON_LEFTSHOULDER, gamefunc_Previous_Weapon }, + { GAMECONTROLLER_BUTTON_RIGHTSHOULDER, gamefunc_Next_Weapon }, + { GAMECONTROLLER_BUTTON_DPAD_LEFT, gamefunc_Inventory_Left }, + { GAMECONTROLLER_BUTTON_DPAD_RIGHT, gamefunc_Inventory_Right }, + }; + + static GameControllerButtonSetting const buttonsFury[] = + { + { GAMECONTROLLER_BUTTON_X, gamefunc_Steroids }, // Reload + { GAMECONTROLLER_BUTTON_LEFTSHOULDER, gamefunc_Crouch }, + { GAMECONTROLLER_BUTTON_RIGHTSHOULDER, gamefunc_Alt_Fire }, + { GAMECONTROLLER_BUTTON_DPAD_LEFT, gamefunc_MedKit }, + { GAMECONTROLLER_BUTTON_DPAD_RIGHT, gamefunc_NightVision }, // Radar + }; + + static GameControllerDigitalAxisSetting const digitalAxes[] = + { + { GAMECONTROLLER_AXIS_TRIGGERLEFT, 1, gamefunc_Jump }, + { GAMECONTROLLER_AXIS_TRIGGERRIGHT, 1, gamefunc_Fire }, + }; + + for (auto const& button : buttons) + button.apply(); + +#if 0 // ouch... + if (FURY) + { + for (auto const& button : buttonsFury) + button.apply(); + } + else +#endif + { + for (auto const& button : buttonsDuke) + button.apply(); + } + + for (auto const& digitalAxis : digitalAxes) + digitalAxis.apply(); +} + +char const* CONFIG_GetGameFuncOnKeyboard(int gameFunc) +{ + const char* string0 = KB_ScanCodeToString(KeyboardKeys[gameFunc][0]); + return string0[0] == '\0' ? KB_ScanCodeToString(KeyboardKeys[gameFunc][1]) : string0; +} + +char const* CONFIG_GetGameFuncOnMouse(int gameFunc) +{ + for (int j = 0; j < 2; ++j) + for (int i = 0; i < joystick.numButtons; ++i) + if (JoystickFunctions[i][j] == gameFunc) + return joyGetName(1, i); + + for (int i = 0; i < joystick.numAxes; ++i) + for (int j = 0; j < 2; ++j) + if (JoystickDigitalFunctions[i][j] == gameFunc) + return joyGetName(0, i); + + return ""; +} + +char const* CONFIG_GetGameFuncOnJoystick(int gameFunc) +{ + for (int j = 0; j < 2; ++j) + for (int i = 0; i < joystick.numButtons; ++i) + if (JoystickFunctions[i][j] == gameFunc) + return joyGetName(1, i); + + for (int i = 0; i < joystick.numAxes; ++i) + for (int j = 0; j < 2; ++j) + if (JoystickDigitalFunctions[i][j] == gameFunc) + return joyGetName(0, i); + + return ""; +} + + +void CONFIG_InitMouseAndController() +{ + memset(MouseFunctions, -1, sizeof(MouseFunctions)); + memset(MouseDigitalFunctions, -1, sizeof(MouseDigitalFunctions)); + memset(JoystickFunctions, -1, sizeof(JoystickFunctions)); + memset(JoystickDigitalFunctions, -1, sizeof(JoystickDigitalFunctions)); + + for (int i = 0; i < MAXMOUSEBUTTONS; i++) + { + MouseFunctions[i][0] = CONFIG_FunctionNameToNum(mousedefaults[i]); + CONTROL_MapButton(MouseFunctions[i][0], i, 0, controldevice_mouse); + if (i >= 4) continue; + MouseFunctions[i][1] = CONFIG_FunctionNameToNum(mouseclickeddefaults[i]); + CONTROL_MapButton(MouseFunctions[i][1], i, 1, controldevice_mouse); + } + + for (int i = 0; i < MAXMOUSEAXES; i++) + { + MouseAnalogueScale[i] = DEFAULTMOUSEANALOGUESCALE; + CONTROL_SetAnalogAxisScale(i, MouseAnalogueScale[i], controldevice_mouse); + + MouseDigitalFunctions[i][0] = CONFIG_FunctionNameToNum(mousedigitaldefaults[i * 2]); + MouseDigitalFunctions[i][1] = CONFIG_FunctionNameToNum(mousedigitaldefaults[i * 2 + 1]); + CONTROL_MapDigitalAxis(i, MouseDigitalFunctions[i][0], 0, controldevice_mouse); + CONTROL_MapDigitalAxis(i, MouseDigitalFunctions[i][1], 1, controldevice_mouse); + + MouseAnalogueAxes[i] = CONFIG_AnalogNameToNum(mouseanalogdefaults[i]); + CONTROL_MapAnalogAxis(i, MouseAnalogueAxes[i], controldevice_mouse); + } + CONFIG_SetupMouse(); + CONFIG_SetupJoystick(); +} + +void CONFIG_PutNumber(const char* key, int number) +{ + FStringf str("%d", number); + GameConfig->SetValueForKey(key, str); +} + +void CONFIG_WriteControllerSettings() +{ + FString buf; + if (in_mouse) + { + FString section = currentGame + ".MouseSettings"; + GameConfig->SetSection(section); + for (int i = 0; i < MAXMOUSEBUTTONS; i++) + { + if (CONFIG_FunctionNumToName(MouseFunctions[i][0])) + { + buf.Format("MouseButton%d", i); + GameConfig->SetValueForKey(buf, CONFIG_FunctionNumToName(MouseFunctions[i][0])); + } + + if (i >= (MAXMOUSEBUTTONS - 2)) continue; + + if (CONFIG_FunctionNumToName(MouseFunctions[i][1])) + { + buf.Format("MouseButtonClicked%d", i); + GameConfig->SetValueForKey(buf, CONFIG_FunctionNumToName(MouseFunctions[i][1])); + } + } + + for (int i = 0; i < MAXMOUSEAXES; i++) + { + if (CONFIG_AnalogNumToName(MouseAnalogueAxes[i])) + { + buf.Format("MouseAnalogAxes%d", i); + GameConfig->SetValueForKey(buf, CONFIG_AnalogNumToName(MouseAnalogueAxes[i])); + } + + if (CONFIG_FunctionNumToName(MouseDigitalFunctions[i][0])) + { + buf.Format("MouseDigitalAxes%d_0", i); + GameConfig->SetValueForKey(buf, CONFIG_FunctionNumToName(MouseDigitalFunctions[i][0])); + } + + if (CONFIG_FunctionNumToName(MouseDigitalFunctions[i][1])) + { + buf.Format("MouseDigitalAxes%d_1", i); + GameConfig->SetValueForKey(buf, CONFIG_FunctionNumToName(MouseDigitalFunctions[i][1])); + } + + buf.Format("MouseAnalogScale%d", i); + CONFIG_PutNumber(buf, MouseAnalogueScale[i]); + } + } + + if (in_joystick) + { + FString section = currentGame + ".ControllerSettings"; + GameConfig->SetSection(section); + for (int dummy = 0; dummy < MAXJOYBUTTONSANDHATS; dummy++) + { + if (CONFIG_FunctionNumToName(JoystickFunctions[dummy][0])) + { + buf.Format("ControllerButton%d", dummy); + GameConfig->SetValueForKey(buf, CONFIG_FunctionNumToName(JoystickFunctions[dummy][0])); + } + + if (CONFIG_FunctionNumToName(JoystickFunctions[dummy][1])) + { + buf.Format("ControllerButtonClicked%d", dummy); + GameConfig->SetValueForKey(buf, CONFIG_FunctionNumToName(JoystickFunctions[dummy][1])); + } + } + for (int dummy = 0; dummy < MAXJOYAXES; dummy++) + { + if (CONFIG_AnalogNumToName(JoystickAnalogueAxes[dummy])) + { + buf.Format("ControllerAnalogAxes%d", dummy); + GameConfig->SetValueForKey(buf, CONFIG_AnalogNumToName(JoystickAnalogueAxes[dummy])); + } + + if (CONFIG_FunctionNumToName(JoystickDigitalFunctions[dummy][0])) + { + buf.Format("ControllerDigitalAxes%d_0", dummy); + GameConfig->SetValueForKey(buf, CONFIG_FunctionNumToName(JoystickDigitalFunctions[dummy][0])); + } + + if (CONFIG_FunctionNumToName(JoystickDigitalFunctions[dummy][1])) + { + buf.Format("ControllerDigitalAxes%d_1", dummy); + GameConfig->SetValueForKey(buf, CONFIG_FunctionNumToName(JoystickDigitalFunctions[dummy][1])); + } + + buf.Format("ControllerAnalogScale%d", dummy); + CONFIG_PutNumber(buf, JoystickAnalogueScale[dummy]); + + buf.Format("ControllerAnalogInvert%d", dummy); + CONFIG_PutNumber(buf, JoystickAnalogueInvert[dummy]); + + buf.Format("ControllerAnalogDead%d", dummy); + CONFIG_PutNumber(buf, JoystickAnalogueDead[dummy]); + + buf.Format("ControllerAnalogSaturate%d", dummy); + CONFIG_PutNumber(buf, JoystickAnalogueSaturate[dummy]); + } + } +} + +#if 0 +// todo + + CONFIG_PutNumber("Misc", "Executions", ud.executions); + + CONFIG_PutNumber("Setup", "ConfigVersion", BYTEVERSION_EDUKE32); + CONFIG_PutNumber("Setup", "ForceSetup", ud.setup.forcesetup); + CONFIG_PutNumber("Setup", "NoAutoLoad", ud.setup.noautoload); + + CONFIG_PutNumber("Screen Setup", "ScreenBPP", ud.setup.bpp); + CONFIG_PutNumber("Screen Setup", "ScreenDisplay", r_displayindex); + CONFIG_PutNumber("Screen Setup", "ScreenHeight", ud.setup.ydim); + CONFIG_PutNumber("Screen Setup", "ScreenMode", ud.setup.fullscreen); + CONFIG_PutNumber("Screen Setup", "ScreenWidth", ud.setup.xdim); + + if (g_grpNamePtr && !g_addonNum) + GameConfig->SetValueForKey("Setup", "SelectedGRP", g_grpNamePtr); + +#ifdef STARTUP_SETUP_WINDOW + if (g_noSetup == 0) + GameConfig->SetValueForKey("Setup", "ModDir", &g_modDir[0]); +#endif + // exit early after only updating the values that can be changed from the startup window + if (flags & 1) + { + SCRIPT_Save(g_setupFileName); + SCRIPT_Free(ud.config.scripthandle); + return; + } + + CONFIG_PutNumber("Screen Setup", "MaxRefreshFreq", maxrefreshfreq); + CONFIG_PutNumber("Screen Setup", "WindowPosX", windowx); + CONFIG_PutNumber("Screen Setup", "WindowPosY", windowy); + CONFIG_PutNumber("Screen Setup", "WindowPositioning", windowpos); + + if (!NAM_WW2GI) + { + CONFIG_PutNumber("Screen Setup", "Out", ud.lockout); + GameConfig->SetValueForKey("Screen Setup", "Password", ud.pwlockout); + } + +#ifdef _WIN32 + CONFIG_PutNumber("Updates", "CheckForUpdates", ud.config.CheckForUpdates); + CONFIG_PutNumber("Updates", "LastUpdateCheck", ud.config.LastUpdateCheck); +#endif + + GameConfig->SetValueForKey("Comm Setup", "PlayerName", &szPlayerName[0]); + + GameConfig->SetValueForKey("Comm Setup", "RTSName", &ud.rtsname[0]); + + char commmacro[] = "CommbatMacro# "; + + for (int dummy = 0; dummy < MAXRIDECULE; dummy++) + { + commmacro[13] = dummy + '0'; + GameConfig->SetValueForKey("Comm Setup", commmacro, &ud.ridecule[dummy][0]); + } + + SCRIPT_Save(g_setupFileName); + + if ((flags & 2) == 0) + SCRIPT_Free(ud.config.scripthandle); + + OSD_Printf("Wrote %s\n", g_setupFileName); + CONFIG_WriteSettings(); + Bfflush(NULL); + +#endif \ No newline at end of file diff --git a/source/common/gamecontrol.h b/source/common/gamecontrol.h index 3c473b500..51f912081 100644 --- a/source/common/gamecontrol.h +++ b/source/common/gamecontrol.h @@ -112,6 +112,15 @@ void CONFIG_MapKey(int which, kb_scancode key1, kb_scancode oldkey1, kb_scancode #define MAXMOUSEAXES 2 #define MAXMOUSEDIGITAL (MAXMOUSEAXES*2) +// default mouse scale +#define DEFAULTMOUSEANALOGUESCALE 65536 + +// default joystick settings + +#define DEFAULTJOYSTICKANALOGUESCALE 65536 +#define DEFAULTJOYSTICKANALOGUEDEAD 1000 +#define DEFAULTJOYSTICKANALOGUESATURATE 9500 + extern int32_t MouseFunctions[MAXMOUSEBUTTONS][2]; extern int32_t MouseDigitalFunctions[MAXMOUSEAXES][2]; @@ -127,3 +136,13 @@ extern int32_t JoystickAnalogueInvert[MAXJOYAXES]; int32_t CONFIG_AnalogNameToNum(const char* func); const char* CONFIG_AnalogNumToName(int32_t func); +void CONFIG_SetupMouse(void); +void CONFIG_SetupJoystick(void); +void CONFIG_WriteControllerSettings(); +void CONFIG_InitMouseAndController(); + +void CONFIG_SetGameControllerDefaultsStandard(); +void CONFIG_SetGameControllerDefaultsPro(); +void CONFIG_SetGameControllerDefaultsClear(); +char const* CONFIG_GetGameFuncOnJoystick(int gameFunc); +char const* CONFIG_GetGameFuncOnKeyboard(int gameFunc); diff --git a/source/duke3d/src/config.cpp b/source/duke3d/src/config.cpp index f9935d514..0e4c9cf96 100644 --- a/source/duke3d/src/config.cpp +++ b/source/duke3d/src/config.cpp @@ -43,56 +43,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_DUKE_NS -static void CONFIG_SetJoystickButtonFunction(int i, int j, int function) -{ - JoystickFunctions[i][j] = function; - CONTROL_MapButton(function, i, j, controldevice_joystick); -} -static void CONFIG_SetJoystickAnalogAxisScale(int i, int scale) -{ - JoystickAnalogueScale[i] = scale; - CONTROL_SetAnalogAxisScale(i, scale, controldevice_joystick); -} -static void CONFIG_SetJoystickAnalogAxisInvert(int i, int invert) -{ - JoystickAnalogueInvert[i] = invert; - CONTROL_SetAnalogAxisInvert(i, invert, controldevice_joystick); -} -static void CONFIG_SetJoystickAnalogAxisDeadSaturate(int i, int dead, int saturate) -{ - JoystickAnalogueDead[i] = dead; - JoystickAnalogueSaturate[i] = saturate; - joySetDeadZone(i, dead, saturate); -} -static void CONFIG_SetJoystickDigitalAxisFunction(int i, int j, int function) -{ - JoystickDigitalFunctions[i][j] = function; - CONTROL_MapDigitalAxis(i, function, j, controldevice_joystick); -} -static void CONFIG_SetJoystickAnalogAxisFunction(int i, int function) -{ - JoystickAnalogueAxes[i] = function; - CONTROL_MapAnalogAxis(i, function, controldevice_joystick); -} - void CONFIG_SetDefaults(void) { ud.config.scripthandle = -1; -#ifdef __ANDROID__ - droidinput.forward_sens = 5.f; - droidinput.gameControlsAlpha = 0.5; - droidinput.hideStick = 0; - droidinput.pitch_sens = 5.f; - droidinput.quickSelectWeapon = 1; - droidinput.strafe_sens = 5.f; - droidinput.toggleCrouch = 1; - droidinput.yaw_sens = 5.f; - - ud.setup.xdim = droidinfo.screen_width; - ud.setup.ydim = droidinfo.screen_height; -#else # if defined RENDERTYPESDL && SDL_MAJOR_VERSION > 1 uint32_t inited = SDL_WasInit(SDL_INIT_VIDEO); if (inited == 0) @@ -112,13 +67,8 @@ void CONFIG_SetDefaults(void) ud.setup.xdim = 1024; ud.setup.ydim = 768; } -#endif -#ifdef USE_OPENGL ud.setup.bpp = 32; -#else - ud.setup.bpp = 8; -#endif ud.camera_time = 0;//4; @@ -181,63 +131,6 @@ void CONFIG_SetDefaults(void) Bstrcpy(ud.ridecule[9], "AARRRGHHHHH!!!"); #endif - memset(MouseFunctions, -1, sizeof(MouseFunctions)); - memset(MouseDigitalFunctions, -1, sizeof(MouseDigitalFunctions)); - memset(JoystickFunctions, -1, sizeof(JoystickFunctions)); - memset(JoystickDigitalFunctions, -1, sizeof(JoystickDigitalFunctions)); - - for (int i=0; i=4) continue; - MouseFunctions[i][1] = CONFIG_FunctionNameToNum(mouseclickeddefaults[i]); - CONTROL_MapButton(MouseFunctions[i][1], i, 1, controldevice_mouse); - } - - for (int i=0; ii, myconnectindex); } @@ -245,329 +138,6 @@ void CONFIG_SetDefaults(void) -void CONFIG_SetupMouse(void) -{ - if (ud.config.scripthandle < 0) - return; - - char str[80]; - char temp[80]; - - for (int i=0; i_settings. { } -void CONFIG_WriteSetup(uint32_t flags) -{ -#if 0 - if (!ud.config.setupread) return; - - if (ud.config.scripthandle < 0) - ud.config.scripthandle = SCRIPT_Init(g_setupFileName); - - SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "Executions", ud.executions, FALSE, FALSE); - - SCRIPT_PutNumber(ud.config.scripthandle, "Setup", "ConfigVersion", BYTEVERSION_EDUKE32, FALSE, FALSE); - SCRIPT_PutNumber(ud.config.scripthandle, "Setup", "ForceSetup", ud.setup.forcesetup, FALSE, FALSE); - SCRIPT_PutNumber(ud.config.scripthandle, "Setup", "NoAutoLoad", ud.setup.noautoload, FALSE, FALSE); - -#ifdef POLYMER - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "Polymer", glrendmode == REND_POLYMER, FALSE, FALSE); -#endif - - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenBPP", ud.setup.bpp, FALSE, FALSE); - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenDisplay", r_displayindex, FALSE, FALSE); - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenHeight", ud.setup.ydim, FALSE, FALSE); - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenMode", ud.setup.fullscreen, FALSE, FALSE); - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenWidth", ud.setup.xdim, FALSE, FALSE); - - if (g_grpNamePtr && !g_addonNum) - SCRIPT_PutString(ud.config.scripthandle, "Setup", "SelectedGRP", g_grpNamePtr); - -#ifdef STARTUP_SETUP_WINDOW - if (g_noSetup == 0) - SCRIPT_PutString(ud.config.scripthandle, "Setup", "ModDir", &g_modDir[0]); -#endif - // exit early after only updating the values that can be changed from the startup window - if (flags & 1) - { - SCRIPT_Save(ud.config.scripthandle, g_setupFileName); - SCRIPT_Free(ud.config.scripthandle); - return; - } - - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "MaxRefreshFreq", maxrefreshfreq, FALSE, FALSE); - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "WindowPosX", windowx, FALSE, FALSE); - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "WindowPosY", windowy, FALSE, FALSE); - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "WindowPositioning", windowpos, FALSE, FALSE); - - if (!NAM_WW2GI) - { - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "Out",ud.lockout,FALSE,FALSE); - SCRIPT_PutString(ud.config.scripthandle, "Screen Setup", "Password",ud.pwlockout); - } - -#ifdef _WIN32 - SCRIPT_PutNumber(ud.config.scripthandle, "Updates", "CheckForUpdates", ud.config.CheckForUpdates, FALSE, FALSE); - SCRIPT_PutNumber(ud.config.scripthandle, "Updates", "LastUpdateCheck", ud.config.LastUpdateCheck, FALSE, FALSE); -#endif - - if (in_mouse) - { - for (int i=0; i= (MAXMOUSEBUTTONS-2)) continue; - - if (CONFIG_FunctionNumToName(MouseFunctions[i][1])) - { - Bsprintf(buf, "MouseButtonClicked%d", i); - SCRIPT_PutString(ud.config.scripthandle, "Controls", buf, CONFIG_FunctionNumToName(MouseFunctions[i][1])); - } - } - - for (int i=0; i 1) { Bstrcpy(apStrings[QUOTE_RESERVED4], "Multiplayer Saving Not Yet Supported"); diff --git a/source/rr/src/config.cpp b/source/rr/src/config.cpp index f4f21e763..7d2707757 100644 --- a/source/rr/src/config.cpp +++ b/source/rr/src/config.cpp @@ -51,19 +51,6 @@ void CONFIG_SetDefaults(void) int32_t i; ud.config.scripthandle = -1; -#ifdef __ANDROID__ - droidinput.forward_sens = 5.f; - droidinput.strafe_sens = 5.f; - droidinput.pitch_sens = 5.f; - droidinput.yaw_sens = 5.f; - droidinput.hideStick = 0; - droidinput.gameControlsAlpha = 0.5; - droidinput.toggleCrouch = 1; - droidinput.quickSelectWeapon = 1; - - ud.setup.xdim = droidinfo.screen_width; - ud.setup.ydim = droidinfo.screen_height; -#else # if defined RENDERTYPESDL && SDL_MAJOR_VERSION > 1 uint32_t inited = SDL_WasInit(SDL_INIT_VIDEO); if (inited == 0) @@ -83,13 +70,8 @@ void CONFIG_SetDefaults(void) ud.setup.xdim = 1024; ud.setup.ydim = 768; } -#endif -#ifdef USE_OPENGL ud.setup.bpp = 32; -#else - ud.setup.bpp = 8; -#endif g_player[0].ps->aim_mode = 1; ud.config.ShowOpponentWeapons = 0; ud.althud = 1; @@ -166,200 +148,6 @@ void CONFIG_SetDefaults(void) Bstrcpy(ud.ridecule[9], "AARRRGHHHHH!!!"); //} - // JBF 20031211 - - memset(MouseFunctions, -1, sizeof(MouseFunctions)); - for (i=0; i=4) continue; - MouseFunctions[i][1] = CONFIG_FunctionNameToNum(mouseclickeddefaults[i]); - CONTROL_MapButton(MouseFunctions[i][1], i, 1, controldevice_mouse); - } - - memset(MouseDigitalFunctions, -1, sizeof(MouseDigitalFunctions)); - for (i=0; i 0) ? REND_POLYMER : REND_POLYMOST; #endif - SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "Executions",&ud.executions); + SCRIPT_GetNumber(ud.config.scripthandle, "Misc", "Executions", &ud.executions); #ifdef _WIN32 SCRIPT_GetNumber(ud.config.scripthandle, "Updates", "CheckForUpdates", &ud.config.CheckForUpdates); @@ -487,185 +267,6 @@ void CONFIG_WriteSettings(void) // save binds and aliases to _settings. { } -void CONFIG_WriteSetup(uint32_t flags) -{ -#if 0 - int32_t dummy; - - if (!ud.config.setupread) return; - - if (ud.config.scripthandle < 0) - ud.config.scripthandle = SCRIPT_Init(g_setupFileName); - - SCRIPT_PutNumber(ud.config.scripthandle, "Misc", "Executions",ud.executions,FALSE,FALSE); - - SCRIPT_PutNumber(ud.config.scripthandle, "Setup","ConfigVersion",BYTEVERSION_EDUKE32,FALSE,FALSE); - SCRIPT_PutNumber(ud.config.scripthandle, "Setup", "ForceSetup", ud.setup.forcesetup, FALSE, FALSE); - SCRIPT_PutNumber(ud.config.scripthandle, "Setup", "NoAutoLoad", ud.setup.noautoload, FALSE, FALSE); - SCRIPT_PutNumber(ud.config.scripthandle, "Setup", "CacheSize", MAXCACHE1DSIZE, FALSE, FALSE); - -#ifdef POLYMER - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "Polymer",glrendmode == REND_POLYMER,FALSE,FALSE); -#endif - - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenBPP", ud.setup.bpp, FALSE, FALSE); - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenHeight", ud.setup.ydim, FALSE, FALSE); - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenMode", ud.setup.fullscreen, FALSE, FALSE); - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "ScreenWidth", ud.setup.xdim, FALSE, FALSE); - - if (g_grpNamePtr && !g_addonNum) - SCRIPT_PutString(ud.config.scripthandle, "Setup","SelectedGRP",g_grpNamePtr); - -#ifdef STARTUP_SETUP_WINDOW - if (g_noSetup == 0) - SCRIPT_PutString(ud.config.scripthandle, "Setup","ModDir",&g_modDir[0]); -#endif - // exit early after only updating the values that can be changed from the startup window - if (flags & 1) - { - SCRIPT_Save(ud.config.scripthandle, g_setupFileName); - SCRIPT_Free(ud.config.scripthandle); - return; - } - - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "WindowPositioning", windowpos, FALSE, FALSE); - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "WindowPosX", windowx, FALSE, FALSE); - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "WindowPosY", windowy, FALSE, FALSE); - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "MaxRefreshFreq", maxrefreshfreq, FALSE, FALSE); - - SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "Out",ud.lockout,FALSE,FALSE); - SCRIPT_PutString(ud.config.scripthandle, "Screen Setup", "Password",ud.pwlockout); - -#ifdef _WIN32 - SCRIPT_PutNumber(ud.config.scripthandle, "Updates", "CheckForUpdates", ud.config.CheckForUpdates, FALSE, FALSE); - SCRIPT_PutNumber(ud.config.scripthandle, "Updates", "LastUpdateCheck", ud.config.LastUpdateCheck, FALSE, FALSE); -#endif - - if (in_mouse) - { - for (dummy=0; dummy= (MAXMOUSEBUTTONS-2)) continue; - - if (CONFIG_FunctionNumToName(MouseFunctions[dummy][1])) - { - Bsprintf(buf, "MouseButtonClicked%d", dummy); - SCRIPT_PutString(ud.config.scripthandle, "Controls", buf, CONFIG_FunctionNumToName(MouseFunctions[dummy][1])); - } - } - - for (dummy=0; dummy 1) { Bstrcpy(apStrings[QUOTE_RESERVED4], "Multiplayer Saving Not Yet Supported"); diff --git a/source/sw/src/config.cpp b/source/sw/src/config.cpp index c416bed2f..2df525f98 100644 --- a/source/sw/src/config.cpp +++ b/source/sw/src/config.cpp @@ -55,7 +55,6 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms BEGIN_SW_NS extern void ReadGameSetup(int32_t scripthandle); -extern void WriteGameSetup(int32_t scripthandle); // // Comm variables @@ -71,18 +70,6 @@ int32_t NumberPlayers,CommPort,PortSpeed,IrqNumber,UartAddress; int32_t UseMouse = 1, UseJoystick = 0; -int32_t MouseButtons[MAXMOUSEBUTTONS]; -int32_t MouseButtonsClicked[MAXMOUSEBUTTONS]; -int32_t MouseDigitalAxes[MAXMOUSEAXES][2]; -int32_t MouseAnalogAxes[MAXMOUSEAXES]; -int32_t MouseAnalogScale[MAXMOUSEAXES]; -int32_t JoystickButtons[MAXJOYBUTTONS]; -int32_t JoystickButtonsClicked[MAXJOYBUTTONS]; -int32_t JoystickDigitalAxes[MAXJOYAXES][2]; -int32_t JoystickAnalogAxes[MAXJOYAXES]; -int32_t JoystickAnalogScale[MAXJOYAXES]; -int32_t JoystickAnalogDead[MAXJOYAXES]; -int32_t JoystickAnalogSaturate[MAXJOYAXES]; // // Screen variables @@ -154,40 +141,8 @@ void CONFIG_SetDefaults(void) Bstrcpy(WangBangMacro[8], MACRO9); Bstrcpy(WangBangMacro[9], MACRO10); - SetMouseDefaults(0); + //SetMouseDefaults(0); - memset(MouseDigitalAxes, -1, sizeof(MouseDigitalAxes)); - for (i=0; i= (MAXMOUSEBUTTONS-2)) continue; // scroll wheel - - Bsprintf(buf,"MouseButtonClicked%d",dummy); - SCRIPT_PutString(scripthandle,"Controls", buf, CONFIG_FunctionNumToName(MouseButtonsClicked[dummy])); - } - - for (dummy=0; dummybits, SK_QUIT_GAME, MultiPlayQuitFlag); +#if 0 // What kind of crap is this...? if (gs.MouseAimingType == 1) // while held { if (BUTTON(gamefunc_Mouse_Aiming)) @@ -5066,6 +5067,7 @@ getinput(SW_PACKET *loc) CONTROL_MapAnalogAxis(1, mouseaxis, controldevice_mouse); MouseYAxisMode = mouseaxis; } +#endif CONTROL_GetInput(&info); diff --git a/source/sw/src/menus.cpp b/source/sw/src/menus.cpp index fcb372e3a..f914a2018 100644 --- a/source/sw/src/menus.cpp +++ b/source/sw/src/menus.cpp @@ -1087,6 +1087,7 @@ static SWBOOL MNU_MouseButtonPostProcess(MenuItem_p item) SWBOOL MNU_MouseButtonSetupCustom(UserCall call, MenuItem_p item) { +#if 0 static int currentfunc = 0; if (call == uc_touchup) @@ -1144,12 +1145,13 @@ SWBOOL MNU_MouseButtonSetupCustom(UserCall call, MenuItem_p item) break; default: break; } - +#endif return TRUE; } static SWBOOL MNU_SetMouseButtonFunctions(MenuItem_p item) { +#if 0 int button, clicked, function; char *p; @@ -1179,6 +1181,7 @@ static SWBOOL MNU_SetMouseButtonFunctions(MenuItem_p item) *p = ' '; } } +#endif return TRUE; } @@ -1193,6 +1196,7 @@ static SWBOOL MNU_MouseDigitalPostProcess(MenuItem_p item) static SWBOOL MNU_MouseDigitalSetupCustom(UserCall call, MenuItem_p item) { +#if 0 static int currentfunc = 0; if (call == uc_touchup) @@ -1235,12 +1239,13 @@ static SWBOOL MNU_MouseDigitalSetupCustom(UserCall call, MenuItem_p item) break; default: break; } - +#endif return TRUE; } static SWBOOL MNU_SetAdvancedMouseFunctions(MenuItem_p item) { +#if 0 int axis; char *p; @@ -1260,6 +1265,7 @@ static SWBOOL MNU_SetAdvancedMouseFunctions(MenuItem_p item) *p = ' '; } } +#endif return TRUE; } @@ -1384,6 +1390,7 @@ static SWBOOL MNU_JoystickButtonPostProcess(MenuItem_p item) static SWBOOL MNU_JoystickButtonSetupCustom(UserCall call, MenuItem *item) { +#if 0 static int currentfunc = 0; if (call == uc_touchup) @@ -1442,7 +1449,7 @@ static SWBOOL MNU_JoystickButtonSetupCustom(UserCall call, MenuItem *item) break; default: break; } - +#endif return TRUE; } @@ -1457,6 +1464,7 @@ static SWBOOL MNU_JoystickButtonNextPage(void) static SWBOOL MNU_SetJoystickButtonFunctions(MenuItem_p item) { +#if 0 int button, clicked, function; char *p; @@ -1485,6 +1493,7 @@ static SWBOOL MNU_SetJoystickButtonFunctions(MenuItem_p item) *p = ' '; } } +#endif return TRUE; } @@ -1493,6 +1502,7 @@ static MenuItem_p joystick_axis_item = NULL; static SWBOOL MNU_JoystickAxesInitialise(MenuItem_p mitem) { +#if 0 if (!CONTROL_JoyPresent) { return TRUE; @@ -1508,7 +1518,7 @@ static SWBOOL MNU_JoystickAxesInitialise(MenuItem_p mitem) slidersettings[sldr_joyaxisscale] = JoystickAnalogScale[JoystickAxisPage] >> 13; slidersettings[sldr_joyaxisdead] = JoystickAnalogDead[JoystickAxisPage] >> 10; slidersettings[sldr_joyaxissatur] = JoystickAnalogSaturate[JoystickAxisPage] >> 10; - +#endif return TRUE; } @@ -1520,6 +1530,7 @@ static SWBOOL MNU_JoystickAxisPostProcess(MenuItem_p item) static SWBOOL MNU_JoystickAxisSetupCustom(UserCall call, MenuItem *item) { +#if 0 static int currentfunc = 0; if (call == uc_touchup) @@ -1563,7 +1574,7 @@ static SWBOOL MNU_JoystickAxisSetupCustom(UserCall call, MenuItem *item) break; default: break; } - +#endif return TRUE; } @@ -1578,6 +1589,7 @@ static SWBOOL MNU_JoystickAxisNextPage(void) static SWBOOL MNU_SetJoystickAxisFunctions(MenuItem_p item) { +#if 0 int function; char *p; @@ -1595,6 +1607,7 @@ static SWBOOL MNU_SetJoystickAxisFunctions(MenuItem_p item) *p = ' '; } } +#endif return TRUE; } @@ -1872,15 +1885,15 @@ MNU_OrderCustom(UserCall call, MenuItem *item) SWBOOL MNU_LoadModernDefaults(void) { - SetDefaultKeyDefinitions(1); - SetMouseDefaults(1); + //SetDefaultKeyDefinitions(1); + //SetMouseDefaults(1); return TRUE; } SWBOOL MNU_LoadClassicDefaults(void) { - SetDefaultKeyDefinitions(0); - SetMouseDefaults(0); + //SetDefaultKeyDefinitions(0); + //SetMouseDefaults(0); return TRUE; } @@ -2253,8 +2266,8 @@ MNU_InitMenus(void) buttonsettings[btn_friendlyfire] = gs.NetHurtTeammate; buttonsettings[btn_parental] = gs.ParentalLock; - slidersettings[sldr_mousescalex] = MouseAnalogScale[0]>>13; - slidersettings[sldr_mousescaley] = MouseAnalogScale[1]>>13; + //slidersettings[sldr_mousescalex] = MouseAnalogScale[0]>>13; + //slidersettings[sldr_mousescaley] = MouseAnalogScale[1]>>13; slidersettings[sldr_joyaxisscale] = 0; slidersettings[sldr_joyaxisanalog] = 0; @@ -3895,7 +3908,7 @@ MNU_DoSlider(short dir, MenuItem_p item, SWBOOL draw) if (slidersettings[item->slider] != offset) { slidersettings[item->slider] = offset; - MouseAnalogScale[item->slider - sldr_mousescalex] = offset<<13; + //MouseAnalogScale[item->slider - sldr_mousescalex] = offset<<13; CONTROL_SetAnalogAxisScale(item->slider - sldr_mousescalex, offset<<13, controldevice_mouse); } @@ -3916,7 +3929,7 @@ MNU_DoSlider(short dir, MenuItem_p item, SWBOOL draw) if (slidersettings[item->slider] != offset) { slidersettings[item->slider] = offset; - JoystickAnalogScale[JoystickAxisPage] = offset<<13; + //JoystickAnalogScale[JoystickAxisPage] = offset<<13; CONTROL_SetAnalogAxisScale(JoystickAxisPage, offset<<13, controldevice_joystick); } @@ -3940,7 +3953,7 @@ MNU_DoSlider(short dir, MenuItem_p item, SWBOOL draw) if (slidersettings[item->slider] != offset) { slidersettings[item->slider] = offset; - JoystickAnalogAxes[JoystickAxisPage] = MNU_ControlAxisNum(offset); + //JoystickAnalogAxes[JoystickAxisPage] = MNU_ControlAxisNum(offset); CONTROL_MapAnalogAxis(JoystickAxisPage, MNU_ControlAxisNum(offset), controldevice_joystick); } @@ -3967,16 +3980,16 @@ MNU_DoSlider(short dir, MenuItem_p item, SWBOOL draw) slidersettings[item->slider] = offset; if (item->slider == sldr_joyaxisdead) { - JoystickAnalogDead[JoystickAxisPage] = min((offset<<10), 32767); + //JoystickAnalogDead[JoystickAxisPage] = min((offset<<10), 32767); //CONTROL_SetJoyAxisDead(JoystickAxisPage, JoystickAnalogDead[JoystickAxisPage]); } else { - JoystickAnalogSaturate[JoystickAxisPage] = min((offset<<10), 32767); + //JoystickAnalogSaturate[JoystickAxisPage] = min((offset<<10), 32767); //CONTROL_SetJoyAxisSaturate(JoystickAxisPage, JoystickAnalogSaturate[JoystickAxisPage]); } - joySetDeadZone(JoystickAxisPage, JoystickAnalogDead[JoystickAxisPage], JoystickAnalogSaturate[JoystickAxisPage]); // [JM] !CHECKME! + //joySetDeadZone(JoystickAxisPage, JoystickAnalogDead[JoystickAxisPage], JoystickAnalogSaturate[JoystickAxisPage]); // [JM] !CHECKME! } sprintf(tmp_text, "%.2f%%", (float)(slidersettings[item->slider]<<10) / 32767.f); diff --git a/source/sw/src/setup.cpp b/source/sw/src/setup.cpp index 972924f22..3ab4c038f 100644 --- a/source/sw/src/setup.cpp +++ b/source/sw/src/setup.cpp @@ -109,7 +109,7 @@ void InitSetup(void) CONTROL_PrintAxes(); }*/ - RTS_Init(RTSName); + //RTS_Init(RTSName); } #if 0 diff --git a/source/sw/src/swconfig.cpp b/source/sw/src/swconfig.cpp index b993a6c3d..56c93ef6a 100644 --- a/source/sw/src/swconfig.cpp +++ b/source/sw/src/swconfig.cpp @@ -356,6 +356,6 @@ void WriteGameSetup(int32_t scripthandle) void TermSetup(void) { extern SWBOOL BotMode; - CONFIG_WriteSetup(); + //CONFIG_WriteSetup(); } END_SW_NS