static int toDifferentLine ( IsSameCharacter isSameCharacter, CanMoveWindow canMoveWindow, int amount, int from, int width ) { if (canMoveWindow()) { ScreenCharacter characters1[width]; unsigned int skipped = 0; if ((isSameCharacter == isSameText) && ses->displayMode) isSameCharacter = isSameAttributes; readScreen(from, ses->winy, width, 1, characters1); do { ScreenCharacter characters2[width]; readScreen(from, ses->winy+=amount, width, 1, characters2); if (!isSameRow(characters1, characters2, width, isSameCharacter) || (showScreenCursor() && (scr.posy == ses->winy) && (scr.posx >= from) && (scr.posx < (from + width)))) { return 1; } /* lines are identical */ alertLineSkipped(&skipped); } while (canMoveWindow()); } alert(ALERT_BOUNCE); return 0; }
size_t formatCharacterDescription (char *buffer, size_t size, int column, int row) { static char *const colours[] = { strtext("black"), strtext("blue"), strtext("green"), strtext("cyan"), strtext("red"), strtext("magenta"), strtext("brown"), strtext("light grey"), strtext("dark grey"), strtext("light blue"), strtext("light green"), strtext("light cyan"), strtext("light red"), strtext("light magenta"), strtext("yellow"), strtext("white") }; size_t length; ScreenCharacter character; readScreen(column, row, 1, 1, &character); STR_BEGIN(buffer, size); { uint32_t text = character.text; STR_PRINTF("char %" PRIu32 " (U+%04" PRIX32 "): %s on %s", text, text, gettext(colours[character.attributes & 0X0F]), gettext(colours[(character.attributes & 0X70) >> 4])); } if (character.attributes & SCR_ATTR_BLINK) { STR_PRINTF(" %s", gettext("blink")); } #ifdef HAVE_ICU { char name[0X40]; UErrorCode error = U_ZERO_ERROR; u_charName(character.text, U_EXTENDED_CHAR_NAME, name, sizeof(name), &error); if (U_SUCCESS(error)) { STR_PRINTF(" [%s]", name); } } #endif /* HAVE_ICU */ length = STR_LENGTH; STR_END; return length; }
extern "C" void TakeScreenshot(int iFrameNumber) { char filepath[PATH_MAX], filename[PATH_MAX]; // get screenshot directory and base filename (based on ROM header) GetBaseFilepath(filepath, PATH_MAX - 10); // look for an unused screenshot filename for (; CurrentShotIndex < 1000; CurrentShotIndex++) { sprintf(filename, "%s-%03i.png", filepath, CurrentShotIndex); FILE *pFile = fopen(filename, "r"); if (pFile == NULL) break; fclose(pFile); } if (CurrentShotIndex >= 1000) { DebugMessage(M64MSG_ERROR, "Can't save screenshot; folder already contains 1000 screenshots for this ROM"); return; } CurrentShotIndex++; // get the width and height int width = 640; int height = 480; readScreen(NULL, &width, &height, 0); // allocate memory for the image unsigned char *pucFrame = (unsigned char *) malloc(width * height * 3); if (pucFrame == 0) return; // grab the back image from OpenGL by calling the video plugin readScreen(pucFrame, &width, &height, 0); // write the image to a PNG SaveRGBBufferToFile(filename, pucFrame, width, height, width * 3); // free the memory free(pucFrame); // print message -- this allows developers to capture frames and use them in the regression test main_message(M64MSG_INFO, OSD_BOTTOM_LEFT, "Captured screenshot for frame %i.", iFrameNumber); }
int trackCursor (int place) { if (!SCR_CURSOR_OK()) return 0; #ifdef ENABLE_CONTRACTED_BRAILLE if (isContracted) { ses->winy = scr.posy; if (scr.posx < ses->winx) { int length = scr.posx + 1; ScreenCharacter characters[length]; int onspace = 1; readScreen(0, ses->winy, length, 1, characters); while (length) { if ((iswspace(characters[--length].text) != 0) != onspace) { if (onspace) { onspace = 0; } else { ++length; break; } } } ses->winx = length; } contractedTrack = 1; return 1; } #endif /* ENABLE_CONTRACTED_BRAILLE */ if (place) { if ((scr.posx < ses->winx) || (scr.posx >= (int)(ses->winx + textCount)) || (scr.posy < ses->winy) || (scr.posy >= (int)(ses->winy + brl.textRows))) { placeWindowHorizontally(scr.posx); } } if (prefs.slidingWindow) { int reset = textCount * 3 / 10; int trigger = prefs.eagerSlidingWindow? textCount*3/20: 0; if (scr.posx < (ses->winx + trigger)) { ses->winx = MAX(scr.posx-reset, 0); } else if (scr.posx >= (int)(ses->winx + textCount - trigger)) { ses->winx = MAX(MIN(scr.posx+reset+1, scr.cols)-(int)textCount, 0); } } else if (scr.posx < ses->winx) { ses->winx -= ((ses->winx - scr.posx - 1) / textCount + 1) * textCount; if (ses->winx < 0) ses->winx = 0; } else { ses->winx += (scr.posx - ses->winx) / textCount * textCount; } slideWindowVertically(scr.posy); return 1; }
int readScreenText (short left, short top, short width, short height, wchar_t *buffer) { unsigned int count = width * height; ScreenCharacter characters[count]; if (!readScreen(left, top, width, height, characters)) return 0; { int i; for (i=0; i<count; ++i) buffer[i] = characters[i].text; } return 1; }
static void sayScreenRegion (int left, int top, int width, int height, int track, SayMode mode) { size_t count = width * height; ScreenCharacter characters[count]; if (mode == sayImmediate) muteSpeech(__func__); readScreen(left, top, width, height, characters); spk.track.isActive = track; spk.track.screenNumber = scr.number; spk.track.firstLine = top; spk.track.speechLocation = SPK_LOC_NONE; sayScreenCharacters(characters, count, 0); }
static void speakDone (const ScreenCharacter *line, int column, int count, int spell) { ScreenCharacter internalBuffer[count]; if (line) { line = &line[column]; } else { readScreen(column, ses->spky, count, 1, internalBuffer); line = internalBuffer; } speakCharacters(line, count, spell); placeWindowHorizontally(ses->spkx); slideWindowVertically(ses->spky); }
static int readScreenRow (RoutingData *routing, ScreenCharacter *buffer, int row) { if (!buffer) buffer = routing->rowBuffer; return readScreen(0, row, routing->screenColumns, 1, buffer); }
/********************************************************************************************************* * emulation thread - runs the core */ m64p_error main_run(void) { VILimit = (float) GetVILimit(); VILimitMilliseconds = (double) 1000.0/VILimit; /* take the r4300 emulator mode from the config file at this point and cache it in a global variable */ r4300emu = ConfigGetParamInt(g_CoreConfig, "R4300Emulator"); /* set some other core parameters based on the config file values */ savestates_set_autoinc_slot(ConfigGetParamBool(g_CoreConfig, "AutoStateSlotIncrement")); savestates_select_slot(ConfigGetParamInt(g_CoreConfig, "CurrentStateSlot")); no_compiled_jump = ConfigGetParamBool(g_CoreConfig, "NoCompiledJump"); /* set up the SDL key repeat and event filter to catch keyboard/joystick commands for the core */ event_initialize(); // initialize memory, and do byte-swapping if it's not been done yet if (g_MemHasBeenBSwapped == 0) { init_memory(1); g_MemHasBeenBSwapped = 1; } else { init_memory(0); } // Attach rom to plugins if (!romOpen_gfx()) { free_memory(); SDL_Quit(); return M64ERR_PLUGIN_FAIL; } if (!romOpen_audio()) { romClosed_gfx(); free_memory(); SDL_Quit(); return M64ERR_PLUGIN_FAIL; } if (!romOpen_input()) { romClosed_audio(); romClosed_gfx(); free_memory(); SDL_Quit(); return M64ERR_PLUGIN_FAIL; } if (ConfigGetParamBool(g_CoreConfig, "OnScreenDisplay")) { // init on-screen display int width = 640, height = 480; readScreen(NULL, &width, &height, 0); // read screen to get width and height osd_init(width, height); } // setup rendering callback from video plugin to the core, for screenshots and On-Screen-Display setRenderingCallback(video_plugin_render_callback); #ifdef WITH_LIRC lircStart(); #endif // WITH_LIRC #ifdef DBG if (ConfigGetParamBool(g_CoreConfig, "EnableDebugger")) init_debugger(); #endif /* Startup message on the OSD */ osd_new_message(OSD_MIDDLE_CENTER, "Mupen64Plus Started..."); g_EmulatorRunning = 1; StateChanged(M64CORE_EMU_STATE, M64EMU_RUNNING); /* call r4300 CPU core and run the game */ r4300_reset_hard(); r4300_reset_soft(); r4300_execute(); #ifdef WITH_LIRC lircStop(); #endif // WITH_LIRC #ifdef DBG if (g_DebuggerActive) destroy_debugger(); #endif if (ConfigGetParamBool(g_CoreConfig, "OnScreenDisplay")) { osd_exit(); } romClosed_RSP(); romClosed_input(); romClosed_audio(); romClosed_gfx(); free_memory(); // clean up g_EmulatorRunning = 0; StateChanged(M64CORE_EMU_STATE, M64EMU_STOPPED); SDL_Quit(); return M64ERR_SUCCESS; }
int handleSpeechCommand (int command, void *datga) { switch (command & BRL_MSK_CMD) { case BRL_CMD_RESTARTSPEECH: restartSpeechDriver(); break; case BRL_CMD_SPKHOME: if (scr.number == spk.track.screenNumber) { trackSpeech(); } else { playTune(&tune_command_rejected); } break; case BRL_CMD_AUTOSPEAK: toggleFeatureSetting(&prefs.autospeak, command); break; case BRL_CMD_ASPK_SEL_LINE: toggleFeatureSetting(&prefs.autospeakSelectedLine, command); break; case BRL_CMD_ASPK_SEL_CHAR: toggleFeatureSetting(&prefs.autospeakSelectedCharacter, command); break; case BRL_CMD_ASPK_INS_CHARS: toggleFeatureSetting(&prefs.autospeakInsertedCharacters, command); break; case BRL_CMD_ASPK_DEL_CHARS: toggleFeatureSetting(&prefs.autospeakDeletedCharacters, command); break; case BRL_CMD_ASPK_REP_CHARS: toggleFeatureSetting(&prefs.autospeakReplacedCharacters, command); break; case BRL_CMD_ASPK_CMP_WORDS: toggleFeatureSetting(&prefs.autospeakCompletedWords, command); break; case BRL_CMD_MUTE: muteSpeech("command"); break; case BRL_CMD_SAY_LINE: sayScreenLines(ses->winy, 1, 0, prefs.sayLineMode); break; case BRL_CMD_SAY_ABOVE: sayScreenLines(0, ses->winy+1, 1, sayImmediate); break; case BRL_CMD_SAY_BELOW: sayScreenLines(ses->winy, scr.rows-ses->winy, 1, sayImmediate); break; case BRL_CMD_SAY_SLOWER: if (!canSetSpeechRate()) { playTune(&tune_command_rejected); } else if (prefs.speechRate > 0) { setSpeechRate(--prefs.speechRate, 1); } else { playTune(&tune_no_change); } break; case BRL_CMD_SAY_FASTER: if (!canSetSpeechRate()) { playTune(&tune_command_rejected); } else if (prefs.speechRate < SPK_RATE_MAXIMUM) { setSpeechRate(++prefs.speechRate, 1); } else { playTune(&tune_no_change); } break; case BRL_CMD_SAY_SOFTER: if (!canSetSpeechVolume()) { playTune(&tune_command_rejected); } else if (prefs.speechVolume > 0) { setSpeechVolume(--prefs.speechVolume, 1); } else { playTune(&tune_no_change); } break; case BRL_CMD_SAY_LOUDER: if (!canSetSpeechVolume()) { playTune(&tune_command_rejected); } else if (prefs.speechVolume < SPK_VOLUME_MAXIMUM) { setSpeechVolume(++prefs.speechVolume, 1); } else { playTune(&tune_no_change); } break; case BRL_CMD_SPEAK_CURR_CHAR: speakCurrentCharacter(); break; case BRL_CMD_SPEAK_PREV_CHAR: if (ses->spkx > 0) { ses->spkx -= 1; speakCurrentCharacter(); } else if (ses->spky > 0) { ses->spky -= 1; ses->spkx = scr.cols - 1; playTune(&tune_wrap_up); speakCurrentCharacter(); } else { playTune(&tune_bounce); } break; case BRL_CMD_SPEAK_NEXT_CHAR: if (ses->spkx < (scr.cols - 1)) { ses->spkx += 1; speakCurrentCharacter(); } else if (ses->spky < (scr.rows - 1)) { ses->spky += 1; ses->spkx = 0; playTune(&tune_wrap_down); speakCurrentCharacter(); } else { playTune(&tune_bounce); } break; case BRL_CMD_SPEAK_FRST_CHAR: { ScreenCharacter characters[scr.cols]; int column; readScreen(0, ses->spky, scr.cols, 1, characters); if ((column = findFirstNonSpaceCharacter(characters, scr.cols)) >= 0) { ses->spkx = column; speakDone(characters, column, 1, 0); } else { playTune(&tune_command_rejected); } break; } case BRL_CMD_SPEAK_LAST_CHAR: { ScreenCharacter characters[scr.cols]; int column; readScreen(0, ses->spky, scr.cols, 1, characters); if ((column = findLastNonSpaceCharacter(characters, scr.cols)) >= 0) { ses->spkx = column; speakDone(characters, column, 1, 0); } else { playTune(&tune_command_rejected); } break; } { int direction; int spell; case BRL_CMD_SPEAK_PREV_WORD: direction = -1; spell = 0; goto speakWord; case BRL_CMD_SPEAK_NEXT_WORD: direction = 1; spell = 0; goto speakWord; case BRL_CMD_SPEAK_CURR_WORD: direction = 0; spell = 0; goto speakWord; case BRL_CMD_SPELL_CURR_WORD: direction = 0; spell = 1; goto speakWord; speakWord: { int row = ses->spky; int column = ses->spkx; ScreenCharacter characters[scr.cols]; ScreenCharacterType type; int onCurrentWord; int from = column; int to = from + 1; findWord: readScreen(0, row, scr.cols, 1, characters); type = (row == ses->spky)? getScreenCharacterType(&characters[column]): SCT_SPACE; onCurrentWord = type != SCT_SPACE; if (direction < 0) { while (1) { if (column == 0) { if ((type != SCT_SPACE) && !onCurrentWord) { ses->spkx = from = column; ses->spky = row; break; } if (row == 0) goto noWord; if (row-- == ses->spky) playTune(&tune_wrap_up); column = scr.cols; goto findWord; } { ScreenCharacterType newType = getScreenCharacterType(&characters[--column]); if (newType != type) { if (onCurrentWord) { onCurrentWord = 0; } else if (type != SCT_SPACE) { ses->spkx = from = column + 1; ses->spky = row; break; } if (newType != SCT_SPACE) to = column + 1; type = newType; } } } } else if (direction > 0) { while (1) { if (++column == scr.cols) { if ((type != SCT_SPACE) && !onCurrentWord) { to = column; ses->spkx = from; ses->spky = row; break; } if (row == (scr.rows - 1)) goto noWord; if (row++ == ses->spky) playTune(&tune_wrap_down); column = -1; goto findWord; } { ScreenCharacterType newType = getScreenCharacterType(&characters[column]); if (newType != type) { if (onCurrentWord) { onCurrentWord = 0; } else if (type != SCT_SPACE) { to = column; ses->spkx = from; ses->spky = row; break; } if (newType != SCT_SPACE) from = column; type = newType; } } } } else if (type != SCT_SPACE) { while (from > 0) { if (getScreenCharacterType(&characters[--from]) != type) { from += 1; break; } } while (to < scr.cols) { if (getScreenCharacterType(&characters[to]) != type) break; to += 1; } } speakDone(characters, from, to-from, spell); break; } noWord: playTune(&tune_bounce); break; } case BRL_CMD_SPEAK_CURR_LINE: speakCurrentLine(); break; { int increment; int limit; case BRL_CMD_SPEAK_PREV_LINE: increment = -1; limit = 0; goto speakLine; case BRL_CMD_SPEAK_NEXT_LINE: increment = 1; limit = scr.rows - 1; goto speakLine; speakLine: if (ses->spky == limit) { playTune(&tune_bounce); } else { if (prefs.skipIdenticalLines) { ScreenCharacter original[scr.cols]; ScreenCharacter current[scr.cols]; int count = 0; readScreen(0, ses->spky, scr.cols, 1, original); do { readScreen(0, ses->spky+=increment, scr.cols, 1, current); if (!isSameRow(original, current, scr.cols, isSameText)) break; if (!count) { playTune(&tune_skip_first); } else if (count < 4) { playTune(&tune_skip); } else if (!(count % 4)) { playTune(&tune_skip_more); } count += 1; } while (ses->spky != limit); } else { ses->spky += increment; } speakCurrentLine(); } break; } case BRL_CMD_SPEAK_FRST_LINE: { ScreenCharacter characters[scr.cols]; int row = 0; while (row < scr.rows) { readScreen(0, row, scr.cols, 1, characters); if (!isAllSpaceCharacters(characters, scr.cols)) break; row += 1; } if (row < scr.rows) { ses->spky = row; ses->spkx = 0; speakCurrentLine(); } else { playTune(&tune_command_rejected); } break; } case BRL_CMD_SPEAK_LAST_LINE: { ScreenCharacter characters[scr.cols]; int row = scr.rows - 1; while (row >= 0) { readScreen(0, row, scr.cols, 1, characters); if (!isAllSpaceCharacters(characters, scr.cols)) break; row -= 1; } if (row >= 0) { ses->spky = row; ses->spkx = 0; speakCurrentLine(); } else { playTune(&tune_command_rejected); } break; } case BRL_CMD_DESC_CURR_CHAR: { char description[0X50]; formatCharacterDescription(description, sizeof(description), ses->spkx, ses->spky); sayString(description, 1); break; } case BRL_CMD_ROUTE_CURR_LOCN: if (routeCursor(ses->spkx, ses->spky, scr.number)) { playTune(&tune_routing_started); } else { playTune(&tune_command_rejected); } break; case BRL_CMD_SPEAK_CURR_LOCN: { char buffer[0X50]; snprintf(buffer, sizeof(buffer), "%s %d, %s %d", gettext("line"), ses->spky+1, gettext("column"), ses->spkx+1); sayString(buffer, 1); break; } case BRL_CMD_SHOW_CURR_LOCN: toggleFeatureSetting(&prefs.showSpeechCursor, command); break; default: return 0; } return 1; }
logic::CScenario* CScenariosXmlDao::readScenario(const string& path){ TiXmlDocument doc(path.c_str()); if(!doc.LoadFile()) return false; // Creamos el escenario para comenzar a llenarlo logic::CScenario* scenario = new logic::CScenario(); TiXmlHandle hDoc(&doc); // Recuperamos el elemento del nodo raiz TiXmlElement* pElem = hDoc.FirstChildElement().Element(); TiXmlHandle hRoot(pElem); // Recorremos los graficos TiXmlElement* pGfxElement = hRoot.FirstChild("gfx").Element(); while(pGfxElement){ //cout<<"Etiqueta: "<<pGfxElement->Value()<<"\n"; // Recorremos los graficos estaticos TiXmlHandle hGfx(pGfxElement); TiXmlElement* pStaticGfxElement = hGfx.FirstChild("static_gfx").Element(); while(pStaticGfxElement){ //cout<<"Etiqueta: "<<pStaticGfxElement->Value()<<"\n"; // Recorremos cada elemento estatico y multimedia TiXmlHandle hStaticGfx(pStaticGfxElement); TiXmlElement* pStaticElement = hStaticGfx.FirstChild("static").Element(); TiXmlElement* pMultElement= hStaticGfx.FirstChild("multimedia").Element(); TiXmlElement* pScreenElement= hStaticGfx.FirstChild("screen").Element(); // Leemos las pantallas que haya while(pScreenElement){ logic::CScreen* screen = readScreen(pScreenElement); scenario->setScreen(screen); pScreenElement = pScreenElement->NextSiblingElement("screen"); } // Leo elementos multimedia while(pMultElement){ logic::CMultimediaFurniture* mult = readMultFur(pMultElement); scenario->addMultimediaFurniture(mult); pMultElement = pMultElement->NextSiblingElement("multimedia"); } // Leo elementos estaticos while(pStaticElement){ //cout<<"Etiqueta: "<<pStaticElement->Value()<<"\n"; logic::CEntity* entity = readStaticEntity(pStaticElement); if(entity->id() == "screen") scenario->setScreen(entity); scenario->addFurniture(entity); pStaticElement = pStaticElement->NextSiblingElement("static"); } pStaticGfxElement = pStaticGfxElement->NextSiblingElement("static_gfx"); } // Recorremos los graficos animados TiXmlElement* pAnimatedGfxElement = hGfx.FirstChild("animated_gfx").Element(); while(pAnimatedGfxElement){ //cout<<"Etiqueta: "<<pAnimatedGfxElement->Value()<<"\n"; TiXmlHandle hAnimatedGfx(pAnimatedGfxElement); // Recorremos cada jugador animado TiXmlElement* pPlayerElement = hAnimatedGfx.FirstChild("player").Element(); while(pPlayerElement){ logic::CPlayer* player = readPlayer(pPlayerElement); scenario->addPlayer(player); pPlayerElement = pPlayerElement->NextSiblingElement("player"); } // Recorremos cada personaje del publico TiXmlElement* pHostElement = hAnimatedGfx.FirstChild("host").Element(); while(pHostElement){ logic::CQuizShowHost* host = readHost(pHostElement); scenario->setHost(host); pHostElement = pHostElement->NextSiblingElement("host"); } // Recorremos cada personaje del publico TiXmlElement* pPublicElement = hAnimatedGfx.FirstChild("public").Element(); while(pPublicElement){ logic::CAvatar* audience = readAudience(pPublicElement); scenario->addAudience(audience); pPublicElement = pPublicElement->NextSiblingElement("public"); } pAnimatedGfxElement = pAnimatedGfxElement->NextSiblingElement("animated_gfx"); } pGfxElement = pGfxElement->NextSiblingElement("gfx"); } return scenario; }
int main (int argc, char *argv[]) { ProgramExitStatus exitStatus; void *driverObject; { static const OptionsDescriptor descriptor = { OPTION_TABLE(programOptions), .applicationName = "scrtest", .argumentsSummary = "[parameter=value ...]" }; PROCESS_OPTIONS(descriptor, argc, argv); } if ((screen = loadScreenDriver(opt_screenDriver, &driverObject, opt_driversDirectory))) { const char *const *parameterNames = getScreenParameters(screen); char **parameterSettings; if (!parameterNames) { static const char *const noNames[] = {NULL}; parameterNames = noNames; } { const char *const *name = parameterNames; unsigned int count; char **setting; while (*name) ++name; count = name - parameterNames; if (!(parameterSettings = malloc((count + 1) * sizeof(*parameterSettings)))) { logMallocError(); return PROG_EXIT_FATAL; } setting = parameterSettings; while (count--) *setting++ = ""; *setting = NULL; } while (argc) { char *assignment = *argv++; int ok = 0; char *delimiter = strchr(assignment, '='); if (!delimiter) { logMessage(LOG_ERR, "missing screen parameter value: %s", assignment); } else if (delimiter == assignment) { logMessage(LOG_ERR, "missing screen parameter name: %s", assignment); } else { size_t nameLength = delimiter - assignment; const char *const *name = parameterNames; while (*name) { if (strncasecmp(assignment, *name, nameLength) == 0) { parameterSettings[name - parameterNames] = delimiter + 1; ok = 1; break; } ++name; } if (!ok) logMessage(LOG_ERR, "invalid screen parameter: %s", assignment); } if (!ok) return PROG_EXIT_SYNTAX; --argc; } if (constructScreenDriver(parameterSettings)) { ScreenDescription description; int left, top, width, height; describeScreen(&description); printf("Screen: %dx%d\n", description.cols, description.rows); printf("Cursor: [%d,%d]\n", description.posx, description.posy); if (setRegion(&left, opt_boxLeft, "starting column", &width, opt_boxWidth, description.cols, "region width")) { if (setRegion(&top, opt_boxTop, "starting row", &height, opt_boxHeight, description.rows, "region height")) { printf("Region: %dx%d@[%d,%d]\n", width, height, left, top); { ScreenCharacter buffer[width * height]; if (readScreen(left, top, width, height, buffer)) { int line; for (line=0; line<height; line++) { int column; for (column=0; column<width; column++) { wchar_t character = buffer[line * width + column].text; if (!iswLatin1(character)) { putchar('?'); } else if (!isprint(character)) { putchar('*'); } else { putchar(character); } } putchar('\n'); } exitStatus = PROG_EXIT_SUCCESS; } else { logMessage(LOG_ERR, "Can't read screen."); exitStatus = PROG_EXIT_FATAL; } } } else { exitStatus = PROG_EXIT_SYNTAX; } } else { exitStatus = PROG_EXIT_SYNTAX; } } else { logMessage(LOG_ERR, "can't open screen."); exitStatus = PROG_EXIT_FATAL; } destructScreenDriver(); } else { logMessage(LOG_ERR, "can't load screen driver."); exitStatus = PROG_EXIT_FATAL; } return exitStatus; }
static int handleSpeechCommands (int command, void *data) { switch (command & BRL_MSK_CMD) { case BRL_CMD_RESTARTSPEECH: restartSpeechDriver(); break; case BRL_CMD_SPKHOME: if (scr.number == spk.track.screenNumber) { trackSpeech(); } else { alert(ALERT_COMMAND_REJECTED); } break; case BRL_CMD_MUTE: muteSpeech(&spk, "command"); break; case BRL_CMD_SAY_LINE: sayScreenLines(ses->winy, 1, 0, prefs.sayLineMode); break; case BRL_CMD_SAY_ABOVE: sayScreenLines(0, ses->winy+1, 1, sayImmediate); break; case BRL_CMD_SAY_BELOW: sayScreenLines(ses->winy, scr.rows-ses->winy, 1, sayImmediate); break; case BRL_CMD_SAY_SLOWER: if (!canSetSpeechRate(&spk)) { alert(ALERT_COMMAND_REJECTED); } else if (prefs.speechRate > 0) { setSpeechRate(&spk, --prefs.speechRate, 1); } else { alert(ALERT_NO_CHANGE); } break; case BRL_CMD_SAY_FASTER: if (!canSetSpeechRate(&spk)) { alert(ALERT_COMMAND_REJECTED); } else if (prefs.speechRate < SPK_RATE_MAXIMUM) { setSpeechRate(&spk, ++prefs.speechRate, 1); } else { alert(ALERT_NO_CHANGE); } break; case BRL_CMD_SAY_SOFTER: if (!canSetSpeechVolume(&spk)) { alert(ALERT_COMMAND_REJECTED); } else if (prefs.speechVolume > 0) { setSpeechVolume(&spk, --prefs.speechVolume, 1); } else { alert(ALERT_NO_CHANGE); } break; case BRL_CMD_SAY_LOUDER: if (!canSetSpeechVolume(&spk)) { alert(ALERT_COMMAND_REJECTED); } else if (prefs.speechVolume < SPK_VOLUME_MAXIMUM) { setSpeechVolume(&spk, ++prefs.speechVolume, 1); } else { alert(ALERT_NO_CHANGE); } break; case BRL_CMD_SPEAK_CURR_CHAR: speakCurrentCharacter(); break; case BRL_CMD_SPEAK_PREV_CHAR: if (ses->spkx > 0) { ses->spkx -= 1; speakCurrentCharacter(); } else if (ses->spky > 0) { ses->spky -= 1; ses->spkx = scr.cols - 1; alert(ALERT_WRAP_UP); speakCurrentCharacter(); } else { alert(ALERT_BOUNCE); } break; case BRL_CMD_SPEAK_NEXT_CHAR: if (ses->spkx < (scr.cols - 1)) { ses->spkx += 1; speakCurrentCharacter(); } else if (ses->spky < (scr.rows - 1)) { ses->spky += 1; ses->spkx = 0; alert(ALERT_WRAP_DOWN); speakCurrentCharacter(); } else { alert(ALERT_BOUNCE); } break; case BRL_CMD_SPEAK_FRST_CHAR: { ScreenCharacter characters[scr.cols]; int column; readScreen(0, ses->spky, scr.cols, 1, characters); if ((column = findFirstNonSpaceCharacter(characters, scr.cols)) >= 0) { ses->spkx = column; speakDone(characters, column, 1, 0); } else { alert(ALERT_COMMAND_REJECTED); } break; } case BRL_CMD_SPEAK_LAST_CHAR: { ScreenCharacter characters[scr.cols]; int column; readScreen(0, ses->spky, scr.cols, 1, characters); if ((column = findLastNonSpaceCharacter(characters, scr.cols)) >= 0) { ses->spkx = column; speakDone(characters, column, 1, 0); } else { alert(ALERT_COMMAND_REJECTED); } break; } { int direction; int spell; case BRL_CMD_SPEAK_PREV_WORD: direction = -1; spell = 0; goto speakWord; case BRL_CMD_SPEAK_NEXT_WORD: direction = 1; spell = 0; goto speakWord; case BRL_CMD_SPEAK_CURR_WORD: direction = 0; spell = 0; goto speakWord; case BRL_CMD_SPELL_CURR_WORD: direction = 0; spell = 1; goto speakWord; speakWord: { int row = ses->spky; int column = ses->spkx; ScreenCharacter characters[scr.cols]; ScreenCharacterType type; int onCurrentWord; int from = column; int to = from + 1; findWord: readScreen(0, row, scr.cols, 1, characters); type = (row == ses->spky)? getScreenCharacterType(&characters[column]): SCT_SPACE; onCurrentWord = type != SCT_SPACE; if (direction < 0) { while (1) { if (column == 0) { if ((type != SCT_SPACE) && !onCurrentWord) { ses->spkx = from = column; ses->spky = row; break; } if (row == 0) goto noWord; if (row-- == ses->spky) alert(ALERT_WRAP_UP); column = scr.cols; goto findWord; } { ScreenCharacterType newType = getScreenCharacterType(&characters[--column]); if (newType != type) { if (onCurrentWord) { onCurrentWord = 0; } else if (type != SCT_SPACE) { ses->spkx = from = column + 1; ses->spky = row; break; } if (newType != SCT_SPACE) to = column + 1; type = newType; } } } } else if (direction > 0) { while (1) { if (++column == scr.cols) { if ((type != SCT_SPACE) && !onCurrentWord) { to = column; ses->spkx = from; ses->spky = row; break; } if (row == (scr.rows - 1)) goto noWord; if (row++ == ses->spky) alert(ALERT_WRAP_DOWN); column = -1; goto findWord; } { ScreenCharacterType newType = getScreenCharacterType(&characters[column]); if (newType != type) { if (onCurrentWord) { onCurrentWord = 0; } else if (type != SCT_SPACE) { to = column; ses->spkx = from; ses->spky = row; break; } if (newType != SCT_SPACE) from = column; type = newType; } } } } else if (type != SCT_SPACE) { while (from > 0) { if (getScreenCharacterType(&characters[--from]) != type) { from += 1; break; } } while (to < scr.cols) { if (getScreenCharacterType(&characters[to]) != type) break; to += 1; } } speakDone(characters, from, to-from, spell); break; } noWord: alert(ALERT_BOUNCE); break; } case BRL_CMD_SPEAK_CURR_LINE: speakCurrentLine(); break; { int increment; int limit; case BRL_CMD_SPEAK_PREV_LINE: increment = -1; limit = 0; goto speakLine; case BRL_CMD_SPEAK_NEXT_LINE: increment = 1; limit = scr.rows - 1; goto speakLine; speakLine: if (ses->spky == limit) { alert(ALERT_BOUNCE); } else { if (prefs.skipIdenticalLines) { ScreenCharacter original[scr.cols]; ScreenCharacter current[scr.cols]; int count = 0; readScreen(0, ses->spky, scr.cols, 1, original); do { readScreen(0, ses->spky+=increment, scr.cols, 1, current); if (!isSameRow(original, current, scr.cols, isSameText)) break; if (!count) { alert(ALERT_SKIP_FIRST); } else if (count < 4) { alert(ALERT_SKIP); } else if (!(count % 4)) { alert(ALERT_SKIP_MORE); } count += 1; } while (ses->spky != limit); } else { ses->spky += increment; } speakCurrentLine(); } break; } case BRL_CMD_SPEAK_FRST_LINE: { ScreenCharacter characters[scr.cols]; int row = 0; while (row < scr.rows) { readScreen(0, row, scr.cols, 1, characters); if (!isAllSpaceCharacters(characters, scr.cols)) break; row += 1; } if (row < scr.rows) { ses->spky = row; ses->spkx = 0; speakCurrentLine(); } else { alert(ALERT_COMMAND_REJECTED); } break; } case BRL_CMD_SPEAK_LAST_LINE: { ScreenCharacter characters[scr.cols]; int row = scr.rows - 1; while (row >= 0) { readScreen(0, row, scr.cols, 1, characters); if (!isAllSpaceCharacters(characters, scr.cols)) break; row -= 1; } if (row >= 0) { ses->spky = row; ses->spkx = 0; speakCurrentLine(); } else { alert(ALERT_COMMAND_REJECTED); } break; } case BRL_CMD_DESC_CURR_CHAR: { char description[0X50]; formatCharacterDescription(description, sizeof(description), ses->spkx, ses->spky); sayString(&spk, description, SAY_OPT_MUTE_FIRST); break; } case BRL_CMD_ROUTE_CURR_LOCN: if (routeCursor(ses->spkx, ses->spky, scr.number)) { alert(ALERT_ROUTING_STARTED); } else { alert(ALERT_COMMAND_REJECTED); } break; case BRL_CMD_SPEAK_CURR_LOCN: { char buffer[0X50]; snprintf(buffer, sizeof(buffer), "%s %d, %s %d", gettext("line"), ses->spky+1, gettext("column"), ses->spkx+1); sayString(&spk, buffer, SAY_OPT_MUTE_FIRST); break; } default: return 0; } return 1; }