Esempio n. 1
0
int
MouseInit (void)
{
    int		i;
    int		fd;
    Kmouse	*km;
    KdMouseInfo	*mi, *next;
    KmouseProt	*mp;
    int		n = 0;
    char	*prot;

    if (!MouseInputType)
	MouseInputType = KdAllocInputType ();

    for (mi = kdMouseInfo; mi; mi = next)
    {
	next = mi->next;
	prot = mi->prot;
	if (!mi->name)
	{
	    for (i = 0; i < NUM_DEFAULT_MOUSE; i++)
	    {
		fd = open (kdefaultMouse[i], 2);
		if (fd >= 0)
		{
		    mi->name = KdSaveString (kdefaultMouse[i]);
		    break;
		}
	    }
	}
	else
	    fd = open (mi->name, 2);
	    
	if (fd >= 0)
	{
	    km = (Kmouse *) xalloc (sizeof (Kmouse));
	    if (km)
	    {
		km->iob.fd = fd;
		km->iob.avail = km->iob.used = 0;
		km->prot = 0;
		km->i_prot = 0;
		km->tty = isatty (fd);
		mi->driver = km;
		MouseFirstProtocol (km, mi->prot);
		if (KdRegisterFd (MouseInputType, fd, MouseRead, (void *) mi))
		    n++;
	    }
	    else
		close (fd);
	}
	else
	    KdMouseInfoDispose (mi);
    }
}
Esempio n. 2
0
static Status
MouseInit (KdPointerInfo *pi)
{
    int		i;
    int		fd;
    Kmouse	*km;

    if (!pi)
        return BadImplementation;
    
    if (!pi->path || strcmp(pi->path, "auto") == 0) {
        for (i = 0; i < NUM_DEFAULT_MOUSE; i++) {
            fd = open (kdefaultMouse[i], 2);
            if (fd >= 0) {
                pi->path = strdup (kdefaultMouse[i]);
                break;
            }
        }
    }
    else {
        fd = open (pi->path, 2);
    }
	    
    if (fd < 0)
        return BadMatch;

    close(fd);

    km = (Kmouse *) xalloc (sizeof (Kmouse));
    if (km) {
        km->iob.avail = km->iob.used = 0;
        MouseFirstProtocol(km, pi->protocol ? pi->protocol : "exps/2");
        /* MouseFirstProtocol sets state to MouseBroken for later protocol
         * checks. Skip these checks if a protocol was supplied */
        if (pi->protocol)
                km->state = MouseWorking;
        km->i_prot = 0;
        km->tty = isatty (fd);
        km->iob.fd = -1;
        pi->driverPrivate = km;
    }
    else {
        close (fd);
        return BadAlloc;
    }

    return Success;
}
Esempio n. 3
0
static Status
MouseInit (KdPointerInfo *pi)
{
    int		i;
    int		fd;
    Kmouse	*km;

    if (!pi)
        return BadImplementation;
    
    if (!pi->path || strcmp(pi->path, "auto") == 0) {
        for (i = 0; i < NUM_DEFAULT_MOUSE; i++) {
            fd = open (kdefaultMouse[i], 2);
            if (fd >= 0) {
                pi->path = KdSaveString (kdefaultMouse[i]);
                break;
            }
        }
    }
    else {
        fd = open (pi->path, 2);
    }
	    
    if (fd < 0)
        return BadMatch;

    close(fd);

    km = (Kmouse *) xalloc (sizeof (Kmouse));
    if (km) {
        km->iob.avail = km->iob.used = 0;
        MouseFirstProtocol(km, "exps/2");
        km->i_prot = 0;
        km->tty = isatty (fd);
        km->iob.fd = -1;
        pi->driverPrivate = km;
    }
    else {
        close (fd);
        return BadAlloc;
    }

    return Success;
}