1
0
mirror of synced 2024-11-30 17:34:33 +01:00

Fix TTS Talking every button press

This commit is contained in:
Aaron M 2020-07-19 11:40:08 +12:00
parent c7a6daf1a0
commit d6eb8440bd

View File

@ -2038,26 +2038,29 @@ DWORD WINAPI AdjustFFBStrengthLoop(LPVOID lpParam)
if (EnableFFBStrengthTextToSpeech == 1) if (EnableFFBStrengthTextToSpeech == 1)
{ {
if (AlternativeFFB == 1) if ((e.jbutton.button == IncreaseFFBStrength) || (e.jbutton.button == DecreaseFFBStrength) || (e.jbutton.button == ResetFFBStrength))
{ {
sprintf(FFBStrength1, "Max Force: %d", configAlternativeMaxForceRight); if (AlternativeFFB == 1)
} {
else sprintf(FFBStrength1, "Max Force: %d", configAlternativeMaxForceRight);
{ }
sprintf(FFBStrength1, "Max Force: %d", configMaxForce); else
} {
sprintf(FFBStrength1, "Max Force: %d", configMaxForce);
}
hr = ::CoInitialize(nullptr); hr = ::CoInitialize(nullptr);
hr = cpVoice.CoCreateInstance(CLSID_SpVoice); hr = cpVoice.CoCreateInstance(CLSID_SpVoice);
mbstowcs(FFBStrength2, FFBStrength1, strlen(FFBStrength1) + 1); mbstowcs(FFBStrength2, FFBStrength1, strlen(FFBStrength1) + 1);
LPWSTR ptr = FFBStrength2; LPWSTR ptr = FFBStrength2;
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
hr = cpVoice->SetRate(3); hr = cpVoice->SetRate(3);
hr = cpVoice->SetOutput(NULL, TRUE); hr = cpVoice->SetOutput(NULL, TRUE);
hr = cpVoice->Speak(ptr, SPF_PURGEBEFORESPEAK, NULL); hr = cpVoice->Speak(ptr, SPF_PURGEBEFORESPEAK, NULL);
::CoUninitialize(); ::CoUninitialize();
}
} }
} }
} }