Exemplo n.º 1
0
adv_error joystickb_svgalib_init(int joystickb_id)
{
	unsigned i;

	log_std(("josytickb:svgalib: joystickb_svgalib_init(id:%d)\n", joystickb_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;
	}

	for(i=0;i<4;++i) {
		if (joystick_init(i, 0)<=0) {
			break;
		}
	}

	if (i==0) {
		error_set("No joystick found.\n");
		return -1;
	}

	svgalib_state.counter = i;

	return 0;
}
Exemplo n.º 2
0
adv_error mouseb_event_init(int mouseb_id)
{
	unsigned i;
	adv_bool eacces = 0;
	struct event_location map[EVENT_MOUSE_DEVICE_MAX];
	unsigned mac;

	log_std(("mouseb:event: mouseb_event_init(id:%d)\n", mouseb_id));

#if defined(USE_SVGALIB)
	/* close the SVGALIB mouse device. SVGALIB always call mouse_init(), also */
	/* if mouse input is not requested */
	if (os_internal_svgalib_get()) {
		mouse_close();
	}
#endif

	log_std(("mouseb:event: opening mouse from 0 to %d\n", EVENT_MOUSE_DEVICE_MAX));

	mac = event_locate(map, EVENT_MOUSE_DEVICE_MAX, &eacces);

	event_state.mac = 0;
	for(i=0;i<mac;++i) {
		int f;

		if (event_state.mac >= EVENT_MOUSE_MAX)
			continue;

		f = event_open(map[i].file, event_state.map[event_state.mac].evtype_bitmask, sizeof(event_state.map[event_state.mac].evtype_bitmask));
		if (f == -1) {
			if (errno == EACCES) {
				eacces = 1;
			}
			continue;
		}

		if (!event_is_mouse(f, event_state.map[event_state.mac].evtype_bitmask)) {
			log_std(("mouseb:event: not a mouse on device %s\n", map[i].file));
			event_close(f);
			continue;
		}

		if (mouseb_setup(&event_state.map[event_state.mac], f) != 0) {
			event_close(f);
			continue;
		}

		++event_state.mac;
	}

	if (!event_state.mac) {
		if (eacces)
			error_set("No mouse found. Check the /dev/input/event* permissions.\n");
		else
			error_set("No mouse found.\n");
		return -1;
	}

	return 0;
}
Exemplo n.º 3
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;
}
Exemplo n.º 4
0
adv_error mouseb_raw_init(int mouseb_id)
{
	unsigned i;
	adv_bool eacces = 0;

	log_std(("mouseb:raw: mouseb_raw_init(id:%d)\n", mouseb_id));

#if defined(USE_SVGALIB)
	/* close the SVGALIB mouse device. SVGALIB always call mouse_init(), also */
	/* if mouse input is not requested */
	if (os_internal_svgalib_get()) {
		mouse_close();
	}
#endif

	raw_state.mac = 0;
	for (i = 0; i < RAW_MOUSE_MAX; ++i) {
		if (raw_mouse_init(&raw_state.map[i].context) == 0) {
			log_std(("mouseb:raw: open device %s\n", raw_state.map[i].context.dev));

			mouseb_setup(&raw_state.map[i]);

			raw_state.map[i].active_flag = 1;
			raw_state.mac = i + 1;
		} else {
			if (errno != ENODEV) {
				log_std(("ERROR:mouseb:raw: error opening device %s, errno %d (%s)\n", raw_state.map[i].context.dev, errno, strerror(errno)));
			}
			if (errno == EACCES) {
				eacces = 1;
			}
			raw_state.map[i].active_flag = 0;
		}
	}

	if (raw_state.mac == 0) {
		if (eacces)
			error_set("No mouse found. Check the /dev/mouse and /dev/input/mouse* permissions.\n");
		else
			error_set("No mouse found.\n");
		return -1;
	}

	return 0;
}