Implement multiple alarms in accessible WinBoard veersion
authorH.G.Muller <hgm@hgm-xboard.(none)>
Fri, 22 Jul 2022 19:55:24 +0000 (21:55 +0200)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Fri, 22 Jul 2022 20:15:57 +0000 (22:15 +0200)
Blind players need to be warned at certain times before their
clock runs out. A new persistent string option -alarmTimes can
specify a comma-separated list of times relative to flagging
(in seconds) at which an alarm has to sound. This alarm uses
the sound selected for the 'ICS Alarm' event. When this is set
to 'no sound', the clock times will be spoken.
The alarm sounds on the first clock to reach the specified time.

common.h
winboard/jaws.c

index 6eb89df..4dbb76a 100644 (file)
--- a/common.h
+++ b/common.h
@@ -824,6 +824,7 @@ typedef struct {
     int tourneyCycles;
     int seedBase;
     int bmpSave;
+    char *alarmTimes;
     Boolean roundSync;
     Boolean cycleSync;
     Boolean numberTag;
index ef5b18e..7760575 100644 (file)
@@ -176,6 +176,7 @@ static int timeflag;
 static int suppressClocks = 0;\r
 static int suppressOneKey = 0;\r
 static HANDLE hAccelJAWS;\r
+extern int jawsClock;\r
 \r
 typedef struct { char *name; int code; } MenuItemDesc;\r
 \r
@@ -966,6 +967,7 @@ SayAllBoard()
                                    Xpos--;\r
                                }\r
                                SayString("empty", FALSE);\r
+\r
                        }\r
                }\r
        }\r
@@ -1148,15 +1150,21 @@ SayMachineMove(int evenIfDuplicate)
 }\r
 \r
 VOID\r
-SayClockTime()\r
+SayClockTime(int warning)\r
 {\r
        char buf1[50], buf2[50];\r
        char *str1, *str2;\r
        static long int lastWhiteTime, lastBlackTime;\r
 \r
-       suppressClocks = 1; // if user is using alt+T command, no reason to display them\r
+    if(!warning) {\r
+       suppressClocks = jawsClock = 1; // if user is using alt+T command, no reason to display them\r
        if(abs(lastWhiteTime - whiteTimeRemaining) < 1000 && abs(lastBlackTime - blackTimeRemaining) < 1000)\r
                suppressClocks = 0; // back on after two requests in rapid succession\r
+       else if(gameMode == EditGame || gameMode == BeginningOfGame) {\r
+               appData.clockMode = TRUE;\r
+               if(!pausing) StartClocks();\r
+       }\r
+    }\r
        snprintf(buf1, sizeof(buf1)/sizeof(buf1[0]),"%s", TimeString(whiteTimeRemaining));\r
        str1 = buf1;\r
        SayString("White clock", FALSE);\r
@@ -1167,6 +1175,7 @@ SayClockTime()
        SayString(str2, FALSE);\r
        lastWhiteTime = whiteTimeRemaining;\r
        lastBlackTime = blackTimeRemaining;\r
+       if(pausing) SayString("neither clock is running", FALSE);\r
        SayString("", TRUE); // flush\r
 }\r
 \r
@@ -1269,12 +1278,32 @@ NiceTime(int x)
        return (x%3000 == 0);\r
 }\r
 \r
+VOID\r
+TimeWarning()\r
+{\r
+  int ta, t = (whiteTimeRemaining < blackTimeRemaining ? whiteTimeRemaining: blackTimeRemaining);\r
+  char *p = appData.alarmTimes;\r
+  static int last_t;\r
+  t = (t + 1000)/2000;\r
+  if(t > last_t) last_t = 0;\r
+  while((ta = atoi(p))) {\r
+    if(t == ta/2 && t != last_t) {\r
+      last_t = t;\r
+      if(sounds[(int)SoundAlarm].name[0] == NULLCHAR) SayString("time warning", FALSE), SayClockTime(1);\r
+      else PlayAlarmSound();\r
+    }\r
+    p = strchr(p, ','); if(p == NULL) break;\r
+    p++;\r
+  }\r
+}\r
+\r
 #define JAWS_ARGS \\r
   { "beepOffBoard", ArgInt, (LPVOID) beeps, TRUE, (ArgIniType) 1 },\\r
   { "beepEmpty", ArgInt, (LPVOID) (beeps+1), TRUE, (ArgIniType) 0 },\\r
   { "beepWhite", ArgInt, (LPVOID) (beeps+2), TRUE, (ArgIniType) 0 },\\r
   { "beepBlack", ArgInt, (LPVOID) (beeps+3), TRUE, (ArgIniType) 0 },\\r
   { "beepHoldings", ArgInt, (LPVOID) (beeps+4), TRUE, (ArgIniType) 0 },\\r
+  { "alarmTimes", ArgString, (LPVOID) &appData.alarmTimes, TRUE, (ArgIniType) "" },\\r
 \r
 #define JAWS_ALT_INTERCEPT \\r
            if(suppressOneKey) {\\r
@@ -1394,7 +1423,7 @@ NiceTime(int x)
                        break;\\r
 \\r
                case IDM_SayClockTime:  /*Say the clock time */\\r
-                       SayClockTime();\\r
+                       SayClockTime(0);\\r
                        break;\\r
 \\r
                case IDM_SayWhosTurn:   /* Say whos turn it its */\\r
@@ -1447,7 +1476,7 @@ NiceTime(int x)
 \r
 #define JAWS_DELETE(X)\r
 \r
-#define JAWS_SILENCE if(suppressClocks) return;\r
+#define JAWS_SILENCE TimeWarning(); if(suppressClocks) return;\r
 \r
 #define JAWS_COPYRIGHT \\r
        SetDlgItemText(hDlg, OPT_MESS, "Auditory/Keyboard Enhancements  By:  Ed Rodriguez (sort of)");\r