コード例 #1
0
ファイル: mouse_1.c プロジェクト: anarsoul/xynth-server
static int mouse_init_return_fd (char *dev, int type, int samplerate)
{
	struct sigaction siga;

	if (!ms.mouse_open) {
		if (strcmp(dev, "") == 0)
			ms.dev = "/dev/mouse";
		else
			ms.dev = dev;
		ms.type = type & MOUSE_TYPE_MASK;
		ms.modem_ctl = type & ~MOUSE_TYPE_MASK;
		ms.sample = samplerate;
		ms.currentinthandler = NULL;
		/* Initialize mouse device. */
		if (ms.type == MOUSE_NONE || ms.type < MOUSE_MICROSOFT || ms.type > MOUSE_LAST)
			return -1;
		if (ms_init())
			return -1;
		/* Install interrupt handler. */
		ms.currentinthandler = mouse_int_handler;
		siga.sa_handler = mouse_int_handler;
		siga.sa_flags = 0;
		zero_sa_mask(&(siga.sa_mask));
		sigaction(SIGINT, &siga, &ms.oldsiga);
		ms.mouse_open = 1;
	}
	return ms.fd;	/* Return mouse fd. */
}
コード例 #2
0
ファイル: mouse.c プロジェクト: carlosphp/svgalib-1
int mouse_init_return_fd(char *dev, int type, int samplerate)
{
    struct sigaction siga;

    if (!mouse_open) {
	    if (strcmp(dev, "") == 0)
		m_dev = "/dev/mouse";
	    else
		m_dev = dev;
	    m_type = type & MOUSE_TYPE_MASK;
	    m_modem_ctl = type & ~MOUSE_TYPE_MASK;
	
	    m_sample = samplerate;
	
	    currentinthandler = NULL;
	
	    /* Initialize mouse device. */
	    if (m_type == MOUSE_UNCONFIGURED) {
	      fprintf(stderr,
		      "Warning: you have not yet configured your mouse type. If you have no mouse,\n"
		      "setting the type to `none' in " SVGALIB_CONFIG_FILE " will get rid of this\n"
		      "annoying message.\n");
	      return -1;
	    }
	    if (m_type == MOUSE_NONE || m_type < MOUSE_MICROSOFT || m_type > MOUSE_LAST)
		return -1;
	    if (ms_init())
		return -1;

	    /* Install default mouse handler. Old coordinates are preserved. */
	    __svgalib_mouse_eventhandler = default_handler;
	
	    /* Install interrupt handler. */
	    currentinthandler = inthandler;
	    siga.sa_handler = inthandler;
	    siga.sa_flags = 0;
	    zero_sa_mask(&(siga.sa_mask));
	    sigaction(SIGINT, &siga, &oldsiga);
	    mouse_open = 1;
    }
    return __svgalib_mouse_fd;	/* Return mouse fd. */
}