Skip to content

Commit 9d36c09

Browse files
committed
The basic setup to be able to call the NVDA text-to-speech API on Win64 only.
1 parent 91cca1c commit 9d36c09

File tree

12 files changed

+745
-1
lines changed

12 files changed

+745
-1
lines changed

Common/Common.vcxproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@
384384
<ClInclude Include="..\ext\libpng17\pnglibconf.h" />
385385
<ClInclude Include="..\ext\libpng17\pngpriv.h" />
386386
<ClInclude Include="..\ext\libpng17\pngstruct.h" />
387+
<ClInclude Include="..\ext\nvda\x64\nvdaController.h" />
387388
<ClInclude Include="..\ext\vma\vk_mem_alloc.h" />
388389
<ClInclude Include="ABI.h" />
389390
<ClInclude Include="Arm64Emitter.h" />
@@ -552,6 +553,7 @@
552553
<ClInclude Include="Thread\ThreadUtil.h" />
553554
<ClInclude Include="Thunk.h" />
554555
<ClInclude Include="TimeUtil.h" />
556+
<ClInclude Include="TTS\TTS.h" />
555557
<ClInclude Include="UI\AsyncImageFileView.h" />
556558
<ClInclude Include="UI\Context.h" />
557559
<ClInclude Include="UI\PopupScreens.h" />
@@ -996,6 +998,7 @@
996998
<ClCompile Include="Thread\ThreadUtil.cpp" />
997999
<ClCompile Include="Thunk.cpp" />
9981000
<ClCompile Include="TimeUtil.cpp" />
1001+
<ClCompile Include="TTS\TTS.cpp" />
9991002
<ClCompile Include="UI\AsyncImageFileView.cpp" />
10001003
<ClCompile Include="UI\Context.cpp" />
10011004
<ClCompile Include="UI\PopupScreens.cpp" />

Common/Common.vcxproj.filters

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,12 @@
464464
<ClInclude Include="UI\PopupScreens.h">
465465
<Filter>UI</Filter>
466466
</ClInclude>
467+
<ClInclude Include="..\ext\nvda\x64\nvdaController.h">
468+
<Filter>ext\nvda</Filter>
469+
</ClInclude>
470+
<ClInclude Include="TTS\TTS.h">
471+
<Filter>TTS</Filter>
472+
</ClInclude>
467473
</ItemGroup>
468474
<ItemGroup>
469475
<ClCompile Include="ABI.cpp" />
@@ -878,6 +884,9 @@
878884
<ClCompile Include="UI\PopupScreens.cpp">
879885
<Filter>UI</Filter>
880886
</ClCompile>
887+
<ClCompile Include="TTS\TTS.cpp">
888+
<Filter>TTS</Filter>
889+
</ClCompile>
881890
</ItemGroup>
882891
<ItemGroup>
883892
<Filter Include="Crypto">
@@ -985,6 +994,12 @@
985994
<Filter Include="VR">
986995
<UniqueIdentifier>{9d1c29fd-8ac7-4475-8ea6-c8c759b695fe}</UniqueIdentifier>
987996
</Filter>
997+
<Filter Include="TTS">
998+
<UniqueIdentifier>{2f13e9d2-148c-4428-9954-c581d481742f}</UniqueIdentifier>
999+
</Filter>
1000+
<Filter Include="ext\nvda">
1001+
<UniqueIdentifier>{a66dfba3-5469-458f-a89a-6341080421c8}</UniqueIdentifier>
1002+
</Filter>
9881003
</ItemGroup>
9891004
<ItemGroup>
9901005
<Text Include="..\ext\libpng17\CMakeLists.txt">

Common/TTS/TTS.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include "ppsspp_config.h"
2+
3+
#include <string>
4+
5+
#if PPSSPP_PLATFORM(WINDOWS) && PPSSPP_ARCH(AMD64) && !PPSSPP_PLATFORM(UWP)
6+
7+
#include "ext/nvda/x64/nvdaController.h"
8+
#include "Common/Data/Encoding/Utf8.h"
9+
10+
void TTS_Say(const char *text) {
11+
std::wstring wstr = ConvertUTF8ToWString(text);
12+
nvdaController_speakText(wstr.c_str());
13+
}
14+
15+
void TTS_Braille(const char *text) {
16+
std::wstring wstr = ConvertUTF8ToWString(text);
17+
nvdaController_speakText(wstr.c_str());
18+
}
19+
20+
bool TTS_Active() {
21+
return nvdaController_testIfRunning() == 0;
22+
}
23+
24+
#else
25+
26+
void TTS_Active() { return false; }
27+
void TTS_Say(const char *text) {}
28+
void TTS_Braille(const char *text) {}
29+
30+
#endif

Common/TTS/TTS.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#pragma once
2+
3+
// Wraps NVDA text-to-speech and possibly other TTS libraries later.
4+
//
5+
// If NVDA is unsupported on the platform or not activated, all the calls will just fail,
6+
// so we don't have to add checks all over the place.
7+
8+
bool TTS_Active();
9+
void TTS_Say(const char *text);
10+
void TTS_Braille(const char *text);

Windows/MainWindow.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "Common/Input/KeyCodes.h"
4141
#include "Common/Thread/ThreadUtil.h"
4242
#include "Common/Data/Encoding/Utf8.h"
43+
#include "Common/TTS/TTS.h"
4344

4445
#include "Core/Core.h"
4546
#include "Core/Config.h"
@@ -471,6 +472,11 @@ namespace MainWindow
471472
}
472473

473474
void UpdateWindowTitle() {
475+
if (TTS_Active()) {
476+
// Don't want to speak the whole version number in debug mode, etc...
477+
SetWindowText(hwndMain, L"PPSSPP");
478+
return;
479+
}
474480
// Seems to be fine to call now since we use a UNICODE build...
475481
std::wstring title = windowTitle;
476482
if (PPSSPP_ID >= 1 && GetInstancePeerCount() > 1) {

Windows/PPSSPP.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@
287287
<AdditionalOptions>$(EXTERNAL_COMPILE_OPTIONS)</AdditionalOptions>
288288
</ClCompile>
289289
<Link>
290-
<AdditionalDependencies>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>
290+
<AdditionalDependencies>..\ext\nvda\x64\nvdaControllerClient64.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>
291291
<AdditionalLibraryDirectories>../ffmpeg/Windows/x86_64/lib</AdditionalLibraryDirectories>
292292
<GenerateDebugInformation>true</GenerateDebugInformation>
293293
<ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>

Windows/main.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454
#include "Common/ConsoleListener.h"
5555
#include "Common/StringUtils.h"
5656

57+
#include "Common/TTS/TTS.h"
58+
5759
#include "Commctrl.h"
5860

5961
#include "UI/GameInfoCache.h"
@@ -573,6 +575,8 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
573575

574576
WinMainInit();
575577

578+
TTS_Say("Welcome to PPSSPP");
579+
576580
#ifndef _DEBUG
577581
bool showLog = false;
578582
#else
@@ -800,6 +804,7 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
800804
timeEndPeriod(1);
801805

802806
LogManager::Shutdown();
807+
803808
WinMainCleanup();
804809

805810
return 0;

0 commit comments

Comments
 (0)