Esempio n. 1
0
static int
handleInput (void) {
  int processed = 0;

  suspendCommandQueue();

  if (!isSuspended) {
    apiClaimDriver();
    if (processInput()) processed = 1;
    apiReleaseDriver();
  }

#ifdef ENABLE_API
  else if (apiStarted) {
    switch (readBrailleCommand(&brl, KTB_CTX_DEFAULT)) {
      case BRL_CMD_RESTARTBRL:
        restartBrailleDriver();
        break;

      default:
        processed = 1;
      case EOF:
        break;
    }
  }
#endif /* ENABLE_API */

  resumeCommandQueue();
  return processed;
}
Esempio n. 2
0
static int
processInput (void) {
  int command = readBrailleCommand(&brl, getCurrentCommandContext());

  if (command != EOF) {
    switch (command & BRL_MSK_CMD) {
      case BRL_CMD_OFFLINE:
        if (!isOffline) {
          logMessage(LOG_DEBUG, "braille display offline");
          isOffline = 1;
        }
        return 0;

      default:
        break;
    }
  }

  if (isOffline) {
    logMessage(LOG_DEBUG, "braille display online");
    isOffline = 0;
  }

  if (command == EOF) return 0;
  enqueueCommand(command);
  return 1;
}
Esempio n. 3
0
static int
processInput (void) {
  int command = readBrailleCommand(&brl, getCurrentCommandContext());

  if (command != EOF) {
    switch (command & BRL_MSK_CMD) {
      case BRL_CMD_OFFLINE:
        setBrailleOffline(&brl);
        return 0;

      default:
        break;
    }
  }

  setBrailleOnline(&brl);
  if (command == EOF) return 0;
  enqueueCommand(command);
  return 1;
}
Esempio n. 4
0
static
GIO_INPUT_HANDLER(handleBrailleInput) {
  int processed = 0;

  {
    int error = parameters->error;

    if (error) {
      logActionError(error, "braille input monitor");
      brl.hasFailed = 1;
      return 0;
    }
  }

  suspendCommandQueue();

  if (!brl.isSuspended) {
    if (brl.api) brl.api->claimDriver();
    if (processInput()) processed = 1;
    if (brl.api) brl.api->releaseDriver();
  }

#ifdef ENABLE_API
  else if (brl.api && brl.api->isStarted()) {
    switch (readBrailleCommand(&brl, KTB_CTX_DEFAULT)) {
      case BRL_CMD_RESTARTBRL:
        brl.hasFailed = 1;
        break;

      default:
        processed = 1;
      case EOF:
        break;
    }
  }
#endif /* ENABLE_API */

  resumeCommandQueue();
  return processed;
}