void VL_Startup() { myint mode; vga_init(); /* TODO: maybe move into main or such? */ if (MS_CheckParm("x2")) { mode = G640x400x256; vwidth = 640; vheight = 400; } else { mode = G320x200x256; vwidth = 320; vheight = 200; } if (gfxbuf == NULL) gfxbuf = malloc(vwidth * vheight * 1); if (vga_hasmode(mode) == 0) Quit("vga_hasmode failed!"); if (vga_setmode(mode) != 0) Quit("vga_setmode failed!"); if ((mode != G320x200x256) && (vga_setlinearaddressing() == -1)) Quit("vga_setlinearaddressing failed!"); graphmem = vga_getgraphmem(); keyboard_init(); keyboard_seteventhandler(keyboard_handlerx); }
void key_init() { if (keyboard_init()) Error ("SVGAlib Keyboard Init Failed"); Installed=1; keyboard_seteventhandler (key_handler); xLastKeyPressTime = TimerGetFixedSeconds(); keyd_bufferType = 1; keyd_repeat = 1; // Clear the keyboard array KeyFlush(); atexit(key_close); }
static int post_enter_graphics (void) { vga_setmousesupport (1); mouse_init("/dev/mouse", vga_getmousetype (), 10); if (keyboard_init() != 0) { leave_graphics_mode (); write_log ("Are you sure you have a keyboard??\n"); return 0; } keyboard_seteventhandler (my_kbd_handlerx); keyboard_translatekeys (DONT_CATCH_CTRLC); mouse_setxrange (-1000, 1000); mouse_setyrange (-1000, 1000); mouse_setposition (0, 0); return 1; }
void S9xGraphicsMode () { if (text_mode) { screen_width = modes [mode].width; screen_height = modes [mode].height; int ret = vga_setmode (modes [mode].mode); if (ret < 0) { fprintf (stderr, "Unable to switch to requested screen mode/resolution:\n"); S9xExit (); } if (vga_setlinearaddressing () < 0) { if (info->flags & EXT_INFO_AVAILABLE) video_page_size = info->aperture_size; else video_page_size = 64 * 1024; } else video_page_size = ~0; if (modes [mode].mode == G320x200x256 && screen_width == 256) { iopl(3); outRegArray (scr256x256, sizeof (scr256x256) / sizeof (Register)); screen_pitch = screen_width; } gl_setcontextvga (modes [mode].mode); if (keyboard_init ()) { fprintf (stdout, "Keyboard initialisation failed.\n"); S9xExit (); } keyboard_seteventhandler(&_S9xSVGAKeyboardHandler); text_mode = FALSE; if (DeltaScreen) memset (DeltaScreen, 0xff, GFX.Pitch * IMAGE_HEIGHT); } }
void I_InitGraphics(void) { int i; // make sure that signals bring us back into text mode signal(SIGINT, (void(*)(int))I_Quit); signal(SIGQUIT, (void(*)(int))I_Quit); signal(SIGHUP, (void(*)(int))I_Quit); signal(SIGTERM, (void(*)(int))I_Quit); // init VGA card if (vga_init() != 0) I_Error("Could not initialize graphics console\n"); if (vga_setmode(G320x200x256) != 0) I_Error("Could not switch to graphics mode\n"); // init keyboard keyboard_init(); keyboard_seteventhandler(keyboard_events); // init mouse if (usemouse) { mouse_type = MOUSE_NONE; for (i = 0; mousetypes[i].name != NULL; i++) { if (!strcmp(mousetype, mousetypes[i].name)) mouse_type = mousetypes[i].type; } mouse_init(mousedev, mouse_type, MOUSE_DEFAULTSAMPLERATE); mouse_setxrange(0, SCREENWIDTH - 1); mouse_setyrange(0, SCREENHEIGHT - 1); mouse_setwrap(MOUSE_NOWRAP); mouse_seteventhandler(mouse_events); } #ifdef USE_JOYSTICK // init joystick if (usejoystick) I_InitJoystick(); #endif }
static int svgalib_key_init () { int err; err = atexit (svgalib_key_close); if (err) { fprintf (stderr, "Couldn't register svgalib_key_close" "with atexit!\n"); perror ("atexit"); return err_Unk; } err = keyboard_init (); if (err) { fprintf (stderr, "Couldn't init. keyboard!\n"); return err_Unk; } keyboard_seteventhandler (svgalib_key_handler); svgalib_key_flush (); return err_OK; }
static void IN_init_kb ( void ) { int i; for (i=0 ; i<128 ; i++) { scantokey[i] = ' '; } scantokey[ 1] = K_ESCAPE; scantokey[ 2] = '1'; scantokey[ 3] = '2'; scantokey[ 4] = '3'; scantokey[ 5] = '4'; scantokey[ 6] = '5'; scantokey[ 7] = '6'; scantokey[ 8] = '7'; scantokey[ 9] = '8'; scantokey[ 10] = '9'; scantokey[ 11] = '0'; scantokey[ 12] = '-'; scantokey[ 13] = '='; scantokey[ 14] = K_BACKSPACE; scantokey[ 15] = K_TAB; scantokey[ 16] = 'q'; scantokey[ 17] = 'w'; scantokey[ 18] = 'e'; scantokey[ 19] = 'r'; scantokey[ 20] = 't'; scantokey[ 21] = 'y'; scantokey[ 22] = 'u'; scantokey[ 23] = 'i'; scantokey[ 24] = 'o'; scantokey[ 25] = 'p'; scantokey[ 26] = '['; scantokey[ 27] = ']'; scantokey[ 28] = K_ENTER; scantokey[ 29] = K_CTRL; /*left */ scantokey[ 30] = 'a'; scantokey[ 31] = 's'; scantokey[ 32] = 'd'; scantokey[ 33] = 'f'; scantokey[ 34] = 'g'; scantokey[ 35] = 'h'; scantokey[ 36] = 'j'; scantokey[ 37] = 'k'; scantokey[ 38] = 'l'; scantokey[ 39] = ';'; scantokey[ 40] = '\''; scantokey[ 41] = '`'; scantokey[ 42] = K_SHIFT; /*left */ scantokey[ 43] = '\\'; scantokey[ 44] = 'z'; scantokey[ 45] = 'x'; scantokey[ 46] = 'c'; scantokey[ 47] = 'v'; scantokey[ 48] = 'b'; scantokey[ 49] = 'n'; scantokey[ 50] = 'm'; scantokey[ 51] = ','; scantokey[ 52] = '.'; scantokey[ 53] = '/'; scantokey[ 54] = K_SHIFT; /*right */ scantokey[ 55] = KP_MULTIPLY; scantokey[ 56] = K_ALT; /*left */ scantokey[ 57] = ' '; scantokey[ 58] = K_CAPSLOCK; scantokey[ 59] = K_F1; scantokey[ 60] = K_F2; scantokey[ 61] = K_F3; scantokey[ 62] = K_F4; scantokey[ 63] = K_F5; scantokey[ 64] = K_F6; scantokey[ 65] = K_F7; scantokey[ 66] = K_F8; scantokey[ 67] = K_F9; scantokey[ 68] = K_F10; scantokey[ 69] = KP_NUMLCK; scantokey[ 70] = K_SCRLCK; scantokey[ 71] = KP_HOME; scantokey[ 72] = KP_UPARROW; scantokey[ 73] = KP_PGUP; scantokey[ 74] = KP_MINUS; scantokey[ 75] = KP_LEFTARROW; scantokey[ 76] = KP_5; scantokey[ 77] = KP_RIGHTARROW; scantokey[ 79] = KP_END; scantokey[ 78] = KP_PLUS; scantokey[ 80] = KP_DOWNARROW; scantokey[ 81] = KP_PGDN; scantokey[ 82] = KP_INS; scantokey[ 83] = KP_DEL; /* 84 to 86 not used */ scantokey[ 87] = K_F11; scantokey[ 88] = K_F12; /* 89 to 95 not used */ scantokey[ 96] = KP_ENTER; /* keypad enter */ scantokey[ 97] = K_CTRL; /* right */ scantokey[ 98] = KP_DIVIDE; scantokey[ 99] = K_PRNTSCR; /* print screen */ scantokey[100] = K_ALT; /* right */ scantokey[101] = K_PAUSE; /* break */ scantokey[102] = K_HOME; scantokey[103] = K_UPARROW; scantokey[104] = K_PGUP; scantokey[105] = K_LEFTARROW; scantokey[106] = K_RIGHTARROW; scantokey[107] = K_END; scantokey[108] = K_DOWNARROW; scantokey[109] = K_PGDN; scantokey[110] = K_INS; scantokey[111] = K_DEL; scantokey[119] = K_PAUSE; if (keyboard_init()) { Sys_Error("keyboard_init() failed"); } keyboard_seteventhandler(keyhandler); }
int SVGA_VideoInit(_THIS, SDL_PixelFormat *vformat) { int keyboard; int i, j; int mode, total_modes; /* Initialize all variables that we clean on shutdown */ for ( i=0; i<NUM_MODELISTS; ++i ) { SDL_nummodes[i] = 0; SDL_modelist[i] = NULL; SDL_vgamode[i] = NULL; } /* Initialize the library */ vga_disabledriverreport(); if ( vga_init() < 0 ) { SDL_SetError("Unable to initialize SVGAlib"); return(-1); } vga_setmode(TEXT); /* Enable mouse and keyboard support */ vga_setmousesupport(1); keyboard = keyboard_init_return_fd(); if ( keyboard < 0 ) { SDL_SetError("Unable to initialize keyboard"); return(-1); } if ( SVGA_initkeymaps(keyboard) < 0 ) { return(-1); } keyboard_seteventhandler(SVGA_keyboardcallback); /* Determine the screen depth (use default 8-bit depth) */ vformat->BitsPerPixel = 8; /* Enumerate the available fullscreen modes */ total_modes = 0; for ( mode=vga_lastmodenumber(); mode; --mode ) { if ( vga_hasmode(mode) ) { if ( SVGA_AddMode(this, mode, 0, 0) ) { ++total_modes; } } } if ( SVGA_AddMode(this, G320x200x256, 0, 1) ) ++total_modes; if ( total_modes == 0 ) { SDL_SetError("No linear video modes available"); return(-1); } for ( i=0; i<NUM_MODELISTS; ++i ) { SDL_vgamode[i] = (int *)malloc(SDL_nummodes[i]*sizeof(int)); if ( SDL_vgamode[i] == NULL ) { SDL_OutOfMemory(); return(-1); } SDL_modelist[i] = (SDL_Rect **) malloc((SDL_nummodes[i]+1)*sizeof(SDL_Rect *)); if ( SDL_modelist[i] == NULL ) { SDL_OutOfMemory(); return(-1); } for ( j=0; j<SDL_nummodes[i]; ++j ) { SDL_modelist[i][j]=(SDL_Rect *)malloc(sizeof(SDL_Rect)); if ( SDL_modelist[i][j] == NULL ) { SDL_OutOfMemory(); return(-1); } memset(SDL_modelist[i][j], 0, sizeof(SDL_Rect)); } SDL_modelist[i][j] = NULL; } for ( mode=vga_lastmodenumber(); mode; --mode ) { if ( vga_hasmode(mode) ) { SVGA_AddMode(this, mode, 1, 0); } } SVGA_AddMode(this, G320x200x256, 1, 1); /* Free extra (duplicated) modes */ for ( i=0; i<NUM_MODELISTS; ++i ) { j = 0; while ( SDL_modelist[i][j] && SDL_modelist[i][j]->w ) { j++; } while ( SDL_modelist[i][j] ) { free(SDL_modelist[i][j]); SDL_modelist[i][j] = NULL; j++; } } /* Fill in our hardware acceleration capabilities */ SVGA_UpdateVideoInfo(this); /* We're done! */ return(0); }
void KBD_Init(Key_Event_fp_t fp) { int i; Key_Event_fp = fp; for (i=0 ; i<128 ; i++) scantokey[i] = ' '; scantokey[ 1] = K_ESCAPE; scantokey[ 2] = '1'; scantokey[ 3] = '2'; scantokey[ 4] = '3'; scantokey[ 5] = '4'; scantokey[ 6] = '5'; scantokey[ 7] = '6'; scantokey[ 8] = '7'; scantokey[ 9] = '8'; scantokey[ 10] = '9'; scantokey[ 11] = '0'; scantokey[ 12] = '-'; scantokey[ 13] = '='; scantokey[ 14] = K_BACKSPACE; scantokey[ 15] = K_TAB; scantokey[ 16] = 'q'; scantokey[ 17] = 'w'; scantokey[ 18] = 'e'; scantokey[ 19] = 'r'; scantokey[ 20] = 't'; scantokey[ 21] = 'y'; scantokey[ 22] = 'u'; scantokey[ 23] = 'i'; scantokey[ 24] = 'o'; scantokey[ 25] = 'p'; scantokey[ 26] = '['; scantokey[ 27] = ']'; scantokey[ 28] = K_ENTER; scantokey[ 29] = K_CTRL; //left scantokey[ 30] = 'a'; scantokey[ 31] = 's'; scantokey[ 32] = 'd'; scantokey[ 33] = 'f'; scantokey[ 34] = 'g'; scantokey[ 35] = 'h'; scantokey[ 36] = 'j'; scantokey[ 37] = 'k'; scantokey[ 38] = 'l'; scantokey[ 39] = ';'; scantokey[ 40] = '\''; scantokey[ 41] = '`'; scantokey[ 42] = K_SHIFT; //left scantokey[ 43] = '\\'; scantokey[ 44] = 'z'; scantokey[ 45] = 'x'; scantokey[ 46] = 'c'; scantokey[ 47] = 'v'; scantokey[ 48] = 'b'; scantokey[ 49] = 'n'; scantokey[ 50] = 'm'; scantokey[ 51] = ','; scantokey[ 52] = '.'; scantokey[ 53] = '/'; scantokey[ 54] = K_SHIFT; //right scantokey[ 55] = '*'; //keypad scantokey[ 56] = K_ALT; //left scantokey[ 57] = ' '; // 58 caps lock scantokey[ 59] = K_F1; scantokey[ 60] = K_F2; scantokey[ 61] = K_F3; scantokey[ 62] = K_F4; scantokey[ 63] = K_F5; scantokey[ 64] = K_F6; scantokey[ 65] = K_F7; scantokey[ 66] = K_F8; scantokey[ 67] = K_F9; scantokey[ 68] = K_F10; // 69 numlock // 70 scrollock scantokey[ 71] = K_KP_HOME; scantokey[ 72] = K_KP_UPARROW; scantokey[ 73] = K_KP_PGUP; scantokey[ 74] = K_KP_MINUS; scantokey[ 75] = K_KP_LEFTARROW; scantokey[ 76] = K_KP_5; scantokey[ 77] = K_KP_RIGHTARROW; scantokey[ 79] = K_KP_END; scantokey[ 78] = K_KP_PLUS; scantokey[ 80] = K_KP_DOWNARROW; scantokey[ 81] = K_KP_PGDN; scantokey[ 82] = K_KP_INS; scantokey[ 83] = K_KP_DEL; // 84 to 86 not used scantokey[ 87] = K_F11; scantokey[ 88] = K_F12; // 89 to 95 not used scantokey[ 96] = K_KP_ENTER; //keypad enter scantokey[ 97] = K_CTRL; //right scantokey[ 98] = K_KP_SLASH; scantokey[ 99] = K_F12; // print screen, bind to screenshot by default scantokey[100] = K_ALT; // right scantokey[101] = K_PAUSE; // break scantokey[102] = K_HOME; scantokey[103] = K_UPARROW; scantokey[104] = K_PGUP; scantokey[105] = K_LEFTARROW; scantokey[106] = K_RIGHTARROW; scantokey[107] = K_END; scantokey[108] = K_DOWNARROW; scantokey[109] = K_PGDN; scantokey[110] = K_INS; scantokey[111] = K_DEL; scantokey[119] = K_PAUSE; if (keyboard_init()) Sys_Error("keyboard_init() failed"); keyboard_seteventhandler(keyhandler); keyboard_translatekeys(DONT_CATCH_CTRLC); }