Add interface to NVDA screen reader in accessibility patch
authorH.G.Muller <hgm@hgm-xboard.(none)>
Tue, 5 Jul 2022 19:26:54 +0000 (21:26 +0200)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Tue, 5 Jul 2022 19:26:54 +0000 (21:26 +0200)
When the compiler switch NVDA is defined, the accessible version will
use the NVDA screen reader when that is running. Otherwise it will still
use JAWS.

winboard/jaws.c

index 1524a80..a6c1927 100644 (file)
@@ -240,16 +240,41 @@ AdaptMenu()
        DrawMenuBar(hwndMain);\r
 }\r
 \r
+#ifdef NVDA\r
+\r
+#   include "nvdaController.h"\r
+\r
+    void\r
+    SayNVDA(char *text, BOOL interrupt)\r
+    {\r
+       static wchar_t buf[8000];\r
+        if(interrupt) nvdaController_cancelSpeech();\r
+       MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, text, -1, buf, 8000);\r
+        nvdaController_speakText(buf);\r
+    }\r
+\r
+\r
+#   undef UNICODE\r
+\r
+#endif\r
+\r
 BOOL\r
 InitJAWS()\r
 {      // to be called at beginning of WinMain, after InitApplication and InitInstance\r
-       HINSTANCE hApi = LoadLibrary("jfwapi32.dll");\r
-       if(!hApi) {\r
+#ifdef NVDA\r
+       RealSayString = (PSAYSTRING) &SayNVDA; // assume NVDA\r
+       if(nvdaController_testIfRunning()) {   // no NVDA; try JAWS\r
+#else\r
+       {\r
+#endif\r
+           HINSTANCE hApi = LoadLibrary("jfwapi32.dll");\r
+           if(!hApi) { // no interface to JAWS either\r
                DisplayInformation("Missing jfwapi32.dll");\r
                return (FALSE);\r
+           }\r
+           RealSayString = (PSAYSTRING)GetProcAddress(hApi, "JFWSayString");\r
        }\r
 \r
-       RealSayString = (PSAYSTRING)GetProcAddress(hApi, "JFWSayString");\r
        if(!RealSayString) {\r
                DisplayInformation("SayString returned a null pointer");\r
                return (FALSE);\r