diff --git a/Common Files/Game.h b/Common Files/Game.h index 0236ed5..4560fd4 100644 --- a/Common Files/Game.h +++ b/Common Files/Game.h @@ -11,6 +11,7 @@ struct EffectTriggers { void(*Rumble)(double lowfrequency, double highfrequency, double length); void(*RumbleDevice2)(double lowfrequency, double highfrequency, double length); void(*RumbleDevice3)(double lowfrequency, double highfrequency, double length); + void(*RumbleTriggers)(double lefttrigger, double righttrigger, double length); void(*LeftRight)(double smallstrength, double largestrength, double length); void(*LeftRightDevice2)(double smallstrength, double largestrength, double length); void(*Springi)(double strength); diff --git a/Config/FFBPlugin.ini b/Config/FFBPlugin.ini index 07d4454..470231a 100644 --- a/Config/FFBPlugin.ini +++ b/Config/FFBPlugin.ini @@ -23,6 +23,8 @@ DeviceGUID= ;Set to 1 if you want to enable rumble, else 0. EnableRumble=1 ReverseRumble=0 +;Set to 1 if you want to enable rumble in triggers, else 0. +EnableRumbleTriggers=1 ; Set to 1 to generate log.txt, else 0. Logs will be appended and not cleared. Logging=0 ; Length of a feedback command. While a long period works fine, some games may still require shorter ones. diff --git a/Dinput8Wrapper.vcxproj b/Dinput8Wrapper.vcxproj index c8f139e..80b1515 100644 --- a/Dinput8Wrapper.vcxproj +++ b/Dinput8Wrapper.vcxproj @@ -403,14 +403,14 @@ cd $(OutDir) && for /D /r %d in (.\Deploy\*) do @xcopy *.dll %d\ - - + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - + + \ No newline at end of file diff --git a/Dinput8Wrapper.vcxproj.filters b/Dinput8Wrapper.vcxproj.filters index d90455d..d66b721 100644 --- a/Dinput8Wrapper.vcxproj.filters +++ b/Dinput8Wrapper.vcxproj.filters @@ -13,8 +13,8 @@ - + diff --git a/DllMain.cpp b/DllMain.cpp index b89e999..1ce0a0e 100644 --- a/DllMain.cpp +++ b/DllMain.cpp @@ -889,6 +889,7 @@ int configMaxForce = GetPrivateProfileInt(TEXT("Settings"), TEXT("MaxForce"), 10 int enableLogging = GetPrivateProfileInt(TEXT("Settings"), TEXT("Logging"), 0, settingsFilename); int PowerMode = GetPrivateProfileInt(TEXT("Settings"), TEXT("PowerMode"), 0, settingsFilename); int EnableRumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("EnableRumble"), 0, settingsFilename); +int EnableRumbleTriggers = GetPrivateProfileInt(TEXT("Settings"), TEXT("EnableRumbleTriggers"), 0, settingsFilename); int ReverseRumble = GetPrivateProfileInt(TEXT("Settings"), TEXT("ReverseRumble"), 0, settingsFilename); wchar_t* deviceGUIDString = new wchar_t[256]; int DeviceGUID = GetPrivateProfileString(TEXT("Settings"), TEXT("DeviceGUID"), NULL, deviceGUIDString, 256, settingsFilename); @@ -1017,8 +1018,9 @@ HINSTANCE Get_hInstance() void Initialize(int device_index) { - SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER | SDL_INIT_HAPTIC); hlp.log("in initialize"); + SDL_SetHint(SDL_HINT_JOYSTICK_RAWINPUT, "0"); + SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC); SDL_JoystickEventState(SDL_ENABLE); SDL_JoystickUpdate(); char joystick_guid[256]; @@ -1934,6 +1936,26 @@ void TriggerRumbleEffectDevice3(double highfrequency, double lowfrequency, doubl } } +void TriggerRumbleTriggerEffect(double lefttrigger, double righttrigger, double length) +{ + if (EnableRumbleTriggers == 1) + { + DWORD minForceLow = (DWORD)(lefttrigger > 0.001 ? (configMinForce / 100.0 * 65535.0) : 0); + DWORD minForceHigh = (DWORD)(righttrigger > 0.001 ? (configMinForce / 100.0 * 65535.0) : 0); + DWORD maxForce = (DWORD)(configMaxForce / 100.0 * 65535.0); + DWORD rangeLow = maxForce - minForceLow; + DWORD rangeHigh = maxForce - minForceHigh; + DWORD LeftMotor = (DWORD)(lefttrigger * rangeLow + minForceLow); + DWORD RightMotor = (DWORD)(righttrigger * rangeHigh + minForceHigh); + + int RumbleTriggers = SDL_JoystickRumbleTriggers(GameController, LeftMotor, RightMotor, length); + if (RumbleTriggers == -1) + { + EnableRumbleTriggers = 0; + } + } +} + void TriggerSpringEffect(double strength) { TriggerSpringEffectWithDefaultOption(strength, false); @@ -2256,6 +2278,7 @@ DWORD WINAPI FFBLoop(LPVOID lpParam) t.Rumble = &TriggerRumbleEffect; t.RumbleDevice2 = &TriggerRumbleEffectDevice2; t.RumbleDevice3 = &TriggerRumbleEffectDevice3; + t.RumbleTriggers = &TriggerRumbleTriggerEffect; t.LeftRight = &TriggerLeftRightEffect; t.LeftRightDevice2 = &TriggerLeftRightDevice2Effect; t.Springi = &TriggerSpringEffectInfinite; @@ -3294,6 +3317,11 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ulReasonForCall, LPVOID lpReserved) { SDL_JoystickRumble(GameController, 0, 0, 0); } + + if (EnableRumbleTriggers == 1) + { + SDL_JoystickRumbleTriggers(GameController, 0, 0, 0); + } } if (GameController2) diff --git a/packages.config b/packages.config index 96f5eb6..fb0cb53 100644 --- a/packages.config +++ b/packages.config @@ -1,5 +1,5 @@  - - + + \ No newline at end of file