Example #1
0
adv_error mouseb_svgalib_init(int mouseb_id)
{
	struct MouseCaps mouse_caps;
	unsigned i;
	unsigned buttons[] = {
		MOUSE_LEFTBUTTON,
		MOUSE_RIGHTBUTTON,
		MOUSE_MIDDLEBUTTON,
		MOUSE_FOURTHBUTTON,
		MOUSE_FIFTHBUTTON,
		MOUSE_SIXTHBUTTON,
		MOUSE_RESETBUTTON,
		0
	};

	log_std(("mouseb:svgalib: mouseb_svgalib_init(id:%d)\n", mouseb_id));

	if (os_internal_wm_active()) {
		error_set("Unsupported in X.\n");
		return -1;
	}

	if (!os_internal_svgalib_get()) {
		error_set("Not supported without the svgalib library.\n");
		return -1;
	}

	/* already opened internally by svgalib */

	if (mouse_getcaps(&mouse_caps)!=0) {
		error_set("No mouse found.\n");
		return -1;
	}

	mouse_setxrange(-8191, 8191);
	mouse_setyrange(-8191, 8191);
	mouse_setscale(1);
	mouse_setwrap(MOUSE_NOWRAP);

	svgalib_state.button_mac = 0;
	for(i=0;buttons[i] && i<BUTTON_MAX;++i) {
		if ((mouse_caps.buttons & buttons[i]) != 0) {
			svgalib_state.button_map[svgalib_state.button_mac] = buttons[i];
			++svgalib_state.button_mac;
		}
	}

	svgalib_state.x = 0;
	svgalib_state.y = 0;
	svgalib_state.button_mask = 0;

	return 0;
}
Example #2
0
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
}