Esempio n. 1
0
static void enterLearnMode(void)
{
  int res;
  brlapi_keyCode_t code;
  int cmd;
  char buf[0X100];

  fprintf(stderr,"Entering command learn mode\n");
  if (brlapi_enterTtyMode(-1, NULL)<0) {
    brlapi_perror("enterTtyMode");
    return;
  }

  if (brlapi_writeText(BRLAPI_CURSOR_OFF, "command learn mode")<0) {
    brlapi_perror("brlapi_writeText");
    exit(PROG_EXIT_FATAL);
  }

  while ((res = brlapi_readKey(1, &code)) != -1) {
    fprintf(stderr, "got key %016"BRLAPI_PRIxKEYCODE"\n",code);
    cmd = cmdBrlapiToBrltty(code);
    describeCommand(cmd, buf, sizeof(buf),
                    CDO_IncludeName | CDO_IncludeOperand);
    brlapi_writeText(BRLAPI_CURSOR_OFF, buf);
    fprintf(stderr, "%s\n", buf);
    if (cmd==BRL_CMD_LEARN) return;
  }
  brlapi_perror("brlapi_readKey");
}
Esempio n. 2
0
static int
handleLearnModeCommands (int command, void *data) {
  LearnModeData *lmd = data;
  logMessage(LOG_DEBUG, "learn: command=%06X", command);

  switch (command & BRL_MSK_CMD) {
    case BRL_CMD_LEARN:
      lmd->state = LMS_EXIT;
      return 1;

    case BRL_CMD_NOOP:
      lmd->state = LMS_CONTINUE;
      return 1;

    default:
      lmd->state = LMS_CONTINUE;
      break;
  }

  {
    char buffer[0X100];

    describeCommand(command, buffer, sizeof(buffer),
                    CDO_IncludeName | CDO_IncludeOperand);

    logMessage(LOG_DEBUG, "learn: %s", buffer);
    if (!message(lmd->mode, buffer, MSG_SYNC|MSG_NODELAY)) lmd->state = LMS_ERROR;
  }

  return 1;
}
Esempio n. 3
0
static int
putCommandDescription (ListGenerationData *lgd, int command, int details) {
  char description[0X60];

  describeCommand(command, description, sizeof(description),
                  details? (CDO_IncludeOperand | CDO_DefaultOperand): 0);
  return putUtf8String(lgd, description);
}
Esempio n. 4
0
static size_t
formatCommand (char *buffer, size_t size, int command) {
  size_t length;
  STR_BEGIN(buffer, size);

  STR_PRINTF("%06X (", command);

  {
    size_t length = describeCommand(command, STR_NEXT, STR_LEFT, 
                                    CDO_IncludeName | CDO_IncludeOperand);
    STR_ADJUST(length);
  }

  STR_PRINTF(")");

  length = STR_LENGTH;
  STR_END;
  return length;
}
Esempio n. 5
0
void MystScriptParser::runOpcode(uint16 op, uint16 var, const ArgumentsArray &args) {
	_scriptNestingLevel++;

	bool ranOpcode = false;
	for (uint16 i = 0; i < _opcodes.size(); i++)
		if (_opcodes[i].op == op) {
			if (DebugMan.isDebugChannelEnabled(kDebugScript)) {
				debugC(kDebugScript, "Running command: %s", describeCommand(_opcodes[i], var, args).c_str());
			}

			(*_opcodes[i].proc)(var, args);
			ranOpcode = true;
			break;
		}

	if (!ranOpcode)
		warning("Trying to run invalid opcode %d", op);

	_scriptNestingLevel--;
}