示例#1
0
文件: mouse.c 项目: L3oV1nc3/VMGL
static Bool
MouseWriteBytes (int fd, unsigned char *c, int n, int timeout)
{
    while (n--)
	if (!MouseWriteByte (fd, *c++, timeout))
	    return FALSE;
    return TRUE;
}
示例#2
0
文件: mouse.c 项目: Agnesa/xserver
static Bool
ps2Init(KdPointerInfo * pi)
{
    Kmouse *km = pi->driverPrivate;
    int skipping;
    Bool waiting;
    int id;
    unsigned char *init;
    int ninit;

    /* Send Intellimouse initialization sequence */
    MouseWriteBytes(km->iob.fd, intelli_init, strlen((char *) intelli_init),
                    100);
    /*
     * Send ID command
     */
    if (!MouseWriteByte(km->iob.fd, PSMC_SEND_DEV_ID, 100))
        return FALSE;
    skipping = 0;
    waiting = FALSE;
    id = ps2SkipInit(pi, 0, TRUE);
    switch (id) {
    case 3:
        init = wheel_3button_init;
        ninit = NINIT_IMPS2;
        km->prot = &imps2Prot;
        break;
    case 4:
        init = wheel_5button_init;
        ninit = NINIT_EXPS2;
        km->prot = &exps2Prot;
        break;
    default:
        init = ps2_init;
        ninit = NINIT_PS2;
        km->prot = &ps2Prot;
        break;
    }
    if (init)
        MouseWriteBytes(km->iob.fd, init, strlen((char *) init), 100);
    /*
     * Flush out the available data to eliminate responses to the
     * initialization string.  Make sure any partial event is
     * skipped
     */
    (void) ps2SkipInit(pi, ninit, FALSE);
    return TRUE;
}