1
0
mirror of synced 2024-11-24 06:50:11 +01:00

Add Text to Speech for FFB Strength Adjustment

This commit is contained in:
Aaron M 2020-06-25 18:30:20 +12:00
parent 301daf6bc1
commit 580f3cd6a6
2 changed files with 35 additions and 7 deletions

View File

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

View File

@ -25,6 +25,8 @@ along with FFB Arcade Plugin.If not, see < https://www.gnu.org/licenses/>.
#include <thread>
#include "IDirectInputDevice.h"
#include <d3d11.h>
#include <sapi.h>
#include <atlbase.h>
#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<ISpVoice> 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();
}
}
}
}
}