diff --git a/Common Files/Game.h b/Common Files/Game.h index 1094928..dab741f 100644 --- a/Common Files/Game.h +++ b/Common Files/Game.h @@ -10,19 +10,33 @@ struct EffectTriggers { void(*LeftRight)(double smallstrength, double largestrength, double length); void(*LeftRightDevice2)(double smallstrength, double largestrength, double length); void(*Springi)(double strength); + void(*Inertia)(double strength); + void(*Ramp)(double start, double end, double length); + void(*Damper)(double strength); + void(*SawtoothUp)(double strength, double length); + void(*SawtoothDown)(double strength, double length); + void(*Triangle)(double strength, double length); }; // classes class EffectCollection { public: - int effect_id = 0; - int effect_left_id = 0; - int effect_right_id = 0; - int effect_friction_id = 0; - int effect_leftright_id = 0; - int effect_sine_id = 0; - int effect_spring_id = 0; - int effect_vibration_id = 0; + int effect_id; + int effect_left_id; + int effect_right_id; + int effect_leftramp_id; + int effect_rightramp_id; + int effect_friction_id; + int effect_leftright_id; + int effect_sine_id; + int effect_spring_id; + int effect_vibration_id; + int effect_inertia_id; + int effect_ramp_id; + int effect_damper_id; + int effect_sawtoothup_id; + int effect_sawtoothdown_id; + int effect_triangle_id; }; class EffectConstants { @@ -94,5 +108,5 @@ public: class Game { public: - virtual void FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers); + virtual void FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers *triggers); }; \ No newline at end of file diff --git a/Config/FFBPlugin.ini b/Config/FFBPlugin.ini index b2c966a..5218a56 100644 --- a/Config/FFBPlugin.ini +++ b/Config/FFBPlugin.ini @@ -24,7 +24,7 @@ DeviceGUID= EnableRumble=1 ; Set to 1 to generate log.txt, else 0. Logs will be appended and not cleared. ReverseRumble=0 -Logging=1 +Logging=0 ; When a command is set that contradicts a prior command, clear the prior command. Probably should stay as 1. ResetFeedback=1 ; Length of a feedback command. While a long period works fine (as long as ResetFeedback=1), some games may still require shorter ones. @@ -52,19 +52,19 @@ ForceShowDeviceGUIDMessageBox=0 [Daytona Championship USA] GameId=1 -MinForce=10 -MaxForce=75 +MinForce=0 +MaxForce=90 FeedbackLength=30000 ShowButtonNumbersForSetup=0 ChangeGearsViaPlugin=0 EscapeKeyExitViaPlugin=0 MenuMovementViaPlugin=0 -Gear1=8 -Gear2=10 -Gear3=9 -Gear4=11 -GearUp=4 -GearDown=5 +Gear1=99 +Gear2=99 +Gear3=99 +Gear4=99 +GearUp=99 +GearDown=99 HideCursor=0 ;Gear buttons pre-set for Logitech G25 Shifter @@ -75,13 +75,13 @@ FFBMode=0 [Wacky Races] GameId=2 -MinForce=5 +MinForce=0 MaxForce=75 DefaultCentering=15 [Chase HQ 2] GameId=3 -MinForce=5 +MinForce=0 MaxForce=75 DefaultCentering=15 @@ -130,36 +130,33 @@ DefaultCentering=15 [InitialD4] GameId=16 -FeedbackLength=500 +FeedbackLength=600 FFBMode=0 [InitialD4Japan] GameId=24 -FeedbackLength=500 +FeedbackLength=600 FFBMode=0 [InitialD5] GameId=23 -FeedbackLength=500 +FeedbackLength=600 FFBMode=0 [InitialD6] GameId=8 -DefaultCentering=30 -FeedbackLength=500 -SineDivision=150 +FeedbackLength=600 +FFBMode=0 [InitialD7] GameId=17 -DefaultCentering=30 -FeedbackLength=500 -SineDivision=150 +FeedbackLength=600 +FFBMode=0 [InitialD8] GameId=18 -DefaultCentering=30 -FeedbackLength=500 -SineDivision=150 +FeedbackLength=600 +FFBMode=0 [Ford Racing] GameId=7 @@ -212,18 +209,41 @@ MaxForce=100 FeedbackLength=500 DefaultCentering=-1 FFBMode=0 +ShowButtonNumbersForSetup=0 +ChangeGearsViaPlugin=0 +Gear1=99 +Gear2=99 +Gear3=99 +Gear4=99 +Gear5=99 +Gear6=99 [Outrun 2 Special Tours Deluxe Real] GameId=35 MinForce=0 MaxForce=100 FeedbackLength=500 +SpringStrength=50 +ShowButtonNumbersForSetup=0 +ChangeGearsViaPlugin=0 +Gear1=99 +Gear2=99 +Gear3=99 +Gear4=99 +Gear5=99 +Gear6=99 [WMMT5] GameId=9 +MinForce=0 +MaxForce=35 DefaultCentering=0 FeedbackLength=80 Logging=0 +AlternativeMinForceLeft=0 +AlternativeMaxForceLeft=-35 +AlternativeMinForceRight=0 +AlternativeMaxForceRight=35 [Mame 0199 32bit] GameId=4 @@ -268,12 +288,21 @@ FFBMode=0 [Road Fighters 3D] GameId=29 +MinForce=0 +MaxForce=70 +AlternativeMinForceLeft=0 +AlternativeMaxForceLeft=-70 +AlternativeMinForceRight=0 +AlternativeMaxForceRight=70 FeedbackLength=500 +Only2D=0 +HackToSkipMenuError=0 +HackToCloseLibmovieErrorAuto=0 FFBMode=0 InputDeviceWheelEnable=0 -InputDeviceWheelSteeringAxis=0 -InputDeviceWheelAcclAxis=1 -InputDeviceWheelBrakeAxis=2 +InputDeviceWheelSteeringAxis=99 +InputDeviceWheelAcclAxis=99 +InputDeviceWheelBrakeAxis=99 InputDeviceWheelReverseAxis=0 InputDeviceCombinedPedals=0 SteeringDeadzone=2 @@ -285,31 +314,31 @@ DpadUp= DpadDown= DpadLeft= DpadRight= -ExitButton=2 -TestButton=7 -ServiceButton=6 -CreditButton=0 -ViewButton=3 -ThreeDimensionalButton=1 -leverUp=4 -leverDown=5 -leverLeft=8 -leverRight=9 +ExitButton=99 +TestButton=99 +ServiceButton=99 +CreditButton=99 +ViewButton=99 +ThreeDimensionalButton=99 +leverUp=99 +leverDown=99 +leverLeft=99 +leverRight=99 Device2GUID= DpadUpDevice2= DpadDownDevice2= DpadLeftDevice2= DpadRightDevice2= -ExitButtonDevice2=2 -TestButtonDevice2=7 -ServiceButtonDevice2=6 -CreditButtonDevice2=0 -ViewButtonDevice2=3 -ThreeDimensionalButtonDevice2=1 -leverUpDevice2=4 -leverDownDevice2=5 -leverLeftDevice2=8 -leverRightDevice2=9 +ExitButtonDevice2=99 +TestButtonDevice2=99 +ServiceButtonDevice2=99 +CreditButtonDevice2=99 +ViewButtonDevice2=99 +ThreeDimensionalButtonDevice2=99 +leverUpDevice2=99 +leverDownDevice2=99 +leverLeftDevice2=99 +leverRightDevice2=99 [Button Rumble 32bit] GameId=28 @@ -320,26 +349,26 @@ RightRumbleMotor=0 RumbleStrength=100 RumbleLength=0 Device2GUID= -Button1Rumble=0 -Button2Rumble=1 -Button3Rumble=2 -Button4Rumble=3 -Button5Rumble=4 -Button6Rumble=5 -Button7Rumble=6 -Button8Rumble=7 -Button9Rumble=8 -Button10Rumble=9 -Button1Device2Rumble=0 -Button2Device2Rumble=1 -Button3Device2Rumble=2 -Button4Device2Rumble=3 -Button5Device2Rumble=4 -Button6Device2Rumble=5 -Button7Device2Rumble=6 -Button8Device2Rumble=7 -Button9Device2Rumble=8 -Button10Device2Rumble=9 +Button1Rumble=99 +Button2Rumble=99 +Button3Rumble=99 +Button4Rumble=99 +Button5Rumble=99 +Button6Rumble=99 +Button7Rumble=99 +Button8Rumble=99 +Button9Rumble=99 +Button10Rumble=99 +Button1Device2Rumble=99 +Button2Device2Rumble=99 +Button3Device2Rumble=99 +Button4Device2Rumble=99 +Button5Device2Rumble=99 +Button6Device2Rumble=99 +Button7Device2Rumble=99 +Button8Device2Rumble=99 +Button9Device2Rumble=99 +Button10Device2Rumble=99 [Button Rumble 64bit] GameId=36 @@ -350,26 +379,26 @@ RightRumbleMotor=0 RumbleStrength=100 RumbleLength=0 Device2GUID= -Button1Rumble=0 -Button2Rumble=1 -Button3Rumble=2 -Button4Rumble=3 -Button5Rumble=4 -Button6Rumble=5 -Button7Rumble=6 -Button8Rumble=7 -Button9Rumble=8 -Button10Rumble=9 -Button1Device2Rumble=0 -Button2Device2Rumble=1 -Button3Device2Rumble=2 -Button4Device2Rumble=3 -Button5Device2Rumble=4 -Button6Device2Rumble=5 -Button7Device2Rumble=6 -Button8Device2Rumble=7 -Button9Device2Rumble=8 -Button10Device2Rumble=9 +Button1Rumble=99 +Button2Rumble=99 +Button3Rumble=99 +Button4Rumble=99 +Button5Rumble=99 +Button6Rumble=99 +Button7Rumble=99 +Button8Rumble=99 +Button9Rumble=99 +Button10Rumble=99 +Button1Device2Rumble=99 +Button2Device2Rumble=99 +Button3Device2Rumble=99 +Button4Device2Rumble=99 +Button5Device2Rumble=99 +Button6Device2Rumble=99 +Button7Device2Rumble=99 +Button8Device2Rumble=99 +Button9Device2Rumble=99 +Button10Device2Rumble=99 [Mario Kart Arcade GP DX v110] GameId=20 diff --git a/Dinput8Wrapper.vcxproj b/Dinput8Wrapper.vcxproj index bab976e..e666d7e 100644 --- a/Dinput8Wrapper.vcxproj +++ b/Dinput8Wrapper.vcxproj @@ -19,7 +19,9 @@ + + @@ -42,7 +44,9 @@ + + diff --git a/Dinput8Wrapper.vcxproj.filters b/Dinput8Wrapper.vcxproj.filters index 2c3129c..fdbc09a 100644 --- a/Dinput8Wrapper.vcxproj.filters +++ b/Dinput8Wrapper.vcxproj.filters @@ -118,6 +118,8 @@ Game Files + + @@ -238,6 +240,12 @@ Common Header Files + + Common Header Files + + + Common Header Files + diff --git a/DllMain.cpp b/DllMain.cpp index 8f963f8..2cf9266 100644 --- a/DllMain.cpp +++ b/DllMain.cpp @@ -18,7 +18,9 @@ #include "Game Files/ChaseHQ2.h" #include "Game Files/Daytona3.h" #include "Game Files/FordRacing.h" +#include "Game Files/FordRacingOther.h" #include "Game Files/FNF.h" +#include "Game Files/GRID.h" #include "Game Files/InitialD4.h" #include "Game Files/InitialD4Japan.h" #include "Game Files/InitialD5.h" @@ -779,10 +781,19 @@ HRESULT WINAPI DirectInputDirectInputCreateEx(HINSTANCE hinst, DWORD dwVersion, // DINPUT8 WRAPPER HRESULT WINAPI DirectInputDirectInput8Create(HINSTANCE hinst, DWORD dwVersion, REFIID riidltf, LPVOID* ppvOut, LPUNKNOWN punkOuter) { - LPVOID val; - HRESULT res = originalDirectInputDirectInput8Create(hinst, dwVersion, riidltf, &val, punkOuter); - *ppvOut = new DirectInputDeviceWrapper(val, (IID_IDirectInput8W == riidltf)); - return res; + /*wchar_t *settingsFilenameA = TEXT(".\\FFBPlugin.ini"); + int configGameIdA = GetPrivateProfileInt(TEXT("Settings"), TEXT("GameId"), 1, settingsFilenameA); + if (configGameIdA == 29) + { + return DIERR_OUTOFMEMORY; + } + else + {*/ + LPVOID val; + HRESULT res = originalDirectInputDirectInput8Create(hinst, dwVersion, riidltf, &val, punkOuter); + *ppvOut = new DirectInputDeviceWrapper(val, (IID_IDirectInput8W == riidltf)); + return res; +// } } HRESULT WINAPI DirectInputDllRegisterServer(void) @@ -848,7 +859,7 @@ wchar_t *deviceGUIDString = new wchar_t[256]; int DeviceGUID = GetPrivateProfileString(TEXT("Settings"), TEXT("DeviceGUID"), NULL, deviceGUIDString, 256, settingsFilename); int configResetFeedback = GetPrivateProfileInt(TEXT("Settings"), TEXT("ResetFeedback"), 1, settingsFilename); int configFeedbackLength = GetPrivateProfileInt(TEXT("Settings"), TEXT("FeedbackLength"), 120, settingsFilename); -int configGameId = GetPrivateProfileInt(TEXT("Settings"), TEXT("GameId"), 1, settingsFilename); +int configGameId = GetPrivateProfileInt(TEXT("Settings"), TEXT("GameId"), 0, settingsFilename); int configDefaultCentering = GetPrivateProfileInt(TEXT("Settings"), TEXT("DefaultCentering"), 0, settingsFilename); int configDefaultFriction = GetPrivateProfileInt(TEXT("Settings"), TEXT("DefaultFriction"), 0, settingsFilename); int BeepWhenHook = GetPrivateProfileInt(TEXT("Settings"), TEXT("BeepWhenHook"), 0, settingsFilename); @@ -857,7 +868,7 @@ int configAlternativeMinForceLeft = GetPrivateProfileInt(TEXT("Settings"), TEXT( int configAlternativeMaxForceLeft = GetPrivateProfileInt(TEXT("Settings"), TEXT("AlternativeMaxForceLeft"), 100, settingsFilename); int configAlternativeMinForceRight = GetPrivateProfileInt(TEXT("Settings"), TEXT("AlternativeMinForceRight"), 0, settingsFilename); int configAlternativeMaxForceRight = GetPrivateProfileInt(TEXT("Settings"), TEXT("AlternativeMaxForceRight"), 100, settingsFilename); -int ForceShowDeviceGUIDMessageBox = GetPrivateProfileInt(TEXT("Settings"), TEXT("ForceShowDeviceGUIDMessageBox"), 100, settingsFilename); +int ForceShowDeviceGUIDMessageBox = GetPrivateProfileInt(TEXT("Settings"), TEXT("ForceShowDeviceGUIDMessageBox"), 0, settingsFilename); char chainedDLL[256]; @@ -867,6 +878,7 @@ const int TEST_GAME_FRICTION = -3; const int TEST_GAME_SPRING = -4; const int TEST_GAME_HEAVY = -5; const int TEST_GAME_LOOSE = -6; +const int TEST_GAME_RUMBLE = -7; const int DAYTONA_3 = 1; const int WACKY_RACES = 2; @@ -903,6 +915,8 @@ const int MAME_020664bit = 33; const int MAME_019964bit = 34; const int OUTRUN_2Real = 35; const int Button_Rumble64bit = 36; +const int GRID_ = 37; +const int FORD_RACING_OTHER = 38; HINSTANCE Get_hInstance() { @@ -914,7 +928,7 @@ HINSTANCE Get_hInstance() void Initialize(int device_index) { hlp.log("in initialize"); - SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER | SDL_INIT_HAPTIC); + SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER | SDL_INIT_HAPTIC | SDL_INIT_TIMER); SDL_JoystickEventState(SDL_ENABLE); SDL_JoystickUpdate; char joystick_guid[256]; @@ -969,7 +983,6 @@ void Initialize(int device_index) SDL_HapticEffect tempEffect; - hlp.log("creating base effects..."); SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect)); @@ -1006,10 +1019,52 @@ void Initialize(int device_index) tempEffect.condition.length = 5000; effects.effect_spring_id = SDL_HapticNewEffect(haptic, &tempEffect); + tempEffect = SDL_HapticEffect(); + tempEffect.type = SDL_HAPTIC_INERTIA; + tempEffect.condition.direction.type = SDL_HAPTIC_CARTESIAN; + tempEffect.condition.delay = 0; + tempEffect.condition.length = 5000; + effects.effect_inertia_id = SDL_HapticNewEffect(haptic, &tempEffect); + + tempEffect = SDL_HapticEffect(); + tempEffect.type = SDL_HAPTIC_DAMPER; + tempEffect.condition.direction.type = SDL_HAPTIC_CARTESIAN; + tempEffect.condition.delay = 0; + tempEffect.condition.length = 5000; + effects.effect_damper_id = SDL_HapticNewEffect(haptic, &tempEffect); + + tempEffect = SDL_HapticEffect(); + tempEffect.type = SDL_HAPTIC_TRIANGLE; + tempEffect.condition.direction.type = SDL_HAPTIC_CARTESIAN; + tempEffect.condition.delay = 0; + tempEffect.condition.length = 5000; + effects.effect_triangle_id = SDL_HapticNewEffect(haptic, &tempEffect); + + tempEffect = SDL_HapticEffect(); + tempEffect.type = SDL_HAPTIC_RAMP; + tempEffect.ramp.direction.type = SDL_HAPTIC_CARTESIAN; + tempEffect.ramp.delay = 0; + tempEffect.ramp.length = 5000; + effects.effect_ramp_id = SDL_HapticNewEffect(haptic, &tempEffect); + + tempEffect = SDL_HapticEffect(); + tempEffect.type = SDL_HAPTIC_SAWTOOTHUP; + tempEffect.condition.direction.type = SDL_HAPTIC_CARTESIAN; + tempEffect.condition.delay = 0; + tempEffect.condition.length = 5000; + effects.effect_sawtoothup_id = SDL_HapticNewEffect(haptic, &tempEffect); + + tempEffect = SDL_HapticEffect(); + tempEffect.type = SDL_HAPTIC_SAWTOOTHDOWN; + tempEffect.condition.direction.type = SDL_HAPTIC_CARTESIAN; + tempEffect.condition.delay = 0; + tempEffect.condition.length = 5000; + effects.effect_sawtoothdown_id = SDL_HapticNewEffect(haptic, &tempEffect); + // TODO: why don't we just define this as hackFix = true in the other file? // Was there a reason to put it here? - extern bool hackFix; - hackFix = true; +// extern bool hackFix; +// hackFix = true; } @@ -1022,23 +1077,21 @@ std::string lastConstantEffectHash = ""; std::string lastFrictionEffectHash = ""; std::string lastSineEffectHash = ""; std::string lastSpringEffectHash = ""; - - void TriggerConstantEffect(int direction, double strength) { if (AlternativeFFB == 1) { - std::chrono::milliseconds now = duration_cast(system_clock::now().time_since_epoch()); + /*std::chrono::milliseconds now = duration_cast(system_clock::now().time_since_epoch()); long long elapsedTime = (std::chrono::duration_cast(now - timeOfLastConstantEffect)).count(); int effectId = direction == effectConst.DIRECTION_FROM_LEFT ? effects.effect_right_id : effects.effect_left_id; std::string effectHash = std::to_string(effectId) + "_" + std::to_string(strength) + "_" + std::to_string(direction); // if the effect is the same as the last effect that was sent AND enough time hasn't elapsed, do nothing - if (effectHash.compare(lastConstantEffectHash) == 0 && elapsedTime < configFeedbackLength) { + if (effectHash.compare(lastConstantEffectHash) == 0 && elapsedTime < configFeedbackLength) { return; // same effect, do nothing. } - // TODO: investigate if we need this + TODO: investigate if we need this if (configResetFeedback || strength <= 0.001) { SDL_HapticStopEffect(haptic, effects.effect_left_id); SDL_HapticStopEffect(haptic, effects.effect_right_id); @@ -1047,10 +1100,8 @@ void TriggerConstantEffect(int direction, double strength) lastConstantEffectHash = effectHash; return; } - } - + }*/ SDL_HapticEffect tempEffect; - SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect)); tempEffect.type = SDL_HAPTIC_CONSTANT; tempEffect.constant.direction.type = SDL_HAPTIC_CARTESIAN; @@ -1065,8 +1116,8 @@ void TriggerConstantEffect(int direction, double strength) SHORT level = (SHORT)(strength * range - minForce); tempEffect.constant.level = level; hlp.log((char *)(std::to_string(level)).c_str()); - SDL_HapticUpdateEffect(haptic, effects.effect_id, &tempEffect); - SDL_HapticRunEffect(haptic, effects.effect_id, 1); + SDL_HapticUpdateEffect(haptic, effects.effect_left_id, &tempEffect); + SDL_HapticRunEffect(haptic, effects.effect_left_id, 1); } else { @@ -1079,15 +1130,15 @@ void TriggerConstantEffect(int direction, double strength) SHORT level = (SHORT)(strength * range + minForce); tempEffect.constant.level = level; hlp.log((char *)(std::to_string(level)).c_str()); - SDL_HapticUpdateEffect(haptic, effects.effect_id, &tempEffect); - SDL_HapticRunEffect(haptic, effects.effect_id, 1); + SDL_HapticUpdateEffect(haptic, effects.effect_right_id, &tempEffect); + SDL_HapticRunEffect(haptic, effects.effect_right_id, 1); } - timeOfLastConstantEffect = now; - lastConstantEffectHash = effectHash; + /*timeOfLastConstantEffect = now; + lastConstantEffectHash = effectHash;*/ } else { - std::chrono::milliseconds now = duration_cast(system_clock::now().time_since_epoch()); + /*std::chrono::milliseconds now = duration_cast(system_clock::now().time_since_epoch()); long long elapsedTime = (std::chrono::duration_cast(now - timeOfLastConstantEffect)).count(); int effectId = direction == effectConst.DIRECTION_FROM_LEFT ? effects.effect_right_id : effects.effect_left_id; std::string effectHash = std::to_string(effectId) + "_" + std::to_string(strength) + "_" + std::to_string(direction); @@ -1106,9 +1157,10 @@ void TriggerConstantEffect(int direction, double strength) lastConstantEffectHash = effectHash; return; } - } + }*/ SDL_HapticEffect tempEffect; + SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect)); tempEffect.type = SDL_HAPTIC_CONSTANT; @@ -1125,8 +1177,8 @@ void TriggerConstantEffect(int direction, double strength) SDL_HapticUpdateEffect(haptic, effects.effect_id, &tempEffect); SDL_HapticRunEffect(haptic, effects.effect_id, 1); - timeOfLastConstantEffect = now; - lastConstantEffectHash = effectHash; + /*timeOfLastConstantEffect = now; + lastConstantEffectHash = effectHash;*/ } } @@ -1157,11 +1209,8 @@ void TriggerFrictionEffectWithDefaultOption(double strength, bool isDefault) { SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect)); tempEffect.type = SDL_HAPTIC_FRICTION; tempEffect.condition.type = SDL_HAPTIC_FRICTION; - tempEffect.condition.direction.type = SDL_HAPTIC_CARTESIAN; tempEffect.condition.delay = 0; tempEffect.condition.length = isDefault ? 0xFFFFFFFF : configFeedbackLength; - tempEffect.condition.direction.dir[0] = 1; // not used - tempEffect.constant.direction.dir[1] = 0; //Y Position tempEffect.condition.left_sat[0] = 0xFFFF; tempEffect.condition.right_sat[0] = 0xFFFF; @@ -1180,6 +1229,142 @@ void TriggerFrictionEffectWithDefaultOption(double strength, bool isDefault) { } } +void TriggerInertiaEffect(double strength) +{ + SDL_HapticEffect tempEffect; + SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect)); + tempEffect.type = SDL_HAPTIC_INERTIA; + tempEffect.condition.type = SDL_HAPTIC_INERTIA; + tempEffect.condition.direction.type = SDL_HAPTIC_CARTESIAN; + tempEffect.condition.delay = 0; + tempEffect.condition.length = configFeedbackLength; + tempEffect.condition.direction.dir[0] = 1; + tempEffect.condition.direction.dir[1] = 1; //Y Position + SHORT minForce = (SHORT)(strength > 0.001 ? (configMinForce / 100.0 * 32767.0) : 0); // strength is a double so we do an epsilon check of 0.001 instead of > 0. + SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0); + SHORT range = maxForce - minForce; + SHORT coeff = (SHORT)(strength * range + minForce); + + tempEffect.condition.left_coeff[0] = (short)(coeff); + tempEffect.condition.right_coeff[0] = (short)(coeff); + tempEffect.condition.left_sat[0] = (short)(coeff) * 10; + tempEffect.condition.right_sat[0] = (short)(coeff) * 10; + tempEffect.condition.center[0] = 0; + + SDL_HapticUpdateEffect(haptic, effects.effect_inertia_id, &tempEffect); + SDL_HapticRunEffect(haptic, effects.effect_inertia_id, 1); +} + +void TriggerTriangleEffect(double strength, double length) +{ + SDL_HapticEffect tempEffect; + SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect)); + tempEffect.type = SDL_HAPTIC_TRIANGLE; + tempEffect.condition.type = SDL_HAPTIC_TRIANGLE; + tempEffect.condition.direction.type = SDL_HAPTIC_CARTESIAN; + tempEffect.periodic.period = 500; + SHORT minForce = (SHORT)(strength > 0.001 ? (configMinForce / 100.0 * 32767.0) : 0); // strength is a double so we do an epsilon check of 0.001 instead of > 0. + SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0); + SHORT range = maxForce - minForce; + SHORT power = (SHORT)(strength * range + minForce); + tempEffect.periodic.magnitude = power; + tempEffect.periodic.length = length; + tempEffect.periodic.attack_length = 1000; + tempEffect.periodic.fade_length = 1000; + + SDL_HapticUpdateEffect(haptic, effects.effect_triangle_id, &tempEffect); + SDL_HapticRunEffect(haptic, effects.effect_triangle_id, 1); +} + +void TriggerDamperEffect(double strength) +{ + SDL_HapticEffect tempEffect; + SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect)); + tempEffect.type = SDL_HAPTIC_DAMPER; + tempEffect.condition.type = SDL_HAPTIC_DAMPER; + tempEffect.condition.direction.type = SDL_HAPTIC_CARTESIAN; + tempEffect.condition.delay = 0; + tempEffect.condition.length = configFeedbackLength; + tempEffect.condition.direction.dir[0] = 1; // not used + tempEffect.condition.direction.dir[1] = 0; //Y Position + SHORT minForce = (SHORT)(strength > 0.001 ? (configMinForce / 100.0 * 32767.0) : 0); // strength is a double so we do an epsilon check of 0.001 instead of > 0. + SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0); + SHORT range = maxForce - minForce; + SHORT coeff = (SHORT)(strength * range + minForce); + tempEffect.condition.left_coeff[0] = (short)(coeff); + tempEffect.condition.right_coeff[0] = (short)(coeff); + tempEffect.condition.left_sat[0] = (short)(coeff) * 10; + tempEffect.condition.right_sat[0] = (short)(coeff) * 10; + + SDL_HapticUpdateEffect(haptic, effects.effect_damper_id, &tempEffect); + SDL_HapticRunEffect(haptic, effects.effect_damper_id, 1); +} + +void TriggerRampEffect(double start,double end,double length) +{ + SDL_HapticEffect tempEffect; + SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect)); + tempEffect.type = SDL_HAPTIC_RAMP; + tempEffect.ramp.type = SDL_HAPTIC_RAMP; + tempEffect.ramp.direction.type = SDL_HAPTIC_CARTESIAN; + tempEffect.ramp.length = length; + SHORT minForce = (SHORT)(start > 0.001 ? (configMinForce / 100.0 * 32767.0) : 0); // strength is a double so we do an epsilon check of 0.001 instead of > 0. + SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0); + SHORT range = maxForce - minForce; + SHORT start1 = (SHORT)(start * range + minForce); + SHORT minForce2 = (SHORT)(end > 0.001 ? (configMinForce / 100.0 * 32767.0) : 0); // strength is a double so we do an epsilon check of 0.001 instead of > 0. + SHORT maxForce2 = (SHORT)(configMaxForce / 100.0 * 32767.0); + SHORT range2 = maxForce - minForce; + SHORT start2 = (SHORT)(end * range + minForce); + tempEffect.ramp.delay = 0; + tempEffect.ramp.start = start1; + tempEffect.ramp.end = -start2; + + SDL_HapticUpdateEffect(haptic, effects.effect_ramp_id, &tempEffect); + SDL_HapticRunEffect(haptic, effects.effect_ramp_id, 1); +} + +void TriggerSawtoothUpEffect(double strength, double length) +{ + SDL_HapticEffect tempEffect; + SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect)); + tempEffect.type = SDL_HAPTIC_SAWTOOTHUP; + tempEffect.condition.type = SDL_HAPTIC_SAWTOOTHUP; + tempEffect.condition.direction.type = SDL_HAPTIC_CARTESIAN; + tempEffect.periodic.period = 500; + SHORT minForce = (SHORT)(strength > 0.001 ? (configMinForce / 100.0 * 32767.0) : 0); // strength is a double so we do an epsilon check of 0.001 instead of > 0. + SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0); + SHORT range = maxForce - minForce; + SHORT power = (SHORT)(strength * range + minForce); + tempEffect.periodic.magnitude = power; + tempEffect.periodic.length = length; + tempEffect.periodic.attack_length = 1000; + tempEffect.periodic.fade_length = 1000; + + SDL_HapticUpdateEffect(haptic, effects.effect_sawtoothup_id, &tempEffect); + SDL_HapticRunEffect(haptic, effects.effect_sawtoothup_id, 1); +} + +void TriggerSawtoothDownEffect(double strength, double length) { + SDL_HapticEffect tempEffect; + SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect)); + tempEffect.type = SDL_HAPTIC_SAWTOOTHDOWN; + tempEffect.condition.type = SDL_HAPTIC_SAWTOOTHDOWN; + tempEffect.condition.direction.type = SDL_HAPTIC_CARTESIAN; + tempEffect.periodic.period = 500; + SHORT minForce = (SHORT)(strength > 0.001 ? (configMinForce / 100.0 * 32767.0) : 0); // strength is a double so we do an epsilon check of 0.001 instead of > 0. + SHORT maxForce = (SHORT)(configMaxForce / 100.0 * 32767.0); + SHORT range = maxForce - minForce; + SHORT power = (SHORT)(strength * range + minForce); + tempEffect.periodic.magnitude = power; + tempEffect.periodic.length = length; + tempEffect.periodic.attack_length = 1000; + tempEffect.periodic.fade_length = 1000; + + SDL_HapticUpdateEffect(haptic, effects.effect_sawtoothdown_id, &tempEffect); + SDL_HapticRunEffect(haptic, effects.effect_sawtoothdown_id, 1); +} + void TriggerFrictionEffect(double strength) { TriggerFrictionEffectWithDefaultOption(strength, false); @@ -1236,7 +1421,7 @@ void TriggerSineEffect(UINT16 period, UINT16 fadePeriod, double strength) } void TriggerSpringEffectWithDefaultOption(double strength, bool isDefault) { - std::chrono::milliseconds now = duration_cast(system_clock::now().time_since_epoch()); + /*std::chrono::milliseconds now = duration_cast(system_clock::now().time_since_epoch()); long long elapsedTime = (std::chrono::duration_cast(now - timeOfLastSpringEffect)).count(); std::string effectHash = std::to_string(effects.effect_spring_id) + "_" + std::to_string(strength); @@ -1255,7 +1440,7 @@ void TriggerSpringEffectWithDefaultOption(double strength, bool isDefault) { return; } } - } + }*/ SDL_HapticEffect tempEffect; SDL_memset(&tempEffect, 0, sizeof(SDL_HapticEffect)); @@ -1281,10 +1466,10 @@ void TriggerSpringEffectWithDefaultOption(double strength, bool isDefault) { SDL_HapticUpdateEffect(haptic, effects.effect_spring_id, &tempEffect); SDL_HapticRunEffect(haptic, effects.effect_spring_id, 1); - if (!isDefault) { + /*if (!isDefault) { timeOfLastSpringEffect = now; lastSpringEffectHash = effectHash; - } + }*/ } void TriggerSpringEffectInfinite(double strength) @@ -1410,7 +1595,6 @@ void TriggerSpringEffect(double strength) DWORD WINAPI FFBLoop(LPVOID lpParam) { - hlp.log("In FFBLoop"); Sleep(2500); SDL_HapticStopAll(haptic); @@ -1427,6 +1611,12 @@ DWORD WINAPI FFBLoop(LPVOID lpParam) t.LeftRight = &TriggerLeftRightEffect; t.LeftRightDevice2 = &TriggerLeftRightDevice2Effect; t.Springi = &TriggerSpringEffectInfinite; + t.Damper = &TriggerDamperEffect; + t.Inertia = &TriggerInertiaEffect; + t.Ramp = &TriggerRampEffect; + t.SawtoothUp = &TriggerSawtoothUpEffect; + t.SawtoothDown = &TriggerSawtoothDownEffect; + t.Triangle = &TriggerTriangleEffect; Game* game; switch (configGameId) { @@ -1442,9 +1632,15 @@ DWORD WINAPI FFBLoop(LPVOID lpParam) case FNF_GAME: game = new FNF; break; + case GRID_: + game = new GRID; + break; case FORD_RACING: game = new FordRacing; break; + case FORD_RACING_OTHER: + game = new FordRacingOther; + break; case INITIAL_D_4: game = new InitialD4; break; @@ -1541,6 +1737,7 @@ DWORD WINAPI FFBLoop(LPVOID lpParam) case TEST_GAME_SPRING: case TEST_GAME_HEAVY: case TEST_GAME_LOOSE: + case TEST_GAME_RUMBLE: game = new TestGame; break; default: @@ -1558,8 +1755,11 @@ DWORD WINAPI FFBLoop(LPVOID lpParam) bool* kr = (bool*)lpParam; while (*kr) { - game->FFBLoop(&effectConst, &hlp, &t); - Sleep(16); + if (game != 0) + { + game->FFBLoop(&effectConst, &hlp, &t); + Sleep(16); + } } hlp.log("about to exit FFBLoop"); return 0; @@ -1595,7 +1795,6 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ulReasonForCall, LPVOID lpReserved) hlp.log((char *)(std::to_string(configMinForce)).c_str()); hlp.log((char *)(std::to_string(configMaxForce)).c_str()); DisableThreadLibraryCalls(hModule); - hlp.log("loading original library..."); GetPrivateProfileStringA("Settings", "ChainLoad", "", chainedDLL, 256, ".\\FFBplugin.ini"); diff --git a/Game Files/AfterburnerClimax.cpp b/Game Files/AfterburnerClimax.cpp index 38a43b5..d7670e1 100644 --- a/Game Files/AfterburnerClimax.cpp +++ b/Game Files/AfterburnerClimax.cpp @@ -1,7 +1,9 @@ #include #include "AfterburnerClimax.h" +#include "SDL.h" void AfterburnerClimax::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) { UINT8 ff = helpers->ReadByte(0x08347A5E, /* isRelativeOffset */ false); + helpers->log("got value: "); std::string ffs = std::to_string(ff); helpers->log((char *)ffs.c_str()); diff --git a/Game Files/BG4JP.cpp b/Game Files/BG4JP.cpp index 67c1edb..2dbe275 100644 --- a/Game Files/BG4JP.cpp +++ b/Game Files/BG4JP.cpp @@ -1,151 +1,78 @@ #include #include "BG4JP.h" - +static int SpeedStrength; void BG4JP::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) { int ff = helpers->ReadInt32(0x42EBB0, /* isRelativeOffset */ true); float ffspeed = helpers->ReadFloat32(0x3F3000, /* isRelativeOffset */ true); float ff2 = helpers->ReadFloat32(0x42EAB4, /* isRelativeOffset */ true); + if ((ffspeed >= 0.1) & (ffspeed <= 15)) + { + SpeedStrength = 10; + } + else if ((ffspeed >= 15.01) & (ffspeed <= 35)) + { + SpeedStrength = 20; + } + else if ((ffspeed >= 35.01) & (ffspeed <= 55)) + { + SpeedStrength = 30; + } + else if ((ffspeed >= 55.01) & (ffspeed <= 75)) + { + SpeedStrength = 40; + } + else if ((ffspeed >= 75.01) & (ffspeed <= 90)) + { + SpeedStrength = 51; + } + else if ((ffspeed >= 90.01) & (ffspeed <= 110)) + { + SpeedStrength = 62; + } + else if ((ffspeed >= 110.01) & (ffspeed <= 130)) + { + SpeedStrength = 75; + } + else if ((ffspeed >= 130.01) & (ffspeed <= 150)) + { + SpeedStrength = 90; + } + else if (ffspeed > 150.01) + { + SpeedStrength = 100; + } + else + { + SpeedStrength = 0; + } helpers->log("got value: "); std::string ffs = std::to_string(ff); helpers->log((char *)ffs.c_str()); - - if ((2000000 < ff) & (ff < 4000000) & (ffspeed >= 0.1) & (ffspeed <= 15)) + if ((2000000 < ff) && (ff < 4000000)) { - double percentForce = (0.1); - double percentLength = (200); - triggers->Rumble(percentForce, percentLength); + double percentForce = SpeedStrength / 100.0; + double percentLength = 150; + triggers->LeftRight(0, percentForce, percentLength); triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); } - else if ((1000000 < ff) & (ff < 1600000) & (ffspeed >= 0.1) & (ffspeed <= 15)) + else if ((1000000 < ff) && (ff < 1600000)) { - double percentForce = (0.1); - double percentLength = (200); - triggers->Rumble(percentForce, percentLength); + double percentForce = SpeedStrength / 100.0; + double percentLength = 150; + triggers->LeftRight(percentForce, 0, percentLength); triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); } - else if ((2000000 < ff) & (ff < 4000000) & (ffspeed >= 15.01) & (ffspeed <= 35)) - { - double percentForce = (0.2); - double percentLength = (200); - triggers->Rumble(percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - } - else if ((1000000 < ff) & (ff < 1600000) & (ffspeed >= 15.01) & (ffspeed <= 35)) - { - double percentForce = (0.2); - double percentLength = (200); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); - triggers->Rumble(percentForce, percentLength); - } - else if ((2000000 < ff) & (ff < 4000000) & (ffspeed >= 35.01) & (ffspeed <= 55)) - { - double percentForce = (0.3); - double percentLength = (250); - triggers->Rumble(percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - } - else if ((1000000 < ff) & (ff < 1600000) & (ffspeed >= 35.01) & (ffspeed <= 55)) - { - double percentForce = (0.3); - double percentLength = (250); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); - triggers->Rumble(percentForce, percentLength); - } - else if ((2000000 < ff) & (ff < 4000000) & (ffspeed >= 55.01) & (ffspeed <= 75)) - { - double percentForce = (0.4); - double percentLength = (280); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - triggers->Rumble(percentForce, percentLength); - } - else if ((1000000 < ff) & (ff < 1600000) & (ffspeed >= 55.01) & (ffspeed <= 75)) - { - double percentForce = (0.4); - double percentLength = (280); - triggers->Rumble(percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); - } - else if ((2000000 < ff) & (ff < 4000000) & (ffspeed >= 75.01) & (ffspeed <= 90)) - { - double percentForce = (0.5); - double percentLength = (320); - triggers->Rumble(percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - } - else if ((1000000 < ff) & (ff < 1600000) & (ffspeed >= 75.01) & (ffspeed <= 90)) - { - double percentForce = (0.5); - double percentLength = (320); - triggers->Rumble(percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); - } - else if ((2000000 < ff) & (ff < 4000000) & (ffspeed >= 90.01) & (ffspeed <= 110)) - { - double percentForce = (0.6); - double percentLength = (370); - triggers->Rumble(percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - } - else if ((1000000 < ff) & (ff < 1600000) & (ffspeed >= 90.01) & (ffspeed <= 110)) - { - double percentForce = (0.6); - double percentLength = (370); - triggers->Rumble(percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); - } - else if ((2000000 < ff) & (ff < 4000000) & (ffspeed >= 110.01) & (ffspeed <= 130)) - { - double percentForce = (0.7); - double percentLength = (400); - triggers->Rumble(percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - } - else if ((1000000 < ff) & (ff < 1600000) & (ffspeed >= 110.01) & (ffspeed <= 130)) - { - double percentForce = (0.7); - double percentLength = (400); - triggers->Rumble(percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); - } - else if ((2000000 < ff) & (ff < 4000000) & (ffspeed >= 130.01) & (ffspeed <= 150)) - { - double percentForce = (0.9); - double percentLength = (450); - triggers->Rumble(percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - } - else if ((1000000 < ff) & (ff < 1600000) & (ffspeed >= 130.01) & (ffspeed <= 150)) - { - double percentForce = (0.9); - double percentLength = (450); - triggers->Rumble(percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); - } - else if ((2000000 < ff) & (ff < 4000000) & (ffspeed > 150.01)) - { - double percentForce = (1.0); - double percentLength = (500); - triggers->Rumble(percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - } - else if ((1000000 < ff) & (ff < 1600000) & (ffspeed > 150.01)) - { - double percentForce = (1.0); - double percentLength = (500); - triggers->Rumble(percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); - } - else if ((0.00000000000000000001 < ff2) & (ffspeed > 0.01)) + else if ((0.00000000000000000001 < ff2) && (ffspeed > 0.01)) { double percentForce = (0.1); double percentLength = (50); triggers->LeftRight(0, percentForce, percentLength); triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); } - else if ((0.00000000000000000001 > ff2) & (ffspeed > 0.01)) + else if ((0.00000000000000000001 > ff2) && (ffspeed > 0.01)) { double percentForce = (0.1); double percentLength = (50); diff --git a/Game Files/ButtonRumble32bit.cpp b/Game Files/ButtonRumble32bit.cpp index 01162a8..a35fec0 100644 --- a/Game Files/ButtonRumble32bit.cpp +++ b/Game Files/ButtonRumble32bit.cpp @@ -7,83 +7,82 @@ extern int joystick_index2; extern SDL_Joystick* GameController2; extern SDL_Haptic* ControllerHaptic2; extern SDL_Haptic* haptic2; +static SDL_Event e; + +static wchar_t *settingsFilename = TEXT(".\\FFBPlugin.ini"); +static int ShowButtonNumbersForSetup = GetPrivateProfileInt(TEXT("Settings"), TEXT("ShowButtonNumbersForSetup"), 0, settingsFilename); +static int BothRumbleMotor = GetPrivateProfileInt(TEXT("Settings"), TEXT("BothRumbleMotor"), 0, settingsFilename); +static int LeftRumbleMotor = GetPrivateProfileInt(TEXT("Settings"), TEXT("LeftRumbleMotor"), 0, settingsFilename); +static int RightRumbleMotor = GetPrivateProfileInt(TEXT("Settings"), TEXT("RightRumbleMotor"), 0, settingsFilename); +static int RumbleStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("RumbleStrength"), 0, settingsFilename); +static int RumbleLength = GetPrivateProfileInt(TEXT("Settings"), TEXT("RumbleLength"), 0, settingsFilename); +static int Button1Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button1Rumble"), 0, settingsFilename); +static int Button2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button2Rumble"), 0, settingsFilename); +static int Button3Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button3Rumble"), 0, settingsFilename); +static int Button4Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button4Rumble"), 0, settingsFilename); +static int Button5Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button5Rumble"), 0, settingsFilename); +static int Button6Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button6Rumble"), 0, settingsFilename); +static int Button7Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button7Rumble"), 0, settingsFilename); +static int Button8Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button8Rumble"), 0, settingsFilename); +static int Button9Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button9Rumble"), 0, settingsFilename); +static int Button10Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button10Rumble"), 0, settingsFilename); +static int Button1Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button1Device2Rumble"), 0, settingsFilename); +static int Button2Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button2Device2Rumble"), 0, settingsFilename); +static int Button3Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button3Device2Rumble"), 0, settingsFilename); +static int Button4Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button4Device2Rumble"), 0, settingsFilename); +static int Button5Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button5Device2Rumble"), 0, settingsFilename); +static int Button6Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button6Device2Rumble"), 0, settingsFilename); +static int Button7Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button7Device2Rumble"), 0, settingsFilename); +static int Button8Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button8Device2Rumble"), 0, settingsFilename); +static int Button9Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button9Device2Rumble"), 0, settingsFilename); +static int Button10Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button10Device2Rumble"), 0, settingsFilename); void ButtonRumble32bit::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) { - - wchar_t *settingsFilename = TEXT(".\\FFBPlugin.ini"); - int ShowButtonNumbersForSetup = GetPrivateProfileInt(TEXT("Settings"), TEXT("ShowButtonNumbersForSetup"), 0, settingsFilename); - int BothRumbleMotor = GetPrivateProfileInt(TEXT("Settings"), TEXT("BothRumbleMotor"), 0, settingsFilename); - int LeftRumbleMotor = GetPrivateProfileInt(TEXT("Settings"), TEXT("LeftRumbleMotor"), 0, settingsFilename); - int RightRumbleMotor = GetPrivateProfileInt(TEXT("Settings"), TEXT("RightRumbleMotor"), 0, settingsFilename); - int RumbleStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("RumbleStrength"), 0, settingsFilename); - int RumbleLength = GetPrivateProfileInt(TEXT("Settings"), TEXT("RumbleLength"), 0, settingsFilename); - int Button1Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button1Rumble"), 0, settingsFilename); - int Button2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button2Rumble"), 0, settingsFilename); - int Button3Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button3Rumble"), 0, settingsFilename); - int Button4Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button4Rumble"), 0, settingsFilename); - int Button5Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button5Rumble"), 0, settingsFilename); - int Button6Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button6Rumble"), 0, settingsFilename); - int Button7Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button7Rumble"), 0, settingsFilename); - int Button8Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button8Rumble"), 0, settingsFilename); - int Button9Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button9Rumble"), 0, settingsFilename); - int Button10Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button10Rumble"), 0, settingsFilename); - int Button1Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button1Device2Rumble"), 0, settingsFilename); - int Button2Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button2Device2Rumble"), 0, settingsFilename); - int Button3Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button3Device2Rumble"), 0, settingsFilename); - int Button4Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button4Device2Rumble"), 0, settingsFilename); - int Button5Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button5Device2Rumble"), 0, settingsFilename); - int Button6Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button6Device2Rumble"), 0, settingsFilename); - int Button7Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button7Device2Rumble"), 0, settingsFilename); - int Button8Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button8Device2Rumble"), 0, settingsFilename); - int Button9Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button9Device2Rumble"), 0, settingsFilename); - int Button10Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button10Device2Rumble"), 0, settingsFilename); - - for (int i = 0; i < SDL_NumJoysticks(); i++) + + while (SDL_WaitEvent(&e) != 0) { - wchar_t * deviceGUIDString2 = new wchar_t[256]; - int Device2GUID = GetPrivateProfileString(TEXT("Settings"), TEXT("Device2GUID"), NULL, deviceGUIDString2, 256, settingsFilename); - char joystick_guid[256]; - sprintf(joystick_guid, "%S", deviceGUIDString2); - SDL_JoystickGUID guid, dev_guid; - int numJoysticks = SDL_NumJoysticks(); - std::string njs = std::to_string(numJoysticks); - ((char)njs.c_str()); for (int i = 0; i < SDL_NumJoysticks(); i++) { - extern int joystick1Index; - if (i == joystick1Index) + wchar_t * deviceGUIDString2 = new wchar_t[256]; + int Device2GUID = GetPrivateProfileString(TEXT("Settings"), TEXT("Device2GUID"), NULL, deviceGUIDString2, 256, settingsFilename); + char joystick_guid[256]; + sprintf(joystick_guid, "%S", deviceGUIDString2); + SDL_JoystickGUID guid, dev_guid; + int numJoysticks = SDL_NumJoysticks(); + std::string njs = std::to_string(numJoysticks); + ((char)njs.c_str()); + for (int i = 0; i < SDL_NumJoysticks(); i++) { - continue; + extern int joystick1Index; + if (i == joystick1Index) + { + continue; + } + SDL_Joystick* js2 = SDL_JoystickOpen(i); + joystick_index2 = SDL_JoystickInstanceID(js2); + SDL_JoystickGUID guid = SDL_JoystickGetGUID(js2); + char guid_str[1024]; + SDL_JoystickGetGUIDString(guid, guid_str, sizeof(guid_str)); + const char* name = SDL_JoystickName(js2); + char text[256]; + sprintf(text, "Joystick: %d / Name: %s / GUID: %s\n", i, name, guid_str); + guid = SDL_JoystickGetGUIDFromString(joystick_guid); + dev_guid = SDL_JoystickGetGUID(js2); + if (!memcmp(&guid, &dev_guid, sizeof(SDL_JoystickGUID))) + { + GameController2 = SDL_JoystickOpen(i); + ControllerHaptic2 = SDL_HapticOpenFromJoystick(GameController2); + break; + } + SDL_JoystickClose(js2); } - SDL_Joystick* js2 = SDL_JoystickOpen(i); - joystick_index2 = SDL_JoystickInstanceID(js2); - SDL_JoystickGUID guid = SDL_JoystickGetGUID(js2); - char guid_str[1024]; - SDL_JoystickGetGUIDString(guid, guid_str, sizeof(guid_str)); - const char* name = SDL_JoystickName(js2); - char text[256]; - sprintf(text, "Joystick: %d / Name: %s / GUID: %s\n", i, name, guid_str); - guid = SDL_JoystickGetGUIDFromString(joystick_guid); - dev_guid = SDL_JoystickGetGUID(js2); - if (!memcmp(&guid, &dev_guid, sizeof(SDL_JoystickGUID))) + haptic2 = ControllerHaptic2; + if ((SDL_HapticRumbleSupported(haptic2) == SDL_TRUE)) { - GameController2 = SDL_JoystickOpen(i); - ControllerHaptic2 = SDL_HapticOpenFromJoystick(GameController2); - break; + SDL_HapticRumbleInit; + SDL_HapticRumbleInit(ControllerHaptic2); } - SDL_JoystickClose(js2); } - haptic2 = ControllerHaptic2; - if ((SDL_HapticRumbleSupported(haptic2) == SDL_TRUE)) - { - SDL_HapticRumbleInit; - SDL_HapticRumbleInit(ControllerHaptic2); - } - } - - SDL_Event e; - while (SDL_PollEvent(&e) != 0) - { if (ShowButtonNumbersForSetup == 1) { if (e.type == SDL_JOYBUTTONDOWN) @@ -152,66 +151,6 @@ void ButtonRumble32bit::FFBLoop(EffectConstants *constants, Helpers *helpers, Ef { MessageBoxA(NULL, "Button 15 Pressed", "", 0); } - else if (e.jbutton.button == 16) - { - MessageBoxA(NULL, "Button 16 Pressed", "", 0); - } - else if (e.jbutton.button == 17) - { - MessageBoxA(NULL, "Button 17 Pressed", "", 0); - } - else if (e.jbutton.button == 18) - { - MessageBoxA(NULL, "Button 18 Pressed", "", 0); - } - else if (e.jbutton.button == 19) - { - MessageBoxA(NULL, "Button 19 Pressed", "", 0); - } - else if (e.jbutton.button == 20) - { - MessageBoxA(NULL, "Button 20 Pressed", "", 0); - } - else if (e.jbutton.button == 21) - { - MessageBoxA(NULL, "Button 21 Pressed", "", 0); - } - else if (e.jbutton.button == 22) - { - MessageBoxA(NULL, "Button 22 Pressed", "", 0); - } - else if (e.jbutton.button == 23) - { - MessageBoxA(NULL, "Button 23 Pressed", "", 0); - } - else if (e.jbutton.button == 24) - { - MessageBoxA(NULL, "Button 24 Pressed", "", 0); - } - else if (e.jbutton.button == 25) - { - MessageBoxA(NULL, "Button 25 Pressed", "", 0); - } - else if (e.jbutton.button == 26) - { - MessageBoxA(NULL, "Button 26 Pressed", "", 0); - } - else if (e.jbutton.button == 27) - { - MessageBoxA(NULL, "Button 27 Pressed", "", 0); - } - else if (e.jbutton.button == 28) - { - MessageBoxA(NULL, "Button 28 Pressed", "", 0); - } - else if (e.jbutton.button == 29) - { - MessageBoxA(NULL, "Button 29 Pressed", "", 0); - } - else if (e.jbutton.button == 30) - { - MessageBoxA(NULL, "Button 30 Pressed", "", 0); - } } } if (e.type == SDL_JOYBUTTONDOWN) diff --git a/Game Files/ButtonRumble64bit.cpp b/Game Files/ButtonRumble64bit.cpp index dcf32d4..4f82e5c 100644 --- a/Game Files/ButtonRumble64bit.cpp +++ b/Game Files/ButtonRumble64bit.cpp @@ -7,83 +7,82 @@ extern int joystick_index2; extern SDL_Joystick* GameController2; extern SDL_Haptic* ControllerHaptic2; extern SDL_Haptic* haptic2; +static SDL_Event e; + +static wchar_t *settingsFilename = TEXT(".\\FFBPlugin.ini"); +static int ShowButtonNumbersForSetup = GetPrivateProfileInt(TEXT("Settings"), TEXT("ShowButtonNumbersForSetup"), 0, settingsFilename); +static int BothRumbleMotor = GetPrivateProfileInt(TEXT("Settings"), TEXT("BothRumbleMotor"), 0, settingsFilename); +static int LeftRumbleMotor = GetPrivateProfileInt(TEXT("Settings"), TEXT("LeftRumbleMotor"), 0, settingsFilename); +static int RightRumbleMotor = GetPrivateProfileInt(TEXT("Settings"), TEXT("RightRumbleMotor"), 0, settingsFilename); +static int RumbleStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("RumbleStrength"), 0, settingsFilename); +static int RumbleLength = GetPrivateProfileInt(TEXT("Settings"), TEXT("RumbleLength"), 0, settingsFilename); +static int Button1Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button1Rumble"), 0, settingsFilename); +static int Button2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button2Rumble"), 0, settingsFilename); +static int Button3Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button3Rumble"), 0, settingsFilename); +static int Button4Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button4Rumble"), 0, settingsFilename); +static int Button5Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button5Rumble"), 0, settingsFilename); +static int Button6Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button6Rumble"), 0, settingsFilename); +static int Button7Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button7Rumble"), 0, settingsFilename); +static int Button8Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button8Rumble"), 0, settingsFilename); +static int Button9Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button9Rumble"), 0, settingsFilename); +static int Button10Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button10Rumble"), 0, settingsFilename); +static int Button1Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button1Device2Rumble"), 0, settingsFilename); +static int Button2Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button2Device2Rumble"), 0, settingsFilename); +static int Button3Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button3Device2Rumble"), 0, settingsFilename); +static int Button4Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button4Device2Rumble"), 0, settingsFilename); +static int Button5Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button5Device2Rumble"), 0, settingsFilename); +static int Button6Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button6Device2Rumble"), 0, settingsFilename); +static int Button7Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button7Device2Rumble"), 0, settingsFilename); +static int Button8Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button8Device2Rumble"), 0, settingsFilename); +static int Button9Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button9Device2Rumble"), 0, settingsFilename); +static int Button10Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button10Device2Rumble"), 0, settingsFilename); void ButtonRumble64bit::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) { - - wchar_t *settingsFilename = TEXT(".\\FFBPlugin.ini"); - int ShowButtonNumbersForSetup = GetPrivateProfileInt(TEXT("Settings"), TEXT("ShowButtonNumbersForSetup"), 0, settingsFilename); - int BothRumbleMotor = GetPrivateProfileInt(TEXT("Settings"), TEXT("BothRumbleMotor"), 0, settingsFilename); - int LeftRumbleMotor = GetPrivateProfileInt(TEXT("Settings"), TEXT("LeftRumbleMotor"), 0, settingsFilename); - int RightRumbleMotor = GetPrivateProfileInt(TEXT("Settings"), TEXT("RightRumbleMotor"), 0, settingsFilename); - int RumbleStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("RumbleStrength"), 0, settingsFilename); - int RumbleLength = GetPrivateProfileInt(TEXT("Settings"), TEXT("RumbleLength"), 0, settingsFilename); - int Button1Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button1Rumble"), 0, settingsFilename); - int Button2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button2Rumble"), 0, settingsFilename); - int Button3Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button3Rumble"), 0, settingsFilename); - int Button4Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button4Rumble"), 0, settingsFilename); - int Button5Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button5Rumble"), 0, settingsFilename); - int Button6Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button6Rumble"), 0, settingsFilename); - int Button7Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button7Rumble"), 0, settingsFilename); - int Button8Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button8Rumble"), 0, settingsFilename); - int Button9Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button9Rumble"), 0, settingsFilename); - int Button10Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button10Rumble"), 0, settingsFilename); - int Button1Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button1Device2Rumble"), 0, settingsFilename); - int Button2Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button2Device2Rumble"), 0, settingsFilename); - int Button3Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button3Device2Rumble"), 0, settingsFilename); - int Button4Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button4Device2Rumble"), 0, settingsFilename); - int Button5Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button5Device2Rumble"), 0, settingsFilename); - int Button6Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button6Device2Rumble"), 0, settingsFilename); - int Button7Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button7Device2Rumble"), 0, settingsFilename); - int Button8Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button8Device2Rumble"), 0, settingsFilename); - int Button9Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button9Device2Rumble"), 0, settingsFilename); - int Button10Device2Rumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("Button10Device2Rumble"), 0, settingsFilename); - for (int i = 0; i < SDL_NumJoysticks(); i++) + while (SDL_WaitEvent(&e) != 0) { - wchar_t * deviceGUIDString2 = new wchar_t[256]; - int Device2GUID = GetPrivateProfileString(TEXT("Settings"), TEXT("Device2GUID"), NULL, deviceGUIDString2, 256, settingsFilename); - char joystick_guid[256]; - sprintf(joystick_guid, "%S", deviceGUIDString2); - SDL_JoystickGUID guid, dev_guid; - int numJoysticks = SDL_NumJoysticks(); - std::string njs = std::to_string(numJoysticks); - ((char)njs.c_str()); for (int i = 0; i < SDL_NumJoysticks(); i++) { - extern int joystick1Index; - if (i == joystick1Index) + wchar_t * deviceGUIDString2 = new wchar_t[256]; + int Device2GUID = GetPrivateProfileString(TEXT("Settings"), TEXT("Device2GUID"), NULL, deviceGUIDString2, 256, settingsFilename); + char joystick_guid[256]; + sprintf(joystick_guid, "%S", deviceGUIDString2); + SDL_JoystickGUID guid, dev_guid; + int numJoysticks = SDL_NumJoysticks(); + std::string njs = std::to_string(numJoysticks); + ((char)njs.c_str()); + for (int i = 0; i < SDL_NumJoysticks(); i++) { - continue; + extern int joystick1Index; + if (i == joystick1Index) + { + continue; + } + SDL_Joystick* js2 = SDL_JoystickOpen(i); + joystick_index2 = SDL_JoystickInstanceID(js2); + SDL_JoystickGUID guid = SDL_JoystickGetGUID(js2); + char guid_str[1024]; + SDL_JoystickGetGUIDString(guid, guid_str, sizeof(guid_str)); + const char* name = SDL_JoystickName(js2); + char text[256]; + sprintf(text, "Joystick: %d / Name: %s / GUID: %s\n", i, name, guid_str); + guid = SDL_JoystickGetGUIDFromString(joystick_guid); + dev_guid = SDL_JoystickGetGUID(js2); + if (!memcmp(&guid, &dev_guid, sizeof(SDL_JoystickGUID))) + { + GameController2 = SDL_JoystickOpen(i); + ControllerHaptic2 = SDL_HapticOpenFromJoystick(GameController2); + break; + } + SDL_JoystickClose(js2); } - SDL_Joystick* js2 = SDL_JoystickOpen(i); - joystick_index2 = SDL_JoystickInstanceID(js2); - SDL_JoystickGUID guid = SDL_JoystickGetGUID(js2); - char guid_str[1024]; - SDL_JoystickGetGUIDString(guid, guid_str, sizeof(guid_str)); - const char* name = SDL_JoystickName(js2); - char text[256]; - sprintf(text, "Joystick: %d / Name: %s / GUID: %s\n", i, name, guid_str); - guid = SDL_JoystickGetGUIDFromString(joystick_guid); - dev_guid = SDL_JoystickGetGUID(js2); - if (!memcmp(&guid, &dev_guid, sizeof(SDL_JoystickGUID))) + haptic2 = ControllerHaptic2; + if ((SDL_HapticRumbleSupported(haptic2) == SDL_TRUE)) { - GameController2 = SDL_JoystickOpen(i); - ControllerHaptic2 = SDL_HapticOpenFromJoystick(GameController2); - break; + SDL_HapticRumbleInit; + SDL_HapticRumbleInit(ControllerHaptic2); } - SDL_JoystickClose(js2); } - haptic2 = ControllerHaptic2; - if ((SDL_HapticRumbleSupported(haptic2) == SDL_TRUE)) - { - SDL_HapticRumbleInit; - SDL_HapticRumbleInit(ControllerHaptic2); - } - } - - SDL_Event e; - while (SDL_PollEvent(&e) != 0) - { if (ShowButtonNumbersForSetup == 1) { if (e.type == SDL_JOYBUTTONDOWN) @@ -152,66 +151,6 @@ void ButtonRumble64bit::FFBLoop(EffectConstants *constants, Helpers *helpers, Ef { MessageBoxA(NULL, "Button 15 Pressed", "", 0); } - else if (e.jbutton.button == 16) - { - MessageBoxA(NULL, "Button 16 Pressed", "", 0); - } - else if (e.jbutton.button == 17) - { - MessageBoxA(NULL, "Button 17 Pressed", "", 0); - } - else if (e.jbutton.button == 18) - { - MessageBoxA(NULL, "Button 18 Pressed", "", 0); - } - else if (e.jbutton.button == 19) - { - MessageBoxA(NULL, "Button 19 Pressed", "", 0); - } - else if (e.jbutton.button == 20) - { - MessageBoxA(NULL, "Button 20 Pressed", "", 0); - } - else if (e.jbutton.button == 21) - { - MessageBoxA(NULL, "Button 21 Pressed", "", 0); - } - else if (e.jbutton.button == 22) - { - MessageBoxA(NULL, "Button 22 Pressed", "", 0); - } - else if (e.jbutton.button == 23) - { - MessageBoxA(NULL, "Button 23 Pressed", "", 0); - } - else if (e.jbutton.button == 24) - { - MessageBoxA(NULL, "Button 24 Pressed", "", 0); - } - else if (e.jbutton.button == 25) - { - MessageBoxA(NULL, "Button 25 Pressed", "", 0); - } - else if (e.jbutton.button == 26) - { - MessageBoxA(NULL, "Button 26 Pressed", "", 0); - } - else if (e.jbutton.button == 27) - { - MessageBoxA(NULL, "Button 27 Pressed", "", 0); - } - else if (e.jbutton.button == 28) - { - MessageBoxA(NULL, "Button 28 Pressed", "", 0); - } - else if (e.jbutton.button == 29) - { - MessageBoxA(NULL, "Button 29 Pressed", "", 0); - } - else if (e.jbutton.button == 30) - { - MessageBoxA(NULL, "Button 30 Pressed", "", 0); - } } } if (e.type == SDL_JOYBUTTONDOWN) @@ -289,30 +228,30 @@ void ButtonRumble64bit::FFBLoop(EffectConstants *constants, Helpers *helpers, Ef } } } - if (e.type == SDL_JOYBUTTONUP) + if (e.type == SDL_JOYBUTTONUP) + { + if (e.jaxis.which == joystick_index1) { - if (e.jaxis.which == joystick_index1) + if (e.jbutton.button == Button1Rumble || e.jbutton.button == Button2Rumble || e.jbutton.button == Button3Rumble || e.jbutton.button == Button4Rumble || e.jbutton.button == Button5Rumble || e.jbutton.button == Button6Rumble || e.jbutton.button == Button7Rumble || e.jbutton.button == Button8Rumble || e.jbutton.button == Button9Rumble || e.jbutton.button == Button10Rumble) { - if (e.jbutton.button == Button1Rumble || e.jbutton.button == Button2Rumble || e.jbutton.button == Button3Rumble || e.jbutton.button == Button4Rumble || e.jbutton.button == Button5Rumble || e.jbutton.button == Button6Rumble || e.jbutton.button == Button7Rumble || e.jbutton.button == Button8Rumble || e.jbutton.button == Button9Rumble || e.jbutton.button == Button10Rumble) { - { - double percentForce = ((RumbleStrength) / 100.0); - double percentLength = (RumbleLength); - triggers->LeftRight(0, 0, percentLength); - } + double percentForce = ((RumbleStrength) / 100.0); + double percentLength = (RumbleLength); + triggers->LeftRight(0, 0, percentLength); } } - if (e.jaxis.which == joystick_index2) + } + if (e.jaxis.which == joystick_index2) + { + if (e.jbutton.button == Button1Device2Rumble || e.jbutton.button == Button2Device2Rumble || e.jbutton.button == Button3Device2Rumble || e.jbutton.button == Button4Device2Rumble || e.jbutton.button == Button5Device2Rumble || e.jbutton.button == Button6Device2Rumble || e.jbutton.button == Button7Device2Rumble || e.jbutton.button == Button8Device2Rumble || e.jbutton.button == Button9Device2Rumble || e.jbutton.button == Button10Device2Rumble) { - if (e.jbutton.button == Button1Device2Rumble || e.jbutton.button == Button2Device2Rumble || e.jbutton.button == Button3Device2Rumble || e.jbutton.button == Button4Device2Rumble || e.jbutton.button == Button5Device2Rumble || e.jbutton.button == Button6Device2Rumble || e.jbutton.button == Button7Device2Rumble || e.jbutton.button == Button8Device2Rumble || e.jbutton.button == Button9Device2Rumble || e.jbutton.button == Button10Device2Rumble) { - { - double percentForce = ((RumbleStrength) / 100.0); - double percentLength = (RumbleLength); - triggers->LeftRightDevice2(0, 0, percentLength); - } + double percentForce = ((RumbleStrength) / 100.0); + double percentLength = (RumbleLength); + triggers->LeftRightDevice2(0, 0, percentLength); } } } } - } \ No newline at end of file + } +} \ No newline at end of file diff --git a/Game Files/Daytona3.cpp b/Game Files/Daytona3.cpp index 853491a..fd1741c 100644 --- a/Game Files/Daytona3.cpp +++ b/Game Files/Daytona3.cpp @@ -2,36 +2,116 @@ #include "Daytona3.h" #include "SDL.h" #include +static EffectTriggers *myTriggers; +static EffectConstants *myConstants; +static Helpers *myHelpers; +static SDL_Event e; +static wchar_t *settingsFilename = TEXT(".\\FFBPlugin.ini"); +static int ShowButtonNumbersForSetup = GetPrivateProfileInt(TEXT("Settings"), TEXT("ShowButtonNumbersForSetup"), 0, settingsFilename); +static int ChangeGearsViaPlugin = GetPrivateProfileInt(TEXT("Settings"), TEXT("ChangeGearsViaPlugin"), 0, settingsFilename); +static int EscapeKeyExitViaPlugin = GetPrivateProfileInt(TEXT("Settings"), TEXT("EscapeKeyExitViaPlugin"), 0, settingsFilename); +static int MenuMovementViaPlugin = GetPrivateProfileInt(TEXT("Settings"), TEXT("MenuMovementViaPlugin"), 0, settingsFilename); +static int Gear1 = GetPrivateProfileInt(TEXT("Settings"), TEXT("Gear1"), 0, settingsFilename); +static int Gear2 = GetPrivateProfileInt(TEXT("Settings"), TEXT("Gear2"), 0, settingsFilename); +static int Gear3 = GetPrivateProfileInt(TEXT("Settings"), TEXT("Gear3"), 0, settingsFilename); +static int Gear4 = GetPrivateProfileInt(TEXT("Settings"), TEXT("Gear4"), 0, settingsFilename); +static int GearUp = GetPrivateProfileInt(TEXT("Settings"), TEXT("GearUp"), 0, settingsFilename); +static int GearDown = GetPrivateProfileInt(TEXT("Settings"), TEXT("GearDown"), 0, settingsFilename); +static int HideCursor = GetPrivateProfileInt(TEXT("Settings"), TEXT("HideCursor"), 0, settingsFilename); + +static int RunningThread(void *ptr) +{ + int cnt; + for (cnt = 0; cnt >= 0; ++cnt) + { + UINT8 steering = myHelpers->ReadByte(0x019B4678, /* isRelativeOffset */ false); + int gamestate = myHelpers->ReadInt32(0x19B5744, /* isRelativeOffset */ false); + int ff = myHelpers->ReadInt32(0x15AFC46, /* isRelativeOffset */ false); + + if (HideCursor == 1) + { + SetCursorPos(2000, 2000); + } + + if (GetAsyncKeyState((VK_ESCAPE)) && (EscapeKeyExitViaPlugin == 1)) + { + HWND hWnd = FindWindowA(0, ("Daytona Championship USA")); + if (hWnd > NULL) + { + //SendMessage(hWnd, WM_CLOSE, NULL, NULL); + system("taskkill /f /im InpWrapper.exe"); + TerminateProcess(GetCurrentProcess(), 0); + } + } + + if ((steering > 137) & (gamestate == 18) && (MenuMovementViaPlugin == 1)) + { + keybd_event(VK_RIGHT, 0x25, 0, 0); + keybd_event(VK_LEFT, 0, KEYEVENTF_KEYUP, 0); + Sleep(100); + keybd_event(VK_RIGHT, 0, KEYEVENTF_KEYUP, 0); + } + else if ((steering > 117 & steering < 138) & (gamestate == 18) && (MenuMovementViaPlugin == 1)) + { + keybd_event(VK_LEFT, 0, KEYEVENTF_KEYUP, 0); + keybd_event(VK_RIGHT, 0, KEYEVENTF_KEYUP, 0); + } + else if ((steering < 118) & (gamestate == 18) && (MenuMovementViaPlugin == 1)) + { + keybd_event(VK_LEFT, 0x25, 0, 0); + keybd_event(VK_RIGHT, 0, KEYEVENTF_KEYUP, 0); + Sleep(100); + keybd_event(VK_LEFT, 0, KEYEVENTF_KEYUP, 0); + } + + if ((steering > 137) & (gamestate == 30) && (MenuMovementViaPlugin == 1)) + { + keybd_event(VK_RIGHT, 0x25, 0, 0); + keybd_event(VK_LEFT, 0, KEYEVENTF_KEYUP, 0); + Sleep(100); + keybd_event(VK_RIGHT, 0, KEYEVENTF_KEYUP, 0); + } + else if ((steering > 117 & steering < 138) & (gamestate == 30) && (MenuMovementViaPlugin == 1)) + { + keybd_event(VK_LEFT, 0, KEYEVENTF_KEYUP, 0); + keybd_event(VK_RIGHT, 0, KEYEVENTF_KEYUP, 0); + } + else if ((steering < 118) & (gamestate == 30) && (MenuMovementViaPlugin == 1)) + { + keybd_event(VK_LEFT, 0x25, 0, 0); + keybd_event(VK_RIGHT, 0, KEYEVENTF_KEYUP, 0); + Sleep(100); + keybd_event(VK_LEFT, 0, KEYEVENTF_KEYUP, 0); + } + + if (ff > 15) + { + double percentForce = (31 - ff) / 15.0; + double percentLength = 100; + myTriggers->LeftRight(percentForce, 0, percentLength); + myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, percentForce); + } + else if (ff > 0) + { + double percentForce = (16 - ff) / 15.0; + double percentLength = 100; + myTriggers->LeftRight(0, percentForce, percentLength); + myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, percentForce); + } + } + return 0; +} void Daytona3::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) { - int ff = helpers->ReadInt32(0x15AFC46, /* isRelativeOffset */ false); - int gamestate = helpers->ReadInt32(0x19B5744, /* isRelativeOffset */ false); + SDL_Thread *thread; + thread = SDL_CreateThread(RunningThread, "RunningThread", (void *)NULL); UINT8 gear = helpers->ReadByte(0x019B468C, /* isRelativeOffset */ false); - UINT8 steering = helpers->ReadByte(0x019B4678, /* isRelativeOffset */ false); + int ff = helpers->ReadInt32(0x15AFC46, /* isRelativeOffset */ false); helpers->log("got value: "); std::string ffs = std::to_string(ff); helpers->log((char *)ffs.c_str()); - wchar_t *settingsFilename = TEXT(".\\FFBPlugin.ini"); - int ShowButtonNumbersForSetup = GetPrivateProfileInt(TEXT("Settings"), TEXT("ShowButtonNumbersForSetup"), 0, settingsFilename); - int ChangeGearsViaPlugin = GetPrivateProfileInt(TEXT("Settings"), TEXT("ChangeGearsViaPlugin"), 0, settingsFilename); - int EscapeKeyExitViaPlugin = GetPrivateProfileInt(TEXT("Settings"), TEXT("EscapeKeyExitViaPlugin"), 0, settingsFilename); - int MenuMovementViaPlugin = GetPrivateProfileInt(TEXT("Settings"), TEXT("MenuMovementViaPlugin"), 0, settingsFilename); - int Gear1 = GetPrivateProfileInt(TEXT("Settings"), TEXT("Gear1"), 0, settingsFilename); - int Gear2 = GetPrivateProfileInt(TEXT("Settings"), TEXT("Gear2"), 0, settingsFilename); - int Gear3 = GetPrivateProfileInt(TEXT("Settings"), TEXT("Gear3"), 0, settingsFilename); - int Gear4 = GetPrivateProfileInt(TEXT("Settings"), TEXT("Gear4"), 0, settingsFilename); - int GearUp = GetPrivateProfileInt(TEXT("Settings"), TEXT("GearUp"), 0, settingsFilename); - int GearDown = GetPrivateProfileInt(TEXT("Settings"), TEXT("GearDown"), 0, settingsFilename); - int HideCursor = GetPrivateProfileInt(TEXT("Settings"), TEXT("HideCursor"), 0, settingsFilename); - - if (HideCursor == 1) - { - SetCursorPos(2000, 2000); - } - - SDL_Event e; - while (SDL_PollEvent(&e) != 0) - { + while (SDL_WaitEvent(&e) != 0) + { /* if (e.type == SDL_KEYDOWN) { if (e.key.keysym.sym == SDLK_ESCAPE) @@ -39,6 +119,9 @@ void Daytona3::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTrigg MessageBoxA(NULL, "test", "", 0); } } */ + myTriggers = triggers; + myConstants = constants; + myHelpers = helpers; if (ShowButtonNumbersForSetup == 1) { if (e.type == SDL_JOYBUTTONDOWN) @@ -107,66 +190,6 @@ void Daytona3::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTrigg { MessageBoxA(NULL, "Button 15 Pressed", "", 0); } - else if (e.jbutton.button == 16) - { - MessageBoxA(NULL, "Button 16 Pressed", "", 0); - } - else if (e.jbutton.button == 17) - { - MessageBoxA(NULL, "Button 17 Pressed", "", 0); - } - else if (e.jbutton.button == 18) - { - MessageBoxA(NULL, "Button 18 Pressed", "", 0); - } - else if (e.jbutton.button == 19) - { - MessageBoxA(NULL, "Button 19 Pressed", "", 0); - } - else if (e.jbutton.button == 20) - { - MessageBoxA(NULL, "Button 20 Pressed", "", 0); - } - else if (e.jbutton.button == 21) - { - MessageBoxA(NULL, "Button 21 Pressed", "", 0); - } - else if (e.jbutton.button == 22) - { - MessageBoxA(NULL, "Button 22 Pressed", "", 0); - } - else if (e.jbutton.button == 23) - { - MessageBoxA(NULL, "Button 23 Pressed", "", 0); - } - else if (e.jbutton.button == 24) - { - MessageBoxA(NULL, "Button 24 Pressed", "", 0); - } - else if (e.jbutton.button == 25) - { - MessageBoxA(NULL, "Button 25 Pressed", "", 0); - } - else if (e.jbutton.button == 26) - { - MessageBoxA(NULL, "Button 26 Pressed", "", 0); - } - else if (e.jbutton.button == 27) - { - MessageBoxA(NULL, "Button 27 Pressed", "", 0); - } - else if (e.jbutton.button == 28) - { - MessageBoxA(NULL, "Button 28 Pressed", "", 0); - } - else if (e.jbutton.button == 29) - { - MessageBoxA(NULL, "Button 29 Pressed", "", 0); - } - else if (e.jbutton.button == 30) - { - MessageBoxA(NULL, "Button 30 Pressed", "", 0); - } } } if (e.type == SDL_JOYBUTTONDOWN) @@ -200,78 +223,4 @@ void Daytona3::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTrigg } } } - if (GetAsyncKeyState((VK_ESCAPE)) && (EscapeKeyExitViaPlugin == 1)) - { - system("taskkill /f /im Daytona.exe"); - system("taskkill /f /im InpWrapper.exe"); - } - - if ((steering > 137) & (gamestate == 18) && (MenuMovementViaPlugin == 1)) - { - keybd_event(VK_RIGHT, 0x25, 0, 0); - keybd_event(VK_LEFT, 0, KEYEVENTF_KEYUP, 0); - Sleep(100); - keybd_event(VK_RIGHT, 0, KEYEVENTF_KEYUP, 0); - } - else if ((steering > 117 & steering < 138) & (gamestate == 18) && (MenuMovementViaPlugin == 1)) - { - keybd_event(VK_LEFT, 0, KEYEVENTF_KEYUP, 0); - keybd_event(VK_RIGHT, 0, KEYEVENTF_KEYUP, 0); - } - else if ((steering < 118) & (gamestate == 18) && (MenuMovementViaPlugin == 1)) - { - keybd_event(VK_LEFT, 0x25, 0, 0); - keybd_event(VK_RIGHT, 0, KEYEVENTF_KEYUP, 0); - Sleep(100); - keybd_event(VK_LEFT, 0, KEYEVENTF_KEYUP, 0); - } - if ((steering > 137) & (gamestate == 30) && (MenuMovementViaPlugin == 1)) - { - keybd_event(VK_RIGHT, 0x25, 0, 0); - keybd_event(VK_LEFT, 0, KEYEVENTF_KEYUP, 0); - Sleep(100); - keybd_event(VK_RIGHT, 0, KEYEVENTF_KEYUP, 0); - } - else if ((steering > 117 & steering < 138) & (gamestate == 30) && (MenuMovementViaPlugin == 1)) - { - keybd_event(VK_LEFT, 0, KEYEVENTF_KEYUP, 0); - keybd_event(VK_RIGHT, 0, KEYEVENTF_KEYUP, 0); - } - else if ((steering < 118) & (gamestate == 30) && (MenuMovementViaPlugin == 1)) - { - keybd_event(VK_LEFT, 0x25, 0, 0); - keybd_event(VK_RIGHT, 0, KEYEVENTF_KEYUP, 0); - Sleep(100); - keybd_event(VK_LEFT, 0, KEYEVENTF_KEYUP, 0); - } - - if (ff > 15) - { - helpers->log("moving wheel right"); - // assume that 30 is the weakest and 16 is the strongest - double percentForce = (31 - ff) / 15.0; - double percentLength = 100; - // direction from left => makes wheel turn right - triggers->LeftRight(percentForce, 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); // old logic: 31 - ff - lastWasStop = 0; - } - else if (ff > 0) - { - helpers->log("moving wheel left"); - // assume that 1 is the strongest and 15 is the weakest - double percentForce = (16 - ff) / 15.0; - double percentLength = 100; - // direction from right => makes wheel turn left - triggers->LeftRight(0, percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); // old logic: 15 - ff - lastWasStop = 0; - } - else - { - if (lastWasStop == 0) { - triggers->Constant(constants->DIRECTION_FROM_LEFT, 0); // just pass the hash of 0 strength so we update lastEffectHash & lastEffectTime - lastWasStop = 1; - } - } - } \ No newline at end of file +} \ No newline at end of file diff --git a/Game Files/FNF.cpp b/Game Files/FNF.cpp index d2ab091..b6363ce 100644 --- a/Game Files/FNF.cpp +++ b/Game Files/FNF.cpp @@ -1,6 +1,17 @@ #include #include "FNF.h" - -void FNF::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) { +void FNF::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) +{ + //HMODULE hMod = GetModuleHandleA("dinput8.dll"); + /*if (hMod) + { + void* fn = GetProcAddress(hMod, "GetdfDIJoystick"); + helpers->WriteNop((INT_PTR)fn + 0x5C0C, false); + helpers->WriteNop((INT_PTR)fn + 0x5C0D, false); + } + else + { + MessageBoxA(NULL, "fuck", "", 0); + } */ } \ No newline at end of file diff --git a/Game Files/FordRacingOther.cpp b/Game Files/FordRacingOther.cpp new file mode 100644 index 0000000..ef3e80a --- /dev/null +++ b/Game Files/FordRacingOther.cpp @@ -0,0 +1,72 @@ +#include +#include "FordRacingOther.h" +static EffectTriggers *myTriggers; +static EffectConstants *myConstants; +static Helpers *myHelpers; +static int __stdcall Out32(DWORD device, DWORD data) +{ + if (device == 0x378) + { + if (data > 0xFFFF0013 && data < 0xFFFF001F) + { + double percentForce = (4294901791 - data) / 10.0; + double percentLength = 100; + myTriggers->LeftRight(0, percentForce, percentLength); + myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, percentForce); + } + else if (data > 5 && data < 16) + { + double percentForce = (16 - data) / 10.0; + double percentLength = 100; + myTriggers->LeftRight(percentForce, 0, percentLength); + myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, percentForce); + } + } + return 0; +} + +static bool Hook(void * toHook, void * ourFunct, int len) { + if (len < 5) { + return false; + } + + DWORD curProtection; + VirtualProtect(toHook, len, PAGE_EXECUTE_READWRITE, &curProtection); + + memset(toHook, 0x90, len); + + DWORD relativeAddress = ((DWORD)ourFunct - (DWORD)toHook) - 5; + + *(BYTE*)toHook = 0xE9; + *(DWORD*)((DWORD)toHook + 1) = relativeAddress; + + DWORD temp; + VirtualProtect(toHook, len, curProtection, &temp); + + return true; +} + +static DWORD jmpBackAddy; + +void FordRacingOther::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) { + bool init = false; + HMODULE hMod = GetModuleHandleA("inpout32.dll"); + if (hMod) + { + if (!init) + { + int hookLength = 6; + DWORD hookAddress = (DWORD)GetProcAddress(GetModuleHandle(L"inpout32.dll"), "Out32"); + if (hookAddress) + { + jmpBackAddy = hookAddress + hookLength; + Hook((void*)hookAddress, Out32, hookLength); + init = true; + } + + } + } + myTriggers = triggers; + myConstants = constants; + myHelpers = helpers; +} \ No newline at end of file diff --git a/Game Files/FordRacingOther.h b/Game Files/FordRacingOther.h new file mode 100644 index 0000000..5cefb3f --- /dev/null +++ b/Game Files/FordRacingOther.h @@ -0,0 +1,7 @@ +#pragma once +#include "../Common Files/Game.h" +class FordRacingOther : public Game { + +public: + void FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers); +}; \ No newline at end of file diff --git a/Game Files/GRID.cpp b/Game Files/GRID.cpp new file mode 100644 index 0000000..9283212 --- /dev/null +++ b/Game Files/GRID.cpp @@ -0,0 +1,56 @@ +#include "GRID.h" +#include +#include + +static bool __stdcall Out32(int a2, DWORD BytesReturned) +{ + static char test[256]; + memset(test, 0, 256); + sprintf(test, "hex print: %08X", BytesReturned); + OutputDebugStringA(test); + return 0; +} + +static bool Hook(void * toHook, void * ourFunct, int len) { + if (len < 5) { + return false; + } + + DWORD curProtection; + VirtualProtect(toHook, len, PAGE_EXECUTE_READWRITE, &curProtection); + + memset(toHook, 0x90, len); + + DWORD relativeAddress = ((DWORD)ourFunct - (DWORD)toHook) - 5; + + *(BYTE*)toHook = 0xE9; + *(DWORD*)((DWORD)toHook + 1) = relativeAddress; + + DWORD temp; + VirtualProtect(toHook, len, curProtection, &temp); + + return true; +} + +static DWORD jmpBackAddy; + +void GRID::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectTriggers * triggers) +{ + bool init = false; + HMODULE hMod = GetModuleHandleA("inpout32.dll"); + if (hMod) + { + if (!init) + { + int hookLength = 6; + DWORD hookAddress = (DWORD)GetProcAddress(GetModuleHandle(L"inpout32.dll"), "Out32"); + if (hookAddress) + { + jmpBackAddy = hookAddress + hookLength; + Hook((void*)hookAddress, Out32, hookLength); + init = true; + } + + } + } +} \ No newline at end of file diff --git a/Game Files/GRID.h b/Game Files/GRID.h new file mode 100644 index 0000000..6ebdd93 --- /dev/null +++ b/Game Files/GRID.h @@ -0,0 +1,7 @@ +#pragma once +#include "../Common Files/Game.h" + +class GRID : public Game { +public: + void FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers); +}; diff --git a/Game Files/InitialD4.cpp b/Game Files/InitialD4.cpp index 3e7daa3..ad4d22b 100644 --- a/Game Files/InitialD4.cpp +++ b/Game Files/InitialD4.cpp @@ -8,40 +8,71 @@ void InitialD4::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectTr int FFBMode = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBMode"), 0, settingsFilename); UINT8 ff = helpers->ReadByte(0x089AE89A, /* isRelativeOffset */ false); UINT8 ff1 = helpers->ReadByte(0x089AE899, /* isRelativeOffset */ false); + UINT8 ff2 = helpers->ReadByte(0x089AE898, /* isRelativeOffset */ false); helpers->log("got value: "); std::string ffs = std::to_string(ff); helpers->log((char *)ffs.c_str()); - if ((ff > 0x37) & (ff < 0x80) & (ff1 == 0) & (FFBMode == 0)) + if (ff2 == 0x86) { - helpers->log("moving wheel right"); - double percentForce = (128 - ff) / 73.0; - double percentLength = 100; - triggers->LeftRight(percentForce, 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); + triggers->Spring(0.8); } - else if ((ff > 0x00) & (ff < 0x49) & (ff1 == 1) & (FFBMode == 0)) + if (ff2 == 0x85) //cars colliding or rubbing against wall etc { - helpers->log("moving wheel left"); - double percentForce = (ff) / 73.0; - double percentLength = 100; - triggers->LeftRight(0, percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); + if (ff1 > 0) + { + double percentLength = 200; + double percentForce = (0.6); + triggers->Inertia(percentForce); + triggers->Friction(percentForce); + triggers->Damper(percentForce); + triggers->LeftRight(percentForce, percentForce, percentLength); + } } - else if ((ff > 0x37) & (ff < 0x80) & (ff1 == 0) & (FFBMode == 1)) + if (FFBMode == 1) { - helpers->log("moving wheel right"); - double percentForce = (128 - ff) / 73.0; - double percentLength = 100; - triggers->LeftRight(pow(percentForce, 0.5), 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, (pow(percentForce, 0.5))); + if (ff2 == 0x84) + { + if ((ff > 0x37) && (ff < 0x80) && (ff1 == 0)) + { + helpers->log("moving wheel right"); + double percentForce = (128 - ff) / 72.0; + double percentLength = 100; + double powforce = (ff - 55) / 72.0; + triggers->LeftRight(pow(percentForce, powforce), 0, percentLength); + triggers->Constant(constants->DIRECTION_FROM_LEFT, (pow(percentForce, powforce))); + } + else if ((ff > 0x00) && (ff < 0x49) && (ff1 == 1)) + { + helpers->log("moving wheel left"); + double percentForce = (ff) / 72.0; + double percentLength = 100; + double powforce = (73 - ff) / 72.0; + triggers->LeftRight(0, pow(percentForce, powforce), percentLength); + triggers->Constant(constants->DIRECTION_FROM_RIGHT, (pow(percentForce, powforce))); + } + } } - else if ((ff > 0x00) & (ff < 0x49) & (ff1 == 1) & (FFBMode == 1)) + else { - helpers->log("moving wheel left"); - double percentForce = (ff) / 73.0; - double percentLength = 100; - triggers->LeftRight(0, pow(percentForce, 0.5), percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT,(pow(percentForce, 0.5))); - } + if (ff2 == 0x84) + { + if ((ff > 0x37) && (ff < 0x80) && (ff1 == 0)) + { + helpers->log("moving wheel right"); + double percentForce = (128 - ff) / 72.0; + double percentLength = 100; + triggers->LeftRight(percentForce, 0, percentLength); + triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); + } + else if ((ff > 0x00) && (ff < 0x49) && (ff1 == 1)) + { + helpers->log("moving wheel left"); + double percentForce = (ff) / 72.0; + double percentLength = 100; + triggers->LeftRight(0, percentForce, percentLength); + triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); + } + } + } } \ No newline at end of file diff --git a/Game Files/InitialD4Japan.cpp b/Game Files/InitialD4Japan.cpp index 28615fd..3df5645 100644 --- a/Game Files/InitialD4Japan.cpp +++ b/Game Files/InitialD4Japan.cpp @@ -7,40 +7,71 @@ void InitialD4Japan::FFBLoop(EffectConstants * constants, Helpers * helpers, Eff int FFBMode = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBMode"), 0, settingsFilename); UINT8 ff = helpers->ReadByte(0x0898985A, /* isRelativeOffset */ false); UINT8 ff1 = helpers->ReadByte(0x08989859, /* isRelativeOffset */ false); + UINT8 ff2 = helpers->ReadByte(0x08989858, /* isRelativeOffset */ false); helpers->log("got value: "); std::string ffs = std::to_string(ff); helpers->log((char *)ffs.c_str()); - if ((ff > 0x37) & (ff < 0x80) & (ff1 == 0) & (FFBMode == 0)) + if (ff2 == 0x86) { - helpers->log("moving wheel right"); - double percentForce = (128 - ff) / 73.0; - double percentLength = 100; - triggers->LeftRight(percentForce, 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); + triggers->Spring(0.8); } - else if ((ff > 0x00) & (ff < 0x49) & (ff1 == 1) & (FFBMode == 0)) + if (ff2 == 0x85) //cars colliding or rubbing against wall etc { - helpers->log("moving wheel left"); - double percentForce = (ff) / 73.0; - double percentLength = 100; - triggers->LeftRight(0, percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); + if (ff1 > 0) + { + double percentLength = 200; + double percentForce = (0.6); + triggers->Inertia(percentForce); + triggers->Friction(percentForce); + triggers->Damper(percentForce); + triggers->LeftRight(percentForce, percentForce, percentLength); + } } - else if ((ff > 0x37) & (ff < 0x80) & (ff1 == 0) & (FFBMode == 1)) + if (FFBMode == 1) { - helpers->log("moving wheel right"); - double percentForce = (128 - ff) / 73.0; - double percentLength = 100; - triggers->LeftRight(pow(percentForce, 0.5), 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, (pow(percentForce, 0.5))); + if (ff2 == 0x84) + { + if ((ff > 0x37) && (ff < 0x80) && (ff1 == 0)) + { + helpers->log("moving wheel right"); + double percentForce = (128 - ff) / 72.0; + double percentLength = 100; + double powforce = (ff - 55) / 72.0; + triggers->LeftRight(pow(percentForce, powforce), 0, percentLength); + triggers->Constant(constants->DIRECTION_FROM_LEFT, (pow(percentForce, powforce))); + } + else if ((ff > 0x00) && (ff < 0x49) && (ff1 == 1)) + { + helpers->log("moving wheel left"); + double percentForce = (ff) / 72.0; + double percentLength = 100; + double powforce = (73 - ff) / 72.0; + triggers->LeftRight(0, pow(percentForce, powforce), percentLength); + triggers->Constant(constants->DIRECTION_FROM_RIGHT, (pow(percentForce, powforce))); + } + } } - else if ((ff > 0x00) & (ff < 0x49) & (ff1 == 1) & (FFBMode == 1)) + else { - helpers->log("moving wheel left"); - double percentForce = (ff) / 73.0; - double percentLength = 100; - triggers->LeftRight(0, pow(percentForce, 0.5), percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, (pow(percentForce, 0.5))); + if (ff2 == 0x84) + { + if ((ff > 0x37) && (ff < 0x80) && (ff1 == 0)) + { + helpers->log("moving wheel right"); + double percentForce = (128 - ff) / 72.0; + double percentLength = 100; + triggers->LeftRight(percentForce, 0, percentLength); + triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); + } + else if ((ff > 0x00) && (ff < 0x49) && (ff1 == 1)) + { + helpers->log("moving wheel left"); + double percentForce = (ff) / 72.0; + double percentLength = 100; + triggers->LeftRight(0, percentForce, percentLength); + triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); + } + } } } \ No newline at end of file diff --git a/Game Files/InitialD5.cpp b/Game Files/InitialD5.cpp index 3b8bb9c..7cec425 100644 --- a/Game Files/InitialD5.cpp +++ b/Game Files/InitialD5.cpp @@ -3,44 +3,76 @@ #include "math.h" void InitialD5::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectTriggers * triggers) { + wchar_t *settingsFilename = TEXT(".\\FFBPlugin.ini"); int FFBMode = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBMode"), 0, settingsFilename); UINT8 ff = helpers->ReadByte(0x08CB6122, /* isRelativeOffset */ false); UINT8 ff1 = helpers->ReadByte(0x08CB6121, /* isRelativeOffset */ false); + UINT8 ff2 = helpers->ReadByte(0x08CB6120, /* isRelativeOffset */ false); helpers->log("got value: "); std::string ffs = std::to_string(ff); helpers->log((char *)ffs.c_str()); - if ((ff > 0x37) & (ff < 0x80) & (ff1 == 0) & (FFBMode == 0)) + if (ff2 == 0x86) { - helpers->log("moving wheel right"); - double percentForce = (128 - ff) / 73.0; - double percentLength = 100; - triggers->LeftRight(percentForce, 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); + triggers->Spring(0.8); } - else if ((ff > 0x00) & (ff < 0x49) & (ff1 == 1) & (FFBMode == 0)) + if (ff2 == 0x85) //cars colliding or rubbing against wall etc { - helpers->log("moving wheel left"); - double percentForce = (ff) / 73.0; - double percentLength = 100; - triggers->LeftRight(0, percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); + if (ff1 > 0) + { + double percentLength = 200; + double percentForce = (0.6); + triggers->Inertia(percentForce); + triggers->Friction(percentForce); + triggers->Damper(percentForce); + triggers->LeftRight(percentForce, percentForce, percentLength); + } } - else if ((ff > 0x37) & (ff < 0x80) & (ff1 == 0) & (FFBMode == 1)) + if (FFBMode == 1) + { + if (ff2 == 0x84) + { + if ((ff > 0x37) && (ff < 0x80) && (ff1 == 0)) + { + helpers->log("moving wheel right"); + double percentForce = (128 - ff) / 72.0; + double percentLength = 100; + double powforce = (ff - 55) / 72.0; + triggers->LeftRight(pow(percentForce, powforce), 0, percentLength); + triggers->Constant(constants->DIRECTION_FROM_LEFT, (pow(percentForce, powforce))); + } + else if ((ff > 0x00) && (ff < 0x49) && (ff1 == 1)) + { + helpers->log("moving wheel left"); + double percentForce = (ff) / 72.0; + double percentLength = 100; + double powforce = (73 - ff) / 72.0; + triggers->LeftRight(0, pow(percentForce, powforce), percentLength); + triggers->Constant(constants->DIRECTION_FROM_RIGHT, (pow(percentForce, powforce))); + } + } + } + else { - helpers->log("moving wheel right"); - double percentForce = (128 - ff) / 73.0; - double percentLength = 100; - triggers->LeftRight(pow(percentForce, 0.5), 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, (pow(percentForce, 0.5))); - } - else if ((ff > 0x00) & (ff < 0x49) & (ff1 == 1) & (FFBMode == 1)) - { - helpers->log("moving wheel left"); - double percentForce = (ff) / 73.0; - double percentLength = 100; - triggers->LeftRight(0, pow(percentForce, 0.5), percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, (pow(percentForce, 0.5))); - } + if (ff2 == 0x84) + { + if ((ff > 0x37) && (ff < 0x80) && (ff1 == 0)) + { + helpers->log("moving wheel right"); + double percentForce = (128 - ff) / 72.0; + double percentLength = 100; + triggers->LeftRight(percentForce, 0, percentLength); + triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); + } + else if ((ff > 0x00) && (ff < 0x49) && (ff1 == 1)) + { + helpers->log("moving wheel left"); + double percentForce = (ff) / 72.0; + double percentLength = 100; + triggers->LeftRight(0, percentForce, percentLength); + triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); + } + } + } } \ No newline at end of file diff --git a/Game Files/InitialD6.cpp b/Game Files/InitialD6.cpp index 2463a72..0c803da 100644 --- a/Game Files/InitialD6.cpp +++ b/Game Files/InitialD6.cpp @@ -1,93 +1,185 @@ #include #include "InitialD6.h" +static int carscollide(int ffcollide) { + switch (ffcollide) { + case 0x50F05: + return 16; + case 0x50E05: + return 15; + case 0x50D05: + return 14; + case 0x50C05: + return 13; + case 0x50B05: + return 12; + case 0x50A05: + return 11; + case 0x50905: + return 10; + case 0x50805: + return 9; + case 0x50705: + return 8; + case 0x50605: + return 7; + case 0x050505: + return 6; + case 0x050405: + return 5; + case 0x050305: + return 4; + case 0x50205: + return 3; + case 0x50105: + return 2; + case 0x50005: + return 1; + default: + return 0; + } +} + +static int rubbingwalls(int ffwalls) { + switch (ffwalls) { + case 0x51F08: + return 31; + case 0x51E08: + return 30; + case 0x51D08: + return 29; + case 0x51C08: + return 28; + case 0x51B08: + return 27; + case 0x51A08: + return 26; + case 0x51908: + return 25; + case 0x51808: + return 24; + case 0x51708: + return 23; + case 0x51608: + return 22; + case 0x51508: + return 21; + case 0x51408: + return 20; + case 0x51308: + return 19; + case 0x51208: + return 18; + case 0x51108: + return 17; + case 0x50F08: + return 16; + case 0x50E08: + return 15; + case 0x50D08: + return 14; + case 0x50C08: + return 13; + case 0x50B08: + return 12; + case 0x50A08: + return 11; + case 0x50908: + return 10; + case 0x50808: + return 9; + case 0x50708: + return 8; + case 0x50608: + return 7; + case 0x50508: + return 6; + case 0x50408: + return 5; + case 0x50308: + return 4; + case 0x50208: + return 3; + case 0x50108: + return 2; + case 0x50008: + return 1; + default: + return 0; + } +} + void InitialD6::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectTriggers * triggers) { - wchar_t *settingsFilename = TEXT(".\\FFBPlugin.ini"); - int SineDivision = GetPrivateProfileInt(TEXT("Settings"), TEXT("SineDivision"), 0, settingsFilename); - helpers->log("in ID6 Ffbloop"); - const int ff = GetTeknoParrotFFB(); - std::string ffs = std::to_string(ff); - helpers->log((char *)ffs.c_str()); + int ffrubbingwalls = 0; + int ffcarcollision = 0; + { + wchar_t *settingsFilename = TEXT(".\\FFBPlugin.ini"); + int FFBMode = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBMode"), 0, settingsFilename); + helpers->log("in ID6 Ffbloop"); + const int ff = GetTeknoParrotFFB(); + std::string ffs = std::to_string(ff); + helpers->log((char *)ffs.c_str()); + ffcarcollision = carscollide(ff); + ffrubbingwalls = rubbingwalls(ff); - if ((ff > 0x4005B) & (ff < 0x40080)) - { - helpers->log("moving wheel right"); - double percentForce = (262272 - ff) / 36.0; - double percentLength = 100; - triggers->LeftRight(percentForce, 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); - } - else if ((ff > 0x40100) & (ff < 0x40125)) - { - helpers->log("moving wheel left"); - double percentForce = (ff - 262400) / 36.0; - double percentLength = 100; - triggers->LeftRight(0, percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - } - else if ((ff >= 390001) && (ff <= 399999)) - { - helpers->log("sine1"); - double percentForce = (ff - 390000) / ((SineDivision) / 1.0); - double percentLength = 100; - triggers->Rumble(percentForce, percentLength); - triggers->Sine(120, 100, percentForce); - } - else if ((ff >= 380001) && (ff <= 389999)) - { - helpers->log("sine2"); - double percentLength = 100; - double percentForce = (ff - 380000) / ((SineDivision) / 1.0); - triggers->Rumble(percentForce, percentLength); - triggers->Sine(130, 120, percentForce); - } - else if ((ff >= 370001) && (ff <= 379999)) - { - helpers->log("sine3"); - double percentLength = 100; - double percentForce = (ff - 370000) / ((SineDivision) / 1.0); - triggers->Rumble(percentForce, percentLength); - triggers->Sine(140, 140, percentForce); - } - else if ((ff >= 360001) && (ff <= 369999)) - { - helpers->log("sine4"); - double percentForce = (ff - 360000) / ((SineDivision) / 1.0); - double percentLength = 100; - triggers->Rumble(percentForce, percentLength); - triggers->Sine(150, 150, percentForce); - } - else if ((ff >= 350001) && (ff <= 359999)) - { - helpers->log("sine5"); - double percentLength = 100; - double percentForce = (ff - 350000) / ((SineDivision) / 1.0); - triggers->Rumble(percentForce, percentLength); - triggers->Sine(160, 160, percentForce); - } - else if ((ff >= 340001) && (ff <= 349999)) - { - helpers->log("sine6"); - double percentLength = 100; - double percentForce = (ff - 340000) / ((SineDivision) / 1.0); - triggers->Rumble(percentForce, percentLength); - triggers->Sine(170, 170, percentForce); - } - else if ((ff >= 330001) && (ff <= 339999)) - { - helpers->log("sine7"); - double percentLength = 100; - double percentForce = (ff - 330000) / ((SineDivision) / 1.0); - triggers->Rumble(percentForce, percentLength); - triggers->Sine(180, 180, percentForce); - } - else if ((ff >= 327681) && (ff <= 329999)) - { - helpers->log("sine8"); - double percentLength = 100; - double percentForce = (ff - 327680) / ((SineDivision) / 1.0); - triggers->Rumble(percentForce, percentLength); - triggers->Sine(190, 190, percentForce); + if (ff == 0x60000) + { + triggers->Spring(0.8); + } + if (ffrubbingwalls > 0) // car rubbing against wall + { + double percentLength = 200; + double percentForce = (ffrubbingwalls / 31.0); + triggers->Inertia(percentForce); + triggers->Friction(percentForce); + triggers->Damper(percentForce); + triggers->LeftRight(percentForce, percentForce, percentLength); + } + if (ffcarcollision > 0) //cars colliding or rubbing with each other + { + double percentLength = 200; + double percentForce = (ffcarcollision / 16.0); + triggers->Inertia(percentForce); + triggers->Friction(percentForce); + triggers->Damper(percentForce); + triggers->LeftRight(percentForce, percentForce, percentLength); + } + if (FFBMode == 1) + { + if ((ff > 0x40037) & (ff < 0x40080)) + { + double percentForce = (262272 - ff) / 72.0; + double percentLength = 100; + double powforce = (ff - 262199) / 72.0; + triggers->LeftRight(pow(percentForce, powforce), 0, percentLength); + triggers->Constant(constants->DIRECTION_FROM_LEFT, (pow(percentForce, powforce))); + } + else if ((ff > 0x40100) & (ff < 0x40149)) + { + double percentForce = (ff - 262400) / 72.0; + double percentLength = 100; + double powforce = (262473 - ff) / 72.0; + triggers->LeftRight(0, pow(percentForce, powforce), percentLength); + triggers->Constant(constants->DIRECTION_FROM_RIGHT, (pow(percentForce, powforce))); + } + } + else + { + if ((ff > 0x40037) & (ff < 0x40080)) + { + double percentForce = (262272 - ff) / 72.0; + double percentLength = 100; + triggers->LeftRight(percentForce, 0, percentLength); + triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); + } + else if ((ff > 0x40100) & (ff < 0x40149)) + { + double percentForce = (ff - 262400) / 72.0; + double percentLength = 100; + triggers->LeftRight(0, percentForce, percentLength); + triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); + } + } } } \ No newline at end of file diff --git a/Game Files/InitialD7.cpp b/Game Files/InitialD7.cpp index da96474..4fc618f 100644 --- a/Game Files/InitialD7.cpp +++ b/Game Files/InitialD7.cpp @@ -1,93 +1,185 @@ #include #include "InitialD7.h" +static int carscollide(int ffcollide) { + switch (ffcollide) { + case 0x50F05: + return 16; + case 0x50E05: + return 15; + case 0x50D05: + return 14; + case 0x50C05: + return 13; + case 0x50B05: + return 12; + case 0x50A05: + return 11; + case 0x50905: + return 10; + case 0x50805: + return 9; + case 0x50705: + return 8; + case 0x50605: + return 7; + case 0x050505: + return 6; + case 0x050405: + return 5; + case 0x050305: + return 4; + case 0x50205: + return 3; + case 0x50105: + return 2; + case 0x50005: + return 1; + default: + return 0; + } +} + +static int rubbingwalls(int ffwalls) { + switch (ffwalls) { + case 0x51F08: + return 31; + case 0x51E08: + return 30; + case 0x51D08: + return 29; + case 0x51C08: + return 28; + case 0x51B08: + return 27; + case 0x51A08: + return 26; + case 0x51908: + return 25; + case 0x51808: + return 24; + case 0x51708: + return 23; + case 0x51608: + return 22; + case 0x51508: + return 21; + case 0x51408: + return 20; + case 0x51308: + return 19; + case 0x51208: + return 18; + case 0x51108: + return 17; + case 0x50F08: + return 16; + case 0x50E08: + return 15; + case 0x50D08: + return 14; + case 0x50C08: + return 13; + case 0x50B08: + return 12; + case 0x50A08: + return 11; + case 0x50908: + return 10; + case 0x50808: + return 9; + case 0x50708: + return 8; + case 0x50608: + return 7; + case 0x50508: + return 6; + case 0x50408: + return 5; + case 0x50308: + return 4; + case 0x50208: + return 3; + case 0x50108: + return 2; + case 0x50008: + return 1; + default: + return 0; + } +} + void InitialD7::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectTriggers * triggers) { - wchar_t *settingsFilename = TEXT(".\\FFBPlugin.ini"); - int SineDivision = GetPrivateProfileInt(TEXT("Settings"), TEXT("SineDivision"), 0, settingsFilename); - helpers->log("in ID6 Ffbloop"); - const int ff = GetTeknoParrotFFB(); - std::string ffs = std::to_string(ff); - helpers->log((char *)ffs.c_str()); + int ffrubbingwalls = 0; + int ffcarcollision = 0; + { + wchar_t *settingsFilename = TEXT(".\\FFBPlugin.ini"); + int FFBMode = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBMode"), 0, settingsFilename); + helpers->log("in ID7 Ffbloop"); + const int ff = GetTeknoParrotFFB(); + std::string ffs = std::to_string(ff); + helpers->log((char *)ffs.c_str()); + ffcarcollision = carscollide(ff); + ffrubbingwalls = rubbingwalls(ff); - if ((ff > 0x4005B) & (ff < 0x40080)) - { - helpers->log("moving wheel right"); - double percentForce = (262272 - ff) / 36.0; - double percentLength = 100; - triggers->LeftRight(percentForce, 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); - } - else if ((ff > 0x40100) & (ff < 0x40125)) - { - helpers->log("moving wheel left"); - double percentForce = (ff - 262400) / 36.0; - double percentLength = 100; - triggers->LeftRight(0, percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - } - else if ((ff >= 390001) && (ff <= 399999)) - { - helpers->log("sine1"); - double percentForce = (ff - 390000) / ((SineDivision) / 1.0); - double percentLength = 100; - triggers->Rumble(percentForce, percentLength); - triggers->Sine(120, 100, percentForce); - } - else if ((ff >= 380001) && (ff <= 389999)) - { - helpers->log("sine2"); - double percentLength = 100; - double percentForce = (ff - 380000) / ((SineDivision) / 1.0); - triggers->Rumble(percentForce, percentLength); - triggers->Sine(130, 120, percentForce); - } - else if ((ff >= 370001) && (ff <= 379999)) - { - helpers->log("sine3"); - double percentLength = 100; - double percentForce = (ff - 370000) / ((SineDivision) / 1.0); - triggers->Rumble(percentForce, percentLength); - triggers->Sine(140, 140, percentForce); - } - else if ((ff >= 360001) && (ff <= 369999)) - { - helpers->log("sine4"); - double percentForce = (ff - 360000) / ((SineDivision) / 1.0); - double percentLength = 100; - triggers->Rumble(percentForce, percentLength); - triggers->Sine(150, 150, percentForce); - } - else if ((ff >= 350001) && (ff <= 359999)) - { - helpers->log("sine5"); - double percentLength = 100; - double percentForce = (ff - 350000) / ((SineDivision) / 1.0); - triggers->Rumble(percentForce, percentLength); - triggers->Sine(160, 160, percentForce); - } - else if ((ff >= 340001) && (ff <= 349999)) - { - helpers->log("sine6"); - double percentLength = 100; - double percentForce = (ff - 340000) / ((SineDivision) / 1.0); - triggers->Rumble(percentForce, percentLength); - triggers->Sine(170, 170, percentForce); - } - else if ((ff >= 330001) && (ff <= 339999)) - { - helpers->log("sine7"); - double percentLength = 100; - double percentForce = (ff - 330000) / ((SineDivision) / 1.0); - triggers->Rumble(percentForce, percentLength); - triggers->Sine(180, 180, percentForce); - } - else if ((ff >= 327681) && (ff <= 329999)) - { - helpers->log("sine8"); - double percentLength = 100; - double percentForce = (ff - 327680) / ((SineDivision) / 1.0); - triggers->Rumble(percentForce, percentLength); - triggers->Sine(190, 190, percentForce); + if (ff == 0x60000) + { + triggers->Spring(0.8); + } + if (ffrubbingwalls > 0) // car rubbing against wall + { + double percentLength = 200; + double percentForce = (ffrubbingwalls / 31.0); + triggers->Inertia(percentForce); + triggers->Friction(percentForce); + triggers->Damper(percentForce); + triggers->LeftRight(percentForce, percentForce, percentLength); + } + if (ffcarcollision > 0) //cars colliding or rubbing with each other + { + double percentLength = 200; + double percentForce = (ffcarcollision / 16.0); + triggers->Inertia(percentForce); + triggers->Friction(percentForce); + triggers->Damper(percentForce); + triggers->LeftRight(percentForce, percentForce, percentLength); + } + if (FFBMode == 1) + { + if ((ff > 0x40037) & (ff < 0x40080)) + { + double percentForce = (262272 - ff) / 72.0; + double percentLength = 100; + double powforce = (ff - 262199) / 72.0; + triggers->LeftRight(pow(percentForce, powforce), 0, percentLength); + triggers->Constant(constants->DIRECTION_FROM_LEFT, (pow(percentForce, powforce))); + } + else if ((ff > 0x40100) & (ff < 0x40149)) + { + double percentForce = (ff - 262400) / 72.0; + double percentLength = 100; + double powforce = (262473 - ff) / 72.0; + triggers->LeftRight(0, pow(percentForce, powforce), percentLength); + triggers->Constant(constants->DIRECTION_FROM_RIGHT, (pow(percentForce, powforce))); + } + } + else + { + if ((ff > 0x40037) & (ff < 0x40080)) + { + double percentForce = (262272 - ff) / 72.0; + double percentLength = 100; + triggers->LeftRight(percentForce, 0, percentLength); + triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); + } + else if ((ff > 0x40100) & (ff < 0x40149)) + { + double percentForce = (ff - 262400) / 72.0; + double percentLength = 100; + triggers->LeftRight(0, percentForce, percentLength); + triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); + } + } } } \ No newline at end of file diff --git a/Game Files/InitialD8.cpp b/Game Files/InitialD8.cpp index 9f35b64..244101e 100644 --- a/Game Files/InitialD8.cpp +++ b/Game Files/InitialD8.cpp @@ -1,93 +1,185 @@ #include #include "InitialD8.h" +static int carscollide(int ffcollide) { + switch (ffcollide) { + case 0x50F05: + return 16; + case 0x50E05: + return 15; + case 0x50D05: + return 14; + case 0x50C05: + return 13; + case 0x50B05: + return 12; + case 0x50A05: + return 11; + case 0x50905: + return 10; + case 0x50805: + return 9; + case 0x50705: + return 8; + case 0x50605: + return 7; + case 0x050505: + return 6; + case 0x050405: + return 5; + case 0x050305: + return 4; + case 0x50205: + return 3; + case 0x50105: + return 2; + case 0x50005: + return 1; + default: + return 0; + } +} + +static int rubbingwalls(int ffwalls) { + switch (ffwalls) { + case 0x51F08: + return 31; + case 0x51E08: + return 30; + case 0x51D08: + return 29; + case 0x51C08: + return 28; + case 0x51B08: + return 27; + case 0x51A08: + return 26; + case 0x51908: + return 25; + case 0x51808: + return 24; + case 0x51708: + return 23; + case 0x51608: + return 22; + case 0x51508: + return 21; + case 0x51408: + return 20; + case 0x51308: + return 19; + case 0x51208: + return 18; + case 0x51108: + return 17; + case 0x50F08: + return 16; + case 0x50E08: + return 15; + case 0x50D08: + return 14; + case 0x50C08: + return 13; + case 0x50B08: + return 12; + case 0x50A08: + return 11; + case 0x50908: + return 10; + case 0x50808: + return 9; + case 0x50708: + return 8; + case 0x50608: + return 7; + case 0x50508: + return 6; + case 0x50408: + return 5; + case 0x50308: + return 4; + case 0x50208: + return 3; + case 0x50108: + return 2; + case 0x50008: + return 1; + default: + return 0; + } +} + void InitialD8::FFBLoop(EffectConstants * constants, Helpers * helpers, EffectTriggers * triggers) { - wchar_t *settingsFilename = TEXT(".\\FFBPlugin.ini"); - int SineDivision = GetPrivateProfileInt(TEXT("Settings"), TEXT("SineDivision"), 0, settingsFilename); - helpers->log("in ID6 Ffbloop"); - const int ff = GetTeknoParrotFFB(); - std::string ffs = std::to_string(ff); - helpers->log((char *)ffs.c_str()); + int ffrubbingwalls = 0; + int ffcarcollision = 0; + { + wchar_t *settingsFilename = TEXT(".\\FFBPlugin.ini"); + int FFBMode = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBMode"), 0, settingsFilename); + helpers->log("in ID8 Ffbloop"); + const int ff = GetTeknoParrotFFB(); + std::string ffs = std::to_string(ff); + helpers->log((char *)ffs.c_str()); + ffcarcollision = carscollide(ff); + ffrubbingwalls = rubbingwalls(ff); - if ((ff > 0x4005B) & (ff < 0x40080)) - { - helpers->log("moving wheel right"); - double percentForce = (262272 - ff) / 36.0; - double percentLength = 100; - triggers->LeftRight(percentForce, 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); - } - else if ((ff > 0x40100) & (ff < 0x40125)) - { - helpers->log("moving wheel left"); - double percentForce = (ff - 262400) / 36.0; - double percentLength = 100; - triggers->LeftRight(0, percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - } - else if ((ff >= 390001) && (ff <= 399999)) - { - helpers->log("sine1"); - double percentForce = (ff - 390000) / ((SineDivision) / 1.0); - double percentLength = 100; - triggers->Rumble(percentForce, percentLength); - triggers->Sine(120, 100, percentForce); - } - else if ((ff >= 380001) && (ff <= 389999)) - { - helpers->log("sine2"); - double percentLength = 100; - double percentForce = (ff - 380000) / ((SineDivision) / 1.0); - triggers->Rumble(percentForce, percentLength); - triggers->Sine(130, 120, percentForce); - } - else if ((ff >= 370001) && (ff <= 379999)) - { - helpers->log("sine3"); - double percentLength = 100; - double percentForce = (ff - 370000) / ((SineDivision) / 1.0); - triggers->Rumble(percentForce, percentLength); - triggers->Sine(140, 140, percentForce); - } - else if ((ff >= 360001) && (ff <= 369999)) - { - helpers->log("sine4"); - double percentForce = (ff - 360000) / ((SineDivision) / 1.0); - double percentLength = 100; - triggers->Rumble(percentForce, percentLength); - triggers->Sine(150, 150, percentForce); - } - else if ((ff >= 350001) && (ff <= 359999)) - { - helpers->log("sine5"); - double percentLength = 100; - double percentForce = (ff - 350000) / ((SineDivision) / 1.0); - triggers->Rumble(percentForce, percentLength); - triggers->Sine(160, 160, percentForce); - } - else if ((ff >= 340001) && (ff <= 349999)) - { - helpers->log("sine6"); - double percentLength = 100; - double percentForce = (ff - 340000) / ((SineDivision) / 1.0); - triggers->Rumble(percentForce, percentLength); - triggers->Sine(170, 170, percentForce); - } - else if ((ff >= 330001) && (ff <= 339999)) - { - helpers->log("sine7"); - double percentLength = 100; - double percentForce = (ff - 330000) / ((SineDivision) / 1.0); - triggers->Rumble(percentForce, percentLength); - triggers->Sine(180, 180, percentForce); - } - else if ((ff >= 327681) && (ff <= 329999)) - { - helpers->log("sine8"); - double percentLength = 100; - double percentForce = (ff - 327680) / ((SineDivision) / 1.0); - triggers->Rumble(percentForce, percentLength); - triggers->Sine(190, 190, percentForce); + if (ff == 0x60000) + { + triggers->Spring(0.8); + } + if (ffrubbingwalls > 0) // car rubbing against wall + { + double percentLength = 200; + double percentForce = (ffrubbingwalls / 31.0); + triggers->Inertia(percentForce); + triggers->Friction(percentForce); + triggers->Damper(percentForce); + triggers->LeftRight(percentForce, percentForce, percentLength); + } + if (ffcarcollision > 0) //cars colliding or rubbing with each other + { + double percentLength = 200; + double percentForce = (ffcarcollision / 16.0); + triggers->Inertia(percentForce); + triggers->Friction(percentForce); + triggers->Damper(percentForce); + triggers->LeftRight(percentForce, percentForce, percentLength); + } + if (FFBMode == 1) + { + if ((ff > 0x40037) & (ff < 0x40080)) + { + double percentForce = (262272 - ff) / 72.0; + double percentLength = 100; + double powforce = (ff - 262199) / 72.0; + triggers->LeftRight(pow(percentForce, powforce), 0, percentLength); + triggers->Constant(constants->DIRECTION_FROM_LEFT, (pow(percentForce, powforce))); + } + else if ((ff > 0x40100) & (ff < 0x40149)) + { + double percentForce = (ff - 262400) / 72.0; + double percentLength = 100; + double powforce = (262473 - ff) / 72.0; + triggers->LeftRight(0, pow(percentForce, powforce), percentLength); + triggers->Constant(constants->DIRECTION_FROM_RIGHT, (pow(percentForce, powforce))); + } + } + else + { + if ((ff > 0x40037) & (ff < 0x40080)) + { + double percentForce = (262272 - ff) / 72.0; + double percentLength = 100; + triggers->LeftRight(percentForce, 0, percentLength); + triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); + } + else if ((ff > 0x40100) & (ff < 0x40149)) + { + double percentForce = (ff - 262400) / 72.0; + double percentLength = 100; + triggers->LeftRight(0, percentForce, percentLength); + triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); + } + } } } \ No newline at end of file diff --git a/Game Files/Machstorm.cpp b/Game Files/Machstorm.cpp index fb48309..a50b898 100644 --- a/Game Files/Machstorm.cpp +++ b/Game Files/Machstorm.cpp @@ -30,44 +30,6 @@ void Machstorm::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTrig int vibration = helpers->ReadInt32(0x6390E9, /* relative */ true); int power = helpers->ReadInt32(0x639109, /* relative */ true); - /*if (DomeFix == 1) - { - U16 *buffer = new U16[1920 * 1080 * 2]; - - for (int y = 0; y < 1080; y++) - { - for (int x = 0; x < 1920; x++) - { - float d = 0.5f; - float xf = x / 1920.0f; - float yf = y / 1080.0f; - xf = 2.0f * xf - 1.0f; - yf = 2.0f * yf - 1.0f; - if (0.0f > xf) - { - float k = 0.95f * -xf / (-xf + d); - xf = -k; - yf = yf * (1.0f - k); - } - else - { - float k = 0.95f * xf / (xf + d); - xf = k; - yf = yf * (1.0f - k); - } - xf = 0.5f * xf + 0.5f; - yf = -0.5f * yf - 0.5f; - buffer[(y * 1920 + x) * 2] = 65535 * xf; - buffer[(y * 1920 + x) * 2 + 1] = 65535 * yf; - } - } - - helpers->WriteByte(0x003D2FEE, 0x45, true); - helpers->WriteByte(0x003D3637, 0xB8, true); - helpers->WriteIntPtr(0x003D3638, (U16)buffer, true); - helpers->WriteIntPtr(0x003D363C, 0x0C244489, true); - }*/ - if (vibration == 16842753) { if (power == 61542) diff --git a/Game Files/OutRun2Fake.cpp b/Game Files/OutRun2Fake.cpp index 4a31e6c..4a61e82 100644 --- a/Game Files/OutRun2Fake.cpp +++ b/Game Files/OutRun2Fake.cpp @@ -1,462 +1,363 @@ #include #include "Outrun2Fake.h" +#include "SDL.h" +#include +static EffectTriggers *myTriggers; +static EffectConstants *myConstants; +static Helpers *myHelpers; +static SDL_Event e; +static wchar_t *settingsFilename = TEXT(".\\FFBPlugin.ini"); +static int FFBMode = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBMode"), 0, settingsFilename); +static int ShowButtonNumbersForSetup = GetPrivateProfileInt(TEXT("Settings"), TEXT("ShowButtonNumbersForSetup"), 0, settingsFilename); +static int ChangeGearsViaPlugin = GetPrivateProfileInt(TEXT("Settings"), TEXT("ChangeGearsViaPlugin"), 0, settingsFilename); +static int Gear1 = GetPrivateProfileInt(TEXT("Settings"), TEXT("Gear1"), 0, settingsFilename); +static int Gear2 = GetPrivateProfileInt(TEXT("Settings"), TEXT("Gear2"), 0, settingsFilename); +static int Gear3 = GetPrivateProfileInt(TEXT("Settings"), TEXT("Gear3"), 0, settingsFilename); +static int Gear4 = GetPrivateProfileInt(TEXT("Settings"), TEXT("Gear4"), 0, settingsFilename); +static int Gear5 = GetPrivateProfileInt(TEXT("Settings"), TEXT("Gear5"), 0, settingsFilename); +static int Gear6 = GetPrivateProfileInt(TEXT("Settings"), TEXT("Gear6"), 0, settingsFilename); +static int SpeedStrength; +static int RunningThread(void *ptr) +{ + int cnt; + for (cnt = 0; cnt >= 0; ++cnt) + { + int ff = myHelpers->ReadInt32(0x0827A1A0, /* isRelativeOffset */ false); + int ffwall = myHelpers->ReadInt32(0x08273FAC, /* isRelativeOffset */ false); + int ff3 = myHelpers->ReadInt32(0x0827A1DA, /* isRelativeOffset */ false); + int ff4 = myHelpers->ReadInt32(0x0827A35D, /* isRelativeOffset */ false); + int ff5 = myHelpers->ReadInt32(0x0827A1D4, /* isRelativeOffset */ false); + UINT8 ff6 = myHelpers->ReadByte(0x08670DC8, /* isRelativeOffset */ false); // steering + float ff7 = myHelpers->ReadFloat32(0x08273AD4, /* isRelativeOffset */ false); + UINT8 ff8 = myHelpers->ReadByte(0x08304ADC, /* isRelativeOffset */ false); // 1 when race + UINT8 ff9 = myHelpers->ReadByte(0x086749CA, /* isRelativeOffset */ false); // 1 when menu + UINT8 gear = myHelpers->ReadByte(0x0827A160, /* isRelativeOffset */ false); // gear address + float ffspeed = myHelpers->ReadFloat32(0x08273DF0, /* isRelativeOffset */ false); //speedo + UINT8 static oldgear = 0; + int static oldFloat = 0.0; + int newFloat = ff3; + int static oldFloat1 = 0.0; + int newFloat1 = ff4; + float newgear = gear; + + if ((ffspeed >= 0.1) && (ffspeed <= 80)) + { + SpeedStrength = 10; + } + else if ((ffspeed >= 80.1) && (ffspeed <= 130)) + { + SpeedStrength = 20; + } + else if ((ffspeed >= 130.1) && (ffspeed <= 180)) + { + SpeedStrength = 30; + } + else if ((ffspeed >= 180.1) && (ffspeed <= 220)) + { + SpeedStrength = 40; + } + else if ((ffspeed >= 220.1) && (ffspeed <= 270)) + { + SpeedStrength = 50; + } + else if ((ffspeed >= 270.1) && (ffspeed <= 320)) + { + SpeedStrength = 60; + } + else if ((ffspeed >= 320.1) && (ffspeed <= 380)) + { + SpeedStrength = 70; + } + else if ((ffspeed >= 380.1) && (ffspeed <= 430)) + { + SpeedStrength = 80; + } + else if ((ffspeed >= 430.1) && (ffspeed <= 500)) + { + SpeedStrength = 90; + } + else if ((ffspeed >= 500.1) && (ffspeed <= 1000)) + { + SpeedStrength = 100; + } + else + { + SpeedStrength = 0; + } + + if (FFBMode == 1) + { + if (ff8 == 1) + { + if ((ff6 >= 0x00) & (ff6 < 0x7F)) + { + double percentForce = ((127 - ff6) / 127.0); + double percentLength = 100; + myTriggers->LeftRight(pow(percentForce, 0.5), 0, percentLength); + myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, (pow(percentForce, 0.5))); + } + if ((ff6 > 0x7F) & (ff6 < 0x100)) + { + double percentForce = ((ff6 - 127) / 128.0); + double percentLength = 100; + myTriggers->LeftRight(0, pow(percentForce, 0.5), percentLength); + myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, (pow(percentForce, 0.5))); + } + } + if (ff9 == 1) + { + if ((ff6 >= 0x00) & (ff6 < 0x7F)) + { + double percentForce = ((127 - ff6) / 127.0); + double percentLength = 100; + myTriggers->LeftRight(pow(percentForce, 0.5), 0, percentLength); + myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, (pow(percentForce, 0.5))); + } + if ((ff6 > 0x7F) & (ff6 < 0x100)) + { + double percentForce = ((ff6 - 127) / 128.0); + double percentLength = 100; + myTriggers->LeftRight(0, pow(percentForce, 0.5), percentLength); + myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, (pow(percentForce, 0.5))); + } + } + if (ff5 == 2) + { + if (oldFloat != newFloat) + { + double percentForce = SpeedStrength / 100.0; + double percentLength = 100; + myTriggers->LeftRight(0, pow(percentForce, 0.5), percentLength); + myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, (pow(percentForce, 0.5))); + } + } + else if (ff5 == 1) + { + if (oldFloat != newFloat) + { + double percentForce = SpeedStrength / 100.0; + double percentLength = 100; + myTriggers->LeftRight(0, pow(percentForce, 0.5), percentLength); + myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, (pow(percentForce, 0.5))); + } + } + } + else + { + if (ff8 == 1) + { + if ((ff6 >= 0x00) & (ff6 < 0x7F)) + { + double percentForce = ((127 - ff6) / 127.0); + double percentLength = 100; + myTriggers->LeftRight(percentForce, 0, percentLength); + myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, percentForce); + } + if ((ff6 > 0x7F) & (ff6 < 0x100)) + { + double percentForce = ((ff6 - 127) / 128.0); + double percentLength = 100; + myTriggers->LeftRight(0, percentForce, percentLength); + myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, percentForce); + } + } + if (ff9 == 1) + { + if ((ff6 >= 0x00) & (ff6 < 0x7F)) + { + double percentForce = ((127 - ff6) / 127.0); + double percentLength = 100; + myTriggers->LeftRight(percentForce, 0, percentLength); + myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, percentForce); + } + if ((ff6 > 0x7F) & (ff6 < 0x100)) + { + double percentForce = ((ff6 - 127) / 128.0); + double percentLength = 100; + myTriggers->LeftRight(0, percentForce, percentLength); + myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, percentForce); + } + } + if (ff5 == 2) + { + if (oldFloat != newFloat) + { + double percentForce = SpeedStrength / 100.0; + double percentLength = 100; + myTriggers->LeftRight(0, percentForce, percentLength); + myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, percentForce); + } + } + else if (ff5 == 1) + { + if (oldFloat != newFloat) + { + double percentForce = SpeedStrength / 100.0; + double percentLength = 100; + myTriggers->LeftRight(percentForce, 0, percentLength); + myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, percentForce); + } + } + } + if (oldFloat1 != newFloat1) + { + double percentForce = SpeedStrength / 100.0; + double percentLength = 100; + myTriggers->LeftRight(percentForce, percentForce, percentLength); + myTriggers->Sine(200, 200, percentForce); + } + else if (ff == 8) + { + if (SpeedStrength > 0) + { + double percentForce = 0.1; + double percentLength = 100; + myTriggers->LeftRight(percentForce, percentForce, percentLength); + myTriggers->Sine(70, 70, percentForce); + } + } + else if (ff == 4) + { + if (SpeedStrength > 0) + { + double percentForce = 0.2; + double percentLength = 50; + myTriggers->LeftRight(percentForce, percentForce, percentLength); + myTriggers->Sine(50, 50, percentForce); + } + } + else if (ff == 16) + { + if (SpeedStrength > 0) + { + double percentForce = 0.2; + double percentLength = 50; + myTriggers->LeftRight(percentForce, percentForce, percentLength); + myTriggers->Sine(100, 50, percentForce); + } + } + oldFloat = newFloat; + oldFloat1 = newFloat1; + } + return 0; +} void OutRun2Fake::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) { - wchar_t *settingsFilename = TEXT(".\\FFBPlugin.ini"); - int FFBMode = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBMode"), 0, settingsFilename); - int ff = helpers->ReadInt32(0x0827A1A0, /* isRelativeOffset */ false); - int ffwall = helpers->ReadInt32(0x08273FAC, /* isRelativeOffset */ false); - float ffspeed = helpers->ReadFloat32(0x08273DF0, /* isRelativeOffset */ false); //speedo - int ff3 = helpers->ReadInt32(0x0827A1DA, /* isRelativeOffset */ false); - int ff4 = helpers->ReadInt32(0x0827A35D, /* isRelativeOffset */ false); - int ff5 = helpers->ReadInt32(0x0827A1D4, /* isRelativeOffset */ false); - UINT8 ff6 = helpers->ReadByte(0x08670DC8, /* isRelativeOffset */ false); // steering - float ff7 = helpers->ReadFloat32(0x08273AD4, /* isRelativeOffset */ false); - UINT8 ff8 = helpers->ReadByte(0x08304ADC, /* isRelativeOffset */ false); // 1 when race - UINT8 ff9 = helpers->ReadByte(0x086749CA, /* isRelativeOffset */ false); // 1 when menu - + SDL_Thread *thread; + thread = SDL_CreateThread(RunningThread, "RunningThread", (void *)NULL); + int ff = myHelpers->ReadInt32(0x0827A1A0, /* isRelativeOffset */ false); helpers->log("got value: "); std::string ffs = std::to_string(ff); helpers->log((char *)ffs.c_str()); - int static oldFloat = 0.0; - int newFloat = ff3; - int static oldFloat1 = 0.0; - int newFloat1 = ff4; - if (FFBMode == 1) + while (SDL_WaitEvent(&e) != 0) { - if ((ff6 >= 0x00) & (ff6 < 0x7F) & (ff8 == 1)) + UINT8 transmission = helpers->ReadByte(0x082932C2, /* isRelativeOffset */ false); // Auto or Manual + myTriggers = triggers; + myConstants = constants; + myHelpers = helpers; + if (ShowButtonNumbersForSetup == 1) { - double percentForce = ((127 - ff6) / 127.0); - double percentLength = 100; - triggers->LeftRight(pow(percentForce, 0.5), 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, (pow(percentForce, 0.5))); + if (e.type == SDL_JOYBUTTONDOWN) + { + if (e.jbutton.button == 0) + { + MessageBoxA(NULL, "Button 0 Pressed", "", 0); + } + else if (e.jbutton.button == 1) + { + MessageBoxA(NULL, "Button 1 Pressed", "", 0); + } + else if (e.jbutton.button == 2) + { + MessageBoxA(NULL, "Button 2 Pressed", "", 0); + } + else if (e.jbutton.button == 3) + { + MessageBoxA(NULL, "Button 3 Pressed", "", 0); + } + else if (e.jbutton.button == 4) + { + MessageBoxA(NULL, "Button 4 Pressed", "", 0); + } + else if (e.jbutton.button == 5) + { + MessageBoxA(NULL, "Button 5 Pressed", "", 0); + } + else if (e.jbutton.button == 6) + { + MessageBoxA(NULL, "Button 6 Pressed", "", 0); + } + else if (e.jbutton.button == 7) + { + MessageBoxA(NULL, "Button 7 Pressed", "", 0); + } + else if (e.jbutton.button == 8) + { + MessageBoxA(NULL, "Button 8 Pressed", "", 0); + } + else if (e.jbutton.button == 9) + { + MessageBoxA(NULL, "Button 9 Pressed", "", 0); + } + else if (e.jbutton.button == 10) + { + MessageBoxA(NULL, "Button 10 Pressed", "", 0); + } + else if (e.jbutton.button == 11) + { + MessageBoxA(NULL, "Button 11 Pressed", "", 0); + } + else if (e.jbutton.button == 12) + { + MessageBoxA(NULL, "Button 12 Pressed", "", 0); + } + else if (e.jbutton.button == 13) + { + MessageBoxA(NULL, "Button 13 Pressed", "", 0); + } + else if (e.jbutton.button == 14) + { + MessageBoxA(NULL, "Button 14 Pressed", "", 0); + } + else if (e.jbutton.button == 15) + { + MessageBoxA(NULL, "Button 15 Pressed", "", 0); + } + } } - if ((ff6 > 0x7F) & (ff6 < 0x100) & (ff8 == 1)) + if (e.type == SDL_JOYBUTTONDOWN) { - double percentForce = ((ff6 - 127) / 128.0); - double percentLength = 100; - triggers->LeftRight(0, pow(percentForce, 0.5), percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, (pow(percentForce, 0.5))); - } - if ((ff6 >= 0x00) & (ff6 < 0x7F) & (ff9 == 1)) - { - double percentForce = ((127 - ff6) / 127.0); - double percentLength = 100; - triggers->LeftRight(pow(percentForce, 0.5), 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, (pow(percentForce, 0.5))); - } - if ((ff6 > 0x7F) & (ff6 < 0x100) & (ff9 == 1)) - { - double percentForce = ((ff6 - 127) / 128.0); - double percentLength = 100; - triggers->LeftRight(0, pow(percentForce, 0.5), percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, (pow(percentForce, 0.5))); - } - if ((oldFloat != newFloat) & (ffspeed >= 0.1) & (ffspeed <= 80) & (ff5 == 2)) - { - double percentForce = (0.1); - double percentLength = 100; - triggers->LeftRight(0, pow(percentForce, 0.5), percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, (pow(percentForce, 0.5))); - } - else if ((oldFloat != newFloat) & (ffspeed >= 80.1) & (ffspeed <= 130) & (ff5 == 2)) - { - double percentForce = (0.2); - double percentLength = 100; - triggers->LeftRight(0, pow(percentForce, 0.5), percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, (pow(percentForce, 0.5))); - } - else if ((oldFloat != newFloat) & (ffspeed >= 130.1) & (ffspeed <= 180) & (ff5 == 2)) - { - double percentForce = (0.3); - double percentLength = 100; - triggers->LeftRight(0, pow(percentForce, 0.5), percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, (pow(percentForce, 0.5))); - } - else if ((oldFloat != newFloat) & (ffspeed >= 180.1) & (ffspeed <= 220) & (ff5 == 2)) - { - double percentForce = (0.4); - double percentLength = 100; - triggers->LeftRight(0, pow(percentForce, 0.5), percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, (pow(percentForce, 0.5))); - } - else if ((oldFloat != newFloat) & (ffspeed >= 220.1) & (ffspeed <= 270) & (ff5 == 2)) - { - double percentForce = (0.5); - double percentLength = 100; - triggers->LeftRight(0, pow(percentForce, 0.5), percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, (pow(percentForce, 0.5))); - } - else if ((oldFloat != newFloat) & (ffspeed >= 270.1) & (ffspeed <= 320) & (ff5 == 2)) - { - double percentForce = (0.6); - double percentLength = 100; - triggers->LeftRight(0, pow(percentForce, 0.5), percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, (pow(percentForce, 0.5))); - } - else if ((oldFloat != newFloat) & (ffspeed >= 320.1) & (ffspeed <= 380) & (ff5 == 2)) - { - double percentForce = (0.7); - double percentLength = 100; - triggers->LeftRight(0, pow(percentForce, 0.5), percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, (pow(percentForce, 0.5))); - } - else if ((oldFloat != newFloat) & (ffspeed >= 380.1) & (ffspeed <= 430) & (ff5 == 2)) - { - double percentForce = (0.8); - double percentLength = 100; - triggers->LeftRight(0, pow(percentForce, 0.5), percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, (pow(percentForce, 0.5))); - } - else if ((oldFloat != newFloat) & (ffspeed >= 430.1) & (ffspeed <= 500) & (ff5 == 2)) - { - double percentForce = (0.9); - double percentLength = 100; - triggers->LeftRight(0, pow(percentForce, 0.5), percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, (pow(percentForce, 0.5))); - } - else if ((oldFloat != newFloat) & (ffspeed >= 500.1) & (ffspeed <= 1000) & (ff5 == 2)) - { - double percentForce = (1.0); - double percentLength = 100; - triggers->LeftRight(0, pow(percentForce, 0.5), percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, (pow(percentForce, 0.5))); - } - else if ((oldFloat != newFloat) & (ffspeed >= 0.1) & (ffspeed <= 80) & (ff5 == 1)) - { - double percentForce = (0.1); - double percentLength = 100; - triggers->LeftRight(pow(percentForce, 0.5), 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, (pow(percentForce, 0.5))); - } - else if ((oldFloat != newFloat) & (ffspeed >= 80.1) & (ffspeed <= 130) & (ff5 == 1)) - { - double percentForce = (0.2); - double percentLength = 100; - triggers->LeftRight(pow(percentForce, 0.5), 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, (pow(percentForce, 0.5))); - } - else if ((oldFloat != newFloat) & (ffspeed >= 130.1) & (ffspeed <= 180) & (ff5 == 1)) - { - double percentForce = (0.3); - double percentLength = 100; - triggers->LeftRight(pow(percentForce, 0.5), 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, (pow(percentForce, 0.5))); - } - else if ((oldFloat != newFloat) & (ffspeed >= 180.1) & (ffspeed <= 220) & (ff5 == 1)) - { - double percentForce = (0.4); - double percentLength = 100; - triggers->LeftRight(pow(percentForce, 0.5), 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, (pow(percentForce, 0.5))); - } - else if ((oldFloat != newFloat) & (ffspeed >= 220.1) & (ffspeed <= 270) & (ff5 == 1)) - { - double percentForce = (0.5); - double percentLength = 100; - triggers->LeftRight(pow(percentForce, 0.5), 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, (pow(percentForce, 0.5))); - } - else if ((oldFloat != newFloat) & (ffspeed >= 270.1) & (ffspeed <= 320) & (ff5 == 1)) - { - double percentForce = (0.6); - double percentLength = 100; - triggers->LeftRight(pow(percentForce, 0.5), 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, (pow(percentForce, 0.5))); - } - else if ((oldFloat != newFloat) & (ffspeed >= 320.1) & (ffspeed <= 380) & (ff5 == 1)) - { - double percentForce = (0.7); - double percentLength = 100; - triggers->LeftRight(pow(percentForce, 0.5), 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, (pow(percentForce, 0.5))); - } - else if ((oldFloat != newFloat) & (ffspeed >= 380.1) & (ffspeed <= 430) & (ff5 == 1)) - { - double percentForce = (0.8); - double percentLength = 100; - triggers->LeftRight(pow(percentForce, 0.5), 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, (pow(percentForce, 0.5))); - } - else if ((oldFloat != newFloat) & (ffspeed >= 430.1) & (ffspeed <= 500) & (ff5 == 1)) - { - double percentForce = (0.9); - double percentLength = 100; - triggers->LeftRight(pow(percentForce, 0.5), 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, (pow(percentForce, 0.5))); - } - else if ((oldFloat != newFloat) & (ffspeed >= 500.1) & (ffspeed <= 1000) & (ff5 == 1)) - { - double percentForce = (1.0); - double percentLength = 100; - triggers->LeftRight(pow(percentForce, 0.5), 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, (pow(percentForce, 0.5))); + if (ChangeGearsViaPlugin == 1) + { + if ((ChangeGearsViaPlugin == 1) && (transmission == 1)) + { + if (e.jbutton.button == Gear1) + { + helpers->WriteByte(0x0827A160, 0x01, false); + } + else if (e.jbutton.button == Gear2) + { + helpers->WriteByte(0x0827A160, 0x02, false); + } + else if (e.jbutton.button == Gear3) + { + helpers->WriteByte(0x0827A160, 0x03, false); + } + else if (e.jbutton.button == Gear4) + { + helpers->WriteByte(0x0827A160, 0x04, false); + } + else if (e.jbutton.button == Gear5) + { + helpers->WriteByte(0x0827A160, 0x05, false); + } + else if (e.jbutton.button == Gear6) + { + helpers->WriteByte(0x0827A160, 0x06, false); + } + } + } } } - else - { - if ((ff6 >= 0x00) & (ff6 < 0x7F) & (ff8 == 1) & (FFBMode == 0)) - { - double percentForce = ((127 - ff6) / 127.0); - double percentLength = 100; - triggers->LeftRight(percentForce, 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); - } - if ((ff6 > 0x7F) & (ff6 < 0x100) & (ff8 == 1)) - { - double percentForce = ((ff6 - 127) / 128.0); - double percentLength = 100; - triggers->LeftRight(0, percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - } - if ((ff6 >= 0x00) & (ff6 < 0x7F) & (ff9 == 1)) - { - double percentForce = ((127 - ff6) / 127.0); - double percentLength = 100; - triggers->LeftRight(percentForce, 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); - } - if ((ff6 > 0x7F) & (ff6 < 0x100) & (ff9 == 1)) - { - double percentForce = ((ff6 - 127) / 128.0); - double percentLength = 100; - triggers->LeftRight(0, percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - } - if ((oldFloat != newFloat) & (ffspeed >= 0.1) & (ffspeed <= 80) & (ff5 == 2)) - { - double percentForce = (0.1); - double percentLength = 100; - triggers->LeftRight(0, percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - } - else if ((oldFloat != newFloat) & (ffspeed >= 80.1) & (ffspeed <= 130) & (ff5 == 2)) - { - double percentForce = (0.2); - double percentLength = 100; - triggers->LeftRight(0, percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - } - else if ((oldFloat != newFloat) & (ffspeed >= 130.1) & (ffspeed <= 180) & (ff5 == 2)) - { - double percentForce = (0.3); - double percentLength = 100; - triggers->LeftRight(0, percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - } - else if ((oldFloat != newFloat) & (ffspeed >= 180.1) & (ffspeed <= 220) & (ff5 == 2)) - { - double percentForce = (0.4); - double percentLength = 100; - triggers->LeftRight(0, percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - } - else if ((oldFloat != newFloat) & (ffspeed >= 220.1) & (ffspeed <= 270) & (ff5 == 2)) - { - double percentForce = (0.5); - double percentLength = 100; - triggers->LeftRight(0, percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - } - else if ((oldFloat != newFloat) & (ffspeed >= 270.1) & (ffspeed <= 320) & (ff5 == 2)) - { - double percentForce = (0.6); - double percentLength = 100; - triggers->LeftRight(0, percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - } - else if ((oldFloat != newFloat) & (ffspeed >= 320.1) & (ffspeed <= 380) & (ff5 == 2)) - { - double percentForce = (0.7); - double percentLength = 100; - triggers->LeftRight(0, percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - } - else if ((oldFloat != newFloat) & (ffspeed >= 380.1) & (ffspeed <= 430) & (ff5 == 2)) - { - double percentForce = (0.8); - double percentLength = 100; - triggers->LeftRight(0, percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - } - else if ((oldFloat != newFloat) & (ffspeed >= 430.1) & (ffspeed <= 500) & (ff5 == 2)) - { - double percentForce = (0.9); - double percentLength = 100; - triggers->LeftRight(0, percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - } - else if ((oldFloat != newFloat) & (ffspeed >= 500.1) & (ffspeed <= 1000) & (ff5 == 2)) - { - double percentForce = (1.0); - double percentLength = 100; - triggers->LeftRight(0, percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - } - else if ((oldFloat != newFloat) & (ffspeed >= 0.1) & (ffspeed <= 80) & (ff5 == 1)) - { - double percentForce = (0.1); - double percentLength = 100; - triggers->LeftRight(percentForce, 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); - } - else if ((oldFloat != newFloat) & (ffspeed >= 80.1) & (ffspeed <= 130) & (ff5 == 1)) - { - double percentForce = (0.2); - double percentLength = 100; - triggers->LeftRight(percentForce, 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); - } - else if ((oldFloat != newFloat) & (ffspeed >= 130.1) & (ffspeed <= 180) & (ff5 == 1)) - { - double percentForce = (0.3); - double percentLength = 100; - triggers->LeftRight(percentForce, 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); - } - else if ((oldFloat != newFloat) & (ffspeed >= 180.1) & (ffspeed <= 220) & (ff5 == 1)) - { - double percentForce = (0.4); - double percentLength = 100; - triggers->LeftRight(percentForce, 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); - } - else if ((oldFloat != newFloat) & (ffspeed >= 220.1) & (ffspeed <= 270) & (ff5 == 1)) - { - double percentForce = (0.5); - double percentLength = 100; - triggers->LeftRight(percentForce, 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); - } - else if ((oldFloat != newFloat) & (ffspeed >= 270.1) & (ffspeed <= 320) & (ff5 == 1)) - { - double percentForce = (0.6); - double percentLength = 100; - triggers->LeftRight(percentForce, 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); - } - else if ((oldFloat != newFloat) & (ffspeed >= 320.1) & (ffspeed <= 380) & (ff5 == 1)) - { - double percentForce = (0.7); - double percentLength = 100; - triggers->LeftRight(percentForce, 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); - } - else if ((oldFloat != newFloat) & (ffspeed >= 380.1) & (ffspeed <= 430) & (ff5 == 1)) - { - double percentForce = (0.8); - double percentLength = 100; - triggers->LeftRight(percentForce, 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); - } - else if ((oldFloat != newFloat) & (ffspeed >= 430.1) & (ffspeed <= 500) & (ff5 == 1)) - { - double percentForce = (0.9); - double percentLength = 100; - triggers->LeftRight(percentForce, 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); - } - else if ((oldFloat != newFloat) & (ffspeed >= 500.1) & (ffspeed <= 1000) & (ff5 == 1)) - { - double percentForce = (1.0); - double percentLength = 100; - triggers->LeftRight(percentForce, 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); - } - } - - if ((oldFloat1 != newFloat1) & (ffspeed >= 0.1) & (ffspeed <= 50)) - { - double percentForce = (0.1); - double percentLength = 100; - triggers->LeftRight(percentForce, percentForce, percentLength); - triggers->Sine(200, 200, percentForce); - } - else if ((oldFloat1 != newFloat1) & (ffspeed >= 50.1) & (ffspeed <= 100)) - { - double percentForce = (0.2); - double percentLength = 100; - triggers->LeftRight(percentForce, percentForce, percentLength); - triggers->Sine(200, 200, percentForce); - } - else if ((oldFloat1 != newFloat1) & (ffspeed >= 100.1) & (ffspeed <= 150)) - { - double percentForce = (0.3); - double percentLength = 100; - triggers->LeftRight(percentForce, percentForce, percentLength); - triggers->Sine(200, 200, percentForce); - } - else if ((oldFloat1 != newFloat1) & (ffspeed >= 150.1) & (ffspeed <= 200)) - { - double percentForce = (0.4); - double percentLength = 100; - triggers->LeftRight(percentForce, percentForce, percentLength); - triggers->Sine(200, 200, percentForce); - } - else if ((oldFloat1 != newFloat1) & (ffspeed >= 200.1) & (ffspeed <= 250)) - { - double percentForce = (0.5); - double percentLength = 100; - triggers->LeftRight(percentForce, percentForce, percentLength); - triggers->Sine(200, 200, percentForce); - } - else if ((oldFloat1 != newFloat1) & (ffspeed >= 250.1) & (ffspeed <= 300)) - { - double percentForce = (0.6); - double percentLength = 100; - triggers->LeftRight(percentForce, percentForce, percentLength); - triggers->Sine(200, 200, percentForce); - } - else if ((oldFloat1 != newFloat1) & (ffspeed >= 300.1) & (ffspeed <= 350)) - { - double percentForce = (0.7); - double percentLength = 100; - triggers->LeftRight(percentForce, percentForce, percentLength); - triggers->Sine(200, 200, percentForce); - } - else if ((oldFloat1 != newFloat1) & (ffspeed >= 350.1) & (ffspeed <= 400)) - { - double percentForce = (0.8); - double percentLength = 100; - triggers->LeftRight(percentForce, percentForce, percentLength); - triggers->Sine(200, 200, percentForce); - } - else if ((oldFloat1 != newFloat1) & (ffspeed >= 450.1) & (ffspeed <= 500)) - { - double percentForce = (0.9); - double percentLength = 100; - triggers->LeftRight(percentForce, percentForce, percentLength); - triggers->Sine(200, 200, percentForce); - } - else if ((oldFloat1 != newFloat1) & (ffspeed >= 500.1) & (ffspeed <= 1000)) - { - double percentForce = (1.0); - double percentLength = 100; - triggers->LeftRight(percentForce, percentForce, percentLength); - triggers->Sine(200, 200, percentForce); - } - else if ((ff == 8) & (ffspeed >= 0.1) & (ffspeed <= 1000)) - { - double percentForce = 0.1; - double percentLength = 100; - triggers->LeftRight(percentForce, percentForce, percentLength); - triggers->Sine(70, 70, percentForce); - } - else if ((ff == 4) & (ffspeed >= 0.1) & (ffspeed <= 1000)) - { - double percentForce = 0.2; - double percentLength = 50; - triggers->LeftRight(percentForce, percentForce, percentLength); - triggers->Sine(50, 50, percentForce); - } - else if ((ff == 16) & (ffspeed >= 0.1) & (ffspeed <= 1000)) - { - double percentForce = 0.2; - double percentLength = 50; - triggers->LeftRight(percentForce, percentForce, percentLength); - triggers->Sine(100, 50, percentForce); - } - oldFloat = newFloat; - oldFloat1 = newFloat1; } \ No newline at end of file diff --git a/Game Files/OutRun2Real.cpp b/Game Files/OutRun2Real.cpp index 63e1d36..ecd50ad 100644 --- a/Game Files/OutRun2Real.cpp +++ b/Game Files/OutRun2Real.cpp @@ -1,62 +1,266 @@ #include #include "Outrun2Real.h" -EffectTriggers* myTriggers; -EffectConstants *myConstants; -Helpers *myHelpers; +#include "SDL.h" +#include +static EffectTriggers *myTriggers; +static EffectConstants *myConstants; +static Helpers *myHelpers; +static SDL_Event e; +static int SpeedStrength; +static wchar_t *settingsFilename = TEXT(".\\FFBPlugin.ini"); +static int ShowButtonNumbersForSetup = GetPrivateProfileInt(TEXT("Settings"), TEXT("ShowButtonNumbersForSetup"), 0, settingsFilename); +static int ChangeGearsViaPlugin = GetPrivateProfileInt(TEXT("Settings"), TEXT("ChangeGearsViaPlugin"), 0, settingsFilename); +static int Gear1 = GetPrivateProfileInt(TEXT("Settings"), TEXT("Gear1"), 0, settingsFilename); +static int Gear2 = GetPrivateProfileInt(TEXT("Settings"), TEXT("Gear2"), 0, settingsFilename); +static int Gear3 = GetPrivateProfileInt(TEXT("Settings"), TEXT("Gear3"), 0, settingsFilename); +static int Gear4 = GetPrivateProfileInt(TEXT("Settings"), TEXT("Gear4"), 0, settingsFilename); +static int Gear5 = GetPrivateProfileInt(TEXT("Settings"), TEXT("Gear5"), 0, settingsFilename); +static int Gear6 = GetPrivateProfileInt(TEXT("Settings"), TEXT("Gear6"), 0, settingsFilename); + +//B hitting right wall hard constant +//1B hitting left wall hard constant +//2 driving on grass sine +//10 scraping car against side rail left side +//4 driving from grass, sand to road if from right side +//14 driving from grass, sand to road if from left side +//00 when over grass, sand etc void SendForceFeedback(__int8 force) { - if (force >= 1 && force <= 0x0F) + float ffspeed = myHelpers->ReadFloat32(0x08273DF0, /* isRelativeOffset */ false); //speedo + /*char gay[256]; + memset(gay, 0, 256); + sprintf(gay, "hex print: %08X", force); + OutputDebugStringA(gay);*/ + if ((force == 0x10) || (force == 0x0B) || (force == 0x04)) { - // direction from right => makes wheel turn left - double percentForce = (16 - force) / 15.0; + double percentForce = SpeedStrength / 100.0; double percentLength = 100; - //myHelpers->log("got value: "); - //std::string ffs = std::to_string(force); - //myHelpers->log((char *)ffs.c_str()); myTriggers->LeftRight(0, percentForce, percentLength); - myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, percentForce); + myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, percentForce); } - else if (force >= 0x10 && force <= 0x1E) + if ((force == 0x00) || (force == 0x1B) || (force == 0x14)) { - // direction from left => makes wheel turn right - double percentForce = (31 - force) / 15.0; + double percentForce = SpeedStrength / 100.0; double percentLength = 100; - //myHelpers->log("got value: "); - //std::string ffs = std::to_string(force); - //myHelpers->log((char *)ffs.c_str()); myTriggers->LeftRight(percentForce, 0, percentLength); myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, percentForce); } + if (force == 0x02) + { + double percentForce = SpeedStrength / 100.0; + double percentLength = 100; + myTriggers->LeftRight(percentForce, percentForce, percentLength); + myTriggers->Sine(70, 80, percentForce); + } } signed int cdecl or2FfbFunction(unsigned __int8 unk1, unsigned __int8 unk2, unsigned __int8 force, char unk3) { + int SpringStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("SpringStrength"), 0, TEXT(".\\FFBPlugin.ini")); if (unk1 == 0x7D) { - // not used afaik + //not used } if (unk1 == 0x7B) { SendForceFeedback(force); } - + else if (unk1 != 0x7B) + { + double percentForce = SpringStrength / 100.0; + myTriggers->Springi(percentForce); + } return 0; } -void OutRun2Real::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) { - bool init = false; - if (!init) +static int RunningThread(void *ptr) +{ + int cnt; + for (cnt = 0; cnt >= 0; ++cnt) { - DWORD tempdw = 0x08105A48; - DWORD cock = (DWORD)(void *)or2FfbFunction; - DWORD tempdw2 = cock - tempdw - 5; - *(BYTE *)tempdw = 0xE9; - *(DWORD *)(tempdw + 1) = tempdw2; - init = true; - } + UINT8 gear = myHelpers->ReadByte(0x0827A160, /* isRelativeOffset */ false); // gear address + UINT8 ff8 = myHelpers->ReadByte(0x08304ADC, /* isRelativeOffset */ false); // 1 when race + float ffspeed = myHelpers->ReadFloat32(0x08273DF0, /* isRelativeOffset */ false); //speedo + UINT8 static oldgear = 0; + float newgear = gear; - myTriggers = triggers; - myConstants = constants; - myHelpers = helpers; + if ((ffspeed >= 0.1) && (ffspeed <= 80)) + { + SpeedStrength = 10; + } + else if ((ffspeed >= 80.1) && (ffspeed <= 130)) + { + SpeedStrength = 20; + } + else if ((ffspeed >= 130.1) && (ffspeed <= 180)) + { + SpeedStrength = 30; + } + else if ((ffspeed >= 180.1) && (ffspeed <= 220)) + { + SpeedStrength = 40; + } + else if ((ffspeed >= 220.1) && (ffspeed <= 270)) + { + SpeedStrength = 50; + } + else if ((ffspeed >= 270.1) && (ffspeed <= 320)) + { + SpeedStrength = 60; + } + else if ((ffspeed >= 320.1) && (ffspeed <= 380)) + { + SpeedStrength = 70; + } + else if ((ffspeed >= 380.1) && (ffspeed <= 430)) + { + SpeedStrength = 80; + } + else if ((ffspeed >= 430.1) && (ffspeed <= 500)) + { + SpeedStrength = 90; + } + else if ((ffspeed >= 500.1) && (ffspeed <= 1000)) + { + SpeedStrength = 100; + } + else + { + SpeedStrength = 0; + } + + if ((oldgear != newgear) && (ff8 == 1) && (ffspeed >= 0.1)) + { + double percentForce = 0.1; + double percentLength = 100; + myTriggers->Sine(240, 320, percentForce); + myTriggers->LeftRight(percentForce, percentForce, percentLength); + } + oldgear = newgear; + } + return 0; +} + +void OutRun2Real::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) { + SDL_Thread *thread; + thread = SDL_CreateThread(RunningThread, "RunningThread", (void *)NULL); + + while (SDL_WaitEvent(&e) != 0) + { + bool init = true; + if (init) + { + DWORD tempdw = 0x08105A48; + DWORD loadffb = (DWORD)(void *)or2FfbFunction; + DWORD tempdw2 = loadffb - tempdw - 5; + *(BYTE *)tempdw = 0xE9; + *(DWORD *)(tempdw + 1) = tempdw2; + init = false; + } + UINT8 transmission = helpers->ReadByte(0x082932C2, /* isRelativeOffset */ false); // Auto or Manual + myTriggers = triggers; + myConstants = constants; + myHelpers = helpers; + if (ShowButtonNumbersForSetup == 1) + { + if (e.type == SDL_JOYBUTTONDOWN) + { + if (e.jbutton.button == 0) + { + MessageBoxA(NULL, "Button 0 Pressed", "", 0); + } + else if (e.jbutton.button == 1) + { + MessageBoxA(NULL, "Button 1 Pressed", "", 0); + } + else if (e.jbutton.button == 2) + { + MessageBoxA(NULL, "Button 2 Pressed", "", 0); + } + else if (e.jbutton.button == 3) + { + MessageBoxA(NULL, "Button 3 Pressed", "", 0); + } + else if (e.jbutton.button == 4) + { + MessageBoxA(NULL, "Button 4 Pressed", "", 0); + } + else if (e.jbutton.button == 5) + { + MessageBoxA(NULL, "Button 5 Pressed", "", 0); + } + else if (e.jbutton.button == 6) + { + MessageBoxA(NULL, "Button 6 Pressed", "", 0); + } + else if (e.jbutton.button == 7) + { + MessageBoxA(NULL, "Button 7 Pressed", "", 0); + } + else if (e.jbutton.button == 8) + { + MessageBoxA(NULL, "Button 8 Pressed", "", 0); + } + else if (e.jbutton.button == 9) + { + MessageBoxA(NULL, "Button 9 Pressed", "", 0); + } + else if (e.jbutton.button == 10) + { + MessageBoxA(NULL, "Button 10 Pressed", "", 0); + } + else if (e.jbutton.button == 11) + { + MessageBoxA(NULL, "Button 11 Pressed", "", 0); + } + else if (e.jbutton.button == 12) + { + MessageBoxA(NULL, "Button 12 Pressed", "", 0); + } + else if (e.jbutton.button == 13) + { + MessageBoxA(NULL, "Button 13 Pressed", "", 0); + } + else if (e.jbutton.button == 14) + { + MessageBoxA(NULL, "Button 14 Pressed", "", 0); + } + else if (e.jbutton.button == 15) + { + MessageBoxA(NULL, "Button 15 Pressed", "", 0); + } + } + } + if (e.type == SDL_JOYBUTTONDOWN) + { + if ((ChangeGearsViaPlugin == 1) && (transmission == 1)) + { + if (e.jbutton.button == Gear1) + { + helpers->WriteByte(0x0827A160, 0x01, false); + } + else if (e.jbutton.button == Gear2) + { + helpers->WriteByte(0x0827A160, 0x02, false); + } + else if (e.jbutton.button == Gear3) + { + helpers->WriteByte(0x0827A160, 0x03, false); + } + else if (e.jbutton.button == Gear4) + { + helpers->WriteByte(0x0827A160, 0x04, false); + } + else if (e.jbutton.button == Gear5) + { + helpers->WriteByte(0x0827A160, 0x05, false); + } + else if (e.jbutton.button == Gear6) + { + helpers->WriteByte(0x0827A160, 0x06, false); + } + } + } + } } \ No newline at end of file diff --git a/Game Files/RoadFighters3D.cpp b/Game Files/RoadFighters3D.cpp index 0ce8536..1f84bb8 100644 --- a/Game Files/RoadFighters3D.cpp +++ b/Game Files/RoadFighters3D.cpp @@ -2,65 +2,279 @@ #include "SDL.h" #include "RoadFighters3D.h" #include +static EffectTriggers *myTriggers; +static EffectConstants *myConstants; +static Helpers *myHelpers; extern HINSTANCE gl_hjgtDll; extern HINSTANCE gl_hlibavs; extern int joystick_index1; extern int joystick_index2; extern SDL_Joystick* GameController2; +static bool avoiderror = true; +static bool testbuttonA; +static bool servicebuttonA; +static bool threedeebuttonA; +static bool viewbuttonA; +static bool leverupA; +static bool leverdownA; +static bool leverleftA; +static bool leverrightA; +static bool stophack; +static SDL_Event e; + +static wchar_t *settingsFilename = TEXT(".\\FFBPlugin.ini"); +static int Only2D = GetPrivateProfileInt(TEXT("Settings"), TEXT("Only2D"), 0, settingsFilename); +static int HackToSkipMenuError = GetPrivateProfileInt(TEXT("Settings"), TEXT("HackToSkipMenuError"), 0, settingsFilename); +static int HackToCloseLibmovieErrorAuto = GetPrivateProfileInt(TEXT("Settings"), TEXT("HackToCloseLibmovieErrorAuto"), 0, settingsFilename); +static int InputDeviceWheelEnable = GetPrivateProfileInt(TEXT("Settings"), TEXT("InputDeviceWheelEnable"), 0, settingsFilename); +static int InputDeviceWheelSteeringAxis = GetPrivateProfileInt(TEXT("Settings"), TEXT("InputDeviceWheelSteeringAxis"), 0, settingsFilename); +static int InputDeviceWheelAcclAxis = GetPrivateProfileInt(TEXT("Settings"), TEXT("InputDeviceWheelAcclAxis"), 0, settingsFilename); +static int InputDeviceWheelBrakeAxis = GetPrivateProfileInt(TEXT("Settings"), TEXT("InputDeviceWheelBrakeAxis"), 0, settingsFilename); +static int InputDeviceWheelReverseAxis = GetPrivateProfileInt(TEXT("Settings"), TEXT("InputDeviceWheelReverseAxis"), 0, settingsFilename); +static int InputDeviceCombinedPedals = GetPrivateProfileInt(TEXT("Settings"), TEXT("InputDeviceCombinedPedals"), 0, settingsFilename); +static int SteeringDeadzone = GetPrivateProfileInt(TEXT("Settings"), TEXT("SteeringDeadzone"), 0, settingsFilename); +static int PedalDeadzone = GetPrivateProfileInt(TEXT("Settings"), TEXT("PedalDeadzone"), 0, settingsFilename); +static int SequentialGears = GetPrivateProfileInt(TEXT("Settings"), TEXT("SequentialGears"), 0, settingsFilename); +static int FFBMode = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBMode"), 0, settingsFilename); +static int ShowButtonNumbersForSetup = GetPrivateProfileInt(TEXT("Settings"), TEXT("ShowButtonNumbersForSetup"), 0, settingsFilename); +static int ShowAxisForSetup = GetPrivateProfileInt(TEXT("Settings"), TEXT("ShowAxisForSetup"), 0, settingsFilename); +static int ExitButton = GetPrivateProfileInt(TEXT("Settings"), TEXT("ExitButton"), 0, settingsFilename); +static int TestButton = GetPrivateProfileInt(TEXT("Settings"), TEXT("TestButton"), 0, settingsFilename); +static int ServiceButton = GetPrivateProfileInt(TEXT("Settings"), TEXT("ServiceButton"), 0, settingsFilename); +static int CreditButton = GetPrivateProfileInt(TEXT("Settings"), TEXT("CreditButton"), 0, settingsFilename); +static int ViewButton = GetPrivateProfileInt(TEXT("Settings"), TEXT("ViewButton"), 0, settingsFilename); +static int ThreeDimensionalButton = GetPrivateProfileInt(TEXT("Settings"), TEXT("ThreeDimensionalButton"), 0, settingsFilename); +static int leverUp = GetPrivateProfileInt(TEXT("Settings"), TEXT("leverUp"), 0, settingsFilename); +static int leverDown = GetPrivateProfileInt(TEXT("Settings"), TEXT("leverDown"), 0, settingsFilename); +static int leverLeft = GetPrivateProfileInt(TEXT("Settings"), TEXT("leverLeft"), 0, settingsFilename); +static int leverRight = GetPrivateProfileInt(TEXT("Settings"), TEXT("leverRight"), 0, settingsFilename); +static int ExitButtonDevice2 = GetPrivateProfileInt(TEXT("Settings"), TEXT("ExitButtonDevice2"), 0, settingsFilename); +static int TestButtonDevice2 = GetPrivateProfileInt(TEXT("Settings"), TEXT("TestButtonDevice2"), 0, settingsFilename); +static int ServiceButtonDevice2 = GetPrivateProfileInt(TEXT("Settings"), TEXT("ServiceButtonDevice2"), 0, settingsFilename); +static int CreditButtonDevice2 = GetPrivateProfileInt(TEXT("Settings"), TEXT("CreditButtonDevice2"), 0, settingsFilename); +static int ViewButtonDevice2 = GetPrivateProfileInt(TEXT("Settings"), TEXT("ViewButtonDevice2"), 0, settingsFilename); +static int ThreeDimensionalButtonDevice2 = GetPrivateProfileInt(TEXT("Settings"), TEXT("ThreeDimensionalButtonDevice2"), 0, settingsFilename); +static int leverUpDevice2 = GetPrivateProfileInt(TEXT("Settings"), TEXT("leverUpDevice2"), 0, settingsFilename); +static int leverDownDevice2 = GetPrivateProfileInt(TEXT("Settings"), TEXT("leverDownDevice2"), 0, settingsFilename); +static int leverLeftDevice2 = GetPrivateProfileInt(TEXT("Settings"), TEXT("leverLeftDevice2"), 0, settingsFilename); +static int leverRightDevice2 = GetPrivateProfileInt(TEXT("Settings"), TEXT("leverRightDevice2"), 0, settingsFilename); + +static int RunningThread(void *ptr) +{ + int cnt; + for (cnt = 0; cnt >= 0; ++cnt) + { + int menuvalue = myHelpers->ReadIntPtr((INT_PTR)gl_hjgtDll + 0x0094BFFC, false); + int menuvalue1 = myHelpers->ReadIntPtr((INT_PTR)menuvalue + 0x46C, false); + int serviceread3 = myHelpers->ReadIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, false); + int timer = myHelpers->ReadIntPtr((INT_PTR)gl_hjgtDll + 0x954394, false); + int cabid = myHelpers->ReadByte((INT_PTR)gl_hjgtDll + 0x951034, false); + int cabid2 = myHelpers->ReadByte((INT_PTR)gl_hjgtDll + 0x952B9C, false); + float timeroutofmenu = myHelpers->ReadByte((INT_PTR)gl_hjgtDll + 0x94BEE8, false); + if (HackToCloseLibmovieErrorAuto == 1) + { + //Remove fucken window error popup + HWND hWnd = FindWindowA(0, ("Libmovie Error Report")); + if (hWnd > NULL) + { + SendMessage(hWnd, WM_CLOSE, NULL, NULL); + } + } + if (HackToSkipMenuError == 1) + { + // Hack to quickly bypass error at start + if (avoiderror) + { + if (cabid > 0) + { + if (menuvalue1 > 700000) + { + myHelpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x02, false); + } + if (menuvalue1 == 0) + { + SDL_Delay(50); + myHelpers->WriteIntPtr((INT_PTR)menuvalue + 0x46C, 0x0F, false); + } + if (menuvalue1 == 15) + { + myHelpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x01, false); + } + if (timeroutofmenu != 0) + { + myHelpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x00, false); + avoiderror = false; + } + } + else + { + if (menuvalue1 > 700000) + { + myHelpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x01, false); + } + if (timeroutofmenu != 0) + { + myHelpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x00, false); + avoiderror = false; + } + } + } + } + + if (Only2D == 1) + { + //2D Only + myHelpers->WriteNop((INT_PTR)gl_hjgtDll + 0x24C9F, false); + myHelpers->WriteNop((INT_PTR)gl_hjgtDll + 0x24CA0, false); + myHelpers->WriteNop((INT_PTR)gl_hjgtDll + 0x24CA1, false); + myHelpers->WriteNop((INT_PTR)gl_hjgtDll + 0x24CAA, false); + myHelpers->WriteNop((INT_PTR)gl_hjgtDll + 0x24CAB, false); + myHelpers->WriteNop((INT_PTR)gl_hjgtDll + 0x24CAC, false); + myHelpers->WriteNop((INT_PTR)gl_hjgtDll + 0x24CBA, false); + myHelpers->WriteNop((INT_PTR)gl_hjgtDll + 0x24CBB, false); + myHelpers->WriteNop((INT_PTR)gl_hjgtDll + 0x24CBC, false); + myHelpers->WriteNop((INT_PTR)gl_hjgtDll + 0x478F, false); + myHelpers->WriteNop((INT_PTR)gl_hjgtDll + 0x4790, false); + myHelpers->WriteNop((INT_PTR)gl_hjgtDll + 0x4791, false); + myHelpers->WriteNop((INT_PTR)gl_hjgtDll + 0x3E6DB, false); + myHelpers->WriteNop((INT_PTR)gl_hjgtDll + 0x3E6DC, false); + myHelpers->WriteNop((INT_PTR)gl_hjgtDll + 0x3E6DD, false); + myHelpers->WriteNop((INT_PTR)gl_hjgtDll + 0x1391D8, false); + myHelpers->WriteNop((INT_PTR)gl_hjgtDll + 0x1391D9, false); + myHelpers->WriteNop((INT_PTR)gl_hjgtDll + 0x1391DA, false); + myHelpers->WriteNop((INT_PTR)gl_hjgtDll + 0x1391EF, false); + myHelpers->WriteNop((INT_PTR)gl_hjgtDll + 0x1391F0, false); + myHelpers->WriteNop((INT_PTR)gl_hjgtDll + 0x1391F1, false); + myHelpers->WriteNop((INT_PTR)gl_hjgtDll + 0x5962F, false); + myHelpers->WriteNop((INT_PTR)gl_hjgtDll + 0x59630, false); + myHelpers->WriteNop((INT_PTR)gl_hjgtDll + 0x59631, false); + int TwoDee1 = myHelpers->ReadIntPtr((INT_PTR)gl_hjgtDll + 0x00946DA0, false); + int TwoDee2 = myHelpers->ReadIntPtr((INT_PTR)TwoDee1 + 0x38, false); + int TwoDee3 = myHelpers->ReadIntPtr((INT_PTR)TwoDee2 + 0x94, false); + myHelpers->WriteIntPtr((INT_PTR)TwoDee3 + 0x74, 0x00, false); + } + if (InputDeviceWheelEnable == 1) + { + //Write New Calibration Values + myHelpers->WriteByte((INT_PTR)gl_hjgtDll + 0x7D2B00, 0x00, false); + myHelpers->WriteByte((INT_PTR)gl_hjgtDll + 0x7D2B01, 0x7F, false); + myHelpers->WriteByte((INT_PTR)gl_hjgtDll + 0x7D2B0C, 0x00, false); + myHelpers->WriteByte((INT_PTR)gl_hjgtDll + 0x7D2B0D, 0xFF, false); + myHelpers->WriteByte((INT_PTR)gl_hjgtDll + 0x7D2B14, 0x00, false); + myHelpers->WriteByte((INT_PTR)gl_hjgtDll + 0x7D2B15, 0xFF, false); + myHelpers->WriteByte((INT_PTR)gl_hjgtDll + 0x7D2B10, 0x00, false); + myHelpers->WriteByte((INT_PTR)gl_hjgtDll + 0x7D2B11, 0xFF, false); + myHelpers->WriteByte((INT_PTR)gl_hjgtDll + 0x7D2B21, 0x00, false); + + // Remove error flashing + myHelpers->WriteByte((INT_PTR)gl_hjgtDll + 0x951154, 0x01, false); + myHelpers->WriteByte((INT_PTR)gl_hjgtDll + 0x951155, 0x01, false); + myHelpers->WriteByte((INT_PTR)gl_hjgtDll + 0x951156, 0x01, false); + } + + UINT8 ff1 = myHelpers->ReadByte((INT_PTR)gl_hjgtDll + 0x7D2BB9, false); + UINT8 ff2 = myHelpers->ReadByte((INT_PTR)gl_hjgtDll + 0x7D2BBA, false); + UINT8 ff3 = myHelpers->ReadByte((INT_PTR)gl_hjgtDll + 0x7D2BBB, false); + UINT8 ff4 = myHelpers->ReadByte((INT_PTR)gl_hjgtDll + 0x7D2BBC, false); + //Change timer back to 0 when test menu & FFB Only while timer above 0 + if ((timer != 0) || (menuvalue1 == 0x00)) + { + if (menuvalue1 == 0x00) + { + myHelpers->WriteFloat32((INT_PTR)gl_hjgtDll + 0x954394, 0, false); + } + if ((ff3 != 0x00) && (ff4 != 0x00)) + { + if (FFBMode == 0) + { + if ((ff2 > 0x00) & (ff2 < 0x40)) + { + double percentForce = (ff2) / 63.0; + double percentLength = 100; + myTriggers->LeftRight(percentForce, percentForce, percentLength); + myTriggers->Sine(120, 120, percentForce); + } + if ((ff1 > 0x00) & (ff1 < 0x08)) + { + //helpers->log("moving wheel left"); + double percentForce = (ff1) / 7.0; + double percentLength = 100; + myTriggers->LeftRight(0, percentForce, percentLength); + myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, percentForce); + } + else if ((ff1 > 0x07) & (ff1 < 0x10)) + { + //helpers->log("moving wheel right"); + double percentForce = (16 - ff1) / 8.0; + double percentLength = 100; + myTriggers->LeftRight(percentForce, 0, percentLength); + myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, percentForce); + } + } + else if (FFBMode == 1) + { + if ((ff2 > 0x00) & (ff2 < 0x40)) + { + double percentForce = (ff2) / 63.0; + double percentLength = 100; + myTriggers->LeftRight(pow(percentForce, 0.5), pow(percentForce, 0.5), percentLength); + myTriggers->Sine(120, 120, pow(percentForce, 0.5)); + } + if ((ff1 > 0x00) & (ff1 < 0x08)) + { + //helpers->log("moving wheel left"); + double percentForce = (ff1) / 7.0; + double percentLength = 100; + myTriggers->LeftRight(pow(percentForce, 0.5), 0, percentLength); + myTriggers->Constant(myConstants->DIRECTION_FROM_LEFT, (pow(percentForce, 0.5))); + } + else if ((ff1 > 0x07) & (ff1 < 0x10)) + { + //helpers->log("moving wheel right"); + double percentForce = (16 - ff1) / 8.0; + double percentLength = 100; + myTriggers->LeftRight(0, pow(percentForce, 0.5), percentLength); + myTriggers->Constant(myConstants->DIRECTION_FROM_RIGHT, (pow(percentForce, 0.5))); + } + } + } + } + } + return 0; +} void RoadFighters3D::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) { - wchar_t *settingsFilename = TEXT(".\\FFBPlugin.ini"); - int InputDeviceWheelEnable = GetPrivateProfileInt(TEXT("Settings"), TEXT("InputDeviceWheelEnable"), 0, settingsFilename); - int InputDeviceWheelSteeringAxis = GetPrivateProfileInt(TEXT("Settings"), TEXT("InputDeviceWheelSteeringAxis"), 0, settingsFilename); - int InputDeviceWheelAcclAxis = GetPrivateProfileInt(TEXT("Settings"), TEXT("InputDeviceWheelAcclAxis"), 0, settingsFilename); - int InputDeviceWheelBrakeAxis = GetPrivateProfileInt(TEXT("Settings"), TEXT("InputDeviceWheelBrakeAxis"), 0, settingsFilename); - int InputDeviceWheelReverseAxis = GetPrivateProfileInt(TEXT("Settings"), TEXT("InputDeviceWheelReverseAxis"), 0, settingsFilename); - int InputDeviceCombinedPedals = GetPrivateProfileInt(TEXT("Settings"), TEXT("InputDeviceCombinedPedals"), 0, settingsFilename); - int SteeringDeadzone = GetPrivateProfileInt(TEXT("Settings"), TEXT("SteeringDeadzone"), 0, settingsFilename); - int PedalDeadzone = GetPrivateProfileInt(TEXT("Settings"), TEXT("PedalDeadzone"), 0, settingsFilename); - int SequentialGears = GetPrivateProfileInt(TEXT("Settings"), TEXT("SequentialGears"), 0, settingsFilename); - int FFBMode = GetPrivateProfileInt(TEXT("Settings"), TEXT("FFBMode"), 0, settingsFilename); - int ShowButtonNumbersForSetup = GetPrivateProfileInt(TEXT("Settings"), TEXT("ShowButtonNumbersForSetup"), 0, settingsFilename); - int ShowAxisForSetup = GetPrivateProfileInt(TEXT("Settings"), TEXT("ShowAxisForSetup"), 0, settingsFilename); - int ExitButton = GetPrivateProfileInt(TEXT("Settings"), TEXT("ExitButton"), 0, settingsFilename); - int TestButton = GetPrivateProfileInt(TEXT("Settings"), TEXT("TestButton"), 0, settingsFilename); - int ServiceButton = GetPrivateProfileInt(TEXT("Settings"), TEXT("ServiceButton"), 0, settingsFilename); - int CreditButton = GetPrivateProfileInt(TEXT("Settings"), TEXT("CreditButton"), 0, settingsFilename); - int ViewButton = GetPrivateProfileInt(TEXT("Settings"), TEXT("ViewButton"), 0, settingsFilename); - int ThreeDimensionalButton = GetPrivateProfileInt(TEXT("Settings"), TEXT("ThreeDimensionalButton"), 0, settingsFilename); - int leverUp = GetPrivateProfileInt(TEXT("Settings"), TEXT("leverUp"), 0, settingsFilename); - int leverDown = GetPrivateProfileInt(TEXT("Settings"), TEXT("leverDown"), 0, settingsFilename); - int leverLeft = GetPrivateProfileInt(TEXT("Settings"), TEXT("leverLeft"), 0, settingsFilename); - int leverRight = GetPrivateProfileInt(TEXT("Settings"), TEXT("leverRight"), 0, settingsFilename); - int ExitButtonDevice2 = GetPrivateProfileInt(TEXT("Settings"), TEXT("ExitButtonDevice2"), 0, settingsFilename); - int TestButtonDevice2 = GetPrivateProfileInt(TEXT("Settings"), TEXT("TestButtonDevice2"), 0, settingsFilename); - int ServiceButtonDevice2 = GetPrivateProfileInt(TEXT("Settings"), TEXT("ServiceButtonDevice2"), 0, settingsFilename); - int CreditButtonDevice2 = GetPrivateProfileInt(TEXT("Settings"), TEXT("CreditButtonDevice2"), 0, settingsFilename); - int ViewButtonDevice2 = GetPrivateProfileInt(TEXT("Settings"), TEXT("ViewButtonDevice2"), 0, settingsFilename); - int ThreeDimensionalButtonDevice2 = GetPrivateProfileInt(TEXT("Settings"), TEXT("ThreeDimensionalButtonDevice2"), 0, settingsFilename); - int leverUpDevice2 = GetPrivateProfileInt(TEXT("Settings"), TEXT("leverUpDevice2"), 0, settingsFilename); - int leverDownDevice2 = GetPrivateProfileInt(TEXT("Settings"), TEXT("leverDownDevice2"), 0, settingsFilename); - int leverLeftDevice2 = GetPrivateProfileInt(TEXT("Settings"), TEXT("leverLeftDevice2"), 0, settingsFilename); - int leverRightDevice2 = GetPrivateProfileInt(TEXT("Settings"), TEXT("leverRightDevice2"), 0, settingsFilename); - if (InputDeviceWheelEnable == 1) { - helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x18D84B, false); - helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x18D84C, false); - helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x18D84D, false); - helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x18D852, false); - helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x18D853, false); - helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x18D854, false); - helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x18D85C, false); - helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x18D85D, false); - helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x18D85E, false); - helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x18DA89, false); - helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x18DA8A, false); - helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x18DA8B, false); - helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x18DA8C, false); - helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x18DA8D, false); - helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x18DA8E, false); + SDL_Thread *thread; + thread = SDL_CreateThread(RunningThread, "RunningThread", (void *)NULL); + + helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x18D84B, false); + helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x18D84C, false); + helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x18D84D, false); + helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x18D852, false); + helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x18D853, false); + helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x18D854, false); + helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x18D85C, false); + helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x18D85D, false); + helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x18D85E, false); + // Spicetools shit below. STOPS test buttons showing in menu etc if not nop + helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x18DA89, false); + helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x18DA8A, false); + helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x18DA8B, false); + helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x18DA8C, false); + helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x18DA8D, false); + helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x18DA8E, false); + helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x18DAA3, false); + helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x18DAA4, false); + helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x18DAA5, false); + helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x18DA97, false); + helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x18DA98, false); + helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x18DA99, false); + helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x18DA9A, false); + helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x18DA9B, false); + helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x18DA9C, false); // Dpad stuff here to set as any button char DpadUpChar[256]; @@ -145,11 +359,6 @@ void RoadFighters3D::FFBLoop(EffectConstants *constants, Helpers *helpers, Effec } } - //if (InputDeviceCombinedPedals == 1) - //{ - // bool BrakePedalFix = true; - //} - if (SequentialGears == 1) { helpers->WriteNop((INT_PTR)gl_hjgtDll + 0x95DDA, false); @@ -161,9 +370,14 @@ void RoadFighters3D::FFBLoop(EffectConstants *constants, Helpers *helpers, Effec const int ACCL_DEAD_ZONE = (1 + PedalDeadzone * 100.0); const int BRAKE_DEAD_ZONE = (1 + PedalDeadzone * 100.0); const int SETUP_DEAD_ZONE = 20000; - SDL_Event e; - while (SDL_PollEvent(&e) != 0) + + while (SDL_WaitEvent(&e) != 0) { + int menuvalue = myHelpers->ReadIntPtr((INT_PTR)gl_hjgtDll + 0x0094BFFC, false); + int menuvalue1 = myHelpers->ReadIntPtr((INT_PTR)menuvalue + 0x46C, false); + myTriggers = triggers; + myConstants = constants; + myHelpers = helpers; if ((e.type == SDL_JOYAXISMOTION) & (ShowAxisForSetup == 0)) { if (e.jaxis.which == joystick_index1) @@ -244,11 +458,6 @@ void RoadFighters3D::FFBLoop(EffectConstants *constants, Helpers *helpers, Effec { if (InputDeviceCombinedPedals == 1) { - //for (static bool BrakePedalFix = true; BrakePedalFix; BrakePedalFix = false) - //{ - //helpers->WriteByte((INT_PTR)gl_hjgtDll + 0x7D2B41, 0xFF, false); - //} - if (e.jaxis.axis == InputDeviceWheelAcclAxis) { if (e.jaxis.value < -ACCL_DEAD_ZONE) @@ -525,66 +734,6 @@ void RoadFighters3D::FFBLoop(EffectConstants *constants, Helpers *helpers, Effec { MessageBoxA(NULL, "Button 15 Pressed", "", 0); } - else if (e.jbutton.button == 16) - { - MessageBoxA(NULL, "Button 16 Pressed", "", 0); - } - else if (e.jbutton.button == 17) - { - MessageBoxA(NULL, "Button 17 Pressed", "", 0); - } - else if (e.jbutton.button == 18) - { - MessageBoxA(NULL, "Button 18 Pressed", "", 0); - } - else if (e.jbutton.button == 19) - { - MessageBoxA(NULL, "Button 19 Pressed", "", 0); - } - else if (e.jbutton.button == 20) - { - MessageBoxA(NULL, "Button 20 Pressed", "", 0); - } - else if (e.jbutton.button == 21) - { - MessageBoxA(NULL, "Button 21 Pressed", "", 0); - } - else if (e.jbutton.button == 22) - { - MessageBoxA(NULL, "Button 22 Pressed", "", 0); - } - else if (e.jbutton.button == 23) - { - MessageBoxA(NULL, "Button 23 Pressed", "", 0); - } - else if (e.jbutton.button == 24) - { - MessageBoxA(NULL, "Button 24 Pressed", "", 0); - } - else if (e.jbutton.button == 25) - { - MessageBoxA(NULL, "Button 25 Pressed", "", 0); - } - else if (e.jbutton.button == 26) - { - MessageBoxA(NULL, "Button 26 Pressed", "", 0); - } - else if (e.jbutton.button == 27) - { - MessageBoxA(NULL, "Button 27 Pressed", "", 0); - } - else if (e.jbutton.button == 28) - { - MessageBoxA(NULL, "Button 28 Pressed", "", 0); - } - else if (e.jbutton.button == 29) - { - MessageBoxA(NULL, "Button 29 Pressed", "", 0); - } - else if (e.jbutton.button == 30) - { - MessageBoxA(NULL, "Button 30 Pressed", "", 0); - } } } } @@ -595,15 +744,92 @@ void RoadFighters3D::FFBLoop(EffectConstants *constants, Helpers *helpers, Effec { if (e.jhat.which == joystick_index1) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x0000, false); + if (testbuttonA) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread -= 0x02, false); + leverleftA = false; + } + if (servicebuttonA) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread -= 0x01, false); + leverrightA = false; + } + if (viewbuttonA) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread -= 0x400, false); + leverrightA = false; + } + if (threedeebuttonA) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread -= 0x800, false); + leverleftA = false; + } + if (leverupA) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread -= 0x1040, false); + leverleftA = false; + } + if (leverdownA) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread -= 0x2080, false); + leverrightA = false; + } + if (leverleftA) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread -= 0x4000, false); + leverleftA = false; + } + if (leverrightA) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread -= 0x8000, false); + leverrightA = false; + } } - else if (e.jhat.which == joystick_index2) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x0000, false); + if (testbuttonA) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread -= 0x02, false); + leverleftA = false; + } + if (servicebuttonA) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread -= 0x01, false); + leverrightA = false; + } + if (viewbuttonA) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread -= 0x400, false); + leverrightA = false; + } + if (threedeebuttonA) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread -= 0x800, false); + leverleftA = false; + } + if (leverupA) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread -= 0x1040, false); + leverleftA = false; + } + if (leverdownA) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread -= 0x2080, false); + leverrightA = false; + } + if (leverleftA) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread -= 0x4000, false); + leverleftA = false; + } + if (leverrightA) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread -= 0x8000, false); + leverrightA = false; + } } } - else if (e.jhat.value == SDL_HAT_UP) + if (e.jhat.value == SDL_HAT_UP) { if (e.jhat.which == joystick_index1) { @@ -611,42 +837,50 @@ void RoadFighters3D::FFBLoop(EffectConstants *constants, Helpers *helpers, Effec { system("taskkill /f /im spice.exe"); } - else if (dpdup.compare(test) == 0) + if (dpdup.compare(test) == 0) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x02, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x02, false); + testbuttonA = true; } - else if (dpdup.compare(service) == 0) + if (dpdup.compare(service) == 0) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x01, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x01, false); + servicebuttonA = true; } - else if (dpdup.compare(coin) == 0) + if (dpdup.compare(coin) == 0) { int credit = helpers->ReadIntPtr((INT_PTR)gl_hlibavs + 0x00042C10, false); helpers->WriteIntPtr((INT_PTR)credit + 0x20, ++creditnumber1, false); } - else if (dpdup.compare(view) == 0) + if (dpdup.compare(view) == 0) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x400, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x400, false); + viewbuttonA = true; } - else if (dpdup.compare(three) == 0) + if (dpdup.compare(three) == 0) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x800, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x800, false); + threedeebuttonA = true; } - else if (dpdup.compare(lvup) == 0) + if (dpdup.compare(lvup) == 0) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x1040, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x1040, false); + leverupA = true; } - else if (dpdup.compare(lvdown) == 0) + if (dpdup.compare(lvdown) == 0) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x2080, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x2080, false); + leverdownA = true; } - else if (dpdup.compare(lvleft) == 0) + if (dpdup.compare(lvleft) == 0) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x4000, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x4000, false); + leverleftA = true; } - else if (dpdup.compare(lvright) == 0) + if (dpdup.compare(lvright) == 0) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x8000, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x8000, false); + leverrightA = true; } } else if (e.jhat.which == joystick_index2) @@ -655,316 +889,372 @@ void RoadFighters3D::FFBLoop(EffectConstants *constants, Helpers *helpers, Effec { system("taskkill /f /im spice.exe"); } - else if (dpdup2.compare(test2) == 0) + if (dpdup2.compare(test2) == 0) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x02, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x02, false); + testbuttonA = true; } - else if (dpdup2.compare(service2) == 0) + if (dpdup2.compare(service2) == 0) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x01, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x01, false); + servicebuttonA = true; } - else if (dpdup2.compare(coin2) == 0) + if (dpdup2.compare(coin2) == 0) { int credit = helpers->ReadIntPtr((INT_PTR)gl_hlibavs + 0x00042C10, false); helpers->WriteIntPtr((INT_PTR)credit + 0x20, ++creditnumber1, false); } - else if (dpdup2.compare(view2) == 0) + if (dpdup2.compare(view2) == 0) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x400, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x400, false); + viewbuttonA = true; } - else if (dpdup2.compare(three2) == 0) + if (dpdup2.compare(three2) == 0) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x800, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x800, false); + threedeebuttonA = true; } - else if (dpdup2.compare(lvup2) == 0) + if (dpdup2.compare(lvup2) == 0) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x1040, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x1040, false); + leverupA = true; } - else if (dpdup2.compare(lvdown2) == 0) + if (dpdup2.compare(lvdown2) == 0) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x2080, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x2080, false); + leverdownA = true; } - else if (dpdup2.compare(lvleft2) == 0) + if (dpdup2.compare(lvleft2) == 0) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x4000, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x4000, false); + leverleftA = true; } - else if (dpdup2.compare(lvright2) == 0) + if (dpdup2.compare(lvright2) == 0) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x8000, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x8000, false); + leverrightA = true; } } } - else if (e.jhat.value == SDL_HAT_DOWN) + if (e.jhat.value == SDL_HAT_DOWN) { - if (e.jhat.which == joystick_index1) - { - if (dpddown.compare(exit) == 0) + if (e.jhat.which == joystick_index1) { - system("taskkill /f /im spice.exe"); + if (dpddown.compare(exit) == 0) + { + system("taskkill /f /im spice.exe"); + } + if (dpddown.compare(test) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x02, false); + testbuttonA = true; + } + if (dpddown.compare(service) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x01, false); + servicebuttonA = true; + } + if (dpddown.compare(coin) == 0) + { + int credit = helpers->ReadIntPtr((INT_PTR)gl_hlibavs + 0x00042C10, false); + helpers->WriteIntPtr((INT_PTR)credit + 0x20, ++creditnumber1, false); + } + if (dpddown.compare(view) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x400, false); + viewbuttonA = true; + } + if (dpddown.compare(three) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x800, false); + threedeebuttonA = true; + } + if (dpddown.compare(lvup) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x1040, false); + leverupA = true; + } + if (dpddown.compare(lvdown) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x2080, false); + leverdownA = true; + } + if (dpddown.compare(lvleft) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x4000, false); + leverleftA = true; + } + if (dpddown.compare(lvright) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x8000, false); + leverrightA = true; + } } - else if (dpddown.compare(test) == 0) + else if (e.jhat.which == joystick_index2) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x02, false); - } - else if (dpddown.compare(service) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x01, false); - } - else if (dpddown.compare(coin) == 0) - { - int credit = helpers->ReadIntPtr((INT_PTR)gl_hlibavs + 0x00042C10, false); - helpers->WriteIntPtr((INT_PTR)credit + 0x20, ++creditnumber1, false); - } - else if (dpddown.compare(view) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x400, false); - } - else if (dpddown.compare(three) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x800, false); - } - else if (dpddown.compare(lvup) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x1040, false); - } - else if (dpddown.compare(lvdown) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x2080, false); - } - else if (dpddown.compare(lvleft) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x4000, false); - } - else if (dpddown.compare(lvright) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x8000, false); + if (dpddown2.compare(exit2) == 0) + { + system("taskkill /f /im spice.exe"); + } + if (dpdup2.compare(test2) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x02, false); + testbuttonA = true; + } + if (dpddown2.compare(service2) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x01, false); + servicebuttonA = true; + } + if (dpddown2.compare(coin2) == 0) + { + int credit = helpers->ReadIntPtr((INT_PTR)gl_hlibavs + 0x00042C10, false); + helpers->WriteIntPtr((INT_PTR)credit + 0x20, ++creditnumber1, false); + } + if (dpddown2.compare(view2) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x400, false); + viewbuttonA = true; + } + if (dpddown2.compare(three2) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x800, false); + threedeebuttonA = true; + } + if (dpddown2.compare(lvup2) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x1040, false); + leverupA = true; + } + if (dpddown2.compare(lvdown2) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x2080, false); + leverdownA = true; + } + if (dpddown2.compare(lvleft2) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x4000, false); + leverleftA = true; + } + if (dpddown2.compare(lvright2) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x8000, false); + leverrightA = true; + } } } + if (e.jhat.value == SDL_HAT_LEFT) + { + if (e.jhat.which == joystick_index1) + { + if (dpdleft.compare(exit) == 0) + { + system("taskkill /f /im spice.exe"); + } + if (dpdleft.compare(test) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x02, false); + testbuttonA = true; + } + if (dpdleft.compare(service) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x01, false); + servicebuttonA = true; + } + if (dpdleft.compare(coin) == 0) + { + int credit = helpers->ReadIntPtr((INT_PTR)gl_hlibavs + 0x00042C10, false); + helpers->WriteIntPtr((INT_PTR)credit + 0x20, ++creditnumber1, false); + } + if (dpdleft.compare(view) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x400, false); + viewbuttonA = true; + } + if (dpdleft.compare(three) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x800, false); + threedeebuttonA = true; + } + if (dpdleft.compare(lvup) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x1040, false); + leverupA = true; + } + if (dpdleft.compare(lvdown) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x2080, false); + leverdownA = true; + } + if (dpdleft.compare(lvleft) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x4000, false); + leverleftA = true; + } + if (dpdleft.compare(lvright) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x8000, false); + leverrightA = true; + } + } else if (e.jhat.which == joystick_index2) { - if (dpddown2.compare(exit2) == 0) - { - system("taskkill /f /im spice.exe"); - } - else if (dpdup2.compare(test2) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x02, false); - } - else if (dpddown2.compare(service2) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x01, false); - } - else if (dpddown2.compare(coin2) == 0) - { - int credit = helpers->ReadIntPtr((INT_PTR)gl_hlibavs + 0x00042C10, false); - helpers->WriteIntPtr((INT_PTR)credit + 0x20, ++creditnumber1, false); - } - else if (dpddown2.compare(view2) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x400, false); - } - else if (dpddown2.compare(three2) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x800, false); - } - else if (dpddown2.compare(lvup2) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x1040, false); - } - else if (dpddown2.compare(lvdown2) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x2080, false); - } - else if (dpddown2.compare(lvleft2) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x4000, false); - } - else if (dpddown2.compare(lvright2) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x8000, false); - } + if (dpdleft2.compare(exit2) == 0) + { + system("taskkill /f /im spice.exe"); + } + if (dpdleft2.compare(test2) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x02, false); + testbuttonA = true; + } + if (dpdleft2.compare(service2) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x01, false); + servicebuttonA = true; + } + if (dpdleft2.compare(coin2) == 0) + { + int credit = helpers->ReadIntPtr((INT_PTR)gl_hlibavs + 0x00042C10, false); + helpers->WriteIntPtr((INT_PTR)credit + 0x20, ++creditnumber1, false); + } + if (dpdleft2.compare(view2) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x400, false); + viewbuttonA = true; + } + if (dpdleft2.compare(three2) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x800, false); + threedeebuttonA = true; + } + if (dpdleft2.compare(lvup2) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x1040, false); + leverupA = true; + } + if (dpdleft2.compare(lvdown2) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x2080, false); + leverdownA = true; + } + if (dpdleft2.compare(lvleft2) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x4000, false); + leverleftA = true; + } + if (dpdleft2.compare(lvright2) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x8000, false); + leverrightA = true; + } } } - else if (e.jhat.value == SDL_HAT_LEFT) + if (e.jhat.value == SDL_HAT_RIGHT) { - if (e.jhat.which == joystick_index1) - { - if (dpdleft.compare(exit) == 0) + if (e.jhat.which == joystick_index1) { - system("taskkill /f /im spice.exe"); + if (dpdright.compare(exit) == 0) + { + system("taskkill /f /im spice.exe"); + } + if (dpdright.compare(test) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x02, false); + testbuttonA = true; + } + if (dpdright.compare(service) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x01, false); + servicebuttonA = true; + } + if (dpdright.compare(coin) == 0) + { + int credit = helpers->ReadIntPtr((INT_PTR)gl_hlibavs + 0x00042C10, false); + helpers->WriteIntPtr((INT_PTR)credit + 0x20, ++creditnumber1, false); + } + if (dpdright.compare(view) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x400, false); + viewbuttonA = true; + } + if (dpdright.compare(three) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x800, false); + threedeebuttonA = true; + } + if (dpdright.compare(lvup) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x1040, false); + leverupA = true; + } + if (dpdright.compare(lvdown) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x2080, false); + leverdownA = true; + } + if (dpdright.compare(lvleft) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x4000, false); + leverleftA = true; + } + if (dpdright.compare(lvright) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x8000, false); + leverrightA = true; + } } - else if (dpdleft.compare(test) == 0) + else if (e.jhat.which == joystick_index2) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x02, false); - } - else if (dpdleft.compare(service) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x01, false); - } - else if (dpdleft.compare(coin) == 0) - { - int credit = helpers->ReadIntPtr((INT_PTR)gl_hlibavs + 0x00042C10, false); - helpers->WriteIntPtr((INT_PTR)credit + 0x20, ++creditnumber1, false); - } - else if (dpdleft.compare(view) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x400, false); - } - else if (dpdleft.compare(three) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x800, false); - } - else if (dpdleft.compare(lvup) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x1040, false); - } - else if (dpdleft.compare(lvdown) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x2080, false); - } - else if (dpdleft.compare(lvleft) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x4000, false); - } - else if (dpdleft.compare(lvright) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x8000, false); - } - } - else if (e.jhat.which == joystick_index2) - { - if (dpdleft2.compare(exit2) == 0) - { - system("taskkill /f /im spice.exe"); - } - else if (dpdleft2.compare(test2) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x02, false); - } - else if (dpdleft2.compare(service2) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x01, false); - } - else if (dpdleft2.compare(coin2) == 0) - { - int credit = helpers->ReadIntPtr((INT_PTR)gl_hlibavs + 0x00042C10, false); - helpers->WriteIntPtr((INT_PTR)credit + 0x20, ++creditnumber1, false); - } - else if (dpdleft2.compare(view2) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x400, false); - } - else if (dpdleft2.compare(three2) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x800, false); - } - else if (dpdleft2.compare(lvup2) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x1040, false); - } - else if (dpdleft2.compare(lvdown2) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x2080, false); - } - else if (dpdleft2.compare(lvleft2) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x4000, false); - } - else if (dpdleft2.compare(lvright2) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x8000, false); - } - } - } - else if (e.jhat.value == SDL_HAT_RIGHT) - { - if (e.jhat.which == joystick_index1) - { - if (dpdright.compare(exit) == 0) - { - system("taskkill /f /im spice.exe"); - } - else if (dpdright.compare(test) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x02, false); - } - else if (dpdright.compare(service) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x01, false); - } - else if (dpdright.compare(coin) == 0) - { - int credit = helpers->ReadIntPtr((INT_PTR)gl_hlibavs + 0x00042C10, false); - helpers->WriteIntPtr((INT_PTR)credit + 0x20, ++creditnumber1, false); - } - else if (dpdright.compare(view) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x400, false); - } - else if (dpdright.compare(three) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x800, false); - } - else if (dpdright.compare(lvup) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x1040, false); - } - else if (dpdright.compare(lvdown) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x2080, false); - } - else if (dpdright.compare(lvleft) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x4000, false); - } - else if (dpdright.compare(lvright) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x8000, false); - } - } - else if (e.jhat.which == joystick_index2) - { - if (dpdright2.compare(exit2) == 0) - { - system("taskkill /f /im spice.exe"); - } - else if (dpdright2.compare(test2) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x02, false); - } - else if (dpdright2.compare(service2) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x01, false); - } - else if (dpdright2.compare(coin2) == 0) - { - int credit = helpers->ReadIntPtr((INT_PTR)gl_hlibavs + 0x00042C10, false); - helpers->WriteIntPtr((INT_PTR)credit + 0x20, ++creditnumber1, false); - } - else if (dpdright2.compare(view2) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x400, false); - } - else if (dpdright2.compare(three2) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x800, false); - } - else if (dpdright2.compare(lvup2) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x1040, false); - } - else if (dpdright2.compare(lvdown2) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x2080, false); - } - else if (dpdright2.compare(lvleft2) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x4000, false); - } - else if (dpdright2.compare(lvright2) == 0) - { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x8000, false); - } + if (dpdright2.compare(exit2) == 0) + { + system("taskkill /f /im spice.exe"); + } + if (dpdright2.compare(test2) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x02, false); + testbuttonA = true; + } + if (dpdright2.compare(service2) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x01, false); + testbuttonA = true; + } + if (dpdright2.compare(coin2) == 0) + { + int credit = helpers->ReadIntPtr((INT_PTR)gl_hlibavs + 0x00042C10, false); + helpers->WriteIntPtr((INT_PTR)credit + 0x20, ++creditnumber1, false); + } + if (dpdright2.compare(view2) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x400, false); + viewbuttonA = true; + } + if (dpdright2.compare(three2) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x800, false); + threedeebuttonA = true; + } + if (dpdright2.compare(lvup2) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x1040, false); + leverupA = true; + } + if (dpdright2.compare(lvdown2) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x2080, false); + leverdownA = true; + } + if (dpdright2.compare(lvleft2) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x4000, false); + leverleftA = true; + } + if (dpdright2.compare(lvright2) == 0) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x8000, false); + leverrightA = true; + } } } } @@ -975,116 +1265,132 @@ void RoadFighters3D::FFBLoop(EffectConstants *constants, Helpers *helpers, Effec { if (e.jbutton.button == TestButton) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x02, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x02, false); } - else if (e.jbutton.button == ExitButton) + if (e.jbutton.button == ExitButton) { system("taskkill /f /im spice.exe"); } - else if (e.jbutton.button == ServiceButton) + if (e.jbutton.button == ServiceButton) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x01, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x01, false); } - else if (e.jbutton.button == CreditButton) + if (e.jbutton.button == CreditButton) { int credit = helpers->ReadIntPtr((INT_PTR)gl_hlibavs + 0x00042C10, false); helpers->WriteIntPtr((INT_PTR)credit + 0x20, ++creditnumber1, false); } - else if (e.jbutton.button == ViewButton) + if (e.jbutton.button == ViewButton) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x400, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x400, false); } - else if (e.jbutton.button == ThreeDimensionalButton) + if (e.jbutton.button == ThreeDimensionalButton) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x800, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x800, false); } - else if ((e.jbutton.button == leverUp) & (SequentialGears == 0)) + if ((e.jbutton.button == leverUp) && (SequentialGears == 0)) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x1040, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x1040, false); } - else if ((e.jbutton.button == leverUp) & (SequentialGears == 1) & (gearnumber3 < 0x06)) + if ((e.jbutton.button == leverUp) && (SequentialGears == 1) && (menuvalue1 == 0x00)) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x1040, false); + } + if ((e.jbutton.button == leverUp) && (SequentialGears == 1) && (gearnumber3 < 0x06)) { int Writegearnumber = helpers->ReadIntPtr((INT_PTR)gl_hjgtDll + 0x00953F70, false); int Writegearnumber1 = helpers->ReadIntPtr((INT_PTR)Writegearnumber + 0x5C, false); int Writegearnumber2 = helpers->ReadIntPtr((INT_PTR)Writegearnumber1 + 0x390, false); helpers->WriteIntPtr((INT_PTR)Writegearnumber2 + 0x18, ++gearnumber3, false); } - else if ((e.jbutton.button == leverDown) & (SequentialGears == 0)) + if ((e.jbutton.button == leverDown) && (SequentialGears == 0)) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x2080, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x2080, false); } - else if ((e.jbutton.button == leverDown) & (SequentialGears == 1) & (gearnumber3 > 0x01)) + if ((e.jbutton.button == leverDown) && (SequentialGears == 1) && (menuvalue1 == 0x00)) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x2080, false); + } + if ((e.jbutton.button == leverDown) && (SequentialGears == 1) && (gearnumber3 > 0x01)) { int Writegearnumber = helpers->ReadIntPtr((INT_PTR)gl_hjgtDll + 0x00953F70, false); int Writegearnumber1 = helpers->ReadIntPtr((INT_PTR)Writegearnumber + 0x5C, false); int Writegearnumber2 = helpers->ReadIntPtr((INT_PTR)Writegearnumber1 + 0x390, false); helpers->WriteIntPtr((INT_PTR)Writegearnumber2 + 0x18, --gearnumber3, false); } - else if (e.jbutton.button == leverLeft) + if (e.jbutton.button == leverLeft) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x4000, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x4000, false); } - else if (e.jbutton.button == leverRight) + if (e.jbutton.button == leverRight) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x8000, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x8000, false); } } else if (e.jbutton.which == joystick_index2) { if (e.jbutton.button == TestButtonDevice2) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x02, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x02, false); } - else if (e.jbutton.button == ExitButtonDevice2) + if (e.jbutton.button == ExitButtonDevice2) { system("taskkill /f /im spice.exe"); } - else if (e.jbutton.button == ServiceButtonDevice2) + if (e.jbutton.button == ServiceButtonDevice2) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x01, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x01, false); } - else if (e.jbutton.button == CreditButtonDevice2) + if (e.jbutton.button == CreditButtonDevice2) { int credit = helpers->ReadIntPtr((INT_PTR)gl_hlibavs + 0x00042C10, false); helpers->WriteIntPtr((INT_PTR)credit + 0x20, ++creditnumber1, false); } - else if (e.jbutton.button == ViewButtonDevice2) + if (e.jbutton.button == ViewButtonDevice2) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x400, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x400, false); } - else if (e.jbutton.button == ThreeDimensionalButtonDevice2) + if (e.jbutton.button == ThreeDimensionalButtonDevice2) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x800, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x800, false); } - else if ((e.jbutton.button == leverUpDevice2) & (SequentialGears == 0)) + if ((e.jbutton.button == leverUpDevice2) && (SequentialGears == 0)) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x1040, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x1040, false); } - else if ((e.jbutton.button == leverUpDevice2) & (SequentialGears == 1) & (gearnumber3 < 0x06)) + if ((e.jbutton.button == leverUpDevice2) && (SequentialGears == 1) && (menuvalue1 == 0x00)) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x1040, false); + } + if ((e.jbutton.button == leverUpDevice2) && (SequentialGears == 1) && (gearnumber3 < 0x06)) { int Writegearnumber = helpers->ReadIntPtr((INT_PTR)gl_hjgtDll + 0x00953F70, false); int Writegearnumber1 = helpers->ReadIntPtr((INT_PTR)Writegearnumber + 0x5C, false); int Writegearnumber2 = helpers->ReadIntPtr((INT_PTR)Writegearnumber1 + 0x390, false); helpers->WriteIntPtr((INT_PTR)Writegearnumber2 + 0x18, ++gearnumber3, false); } - else if ((e.jbutton.button == leverDownDevice2) & (SequentialGears == 0)) + if ((e.jbutton.button == leverDownDevice2) & (SequentialGears == 0)) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x2080, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x2080, false); } - else if ((e.jbutton.button == leverDownDevice2) & (SequentialGears == 1) & (gearnumber3 > 0x01)) + if ((e.jbutton.button == leverDownDevice2) & (SequentialGears == 1) && (menuvalue1 == 0x00)) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x2080, false); + } + if ((e.jbutton.button == leverDownDevice2) & (SequentialGears == 1) & (gearnumber3 > 0x01)) { int Writegearnumber = helpers->ReadIntPtr((INT_PTR)gl_hjgtDll + 0x00953F70, false); int Writegearnumber1 = helpers->ReadIntPtr((INT_PTR)Writegearnumber + 0x5C, false); int Writegearnumber2 = helpers->ReadIntPtr((INT_PTR)Writegearnumber1 + 0x390, false); helpers->WriteIntPtr((INT_PTR)Writegearnumber2 + 0x18, --gearnumber3, false); } - else if (e.jbutton.button == leverLeftDevice2) + if (e.jbutton.button == leverLeftDevice2) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x4000, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x4000, false); } - else if (e.jbutton.button == leverRightDevice2) + if (e.jbutton.button == leverRightDevice2) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x8000, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread += 0x8000, false); } } } @@ -1094,133 +1400,100 @@ void RoadFighters3D::FFBLoop(EffectConstants *constants, Helpers *helpers, Effec { if (e.jbutton.button == TestButton) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x0000, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread -= 0x02, false); } - else if (e.jbutton.button == ServiceButton) + if (e.jbutton.button == ServiceButton) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x0000, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread -= 0x01, false); } - else if (e.jbutton.button == ViewButton) + if (e.jbutton.button == ViewButton) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x0000, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread -= 0x400, false); } - else if (e.jbutton.button == ThreeDimensionalButton) + if (e.jbutton.button == ThreeDimensionalButton) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x0000, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread -= 0x800, false); } - else if (e.jbutton.button == leverUp) + if ((e.jbutton.button == leverUp) && (SequentialGears == 0)) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x0000, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread -= 0x1040, false); } - else if (e.jbutton.button == leverDown) + if ((e.jbutton.button == leverUp) && (SequentialGears == 1) && (menuvalue1 == 0x00)) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x0000, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread -= 0x1040, false); } - else if (e.jbutton.button == leverLeft) + if ((e.jbutton.button == leverDown) && (SequentialGears == 0)) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x0000, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread -= 0x2080, false); } - else if (e.jbutton.button == leverRight) + if ((e.jbutton.button == leverDown) && (SequentialGears == 1) && (menuvalue1 == 0x00)) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x0000, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread -= 0x2080, false); + } + if (e.jbutton.button == leverLeft) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread -= 0x4000, false); + } + if (e.jbutton.button == leverRight) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread -= 0x8000, false); } } else if (e.jbutton.which == joystick_index2) { if (e.jbutton.button == TestButtonDevice2) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x0000, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread -= 0x02, false); } - else if (e.jbutton.button == ServiceButtonDevice2) + if (e.jbutton.button == ServiceButtonDevice2) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x0000, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread -= 0x01, false); } - else if (e.jbutton.button == ViewButtonDevice2) + if (e.jbutton.button == ViewButtonDevice2) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x0000, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread -= 0x400, false); } - else if (e.jbutton.button == ThreeDimensionalButtonDevice2) + if (e.jbutton.button == ThreeDimensionalButtonDevice2) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x0000, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread -= 0x800, false); } - else if (e.jbutton.button == leverUpDevice2) + if ((e.jbutton.button == leverUpDevice2) && (SequentialGears == 0)) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x0000, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread -= 0x1040, false); } - else if (e.jbutton.button == leverDownDevice2) + if ((e.jbutton.button == leverUpDevice2) && (SequentialGears == 1) && (menuvalue1 == 0x00)) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x0000, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread -= 0x1040, false); } - else if (e.jbutton.button == leverLeftDevice2) + if ((e.jbutton.button == leverDownDevice2) && (SequentialGears == 0)) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x0000, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread -= 0x2080, false); } - else if (e.jbutton.button == leverRightDevice2) + if ((e.jbutton.button == leverDownDevice2) && (SequentialGears == 1) && (menuvalue1 == 0x00)) { - helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, 0x0000, false); + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread -= 0x2080, false); + } + if (e.jbutton.button == leverLeftDevice2) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread -= 0x4000, false); + } + if (e.jbutton.button == leverRightDevice2) + { + helpers->WriteIntPtr((INT_PTR)gl_hjgtDll + 0x7D2B24, serviceread -= 0x8000, false); } } } } } - - - UINT8 ff1 = helpers->ReadByte((INT_PTR)gl_hjgtDll + 0x7D2BB9, false); - UINT8 ff2 = helpers->ReadByte((INT_PTR)gl_hjgtDll + 0x7D2BBA, false); - helpers->log("got value: "); - std::string ffs = std::to_string(ff2); - helpers->log((char *)ffs.c_str()); - - if (FFBMode == 0) - { - if ((ff2 > 0x00) & (ff2 < 0x40)) - { - double percentForce = (ff2) / 63.0; - double percentLength = 100; - triggers->LeftRight(percentForce, percentForce, percentLength); - triggers->Sine(120, 120, percentForce); - } - if ((ff1 > 0x00) & (ff1 < 0x08)) - { - //helpers->log("moving wheel left"); - double percentForce = (ff1) / 7.0; - double percentLength = 100; - triggers->LeftRight(0, percentForce, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, percentForce); - } - else if ((ff1 > 0x07) & (ff1 < 0x10)) - { - //helpers->log("moving wheel right"); - double percentForce = (16 - ff1) / 8.0; - double percentLength = 100; - triggers->LeftRight(percentForce, 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, percentForce); - } - } - else if (FFBMode == 1) - { - if ((ff2 > 0x00) & (ff2 < 0x40)) - { - double percentForce = (ff2) / 63.0; - double percentLength = 100; - triggers->LeftRight(pow(percentForce, 0.5), pow(percentForce, 0.5), percentLength); - triggers->Sine(120, 120, pow(percentForce, 0.5)); - } - if ((ff1 > 0x00) & (ff1 < 0x08)) - { - //helpers->log("moving wheel left"); - double percentForce = (ff1) / 7.0; - double percentLength = 100; - triggers->LeftRight(pow(percentForce, 0.5), 0, percentLength); - triggers->Constant(constants->DIRECTION_FROM_LEFT, (pow(percentForce, 0.5))); - } - else if ((ff1 > 0x07) & (ff1 < 0x10)) - { - //helpers->log("moving wheel right"); - double percentForce = (16 - ff1) / 8.0; - double percentLength = 100; - triggers->LeftRight(0, pow(percentForce, 0.5), percentLength); - triggers->Constant(constants->DIRECTION_FROM_RIGHT, (pow(percentForce, 0.5))); - } - } - } \ No newline at end of file + else + { + SDL_Thread *thread; + thread = SDL_CreateThread(RunningThread, "RunningThread", (void *)NULL); + while (SDL_WaitEvent(&e) != 0) + { + myTriggers = triggers; + myConstants = constants; + myHelpers = helpers; + } +} +} \ No newline at end of file diff --git a/Game Files/SegaRacingClassic.cpp b/Game Files/SegaRacingClassic.cpp index 3239b6b..caf80d0 100644 --- a/Game Files/SegaRacingClassic.cpp +++ b/Game Files/SegaRacingClassic.cpp @@ -23,7 +23,7 @@ void SegaRacingClassic::FFBLoop(EffectConstants *constants, Helpers *helpers, Ef //Centering double percentForce = (200 - ff ) / 8.0; double percentLength = 100; - triggers->Spring(percentForce); + triggers->Spring(pow(percentForce, 0.1)); } else if ((ff > 0xB7) & (ff < 0xC0)) { @@ -63,7 +63,7 @@ void SegaRacingClassic::FFBLoop(EffectConstants *constants, Helpers *helpers, Ef //Centering double percentForce = (200 - ff) / 8.0; double percentLength = 100; - triggers->Spring(pow(percentForce, 0.5)); + triggers->Spring(pow(percentForce, 0.1)); } else if ((ff > 0xB7) & (ff < 0xC0)) { diff --git a/Game Files/SegaRally3.cpp b/Game Files/SegaRally3.cpp index ed35afd..33a2693 100644 --- a/Game Files/SegaRally3.cpp +++ b/Game Files/SegaRally3.cpp @@ -1,7 +1,27 @@ #include #include "SegaRally3.h" +static int __stdcall Out32(DWORD device, DWORD data) +{ + /*static char test[256]; + memset(test, 0, 256); + sprintf(test, "hex print: %08X", data); + OutputDebugStringA(test); + return 0;*/ +} + void SegaRally3::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers) { + /*bool init = false; + HMODULE hMod = GetModuleHandleA("inpout32.dll"); + if (hMod) + { + if (!init) + { + //injector::MakeJMP((DWORD)GetProcAddress(GetModuleHandle(L"inpout32.dll"), "Inp32"), Inp32); + injector::MakeJMP((DWORD)GetProcAddress(GetModuleHandle(L"inpout32.dll"), "Out32"), Out32); + init = true; + } + }*/ helpers->log("in SR3 Ffbloop"); const int ff = GetTeknoParrotFFB(); std::string ffs = std::to_string(ff); diff --git a/Game Files/TestGame.cpp b/Game Files/TestGame.cpp index 8e08eb4..d33a546 100644 --- a/Game Files/TestGame.cpp +++ b/Game Files/TestGame.cpp @@ -1,5 +1,6 @@ #include #include "TestGame.h" +#include "SDL.h" //settingsFN copied from DllMain.cpp; renamed from settingsFilename wchar_t *settingsFN = TEXT(".\\FFBPlugin.ini"); @@ -36,5 +37,8 @@ void TestGame::FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTrigg triggers->Friction(0); triggers->Spring(0); break; + case -7: + triggers->LeftRight(1.0, 1.0, SDL_HAPTIC_INFINITY); + break; } } \ No newline at end of file diff --git a/IDirectInputDevice.cpp b/IDirectInputDevice.cpp index df25ff1..a2e50a2 100644 --- a/IDirectInputDevice.cpp +++ b/IDirectInputDevice.cpp @@ -57,13 +57,13 @@ HRESULT STDMETHODCALLTYPE DirectInputDeviceWrapper::EnumCreatedEffectObjects(LPD HRESULT STDMETHODCALLTYPE DirectInputDeviceWrapper::EnumEffects(LPDIENUMEFFECTSCALLBACK lpCallback, LPVOID pvRef, DWORD dwEffType) { - if (pDeviceA) return pDeviceA->EnumEffects((LPDIENUMEFFECTSCALLBACKA) lpCallback, pvRef, dwEffType); + if (pDeviceA) return pDeviceA->EnumEffects((LPDIENUMEFFECTSCALLBACKA)lpCallback, pvRef, dwEffType); return pDeviceW->EnumEffects(lpCallback, pvRef, dwEffType); } HRESULT STDMETHODCALLTYPE DirectInputDeviceWrapper::EnumEffectsInFile(LPCTSTR lptszFileName, LPDIENUMEFFECTSINFILECALLBACK pec, LPVOID pvRef, DWORD dwFlags) { - if (pDeviceA) return pDeviceA->EnumEffectsInFile((LPCSTR) lptszFileName, pec, pvRef, dwFlags); + if (pDeviceA) return pDeviceA->EnumEffectsInFile((LPCSTR)lptszFileName, pec, pvRef, dwFlags); return pDeviceW->EnumEffectsInFile(lptszFileName, pec, pvRef, dwFlags); } @@ -81,8 +81,18 @@ HRESULT STDMETHODCALLTYPE DirectInputDeviceWrapper::Escape(LPDIEFFESCAPE pesc) HRESULT STDMETHODCALLTYPE DirectInputDeviceWrapper::GetCapabilities(LPDIDEVCAPS lpDIDevCaps) { - if (pDeviceA) return pDeviceA->GetCapabilities(lpDIDevCaps); - return pDeviceW->GetCapabilities(lpDIDevCaps); + wchar_t *settingsFilenameA = TEXT(".\\FFBPlugin.ini"); + int configGameId = GetPrivateProfileInt(TEXT("Settings"), TEXT("GameId"), 1, settingsFilenameA); + if (configGameId == 29) + { + if (pDeviceA) return pDeviceA->GetCapabilities(NULL); + return pDeviceW->GetCapabilities(lpDIDevCaps); + } + else + { + if (pDeviceA) return pDeviceA->GetCapabilities(lpDIDevCaps); + return pDeviceW->GetCapabilities(lpDIDevCaps); + } } HRESULT STDMETHODCALLTYPE DirectInputDeviceWrapper::GetDeviceData(DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) @@ -93,7 +103,7 @@ HRESULT STDMETHODCALLTYPE DirectInputDeviceWrapper::GetDeviceData(DWORD cbObject HRESULT STDMETHODCALLTYPE DirectInputDeviceWrapper::GetDeviceInfo(LPDIDEVICEINSTANCE pdidi) { - if (pDeviceA) return pDeviceA->GetDeviceInfo((LPDIDEVICEINSTANCEA) pdidi); + if (pDeviceA) return pDeviceA->GetDeviceInfo((LPDIDEVICEINSTANCEA)pdidi); return pDeviceW->GetDeviceInfo(pdidi); } @@ -105,7 +115,7 @@ HRESULT STDMETHODCALLTYPE DirectInputDeviceWrapper::GetDeviceState(DWORD cbData, HRESULT STDMETHODCALLTYPE DirectInputDeviceWrapper::GetEffectInfo(LPDIEFFECTINFO pdei, REFGUID rguid) { - if (pDeviceA) return pDeviceA->GetEffectInfo((LPDIEFFECTINFOA) pdei, rguid); + if (pDeviceA) return pDeviceA->GetEffectInfo((LPDIEFFECTINFOA)pdei, rguid); return pDeviceW->GetEffectInfo(pdei, rguid); } @@ -117,7 +127,7 @@ HRESULT STDMETHODCALLTYPE DirectInputDeviceWrapper::GetForceFeedbackState(LPDWOR HRESULT STDMETHODCALLTYPE DirectInputDeviceWrapper::GetObjectInfo(LPDIDEVICEOBJECTINSTANCE pdidoi, DWORD dwObj, DWORD dwHow) { - if (pDeviceA) return pDeviceA->GetObjectInfo((LPDIDEVICEOBJECTINSTANCEA) pdidoi, dwObj, dwHow); + if (pDeviceA) return pDeviceA->GetObjectInfo((LPDIDEVICEOBJECTINSTANCEA)pdidoi, dwObj, dwHow); return pDeviceW->GetObjectInfo(pdidoi, dwObj, dwHow); } @@ -199,7 +209,7 @@ HRESULT STDMETHODCALLTYPE DirectInputDeviceWrapper::Unacquire(void) HRESULT STDMETHODCALLTYPE DirectInputDeviceWrapper::WriteEffectToFile(LPCTSTR lptszFileName, DWORD dwEntries, LPDIFILEEFFECT rgDiFileEft, DWORD dwFlags) { - if (pDeviceA) return pDeviceA->WriteEffectToFile((LPCSTR) lptszFileName, dwEntries, rgDiFileEft, dwFlags); + if (pDeviceA) return pDeviceA->WriteEffectToFile((LPCSTR)lptszFileName, dwEntries, rgDiFileEft, dwFlags); return pDeviceW->WriteEffectToFile(lptszFileName, dwEntries, rgDiFileEft, dwFlags); } @@ -207,13 +217,13 @@ HRESULT STDMETHODCALLTYPE DirectInputDeviceWrapper::WriteEffectToFile(LPCTSTR lp HRESULT STDMETHODCALLTYPE DirectInputDeviceWrapper::BuildActionMap(LPDIACTIONFORMAT lpdiaf, LPCTSTR lpszUserName, DWORD dwFlags) { - if (pDeviceA) return pDeviceA->BuildActionMap((LPDIACTIONFORMATA) lpdiaf, (LPCSTR) lpszUserName, dwFlags); + if (pDeviceA) return pDeviceA->BuildActionMap((LPDIACTIONFORMATA)lpdiaf, (LPCSTR)lpszUserName, dwFlags); return pDeviceW->BuildActionMap(lpdiaf, lpszUserName, dwFlags); } HRESULT STDMETHODCALLTYPE DirectInputDeviceWrapper::GetImageInfo(LPDIDEVICEIMAGEINFOHEADER lpdiDevImageInfoHeader) { - if (pDeviceA) return pDeviceA->GetImageInfo((LPDIDEVICEIMAGEINFOHEADERA) lpdiDevImageInfoHeader); + if (pDeviceA) return pDeviceA->GetImageInfo((LPDIDEVICEIMAGEINFOHEADERA)lpdiDevImageInfoHeader); return pDeviceW->GetImageInfo(lpdiDevImageInfoHeader); } diff --git a/IDirectInputDevice.h b/IDirectInputDevice.h index 2467d1d..afb4f84 100644 --- a/IDirectInputDevice.h +++ b/IDirectInputDevice.h @@ -10,9 +10,9 @@ private: bool useUnicode; public: - DirectInputDeviceWrapper( LPVOID device, bool unicode ); + DirectInputDeviceWrapper(LPVOID device, bool unicode); virtual ~DirectInputDeviceWrapper(void); - + public: // -------- METHODS: IUnknown ---------------------------------------------- // virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, LPVOID* ppvObj); diff --git a/Includes/FFBPlugin.txt b/Includes/FFBPlugin.txt index f00d79b..28b96fa 100644 --- a/Includes/FFBPlugin.txt +++ b/Includes/FFBPlugin.txt @@ -1,14 +1,66 @@ ***FFB Arcade Plugin*** -Version 0.8 +Version 0.9 Created by Boomslangnz, Ducon2016 & Spazzy. This is a plugin to provide Force Feedback and Rumble (and in certain cases added input support) to various arcade games. Initially this was a small project to add FFB to Daytona Championship USA and it grew from there to support several more games and rumble was added. While best efforts were made to try to resemble the real arcade force feedback, It will never be 100% accurate & -in some cases eg Mario Kart GP DX, Pokken Tournament and Battle Gear 4. Effects were created entirely from scratch -so are not using any real force feedback values +in some cases eg Mario Kart GP DX, Pokken Tournament and Battle Gear 4,effects were created entirely from scratch +so are not using real force feedback values. Most games use correct ffb values however :) + +***0.9 Changes*** + +- Added scroll bar to MKDX and Road Fighters 3D input side as couldn't see all options unless very high resolution monitor on GUI + +- Completely Modified OR2 SP Real plugin as effects were set quite wrong previously & added gear shift rumble as requested + +- Added optional input support for OR2 SP for H-Pattern gear changes (will only work if you select manual transmission) + +- Fixed issue which would cause Force Feedback to not work on Road Fighters 3D due to dinput8 blocker i was using previously on certain wheels. +PLEASE REMOVE d3d9.dll & dinput8.dll if used old version!!! +Blocker is not necessary anymore and ive fixed it properly compared to being lazy lol. Enable input support to disable default dinput8 controls used by Road Fighters 3D + +- Modified Road Fighters 3D FFB to only work when racing starts as otherwise it does crazy stuff before race or while attract mode plays + +- Added option to disable 3D for Road Fighters 3D + +- Added option to do a hack to try skip past error menu screen quickly for Road Fighters 3D on startup + +- Added option to close Libmovie error popup automatically if it happens for Road Fighters 3D + +- Lowered default Max Force for WMMT5 since people never read readme, then complain it's too strong + +- Huge overhaul for when adding inputs to input supported games via gui, Works much better (Click on axis/button number on right side to remove if required) + +- Re-wrote input system for every supported game via plugin itself + +- Fixed various bugs found in GUI + +- Renamed Input Setup in FFBPluginGUI.exe to Input / Miscellaneous Setup as it has options other then JUST input on certain games + +- Added Force Feedback test page to GUI for users to test effects on their devices + +- Fixed issue where Feedback Length wouldn't allow enough characters and modify ini setting automatically + +- Defaulted log to off, not as necessary anymore with GUI around + +- Modified Initial D4,D5,D6,D7 & D8 plugin (Be sure to try out both FFBMode and without) Remember to set FORCE=10 in test menu + +- Added support for new haptic effect forces damper, inertia, ramp, sawtoothup, sawtoothdown & triangle + +- Modified Daytona Championship USA exit method for better way + +- Modified forces to avoid the "tick" feeling with certain effects + +- Raised spring strength in Sega Racing Classic plugin + +- Tidied up Battle Gear 4 code and replace simple rumble with left/right effects for rumble + +- Added test code to rumble for infinite time period. Set GameID to -7 if you want to check rumble works via plugin + +- Fixed issue where plugin could crash game if no FFBPlugin.ini was present in game folder ***0.8 Changes*** @@ -166,8 +218,6 @@ extremely generous. - Mame team -- Racer_S for making dinput8 blocker used on Road Fighters 3D - - SailorSat for finding the offsets etc required for Daytona USA Multiplayer AI hack - Nuexzz for finding offset required for Daytona Panoramic Force Hack @@ -252,7 +302,7 @@ TURN ON FEEDBACK STEERING IN GAME SETTINGS OR YOU WILL NOT RECIEVE FORCE FEEDBAC -GTI Club Supermini Festa [dinput8.dll into game exe folder] --Road Fighters 3D [d3d9.dll & dinput8.dll(if using ffb plugin for inputs) into game exe folder] +-Road Fighters 3D [dinput8.dll into game exe folder] -Nascar Racing [dinput8.dll into demul 180428 version folder] @@ -287,7 +337,7 @@ EnableRumble= **Turn Off (0) if your wheel supports rumble effect. For controlle Logging= **Turn On (1) to allow log.txt to be made to log plugin. Device GUID is given in here** -ResetFeedback= **When a command is set that contradicts a prior command, clear the prior command. Should stay as 1** +ResetFeedback= **When a command is set that contradicts a prior command, clear the prior command.** FeedbackLength= **Length of a feedback command**