1
0
mirror of synced 2024-11-12 01:20:49 +01:00

updated to 0.9

This commit is contained in:
Aaron M 2019-05-15 19:25:41 +12:00
parent 65747e84b8
commit bc0bc3543c
31 changed files with 3058 additions and 2101 deletions

View File

@ -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);
};

View File

@ -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

View File

@ -19,7 +19,9 @@
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Game Files\FordRacingOther.h" />
<ClInclude Include="Game Files\ButtonRumble64bit.h" />
<ClInclude Include="Game Files\GRID.h" />
<ClInclude Include="Game Files\OutRun2Real.h" />
<ClInclude Include="Game Files\Mame019964bit.h" />
<ClInclude Include="Game Files\Mame020664bit.h" />
@ -42,7 +44,9 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="Game Files\FordRacingOther.cpp" />
<ClCompile Include="Game Files\ButtonRumble64bit.cpp" />
<ClCompile Include="Game Files\GRID.cpp" />
<ClCompile Include="Game Files\OutRun2Real.cpp" />
<ClCompile Include="Game Files\Mame019964bit.cpp" />
<ClCompile Include="Game Files\Mame020664bit.cpp" />

View File

@ -118,6 +118,8 @@
<Filter>Game Files</Filter>
</ClCompile>
<ClCompile Include="Game Files\ButtonRumble64bit.cpp" />
<ClCompile Include="Game Files\GRID.cpp" />
<ClCompile Include="Game Files\FordRacingOther.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Game Files\Daytona3.h">
@ -238,6 +240,12 @@
<ClInclude Include="Game Files\ButtonRumble64bit.h">
<Filter>Common Header Files</Filter>
</ClInclude>
<ClInclude Include="Game Files\GRID.h">
<Filter>Common Header Files</Filter>
</ClInclude>
<ClInclude Include="Game Files\FordRacingOther.h">
<Filter>Common Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Text Include="Includes\FFBPlugin.txt" />

View File

@ -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<milliseconds>(system_clock::now().time_since_epoch());
/*std::chrono::milliseconds now = duration_cast<milliseconds>(system_clock::now().time_since_epoch());
long long elapsedTime = (std::chrono::duration_cast<std::chrono::milliseconds>(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<milliseconds>(system_clock::now().time_since_epoch());
/*std::chrono::milliseconds now = duration_cast<milliseconds>(system_clock::now().time_since_epoch());
long long elapsedTime = (std::chrono::duration_cast<std::chrono::milliseconds>(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<milliseconds>(system_clock::now().time_since_epoch());
/*std::chrono::milliseconds now = duration_cast<milliseconds>(system_clock::now().time_since_epoch());
long long elapsedTime = (std::chrono::duration_cast<std::chrono::milliseconds>(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");

View File

@ -1,7 +1,9 @@
#include <string>
#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());

View File

@ -1,151 +1,78 @@
#include <string>
#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);

View File

@ -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)

View File

@ -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);
}
}
}
}
}
}
}

View File

@ -2,36 +2,116 @@
#include "Daytona3.h"
#include "SDL.h"
#include <Windows.h>
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;
}
}
}
}

View File

@ -1,6 +1,17 @@
#include <string>
#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);
} */
}

View File

@ -0,0 +1,72 @@
#include <string>
#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;
}

View File

@ -0,0 +1,7 @@
#pragma once
#include "../Common Files/Game.h"
class FordRacingOther : public Game {
public:
void FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers);
};

56
Game Files/GRID.cpp Normal file
View File

@ -0,0 +1,56 @@
#include "GRID.h"
#include <Windows.h>
#include <string>
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;
}
}
}
}

7
Game Files/GRID.h Normal file
View File

@ -0,0 +1,7 @@
#pragma once
#include "../Common Files/Game.h"
class GRID : public Game {
public:
void FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers);
};

View File

@ -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);
}
}
}
}

View File

@ -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);
}
}
}
}

View File

@ -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);
}
}
}
}

View File

@ -1,93 +1,185 @@
#include <string>
#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);
}
}
}
}

View File

@ -1,93 +1,185 @@
#include <string>
#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);
}
}
}
}

View File

@ -1,93 +1,185 @@
#include <string>
#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);
}
}
}
}

View File

@ -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<U8>(0x003D2FEE, 0x45, true);
helpers->WriteByte<U8>(0x003D3637, 0xB8, true);
helpers->WriteIntPtr<U32>(0x003D3638, (U16)buffer, true);
helpers->WriteIntPtr<U32>(0x003D363C, 0x0C244489, true);
}*/
if (vibration == 16842753)
{
if (power == 61542)

View File

@ -1,462 +1,363 @@
#include <string>
#include "Outrun2Fake.h"
#include "SDL.h"
#include <Windows.h>
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;
}

View File

@ -1,62 +1,266 @@
#include <string>
#include "Outrun2Real.h"
EffectTriggers* myTriggers;
EffectConstants *myConstants;
Helpers *myHelpers;
#include "SDL.h"
#include <Windows.h>
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);
}
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -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))
{

View File

@ -1,7 +1,27 @@
#include <string>
#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);

View File

@ -1,5 +1,6 @@
#include <string>
#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;
}
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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**