示例#1
0
文件: svga.c 项目: Pa0l0ne/Amiga360
static int enter_graphics_mode_picasso (int which)
{
    int oldmode = current_vgamode;
    if (which == oldmode)
	return 1;

    vga_setmode (TEXT);
    if (vga_setmode (which) < 0) {
	sleep (1);
	vga_setmode (TEXT);
	write_log ("SVGAlib doesn't like my video mode (%d). Giving up.\n", which);
	exit (1);
    }
    current_vgamode = which;

    linear_mem = 0;
    if ((modeinfo.flags & CAPABLE_LINEAR) && ! currprefs.svga_no_linear) {
	int val = vga_setlinearaddressing ();
	if (val != -1) {
	    linear_mem = (char *)vga_getgraphmem ();
	    write_log ("Using linear addressing: %p.\n", linear_mem);
	}
    }

    keyboard_close ();
    mouse_close ();
    return post_enter_graphics ();
}
示例#2
0
static void svgalib_key_close ()
{
	keyboard_setdefaulteventhandler ();
	keyboard_clearstate ();
	keyboard_translatekeys (0);
	keyboard_close ();
}
示例#3
0
/* Note:  If we are terminated, this could be called in the middle of
   another SDL video routine -- notably UpdateRects.
*/
void SVGA_VideoQuit(_THIS)
{
	int i, j;

	/* Reset the console video mode */
	if ( this->screen && (this->screen->w && this->screen->h) ) {
		vga_setmode(TEXT);
	}
	keyboard_close();

	/* Free video mode lists */
	for ( i=0; i<NUM_MODELISTS; ++i ) {
		if ( SDL_modelist[i] != NULL ) {
			for ( j=0; SDL_modelist[i][j]; ++j )
				free(SDL_modelist[i][j]);
			free(SDL_modelist[i]);
			SDL_modelist[i] = NULL;
		}
		if ( SDL_vgamode[i] != NULL ) {
			free(SDL_vgamode[i]);
			SDL_vgamode[i] = NULL;
		}
	}
	if ( this->screen && (this->screen->flags & SDL_HWSURFACE) ) {
		/* Direct screen access, no memory buffer */
		this->screen->pixels = NULL;
	}
}
示例#4
0
static void _qdgdfv_shutdown(void)
{
    vga_setmode(TEXT);
    keyboard_close();

    printf("\x1b[H\x1b[J\n");
}
示例#5
0
static void timeout(int sig)
{
    keyboard_close();
    vga_setmode(TEXT);
    puts("Automatic termination after 60 seconds.");
    exit(1);
}
示例#6
0
文件: svga.c 项目: Pa0l0ne/Amiga360
static void leave_graphics_mode (void)
{
    keyboard_close ();
    mouse_close ();
    sleep (1); /* Maybe this will fix the "screen full of garbage" problem */
    current_vgamode = TEXT;
    vga_setmode (TEXT);
}
示例#7
0
void S9xTextMode ()
{
//    if (!text_mode)
    {
	keyboard_close ();
	vga_setmode (TEXT);
	text_mode = TRUE;
    }
}
示例#8
0
void
IN_Shutdown ( void )
{
	Con_Printf("IN_Shutdown\n");

	if (UseMouse) mouse_close();
	if (UseKeyboard) keyboard_close();
	in_svgalib_inited = 0;
}
示例#9
0
void I_ShutdownGraphics(void)
{
	keyboard_close();
	if (usemouse)
		mouse_close();

	if (vga_getcurrentmode() != TEXT)
		vga_setmode(TEXT);
}
示例#10
0
void VL_Shutdown()
{
	keyboard_close();
	
	if (gfxbuf != NULL) {
		free(gfxbuf);
		gfxbuf = NULL;
	}
	vga_setmode(TEXT);
}
void main(void)
{
    struct timeval timeout;
    fd_set inputs;
    char bitmap[16 * 16 * 4];	/* big enough for 10x10 bitmap in any mode */
    int vgamode, color, pipefd[2], x, y, button, event, cursorsize = 5;
    char loop = 1, drawcursor = 1;
#ifdef USE_RAWKEYBOARD
    char space_pressed = 0;
#endif

    puts("This is a demo showing the abilities of the new vga_waitevent() function\n"
	 "If something goes wrong it might hang your machine. Thus hit <ctrl>-C now\n"
	 "to bailout if in doubt.\n"
	 "Use mouse to move cursor. 1-9,0 to set the cursor size. Space to change the\n"
    "cursor color. Left button to draw. Right button or 'Q' to bailout.\n"
	 "The cursor goes on/off every half second by usage of a timeout passed to\n"
	 "vga_waitevent. Every 5 secs a string from a child process (the time) arrives\n"
	 "asynchronously and is displayed by the frontend.");
#ifdef USE_RAWKEYBOARD
    puts("\nBEWARE! This has been compiled to use the raw keyboard. A crash might\n"
	 "render the console unusable. (but shouldn't).");
#endif
    fputs("\nHit <Enter> if brave enough, else ^C to bailout: ", stdout);
    fflush(stdout);
    getchar();
    fflush(stdin);		/* clear I/O buffer */

    pipe(pipefd);
    if (fork() == 0) {		/* fork off b4 touching graphix to avoid side effects */
	close(pipefd[0]);	/* Important: close reading side, else it remains     */
	/* opened by child when parent exits and we don't get */
	/* a SIGPIPE!                                         */
	child(pipefd[1]);
    }
    vga_init();
    vgamode = vga_getdefaultmode();
    if (vgamode == -1)
	vgamode = G320x200x256;

    if (!vga_hasmode(vgamode)) {
	printf("Mode not available.\n");
	exit(-1);
    }
    /* Enable automatic mouse setup at mode set. */
    vga_setmousesupport(1);
    vga_setmode(vgamode);
    /* Disable wrapping (default). */
    /* mouse_setwrap(MOUSE_NOWRAP); */
    gl_setcontextvga(vgamode);
    gl_enableclipping();

    /* There might be some scrap data in the serial buffer
       from the mouse. It will make vga_waitevent block
       because it thinks the mouse wants to send data but
       then no mouse packet arrives. */
    color = newcolor();
    x = 0;
    y = 0;
    gl_setwritemode(WRITEMODE_OVERWRITE | FONT_COMPRESSED);
    gl_setfont(8, 8, gl_font8x8);
    gl_setfontcolors(0, newcolor());

#ifdef USE_RAWKEYBOARD
    if (keyboard_init()) {
	printf("Could not initialize keyboard.\n");
	exit(1);
    }
#endif

    while (loop) {
	gl_getbox(x, y, 10, 10, bitmap);
	if (drawcursor) {
	    gl_hline(x, y, x + cursorsize, color);
	    gl_hline(x, y + cursorsize, x + cursorsize, color);
	    gl_line(x, y, x, y + cursorsize, color);
	    gl_line(x + cursorsize, y, x + cursorsize, y + cursorsize, color);
	}
	FD_ZERO(&inputs);
	FD_SET(pipefd[0], &inputs);
	timeout.tv_sec = 0;
	timeout.tv_usec = 500000;	/* 0.5 second time out */
	event = vga_waitevent(VGA_MOUSEEVENT | VGA_KEYEVENT,
			      &inputs, NULL, NULL, &timeout);
	gl_putbox(x, y, 10, 10, bitmap);
	if (timeout.tv_sec || timeout.tv_usec) {
	    /* No timeout. An actual event occured. Reset to visible
	       cursor. Note:
	       This is actually a bug as the cursor will get visible on time
	       updates. However, it's better this way for demo/test
	       purposes. */
	    drawcursor = 1;
	} else {
	    drawcursor ^= 1;
	}
	if (FD_ISSET(pipefd[0], &inputs))
	    process_input(pipefd[0]);
	if (event & VGA_MOUSEEVENT) {
	    x = mouse_getx();
	    y = mouse_gety();
	    button = mouse_getbutton();
	    if (button & MOUSE_LEFTBUTTON)
		gl_fillbox(x, y, cursorsize + 1, cursorsize + 1, color);
	    if (button & MOUSE_RIGHTBUTTON)
		loop = 0;
	}
	if (event & VGA_KEYEVENT) {
#ifdef USE_RAWKEYBOARD
	    if (keyboard_keypressed(SCANCODE_1))
		cursorsize = 0;
	    if (keyboard_keypressed(SCANCODE_2))
		cursorsize = 1;
	    if (keyboard_keypressed(SCANCODE_3))
		cursorsize = 2;
	    if (keyboard_keypressed(SCANCODE_4))
		cursorsize = 3;
	    if (keyboard_keypressed(SCANCODE_5))
		cursorsize = 4;
	    if (keyboard_keypressed(SCANCODE_6))
		cursorsize = 5;
	    if (keyboard_keypressed(SCANCODE_7))
		cursorsize = 6;
	    if (keyboard_keypressed(SCANCODE_8))
		cursorsize = 7;
	    if (keyboard_keypressed(SCANCODE_9))
		cursorsize = 8;
	    if (keyboard_keypressed(SCANCODE_0))
		cursorsize = 9;
	    if (keyboard_keypressed(SCANCODE_Q))
		loop = 0;
	    if (keyboard_keypressed(SCANCODE_SPACE)) {
		if (!space_pressed) {
		    color = newcolor();
		    space_pressed = 1;
		}
	    } else {
		space_pressed = 0;
	    }
#else
	    switch (vga_getch()) {
	    case '1':
		cursorsize = 0;
		break;
	    case '2':
		cursorsize = 1;
		break;
	    case '3':
		cursorsize = 2;
		break;
	    case '4':
		cursorsize = 3;
		break;
	    case '5':
		cursorsize = 4;
		break;
	    case '6':
		cursorsize = 5;
		break;
	    case '7':
		cursorsize = 6;
		break;
	    case '8':
		cursorsize = 7;
		break;
	    case '9':
		cursorsize = 8;
		break;
	    case '0':
		cursorsize = 9;
		break;
	    case ' ':
		color = newcolor();
		break;
	    case 'q':
	    case 'Q':
		loop = 0;
		break;
	    default:
		ping();
		break;
	    }
#endif
	}
    }

#ifdef USE_RAWKEYBOARD
    keyboard_close();		/* Don't forget this! */
#endif
    vga_setmode(TEXT);
    exit(0);
}
示例#12
0
文件: key.c 项目: paud/d2x-xl
void key_close()
{
	Installed = 0;
	keyboard_close();
}
示例#13
0
void xfer(serial_h com, configuration_t *config)
{
  FILE *log = NULL ;
  int ch ;
  int linelen ;
  char buffer[MAXLINELEN] ;

  do {
    bbc_status_t result = BBC_OK ;

    printf("\f\n\n"
           "     (R)eceive files from BBC          (S)end files to BBC\n"
           "     (*)-command on BBC                (D)o command on PC\n"
           "     (T)erminal emulation              (G)et disc image from BBC\n"
           "     (L)og BBC OSCLI output %s      (C)d to directory\n"
           "     (P)C file CRC                     (B)BC file CRC\n"
           "     (Q)uit\n\n"
           "Enter command: ", log ? "(on) " : "(off)") ;

    do {
      ch = toupper(keyboard_char()) ;
    } while ( strchr("RS*DTGLCQPB", ch) == NULL ) ;

    putchar(ch) ;

    switch ( ch ) {
    case 'L':
      putchar('\n') ;
      if ( log ) {
        fclose(log) ;
        log = NULL ;
        puts("Logging turned off") ;
      } else {
        printf("Log OSCLI output to file: ") ;
        linelen = keyboard_line(buffer, MAXLINELEN) ;

        if ( linelen == 0 )
          puts("No log file specified, not logging\n") ;
        else if ( (log = fopen(buffer, "w+")) == NULL )
          printf("Problem opening log file %s, not logging\n", buffer) ;
      }

      break ;
    case 'R':
      putchar('\n') ;
      result = retrieve_files(com, config->wildcards, config->directories) ;
      break ;
    case 'S':
      putchar('\n') ;
      result = send_files(com, config->wildcards, config->directories) ;
      break ;
    case 'P':
      putchar('\n') ;
      result = local_crc() ;
      break ;
    case 'B':
      putchar('\n') ;
      result = remote_crc(com, config->wildcards, config->directories) ;
      break ;
    case '*':
      result = oscli(com, log) ;
      break ;
    case 'G':
      putchar('\n') ;
      result = retrieve_disc(com) ;
      break ;
    case 'D':
      (void)getcwd(buffer, MAXLINELEN) ;
      printf("\n%s> ", buffer) ;
      linelen = keyboard_line(buffer, MAXLINELEN) ;

      fflush(stdout) ;
      fflush(stdin) ;

      if ( linelen > 0 ) {
        keyboard_close() ;
        system(buffer) ;
        keyboard_open() ;
      }

      break ;
    case 'C':
      printf("\nDirectory: ") ;
      linelen = keyboard_line(buffer, MAXLINELEN) ;

      if ( chdir(buffer) != 0 )
        printf("Problem changing directory to %s, ignoring\n", buffer) ;

      break ;
    case 'T':
      putchar('\n') ;
      result = terminal(com) ;
      break ;
    }

    while ( result == BBC_ERROR ) {
      serial_printf(com, ERR_TXT) ;
      if ( (result = bbc_readline(com, buffer, MAXLINELEN)) == BBC_OK &&
           (result = bbc_readline(com, buffer, MAXLINELEN)) == BBC_OK )
        printf("BBC Error: %s\n", buffer) ;
    }
  } while ( ch != 'Q' ) ;

  putchar('\n') ;

  serial_printf(com, "Q") ;

  if ( log )
    fclose(log) ;
}
示例#14
0
void end_input_devices(void)
{
     keyboard_close();
}
示例#15
0
void main(void)
{
    int vgamode, color, leftpressed;
    int x, y;
    vga_init();
    vgamode = vga_getdefaultmode();
    if ((vgamode == -1) || (vga_getmodeinfo(vgamode)->bytesperpixel != 1))
        vgamode = G320x200x256;

    if (!vga_hasmode(vgamode)) {
        printf("Mode not available.\n");
        exit(1);
    }
    printf("\nWARNING: This program will set the keyboard to RAW mode.\n"
           "The keyboard routines in svgalib have not been tested\n"
           "very much. There may be no recovery if something goes\n"
           "wrong.\n\n"
           "Press ctrl-c now to bail out, enter to continue.\n"
           "In the test itself, use 'q' or Escape to quit.\n"
           "It will also terminate after 60 seconds.\n"
           "Use any cursor keys to move, keypad 0 or enter to change color.\n");

    getchar();

    vga_setmode(vgamode);
    gl_setcontextvga(vgamode);
    gl_enableclipping();

    signal(SIGALRM, timeout);

    /* This installs the default handler, which is good enough for most */
    /* purposes. */
    if (keyboard_init()) {
        printf("Could not initialize keyboard.\n");
        exit(1);
    }
    /* Translate to 4 keypad cursor keys, and unify enter key. */
    keyboard_translatekeys(TRANSLATE_CURSORKEYS | TRANSLATE_KEYPADENTER |
                           TRANSLATE_DIAGONAL);
    /* (TRANSLATE_DIAGONAL seems to give problems.) Michael: No doesn't...
       but might not do what you expect.. */

    alarm(60);			/* Terminate after 60 seconds for safety. */

    x = WIDTH / 2;
    y = HEIGHT / 2;
    color = newcolor();
    leftpressed = 0;
    for (;;) {
        /* Draw moving box. */
        gl_fillbox(x, y, 5, 5, color);

        /* Draw key status bar at top of screen. */
        gl_putbox(0, 0, 128, 1, keyboard_getstate());

        /* Wait about 1/100th of a second. */
        /* Note that use of this function makes things less */
        /* smooth because of timer latency. */
        usleep(10000);

        keyboard_update();

        /* Move. */
        if (keyboard_keypressed(SCANCODE_CURSORLEFT))
            x--;
        if (keyboard_keypressed(SCANCODE_CURSORRIGHT))
            x++;
        if (keyboard_keypressed(SCANCODE_CURSORUP))
            y--;
        if (keyboard_keypressed(SCANCODE_CURSORDOWN))
            y++;

        /* Boundary checks. */
        if (x < 0)
            x = 0;
        if (x >= WIDTH)
            x = WIDTH - 1;
        if (y < 1)
            y = 1;
        if (y >= HEIGHT)
            y = HEIGHT - 1;

        /* Check for color change. */
        if (keyboard_keypressed(SCANCODE_KEYPAD0) ||
                keyboard_keypressed(SCANCODE_ENTER)) {
            if (!leftpressed) {
                color = newcolor();
                leftpressed = 1;
            }
        } else
            leftpressed = 0;

        if (keyboard_keypressed(SCANCODE_Q) ||
                keyboard_keypressed(SCANCODE_ESCAPE))
            break;
    }

    keyboard_close();		/* Don't forget this! */
    vga_setmode(TEXT);
    exit(0);
}
示例#16
0
void KBD_Close(void)
{
	keyboard_close();
}