diff --git a/Config/FFBPlugin.ini b/Config/FFBPlugin.ini index 1b38c6e..08d68fe 100644 --- a/Config/FFBPlugin.ini +++ b/Config/FFBPlugin.ini @@ -52,12 +52,8 @@ ResetFFBStrength= ; Step is the amount to adjust when increasing or decreasing per button where FFB strength is represented on ; a scale of 0-100. StepFFBStrength=5 -; Set to 1 if you want FFB strength adjustments to persist between loads, else 0. -EnablePersistentMaxForce=0 -; 0-100: the previous max force strength set if persistence is enabled. -1 means this has not yet been saved. -PersistentMaxForce=-1 -PersistentAlternativeMaxForceLeft=1 -PersistentAlternativeMaxForceRight=-1 +; Set to 1 if you want FFB strength adjustments text to speech over speaker +EnableFFBStrengthTextToSpeech=0 ; *********************************************************************************************************************************** ; ************************************************ Game overrides are specified below *********************************************** diff --git a/DllMain.cpp b/DllMain.cpp index e2e89fe..bfb72eb 100644 --- a/DllMain.cpp +++ b/DllMain.cpp @@ -25,6 +25,8 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>. #include #include "IDirectInputDevice.h" #include +#include +#include #include "Config/PersistentValues.h" @@ -927,11 +929,17 @@ int IncreaseFFBStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("IncreaseF int DecreaseFFBStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("DecreaseFFBStrength"), NULL, settingsFilename); int ResetFFBStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("ResetFFBStrength"), NULL, settingsFilename); int StepFFBStrength = GetPrivateProfileInt(TEXT("Settings"), TEXT("StepFFBStrength"), 5, settingsFilename); +int EnableFFBStrengthTextToSpeech = GetPrivateProfileInt(TEXT("Settings"), TEXT("EnableFFBStrengthTextToSpeech"), 0, settingsFilename); extern void DefaultConfigValues(); extern void CustomFFBStrengthSetup(); char chainedDLL[256]; +static char FFBStrength1[256]; +static wchar_t FFBStrength2[256]; + +HRESULT hr; +CComPtr cpVoice; const int TEST_GAME_CONST = -1; const int TEST_GAME_SINE = -2; @@ -1954,7 +1962,7 @@ void WritePersistentMaxForce() DWORD WINAPI AdjustFFBStrengthLoop(LPVOID lpParam) { SDL_Event e; - + while (true) { while (SDL_WaitEvent(&e) != 0) @@ -2020,6 +2028,30 @@ DWORD WINAPI AdjustFFBStrengthLoop(LPVOID lpParam) DefaultConfigValues(); WritePersistentMaxForce(); } + + if (EnableFFBStrengthTextToSpeech == 1) + { + if (AlternativeFFB == 1) + { + sprintf(FFBStrength1, "Max Force: %d", configAlternativeMaxForceRight); + } + else + { + sprintf(FFBStrength1, "Max Force: %d", configMaxForce); + } + + hr = ::CoInitialize(nullptr); + hr = cpVoice.CoCreateInstance(CLSID_SpVoice); + mbstowcs(FFBStrength2, FFBStrength1, strlen(FFBStrength1) + 1); + LPWSTR ptr = FFBStrength2; + + if (SUCCEEDED(hr)) + { + hr = cpVoice->SetOutput(NULL, TRUE); + hr = cpVoice->Speak(ptr, SPF_PURGEBEFORESPEAK, NULL); + ::CoUninitialize(); + } + } } } }