diff options
author | Sergeanur <s.anureev@yandex.ua> | 2020-12-28 07:36:21 +0100 |
---|---|---|
committer | Sergeanur <s.anureev@yandex.ua> | 2020-12-28 07:36:21 +0100 |
commit | b9747de5d6832542bbdd4b94f4e5e1f0b90b08bb (patch) | |
tree | e0296a9a6018ca0423fc83ec85212cd068a0892a /src/core | |
parent | Ped: WeaponInfo: little fixes and renamings (diff) | |
download | re3-b9747de5d6832542bbdd4b94f4e5e1f0b90b08bb.tar re3-b9747de5d6832542bbdd4b94f4e5e1f0b90b08bb.tar.gz re3-b9747de5d6832542bbdd4b94f4e5e1f0b90b08bb.tar.bz2 re3-b9747de5d6832542bbdd4b94f4e5e1f0b90b08bb.tar.lz re3-b9747de5d6832542bbdd4b94f4e5e1f0b90b08bb.tar.xz re3-b9747de5d6832542bbdd4b94f4e5e1f0b90b08bb.tar.zst re3-b9747de5d6832542bbdd4b94f4e5e1f0b90b08bb.zip |
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/ControllerConfig.cpp | 43 | ||||
-rw-r--r-- | src/core/config.h | 2 |
2 files changed, 43 insertions, 2 deletions
diff --git a/src/core/ControllerConfig.cpp b/src/core/ControllerConfig.cpp index b56a19f0..bf4893ea 100644 --- a/src/core/ControllerConfig.cpp +++ b/src/core/ControllerConfig.cpp @@ -132,6 +132,10 @@ void CControllerConfigManager::LoadSettings(int32 file) { bool bValid = true; +#ifdef BIND_VEHICLE_FIREWEAPON + bool skipVehicleFireWeapon = false; +#endif + if (file) { char buff[29]; @@ -139,18 +143,55 @@ void CControllerConfigManager::LoadSettings(int32 file) if (!strncmp(buff, TopLineEmptyFile, sizeof(TopLineEmptyFile)-1)) bValid = false; - else + else { CFileMgr::Seek(file, 0, 0); + +#ifdef BIND_VEHICLE_FIREWEAPON + // HACK! + // All of this is hacky as fuck. + // We are checking the file size to read the .set file correctly. + // But because .set file is opened in text mode we have to read + // the WHOLE file to get the size we should be working with. + // Joy, ain't it? + char tempBuf[0x1000]; + size_t fileSize = 0, blockSize; + do + { + blockSize = CFileMgr::Read(file, tempBuf, sizeof(tempBuf)); + fileSize += blockSize; + } while (blockSize == sizeof(tempBuf)); + + CFileMgr::Seek(file, 0, 0); + + if (fileSize == 0x671) + skipVehicleFireWeapon = true; +#endif + } } if (bValid) { ControlsManager.MakeControllerActionsBlank(); +#ifdef BIND_VEHICLE_FIREWEAPON + // Set the default settings of VEHICLE_FIREWEAPON + if (skipVehicleFireWeapon) { + SetControllerKeyAssociatedWithAction(VEHICLE_FIREWEAPON, rsPADINS, KEYBOARD); + SetControllerKeyAssociatedWithAction(VEHICLE_FIREWEAPON, rsLCTRL, OPTIONAL_EXTRA); + if (m_bMouseAssociated) + SetMouseButtonAssociatedWithAction(VEHICLE_FIREWEAPON, 1); + } +#endif + for (int32 i = 0; i < MAX_CONTROLLERTYPES; i++) { for (int32 j = 0; j < MAX_CONTROLLERACTIONS; j++) { +#ifdef BIND_VEHICLE_FIREWEAPON + // Skip file read + if (skipVehicleFireWeapon && j == VEHICLE_FIREWEAPON) + continue; +#endif CFileMgr::Read(file, (char *)&ControlsManager.m_aSettings[j][i], sizeof(tControllerConfigBind)); } } diff --git a/src/core/config.h b/src/core/config.h index d3196f9b..a9bb1a17 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -274,7 +274,7 @@ enum Config { #define ALLCARSHELI_CHEAT #define ALT_DODO_CHEAT #define REGISTER_START_BUTTON -//#define BIND_VEHICLE_FIREWEAPON // Adds ability to rebind fire key for 'in vehicle' controls +#define BIND_VEHICLE_FIREWEAPON // Adds ability to rebind fire key for 'in vehicle' controls #define BUTTON_ICONS // use textures to show controller buttons // Hud, frontend and radar |