示例#1
0
void __svgalib_readconfigfile(void)
{
  static int configfileread = 0;
  if (configfileread)
    return;
  configfileread = 1;
  mouse_type = -1;
  __svgalib_read_options(vga_conf_commands, process_option);
  if (mouse_type == -1) {
    mouse_type = MOUSE_MICROSOFT;	/* Default. */
    puts("svgalib: Assuming Microsoft mouse.");
  }
}
int keyboard_init_return_fd(void) {
    char *ptr;

    keyboard_translatekeys(translatemode); /* Honour 'nosigint' setting */

    /* Install default keyboard handler. */
    __svgalib_keyboard_eventhandler = default_handler;

    __svgalib_open_devconsole();
    __svgalib_kbd_fd = __svgalib_tty_fd; /* We are initialized. */

    if (ioctl(__svgalib_kbd_fd, KDGKBMODE, &oldkbmode)) {
	printf("svgalib: cannot get keyboard mode.\n");
	return -1;
    }
    tcgetattr(__svgalib_kbd_fd, &oldkbdtermios);
    newkbdtermios = oldkbdtermios;

    newkbdtermios.c_lflag &= ~(ICANON | ECHO | ISIG);
    newkbdtermios.c_iflag &= ~(ISTRIP | IGNCR | ICRNL | INLCR | IXOFF | IXON);
    newkbdtermios.c_cc[VMIN] = 0;	/* Making these 0 seems to have the */
    newkbdtermios.c_cc[VTIME] = 0;	/* desired effect. */

    tcsetattr(__svgalib_kbd_fd, TCSAFLUSH, &newkbdtermios);

    ioctl(__svgalib_kbd_fd, KDSKBMODE, K_MEDIUMRAW);

    keyboard_clearstate();

    __svgalib_read_options(kbd_config_options, kbd_process_option);

    /* Check SVGALIB_KEYMAP env var */
    if ( (ptr = getenv("SVGALIB_KEYMAP")) != 0) {
        kbd_load_keymap(ptr);
    }

    return __svgalib_kbd_fd;		/* OK, return fd. */
}