示例#1
0
/*
 * DANG_BEGIN_FUNCTION raw_keyboard_init
 * 
 * Initialize the keyboard for RAW mode.
 * 
 * DANG_END_FUNCTION
 */
static int raw_keyboard_init(void)
{
  k_printf("KBD(raw): raw_keyboard_init()\n");
   
  kbd_fd = STDIN_FILENO;

  ioctl(kbd_fd, KDGKBMODE, (int)&save_mode);

  if (tcgetattr(kbd_fd, &save_termios) < 0) {
    error("KBD(raw): Couldn't tcgetattr(kbd_fd,...) !\n");
    memset(&save_termios, 0, sizeof(save_termios));
    return FALSE;
  }

  save_kbd_flags = fcntl(kbd_fd, F_GETFL);
  fcntl(kbd_fd, F_SETFL, O_RDONLY | O_NONBLOCK);

  set_raw_mode();

  if (!isatty(kbd_fd)) {
    k_printf("KBD(raw): Using SIGIO\n");
    add_to_io_select(kbd_fd, 1, keyb_client_run);
  }
  else {
    k_printf("KBD(raw): Not using SIGIO\n");
    add_to_io_select(kbd_fd, 0, keyb_client_run);
  }
   
  return TRUE;
}
示例#2
0
static gboolean create_tty(const char *modem_path)
{
	int master, slave;
	char pty_name[256];
	GIOChannel *server_io;

	if (modem_path == NULL)
		return FALSE;

	if (openpty(&master, &slave, pty_name, NULL, NULL) < 0)
		return FALSE;

	set_raw_mode(slave);

	g_print("new pty is created at %s\n", pty_name);

	server_io = g_io_channel_unix_new(master);

	server = g_at_server_new(server_io);
	if (server == NULL) {
		g_io_channel_shutdown(server_io, FALSE, NULL);
		g_io_channel_unref(server_io);

		return FALSE;
	}

	g_io_channel_unref(server_io);

	return TRUE;
}
int main()
{ 
    ret = init_vga(G320x200x256, VGA, PCI_DEVICE_ID_S3_TRIO64V2);            
    
    int i;
    for(i=0;i<64;i++){
        vga_setpalette(i, i, i, i);
    }
    
    for(i=0;i<64;i++){
        vga_setpalette(i+64, i, 0, 0);
    }
    
    for(i=0;i<64;i++){
        vga_setpalette(i+64+64, 0, i, 0);
    }
   
    buffer = (unsigned char *)malloc(VGA_WIDTH*VGA_HEIGHT);//virtual canvas
    memset(buffer, 0, VGA_WIDTH*VGA_HEIGHT);    
            
    set_raw_mode();

    unsigned int seed = (unsigned) time(NULL);
    srand(seed);
    /*srand(seed);rand();*/

    float period = 1.0/60.0;
    //period_ts = double_to_timespec(period);  //old versions of MaRTE OS
    double_to_timespec(period,&period_ts); //new versions of MaRTE OS
    
    while(1){
        
        DrawObjects();
        //flip
        vga_drawscansegment(buffer,0,0,VGA_WIDTH*VGA_HEIGHT); 
        nanosleep(&period_ts, NULL);

    }
    
    
    while(getchar()==-1);

    return 0;
}
示例#4
0
/*
 * DANG_BEGIN_FUNCTION raw_keyboard_init
 *
 * Initialize the keyboard for RAW mode.
 *
 * DANG_END_FUNCTION
 */
static int raw_keyboard_init(void)
{
  if (config.console_keyb > KEYB_TTY)
    return FALSE;

  k_printf("KBD(raw): raw_keyboard_init()\n");

  kbd_fd = STDIN_FILENO;

  if (config.console_keyb == KEYB_RAW)
    ioctl(kbd_fd, KDGKBMODE, &save_mode);

  if (tcgetattr(kbd_fd, &save_termios) < 0) {
    error("KBD(raw): Couldn't tcgetattr(kbd_fd,...) !\n");
    memset(&save_termios, 0, sizeof(save_termios));
    return FALSE;
  }

  set_raw_mode();

  add_to_io_select(kbd_fd, do_raw_getkeys, NULL);

  return TRUE;
}