<commit_before>/*
 * BRLTTY - A background process providing access to the console screen (when in
 *          text mode) for a blind person using a refreshable braille display.
 *
 * Copyright (C) 1995-2006 by The BRLTTY Team. All rights reserved.
 *
 * BRLTTY comes with ABSOLUTELY NO WARRANTY.
 *
 * This is free software, placed under the terms of the
 * GNU General Public License, as published by the Free Software
 * Foundation.  Please see the file COPYING for details.
 *
 * Web Page: http://mielke.cc/brltty/
 *
 * This software is maintained by <NAME> <<EMAIL>>.
 */

#include "prologue.h"

#include <stdio.h>
#include <string.h>
#include <errno.h>

#include "Programs/misc.h"
#include "Programs/at2.h"

typedef enum {
  PARM_INPUTMODE
} DriverParameter;
#define BRLPARMS "inputmode"

#define BRLSTAT ST_AlvaStyle
#define BRL_HAVE_PACKET_IO
#include "Programs/brl_driver.h"
#include "braille.h"

/* Communication codes */
static unsigned char HandyDescribe[] = {0XFF};
static unsigned char HandyDescription[] = {0XFE};
static unsigned char HandyBrailleStart[] = {0X01};	/* general header to display braille */
static unsigned char BookwormBrailleEnd[] = {0X16};	/* bookworm trailer to display braille */
static unsigned char BookwormStop[] = {0X05, 0X07};	/* bookworm trailer to display braille */

typedef struct {
  unsigned long int front;
  int column;
  int status;
} Keys;
static Keys currentKeys, pressedKeys, nullKeys;
static unsigned int inputMode;

/* Braille display parameters */
typedef int (ByteInterpreter) (BRL_DriverCommandContext context, unsigned char byte, int *command);
static ByteInterpreter interpretKeyByte;
static ByteInterpreter interpretBookwormByte;
typedef int (KeysInterpreter) (BRL_DriverCommandContext context, const Keys *keys, int *command);
static KeysInterpreter interpretModularKeys;
static KeysInterpreter interpretBrailleWaveKeys;
static KeysInterpreter interpretBrailleStarKeys;
typedef struct {
  const char *name;
  unsigned char identifier;
  unsigned char columns;
  unsigned char statusCells;
  unsigned char helpPage;
  ByteInterpreter *interpretByte;
  KeysInterpreter *interpretKeys;
  unsigned char *brailleStartAddress;
  unsigned char *brailleEndAddress;
  unsigned char *stopAddress;
  unsigned char brailleStartLength;
  unsigned char brailleEndLength;
  unsigned char stopLength;
} ModelDescription;
static const ModelDescription Models[] = {
  {
    .name = "Modular 20+4",
    .identifier = 0X80,
    .columns = 20,
    .statusCells = 4,
    .helpPage = 0,
    .interpretByte = interpretKeyByte,
    .interpretKeys = interpretModularKeys,
    .brailleStartAddress = HandyBrailleStart,
    .brailleStartLength = sizeof(HandyBrailleStart)
  }
  ,
  {
    .name = "Modular 40+4",
    .identifier = 0X89,
    .columns = 40,
    .statusCells = 4,
    .helpPage = 0,
    .interpretByte = interpretKeyByte,
    .interpretKeys = interpretModularKeys,
    .brailleStartAddress = HandyBrailleStart,
    .brailleStartLength = sizeof(HandyBrailleStart)
  }
  ,
  {
    .name = "Modular 80+4",
    .identifier = 0X88,
    .columns = 80,
    .statusCells = 4,
    .helpPage = 0,
    .interpretByte = interpretKeyByte,
    .interpretKeys = interpretModularKeys,
    .brailleStartAddress = HandyBrailleStart,
    .brailleStartLength = sizeof(HandyBrailleStart)
  }
  ,
  {
    .name = "Braille Wave 40",
    .identifier = 0X05,
    .columns = 40,
    .statusCells = 0,
    .helpPage = 0,
    .interpretByte = interpretKeyByte,
    .interpretKeys = interpretBrailleWaveKeys,
    .brailleStartAddress = HandyBrailleStart,
    .brailleStartLength = sizeof(HandyBrailleStart)
  }
  ,
  {
    .name = "Bookworm",
    .identifier = 0X90,
    .columns = 8,
    .statusCells = 0,
    .helpPage = 1,
    .interpretByte = interpretBookwormByte,
    .brailleStartAddress = HandyBrailleStart,
    .brailleStartLength = sizeof(HandyBrailleStart),
    .brailleEndAddress = BookwormBrailleEnd,
    .brailleEndLength = sizeof(BookwormBrailleEnd),
    .stopAddress = BookwormStop,
    .stopLength = sizeof(BookwormStop)
  }
  ,
  {
    .name = "Braillino 20",
    .identifier = 0X72,
    .columns = 20,
    .statusCells = 0,
    .helpPage = 2,
    .interpretByte = interpretKeyByte,
    .interpretKeys = interpretBrailleStarKeys,
    .brailleStartAddress = HandyBrailleStart,
    .brailleStartLength = sizeof(HandyBrailleStart)
  }
  ,
  {
    .name = "Braille Star 40",
    .identifier = 0X74,
    .columns = 40,
    .statusCells = 0,
    .helpPage = 2,
    .interpretByte = interpretKeyByte,
    .interpretKeys = interpretBrailleStarKeys,
    .brailleStartAddress = HandyBrailleStart,
    .brailleStartLength = sizeof(HandyBrailleStart)
  }
  ,
  {
    .name = "Braille Star 80",
    .identifier = 0X78,
    .columns = 80,
    .statusCells = 0,
    .helpPage = 3,
    .interpretByte = interpretKeyByte,
    .interpretKeys = interpretBrailleStarKeys,
    .brailleStartAddress = HandyBrailleStart,
    .brailleStartLength = sizeof(HandyBrailleStart)
  }
  ,
  { /* end of table */ }
};

#define BRLROWS		1
#define MAX_STCELLS	4	/* highest number of status cells */



/* This is the brltty braille mapping standard to Handy's mapping table.
 */
static TranslationTable outputTable;
<commit_msg>Some compilers don't like empty initializers. (dm)<commit_after>/*
 * BRLTTY - A background process providing access to the console screen (when in
 *          text mode) for a blind person using a refreshable braille display.
 *
 * Copyright (C) 1995-2006 by The BRLTTY Team. All rights reserved.
 *
 * BRLTTY comes with ABSOLUTELY NO WARRANTY.
 *
 * This is free software, placed under the terms of the
 * GNU General Public License, as published by the Free Software
 * Foundation.  Please see the file COPYING for details.
 *
 * Web Page: http://mielke.cc/brltty/
 *
 * This software is maintained by <NAME> <<EMAIL>>.
 */

#include "prologue.h"

#include <stdio.h>
#include <string.h>
#include <errno.h>

#include "Programs/misc.h"
#include "Programs/at2.h"

typedef enum {
  PARM_INPUTMODE
} DriverParameter;
#define BRLPARMS "inputmode"

#define BRLSTAT ST_AlvaStyle
#define BRL_HAVE_PACKET_IO
#include "Programs/brl_driver.h"
#include "braille.h"

/* Communication codes */
static unsigned char HandyDescribe[] = {0XFF};
static unsigned char HandyDescription[] = {0XFE};
static unsigned char HandyBrailleStart[] = {0X01};	/* general header to display braille */
static unsigned char BookwormBrailleEnd[] = {0X16};	/* bookworm trailer to display braille */
static unsigned char BookwormStop[] = {0X05, 0X07};	/* bookworm trailer to display braille */

typedef struct {
  unsigned long int front;
  int column;
  int status;
} Keys;
static Keys currentKeys, pressedKeys, nullKeys;
static unsigned int inputMode;

/* Braille display parameters */
typedef int (ByteInterpreter) (BRL_DriverCommandContext context, unsigned char byte, int *command);
static ByteInterpreter interpretKeyByte;
static ByteInterpreter interpretBookwormByte;
typedef int (KeysInterpreter) (BRL_DriverCommandContext context, const Keys *keys, int *command);
static KeysInterpreter interpretModularKeys;
static KeysInterpreter interpretBrailleWaveKeys;
static KeysInterpreter interpretBrailleStarKeys;
typedef struct {
  const char *name;
  unsigned char identifier;
  unsigned char columns;
  unsigned char statusCells;
  unsigned char helpPage;
  ByteInterpreter *interpretByte;
  KeysInterpreter *interpretKeys;
  unsigned char *brailleStartAddress;
  unsigned char *brailleEndAddress;
  unsigned char *stopAddress;
  unsigned char brailleStartLength;
  unsigned char brailleEndLength;
  unsigned char stopLength;
} ModelDescription;
static const ModelDescription Models[] = {
  {
    .name = "Modular 20+4",
    .identifier = 0X80,
    .columns = 20,
    .statusCells = 4,
    .helpPage = 0,
    .interpretByte = interpretKeyByte,
    .interpretKeys = interpretModularKeys,
    .brailleStartAddress = HandyBrailleStart,
    .brailleStartLength = sizeof(HandyBrailleStart)
  }
  ,
  {
    .name = "Modular 40+4",
    .identifier = 0X89,
    .columns = 40,
    .statusCells = 4,
    .helpPage = 0,
    .interpretByte = interpretKeyByte,
    .interpretKeys = interpretModularKeys,
    .brailleStartAddress = HandyBrailleStart,
    .brailleStartLength = sizeof(HandyBrailleStart)
  }
  ,
  {
    .name = "Modular 80+4",
    .identifier = 0X88,
    .columns = 80,
    .statusCells = 4,
    .helpPage = 0,
    .interpretByte = interpretKeyByte,
    .interpretKeys = interpretModularKeys,
    .brailleStartAddress = HandyBrailleStart,
    .brailleStartLength = sizeof(HandyBrailleStart)
  }
  ,
  {
    .name = "Braille Wave 40",
    .identifier = 0X05,
    .columns = 40,
    .statusCells = 0,
    .helpPage = 0,
    .interpretByte = interpretKeyByte,
    .interpretKeys = interpretBrailleWaveKeys,
    .brailleStartAddress = HandyBrailleStart,
    .brailleStartLength = sizeof(HandyBrailleStart)
  }
  ,
  {
    .name = "Bookworm",
    .identifier = 0X90,
    .columns = 8,
    .statusCells = 0,
    .helpPage = 1,
    .interpretByte = interpretBookwormByte,
    .brailleStartAddress = HandyBrailleStart,
    .brailleStartLength = sizeof(HandyBrailleStart),
    .brailleEndAddress = BookwormBrailleEnd,
    .brailleEndLength = sizeof(BookwormBrailleEnd),
    .stopAddress = BookwormStop,
    .stopLength = sizeof(BookwormStop)
  }
  ,
  {
    .name = "<NAME>",
    .identifier = 0X72,
    .columns = 20,
    .statusCells = 0,
    .helpPage = 2,
    .interpretByte = interpretKeyByte,
    .interpretKeys = interpretBrailleStarKeys,
    .brailleStartAddress = HandyBrailleStart,
    .brailleStartLength = sizeof(HandyBrailleStart)
  }
  ,
  {
    .name = "Braille Star 40",
    .identifier = 0X74,
    .columns = 40,
    .statusCells = 0,
    .helpPage = 2,
    .interpretByte = interpretKeyByte,
    .interpretKeys = interpretBrailleStarKeys,
    .brailleStartAddress = HandyBrailleStart,
    .brailleStartLength = sizeof(HandyBrailleStart)
  }
  ,
  {
    .name = "Braille Star 80",
    .identifier = 0X78,
    .columns = 80,
    .statusCells = 0,
    .helpPage = 3,
    .interpretByte = interpretKeyByte,
    .interpretKeys = interpretBrailleStarKeys,
    .brailleStartAddress = HandyBrailleStart,
    .brailleStartLength = sizeof(HandyBrailleStart)
  }
  ,
  { /* end of table */
    .name = NULL
  }
};

#define BRLROWS		1
#define MAX_STCELLS	4	/* highest number of status cells */



/* This is the brltty braille mapping standard to Handy's mapping table.
 */
static TranslationTable outputTable;

{'fraction_non_alphanumeric': 0.09630757518081462, 'fraction_numerical': 0.018271792919680244, 'mean_word_length': 3.6234051913770347, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4131909', 'n_tokens_mistral': 3588, 'n_tokens_neox': 3302, 'n_words': 885}