Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic setup to be able to call the NVDA text-to-speech API on Win64 only. #16847

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Common/Common.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@
<ClInclude Include="..\ext\libpng17\pnglibconf.h" />
<ClInclude Include="..\ext\libpng17\pngpriv.h" />
<ClInclude Include="..\ext\libpng17\pngstruct.h" />
<ClInclude Include="..\ext\nvda\x64\nvdaController.h" />
<ClInclude Include="..\ext\vma\vk_mem_alloc.h" />
<ClInclude Include="ABI.h" />
<ClInclude Include="Arm64Emitter.h" />
Expand Down Expand Up @@ -552,6 +553,7 @@
<ClInclude Include="Thread\ThreadUtil.h" />
<ClInclude Include="Thunk.h" />
<ClInclude Include="TimeUtil.h" />
<ClInclude Include="TTS\TTS.h" />
<ClInclude Include="UI\AsyncImageFileView.h" />
<ClInclude Include="UI\Context.h" />
<ClInclude Include="UI\PopupScreens.h" />
Expand Down Expand Up @@ -996,6 +998,7 @@
<ClCompile Include="Thread\ThreadUtil.cpp" />
<ClCompile Include="Thunk.cpp" />
<ClCompile Include="TimeUtil.cpp" />
<ClCompile Include="TTS\TTS.cpp" />
<ClCompile Include="UI\AsyncImageFileView.cpp" />
<ClCompile Include="UI\Context.cpp" />
<ClCompile Include="UI\PopupScreens.cpp" />
Expand Down
15 changes: 15 additions & 0 deletions Common/Common.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,12 @@
<ClInclude Include="UI\PopupScreens.h">
<Filter>UI</Filter>
</ClInclude>
<ClInclude Include="..\ext\nvda\x64\nvdaController.h">
<Filter>ext\nvda</Filter>
</ClInclude>
<ClInclude Include="TTS\TTS.h">
<Filter>TTS</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="ABI.cpp" />
Expand Down Expand Up @@ -878,6 +884,9 @@
<ClCompile Include="UI\PopupScreens.cpp">
<Filter>UI</Filter>
</ClCompile>
<ClCompile Include="TTS\TTS.cpp">
<Filter>TTS</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Filter Include="Crypto">
Expand Down Expand Up @@ -985,6 +994,12 @@
<Filter Include="VR">
<UniqueIdentifier>{9d1c29fd-8ac7-4475-8ea6-c8c759b695fe}</UniqueIdentifier>
</Filter>
<Filter Include="TTS">
<UniqueIdentifier>{2f13e9d2-148c-4428-9954-c581d481742f}</UniqueIdentifier>
</Filter>
<Filter Include="ext\nvda">
<UniqueIdentifier>{a66dfba3-5469-458f-a89a-6341080421c8}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<Text Include="..\ext\libpng17\CMakeLists.txt">
Expand Down
30 changes: 30 additions & 0 deletions Common/TTS/TTS.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include "ppsspp_config.h"

#include <string>

#if PPSSPP_PLATFORM(WINDOWS) && PPSSPP_ARCH(AMD64) && !PPSSPP_PLATFORM(UWP)

#include "ext/nvda/x64/nvdaController.h"
#include "Common/Data/Encoding/Utf8.h"

void TTS_Say(const char *text) {
std::wstring wstr = ConvertUTF8ToWString(text);
nvdaController_speakText(wstr.c_str());
}

void TTS_Braille(const char *text) {
std::wstring wstr = ConvertUTF8ToWString(text);
nvdaController_speakText(wstr.c_str());
}

bool TTS_Active() {
return nvdaController_testIfRunning() == 0;
}

#else

void TTS_Active() { return false; }
void TTS_Say(const char *text) {}
void TTS_Braille(const char *text) {}

#endif
10 changes: 10 additions & 0 deletions Common/TTS/TTS.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#pragma once

// Wraps NVDA text-to-speech and possibly other TTS libraries later.
//
// If NVDA is unsupported on the platform or not activated, all the calls will just fail,
// so we don't have to add checks all over the place.

bool TTS_Active();
void TTS_Say(const char *text);
void TTS_Braille(const char *text);
6 changes: 6 additions & 0 deletions Windows/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "Common/Input/KeyCodes.h"
#include "Common/Thread/ThreadUtil.h"
#include "Common/Data/Encoding/Utf8.h"
#include "Common/TTS/TTS.h"

#include "Core/Core.h"
#include "Core/Config.h"
Expand Down Expand Up @@ -473,6 +474,11 @@ namespace MainWindow
}

void UpdateWindowTitle() {
if (TTS_Active()) {
// Don't want to speak the whole version number in debug mode, etc...
SetWindowText(hwndMain, L"PPSSPP");
return;
}
// Seems to be fine to call now since we use a UNICODE build...
std::wstring title = windowTitle;
if (PPSSPP_ID >= 1 && GetInstancePeerCount() > 1) {
Expand Down
4 changes: 2 additions & 2 deletions Windows/PPSSPP.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@
<AdditionalOptions>$(EXTERNAL_COMPILE_OPTIONS)</AdditionalOptions>
</ClCompile>
<Link>
<AdditionalDependencies>uxtheme.lib;mf.lib;mfplat.lib;mfreadwrite.lib;mfuuid.lib;shlwapi.lib;Winmm.lib;Ws2_32.lib;dsound.lib;comctl32.lib;d3d9.lib;dxguid.lib;avcodec.lib;avformat.lib;avutil.lib;swresample.lib;swscale.lib;opengl32.lib;glu32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>..\ext\nvda\x64\nvdaControllerClient64.lib;muxtheme.lib;mf.lib;mfplat.lib;mfreadwrite.lib;mfuuid.lib;shlwapi.lib;Winmm.lib;Ws2_32.lib;dsound.lib;comctl32.lib;d3d9.lib;dxguid.lib;avcodec.lib;avformat.lib;avutil.lib;swresample.lib;swscale.lib;opengl32.lib;glu32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>../ffmpeg/Windows/x86_64/lib</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
Expand Down Expand Up @@ -1768,4 +1768,4 @@
<UserProperties RESOURCE_FILE="DaSh.rc" />
</VisualStudio>
</ProjectExtensions>
</Project>
</Project>
5 changes: 5 additions & 0 deletions Windows/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
#include "Common/ConsoleListener.h"
#include "Common/StringUtils.h"

#include "Common/TTS/TTS.h"

#include "Commctrl.h"

#include "UI/GameInfoCache.h"
Expand Down Expand Up @@ -576,6 +578,8 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin

WinMainInit();

TTS_Say("Welcome to PPSSPP");

#ifndef _DEBUG
bool showLog = false;
#else
Expand Down Expand Up @@ -803,6 +807,7 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
timeEndPeriod(1);

LogManager::Shutdown();

WinMainCleanup();

return 0;
Expand Down
Loading