コード例 #1
0
ファイル: BDevice.cpp プロジェクト: kevinderome/bcat
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);
}
コード例 #2
0
ファイル: braille.c プロジェクト: Feechka/UOBP
/* Opens a connection with BrlAPI's server */
static int brl_construct(BrailleDisplay *brl, char **parameters, const char *device)
{
  brlapi_connectionSettings_t settings;
  settings.host = parameters[PARM_HOST];
  settings.auth = parameters[PARM_AUTH];
  CHECK((brlapi_openConnection(&settings, &settings)>=0), out);
  logMessage(LOG_DEBUG, "Connected to %s using %s", settings.host, settings.auth);
  CHECK((brlapi_enterTtyModeWithPath(NULL, 0, NULL)>=0), out0);
  logMessage(LOG_DEBUG, "Got tty successfully");
  CHECK((brlapi_getDisplaySize(&brl->textColumns, &brl->textRows)==0), out1);
  logMessage(LOG_DEBUG,"Found out display size: %dx%d", brl->textColumns, brl->textRows);
  displaySize = brl->textColumns*brl->textRows;
  prevData = malloc(displaySize);
  CHECK((prevData!=NULL), out1);
  prevText = malloc(displaySize * sizeof(wchar_t));
  CHECK((prevText!=NULL), out2);
  prevShown = 0;
  restart = 0;
  logMessage(LOG_DEBUG, "Memory allocated, returning 1");
  return 1;
  
out2:
  free(prevData);
out1:
  brlapi_leaveTtyMode();
out0:
  brlapi_closeConnection();
out:
  logMessage(LOG_DEBUG, "Something went wrong, returning 0");
  return 0;
}
コード例 #3
0
ファイル: apitest.c プロジェクト: plundblad/brltty
END_OPTION_TABLE

static void showDisplaySize(void)
{
  unsigned int x, y;
  fprintf(stderr,"Getting display size: ");
  if (brlapi_getDisplaySize(&x, &y)<0) {
    brlapi_perror("failed");
    exit(PROG_EXIT_FATAL);
  }
  fprintf(stderr, "%dX%d\n", x, y);
}
コード例 #4
0
ファイル: apitest.c プロジェクト: plundblad/brltty
static void showDots(void)
{
  unsigned int x, y;
  brlapi_keyCode_t k;
  if (brlapi_getDisplaySize(&x, &y)<0) {
    brlapi_perror("failed");
    exit(PROG_EXIT_FATAL);
  }
  if (brlapi_enterTtyMode(-1, NULL)<0) {
    brlapi_perror("enterTtyMode");
    exit(PROG_EXIT_FATAL);
  }
  if (x*y<DOTS_TOTALLEN) {
    fprintf(stderr,"can't show dots with a braille display with less than %d cells\n",(int)DOTS_TOTALLEN);
    exit(PROG_EXIT_SEMANTIC);
  }
  {
    char text[x*y+1];
    unsigned char or[x*y];
    brlapi_writeArguments_t wa = BRLAPI_WRITEARGUMENTS_INITIALIZER;
    fprintf(stderr,"Showing dot patterns\n");
    memcpy(text,DOTS_TEXT,DOTS_TEXTLEN);
    memset(text+DOTS_TEXTLEN,' ',sizeof(text)-DOTS_TEXTLEN);
    text[x*y] = 0;
    wa.regionBegin = 1;
    wa.regionSize = sizeof(or);
    wa.text = text;
    memset(or,0,sizeof(or));
    or[DOTS_TEXTLEN+0] = BRL_DOT_1;
    or[DOTS_TEXTLEN+1] = BRL_DOT_2;
    or[DOTS_TEXTLEN+2] = BRL_DOT_3;
    or[DOTS_TEXTLEN+3] = BRL_DOT_4;
    or[DOTS_TEXTLEN+4] = BRL_DOT_5;
    or[DOTS_TEXTLEN+5] = BRL_DOT_6;
    or[DOTS_TEXTLEN+6] = BRL_DOT_7;
    or[DOTS_TEXTLEN+7] = BRL_DOT_8;
    wa.orMask = or;
    if (brlapi_write(&wa)<0) {
      brlapi_perror("brlapi_write");
      exit(PROG_EXIT_FATAL);
    }
  }
  brlapi_readKey(1, &k);
}
コード例 #5
0
ファイル: eutp_brl.c プロジェクト: MarkMielke/brltty
/*
** 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;
}