Пример #1
0
static void suspendDriver(void)
{
  char name[30];
  fprintf(stderr, "Getting driver name: ");
  if (brlapi_getDriverName(name, sizeof(name))<0) {
    brlapi_perror("failed");
    exit(PROG_EXIT_FATAL);
  }
  fprintf(stderr, "%s\n", name);
  fprintf(stderr, "Suspending\n");
  if (brlapi_suspendDriver(name)) {
    brlapi_perror("suspend");
  } else {
#ifdef SIGUSR1
    signal(SIGUSR1,emptySignalHandler);
#endif /* SIGUSR1 */
    fprintf(stderr, "Sleeping\n");
#ifdef HAVE_PAUSE
    pause();
#endif /* HAVE_PAUSE */
    fprintf(stderr, "Resuming\n");
#ifdef SIGUSR1
    signal(SIGUSR1,SIG_DFL);
#endif /* SIGUSR1 */
    if (brlapi_resumeDriver())
      brlapi_perror("resumeDriver");
  }
}
Пример #2
0
static void showKeyCodes(void)
{
  int res;
  brlapi_keyCode_t cmd;
  char buf[0X100];

  fprintf(stderr,"Entering keycode learn mode\n");
  if (brlapi_getDriverName(buf, sizeof(buf))==-1) {
    brlapi_perror("getDriverName");
    return;
  }
  if (brlapi_enterTtyMode(-1, buf)<0) {
    brlapi_perror("enterTtyMode");
    return;
  }

  if (brlapi_acceptAllKeys()==-1) {
    brlapi_perror("acceptAllKeys");
    return;
  }

  if (brlapi_writeText(BRLAPI_CURSOR_OFF, "show key codes")<0) {
    brlapi_perror("brlapi_writeText");
    exit(PROG_EXIT_FATAL);
  }

  while ((res = brlapi_readKey(1, &cmd)) != -1) {
    sprintf(buf, "0X%" BRLAPI_PRIxKEYCODE " (%" BRLAPI_PRIuKEYCODE ")",cmd, cmd);
    brlapi_writeText(BRLAPI_CURSOR_OFF, buf);
    fprintf(stderr, "%s\n", buf);
  }
  brlapi_perror("brlapi_readKey");
}
Пример #3
0
BDevice::BDevice() : accessibilityMode(false), x(0), y(0)
{
  name.resize(BRLAPI_MAXNAMELENGTH + 1);
  this->socket = brlapi_openConnection(NULL, NULL);
  brlapi_getDisplaySize(&x, &y);
  brlapi_getDriverName(&name[0], BRLAPI_MAXNAMELENGTH + 1);
}
Пример #4
0
static void showDriverName(void)
{
  char name[30];
  fprintf(stderr, "Getting driver name: ");
  if (brlapi_getDriverName(name, sizeof(name))<0) {
    brlapi_perror("failed");
    exit(PROG_EXIT_FATAL);
  }
  fprintf(stderr, "%s\n", name);
}
Пример #5
0
/*
** Initialize the application and connect to brlapi
** Init brlapi raw mode and print a welcome message on the terminal
*/
int		brl_init(t_env *env)
{
  brlapi_settings_t settings;
  char p[100];
  unsigned int x, y;

  settings.host = NULL;
  /* Connect to BrlAPI */
  if (brlapi_initializeConnection(NULL, NULL) < 0)
    {
      brlapi_perror("brlapi_initializeConnection");
      return -1;
    }

  /* Get driver id & name */

  brlapi_getDriverName(p, 100);
  if (!p)
    brlapi_perror("brlapi_getDriverName");
  else
    printf("Driver name: %s\n",p);

  /* Get display size */
  if (brlapi_getDisplaySize(&x, &y) < 0)
    brlapi_perror("brlapi_getDisplaySize");
  else
    printf("Braille display has %d line%s of %d column%s\n",y,y>1?"s":"",x,x>1?"s":"");

  /* Try entering raw mode, immediately go out from raw mode */
  printf("Trying to enter in raw mode... ");
  if (brlapi_enterRawMode("EuroBraille") < 0)
    brlapi_perror("brlapi_getRaw");
  else {
    printf("Ok\n");
  }
  /* welcome message */
  brl_lasting_message(EUTP_VERSION);
  get_ident(env->ident);
  printf("Identification: %20s\n", env->ident);
  return 0;
}
Пример #6
0
int main(int argc, char *argv[]) {
 transferfun *transfer;
 char driverName[13];
 int stilloptions=1;
 char *home;
 brlapi_settings_t brlapi_settings;
 
 transfer=CheckSendOrRecv(argv[0]);

/* first use options file */
 if ((home=getenv("HOME"))) {
  char vstprc[strlen(home)+strlen(VSTPRC)+2];
  strcpy(vstprc,home);
  strcat(vstprc,"/" VSTPRC);
  Parse(vstprc);
 }

/* a first pass to check options and record them, before doing anything */
 CheckOptions(argc--,argv++);

/* ok, one can try to open the socket */
 brlapi_settings.host = socketport;
 brlapi_settings.auth = keyname; 
 if (brlapi_initializeConnection(&brlapi_settings,NULL)<0)
 {
  brlapi_perror("Couldn't initialize connection with BrlAPI");
  exit(RET_ECONN);
 }
 if (brlapi_getDriverName(driverName, sizeof(driverName))<12)
 {
  brlapi_perror("Couldn't get driver name");
  brlapi_closeConnection();
  exit(RET_ECONN);
 }
 if (strcmp(driverName,"VisioBraille"))
 {
  fprintf(stderr,"braille driver is not VisioBraille\n");
  brlapi_closeConnection();
  exit(RET_ECONN);  
 }
 
 if (brlapi_enterRawMode("VisioBraille")<0) {
  fprintf(stderr,"Couldn't get raw mode\n");
  brlapi_closeConnection();
  exit(RET_ECONN);
 }

 signal(SIGINT,handleint);
 signal(SIGTERM,handleint);

#ifdef SIGHUP
 signal(SIGHUP,handleint);
#endif /* SIGHUP */

#ifdef SIGQUIT
 signal(SIGQUIT,handleint);
#endif /* SIGQUIT */

#ifdef SIGPIPE
 signal(SIGPIPE,handleint);
#endif /* SIGPIPE */

#ifdef SIGALRM
 signal(SIGALRM,transfer_timeout);
#endif /* SIGALRM */

 if (visiobases_dir && chdir(visiobases_dir)<0) {
  perror(visiobases_dir);
  fprintf(stderr,"couldn't chdir to download dir, please use -d if you want to store files in .\n");
  exit(RET_EUNIX);
 }

 for(;argc;argc--, argv++) {
/* is it an option ? */
  if (stilloptions)
  if (argv[0][0]=='-') {
   switch (argv[0][1]) {
     case '-': stilloptions=0; continue;
     case 's': /* already parsed */
     case 'k':
     case 'm':
	       argc--;
	       argv++;
     case 'b':
     case 'n':
     case 'f':
     case 'i':
     case 'd':
     default:
	       continue;
   }
  }
  
/* no, a file name, let's try to transfer it */
  transfer(argv[0]);
 }
 printf("transfers finished\n");
 transfer_finish(transfer);
 brlapi_leaveRawMode(); /* can't do much it it fails ! */
 brlapi_closeConnection();
 return 0;
}