static Status
TsEnable (KdPointerInfo *pi)
{
    int fd;

    if (!pi || !pi->path)
        return BadImplementation;

    fd = open(pi->path, 0);

    if (fd < 0) {
        ErrorF("TsInit: Couldn't open %s\n", pi->path);
        return BadMatch;
    }

    struct h3600_ts_calibration cal;
    /*
     * Check to see if this is a touch screen
     */
    if (ioctl (fd, TS_GET_CAL, &cal) != -1) {
        mi->driverPrivate = (void *) fd;
        if (!KdRegisterFd (fd, TsRead, (void *) mi)) {
            close(fd);
            return BadAlloc;
        }
    }
    else {
        ErrorF("TsEnable: %s is not a touchscreen\n", pi->path);
        close (fd);
        return BadMatch;
    }

    return Success;
}
Beispiel #2
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);
    }
}
Beispiel #3
0
int
LinuxKeyboardInit (void)
{
    if (!LinuxKbdType)
	LinuxKbdType = KdAllocInputType ();

    KdRegisterFd (LinuxKbdType, LinuxConsoleFd, LinuxKeyboardRead, 0);
    LinuxKeyboardEnable (LinuxConsoleFd, 0);
    KdRegisterFdEnableDisable (LinuxConsoleFd, 
			       LinuxKeyboardEnable,
			       LinuxKeyboardDisable);
    return 1;
}
Beispiel #4
0
int
TsInit (void)
{
    int		i;
    int		fd;
    KdMouseInfo	*mi, *next;
    int		n = 0;

    if (!TsInputType)
	TsInputType = KdAllocInputType ();
    
    for (mi = kdMouseInfo; mi; mi = next)
    {
	next = mi->next;
	if (mi->inputType)
	    continue;
	if (!mi->name)
	{
	    for (i = 0; i < NUM_TS_NAMES; i++)    
	    {
		fd = open (TsNames[i], 0);
		if (fd >= 0) 
		{
		    mi->name = KdSaveString (TsNames[i]);
		    break;
		}
	    }
	}
	else
	    fd = open (mi->name, 0);
	if (fd >= 0)
	{
	    struct h3600_ts_calibration cal;
	    /*
	     * Check to see if this is a touch screen
	     */
	    if (ioctl (fd, TS_GET_CAL, &cal) != -1)
	    {
		mi->driver = (void *) fd;
		mi->inputType = TsInputType;
		if (KdRegisterFd (TsInputType, fd, TsRead, (void *) mi))
		    n++;
	    }
	    else
		close (fd);
	}
    }
}
Beispiel #5
0
static int
BusEnable (KdPointerInfo *pi)
{
    int fd = open(pi->common.path, 0);

    if (fd > 0)
    {
        KdRegisterFd(fd, BusRead, pi);
        pi->driverPrivate = (void *)fd;
        return Success;
    }
    else
    {
        return !Success;
    }
}
Beispiel #6
0
int
TslibInit (void)
{
    int		i;
    KdMouseInfo	*mi, *next;
    int		fd= 0;
    int		n = 0;

    if (!TsInputType)
	TsInputType = KdAllocInputType ();
    
    for (mi = kdMouseInfo; mi; mi = next)
    {
	next = mi->next;
	if (mi->inputType)
	    continue;

	if (!mi->name)
	{
	    for (i = 0; i < NUM_TS_NAMES; i++)    
	    {
		if(!(tsDev = ts_open(TsNames[i],0))) continue;
	        ts_config(tsDev); 
	        fd=ts_fd(tsDev);
		if (fd >= 0) 
		{
		    mi->name = KdSaveString (TsNames[i]);
		    break;
		}
	    }
	}

	if (fd > 0 && tsDev != 0) 
	  {
	    mi->driver = (void *) fd;
	    mi->inputType = TsInputType;
	    	if (KdRegisterFd (TsInputType, fd, TsRead, (void *) mi))
		    n++;
	  } 
	else 
	  if (fd > 0) close(fd);
	}
}
Beispiel #7
0
int
BusInit (void)
{
    int	    i;
    int	    busPort;
    int	    n = 0;

    if (!BusInputType)
	BusInputType = KdAllocInputType ();
    
    for (i = 0; i < NUM_BUS_NAMES; i++)
    {
	busPort = open (BusNames[i], 0);
	{
	    KdRegisterFd (BusInputType, busPort, BusRead, 0);
	    n++;
	}
    }
    return n;
}
Beispiel #8
0
int
Ps2Init (void)
{
    int	    i;
    int	    ps2Port;
    int	    n;

    if (!Ps2InputType)
	Ps2InputType = KdAllocInputType ();
    n = 0;
    for (i = 0; i < NUM_PS2_NAMES; i++)
    {
	ps2Port = open (Ps2Names[i], 0);
	if (ps2Port >= 0)
	{
	    if (KdRegisterFd (Ps2InputType, ps2Port, Ps2Read, (void *) i))
		n++;
	}
    }
    return n;
}
Beispiel #9
0
static Status
Ps2Enable (KdPointerInfo *pi)
{
    int fd;
    
    if (!pi)
        return BadImplementation;

    fd = open (pi->common.path, 0);
    if (fd < 0)
        return BadMatch;

    if (!KdRegisterFd (fd, Ps2Read, pi)) {
        close(fd);
        return BadAlloc;
    }

    pi->driverPrivate = (void *)fd;

    return Success;
}
Beispiel #10
0
static Status
wsmouseEnable(KdPointerInfo *pi)
{
	int fd;

	DBG(("wsmouseEnable\n"));

	if (pi == NULL || pi->driverPrivate == NULL || pi->path == NULL)
		return BadImplementation;

	fd = open(pi->path, O_RDWR | O_NONBLOCK);
	if (fd < 0)
		return BadMatch;

	if (!KdRegisterFd(fd, wsmouseRead, pi)) {
		close(fd);
		return BadAlloc;
	}
	pi->driverPrivate = (void *)(intptr_t)fd;
	return Success;
}
Beispiel #11
0
static Status
MouseEnable(KdPointerInfo * pi)
{
    Kmouse *km;

    if (!pi || !pi->driverPrivate || !pi->path)
        return BadImplementation;

    km = pi->driverPrivate;

    km->iob.fd = open(pi->path, 2);
    if (km->iob.fd < 0)
        return BadMatch;

    if (!KdRegisterFd(km->iob.fd, MouseRead, pi)) {
        close(km->iob.fd);
        return BadAlloc;
    }

    return Success;
}
Beispiel #12
0
static Status
EvdevKbdEnable(KdKeyboardInfo * ki)
{
    unsigned long ev[NBITS(EV_MAX)];
    Kevdev *ke;
    int fd;

    if (!ki || !ki->path)
        return BadImplementation;

    fd = open(ki->path, O_RDWR);
    if (fd < 0)
        return BadMatch;

    if (ioctl(fd, EVIOCGRAB, 1) < 0)
        perror("Grabbing evdev keyboard device failed");

    if (ioctl(fd, EVIOCGBIT(0 /*EV*/, sizeof(ev)), ev) < 0) {
        perror("EVIOCGBIT 0");
        close(fd);
        return BadMatch;
    }

    ke = calloc(1, sizeof(Kevdev));
    if (!ke) {
        close(fd);
        return BadAlloc;
    }

    if (!KdRegisterFd(fd, EvdevKbdRead, ki)) {
        free(ke);
        close(fd);
        return BadAlloc;
    }
    ki->driverPrivate = ke;
    ke->fd = fd;

    return Success;
}
Beispiel #13
0
static Status
EvdevPtrEnable(KdPointerInfo * pi)
{
    int fd;
    unsigned long ev[NBITS(EV_MAX)];
    Kevdev *ke;

    if (!pi || !pi->path)
        return BadImplementation;

    fd = open(pi->path, 2);
    if (fd < 0)
        return BadMatch;

    if (ioctl(fd, EVIOCGRAB, 1) < 0)
        perror("Grabbing evdev mouse device failed");

    if (ioctl(fd, EVIOCGBIT(0 /*EV*/, sizeof(ev)), ev) < 0) {
        perror("EVIOCGBIT 0");
        close(fd);
        return BadMatch;
    }
    ke = calloc(1, sizeof(Kevdev));
    if (!ke) {
        close(fd);
        return BadAlloc;
    }
    if (ISBITSET(ev, EV_KEY)) {
        if (ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(ke->keybits)), ke->keybits) < 0) {
            perror("EVIOCGBIT EV_KEY");
            free(ke);
            close(fd);
            return BadMatch;
        }
    }
    if (ISBITSET(ev, EV_REL)) {
        if (ioctl(fd, EVIOCGBIT(EV_REL, sizeof(ke->relbits)), ke->relbits) < 0) {
            perror("EVIOCGBIT EV_REL");
            free(ke);
            close(fd);
            return BadMatch;
        }
        for (ke->max_rel = REL_MAX; ke->max_rel >= 0; ke->max_rel--)
            if (ISBITSET(ke->relbits, ke->max_rel))
                break;
    }
    if (ISBITSET(ev, EV_ABS)) {
        int i;

        if (ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(ke->absbits)), ke->absbits) < 0) {
            perror("EVIOCGBIT EV_ABS");
            free(ke);
            close(fd);
            return BadMatch;
        }
        for (ke->max_abs = ABS_MAX; ke->max_abs >= 0; ke->max_abs--)
            if (ISBITSET(ke->absbits, ke->max_abs))
                break;
        for (i = 0; i <= ke->max_abs; i++) {
            if (ISBITSET(ke->absbits, i))
                if (ioctl(fd, EVIOCGABS(i), &ke->absinfo[i]) < 0) {
                    perror("EVIOCGABS");
                    break;
                }
            ke->prevabs[i] = ABS_UNSET;
        }
        if (i <= ke->max_abs) {
            free(ke);
            close(fd);
            return BadValue;
        }
    }
    if (!KdRegisterFd(fd, EvdevPtrRead, pi)) {
        free(ke);
        close(fd);
        return BadAlloc;
    }
    pi->driverPrivate = ke;
    ke->fd = fd;

    return Success;
}
Beispiel #14
0
static Bool
EvdevKbdInit (void)
{
    int         i;
    int         fd;
    int         n = 0;
    char        name[100];

    if (!EvdevInputType)
        EvdevInputType = KdAllocInputType ();

    for (i = 0; i < NUM_DEFAULT_EVDEV; i++)
    {
        fd = open (kdefaultEvdev1[i], 2);
        if (fd >= 0)
        {
            ioctl(fd, EVIOCGRAB, 1);

            ioctl(fd, EVIOCGNAME(sizeof(name)), name);
            ErrorF("Name is %s\n", name);
            ioctl(fd, EVIOCGPHYS(sizeof(name)), name);
            ErrorF("Phys Loc is %s\n", name);
            ioctl(fd, EVIOCGUNIQ(sizeof(name)), name);
            ErrorF("Unique is %s\n", name);

        }

        if (fd >= 0)
        {
            unsigned long   ev[NBITS(EV_MAX)];
            Kevdev          *ke;

            if (ioctl (fd, EVIOCGBIT(0 /*EV*/, sizeof (ev)), ev) < 0)
            {
                perror ("EVIOCGBIT 0");
                close (fd);
                continue;
            }
            ke = xalloc (sizeof (Kevdev));
            if (!ke)
            {
                close (fd);
                continue;
            }
            memset (ke, '\0', sizeof (Kevdev));
            if (ISBITSET (ev, EV_KEY))
            {
                if (ioctl (fd, EVIOCGBIT (EV_KEY, sizeof (ke->keybits)),
                           ke->keybits) < 0)
                {
                    perror ("EVIOCGBIT EV_KEY");
                    xfree (ke);
                    close (fd);
                    continue;
                }
            }
            if (ISBITSET (ev, EV_REL))
            {
                if (ioctl (fd, EVIOCGBIT (EV_REL, sizeof (ke->relbits)),
                           ke->relbits) < 0)
                {
                    perror ("EVIOCGBIT EV_REL");
                    xfree (ke);
                    close (fd);
                    continue;
                }
                for (ke->max_rel = REL_MAX; ke->max_rel >= 0; ke->max_rel--)
                    if (ISBITSET(ke->relbits, ke->max_rel))
                        break;
            }
            if (ISBITSET (ev, EV_ABS))
            {
                int i;

                if (ioctl (fd, EVIOCGBIT (EV_ABS, sizeof (ke->absbits)),
                           ke->absbits) < 0)
                {
                    perror ("EVIOCGBIT EV_ABS");
                    xfree (ke);
                    close (fd);
                    continue;
                }
                for (ke->max_abs = ABS_MAX; ke->max_abs >= 0; ke->max_abs--)
                    if (ISBITSET(ke->absbits, ke->max_abs))
                        break;
                for (i = 0; i <= ke->max_abs; i++)
                {
                    if (ISBITSET (ke->absbits, i))
                        if (ioctl (fd, EVIOCGABS(i), &ke->absinfo[i]) < 0)
                        {
                            perror ("EVIOCGABS");
                            break;
                        }
                    ke->prevabs[i] = ABS_UNSET;
                }
                if (i <= ke->max_abs)
                {
                    xfree (ke);
                    close (fd);
                    continue;
                }
            }
            if (KdRegisterFd (EvdevInputType, fd, EvdevRead1, NULL))
                n++;
        }
    }
    return TRUE;
}