Ejemplo n.º 1
0
BOOL InitCustomInput (INPUT* input, const char* mdev, const char* mtype)
{
    char file [50];
    int display;

#ifdef _MGINCORE_RES
    display = 0;
#else
    /* get display number */
    if (GetMgEtcIntValue ("qvfb", "display", &display) < 0)
        return FALSE;
#endif

    /* open mouse pipe */
    sprintf (file, QT_VFB_MOUSE_PIPE, display);
    if ((mouse_fd = open (file, O_RDONLY)) < 0) {
        fprintf (stderr, "QVFB IAL engine: can not open mouse pipe.\n");
        return FALSE;
    }
    /* open keyboard pipe */
    sprintf (file, QT_VFB_KEYBOARD_PIPE, display);
    if ((kbd_fd = open (file, O_RDONLY)) < 0) {
        fprintf (stderr, "QVFB IAL engine: can not open keyboard pipe.\n");
        return FALSE;
    }

    input->update_mouse = mouse_update;
    input->get_mouse_xy = mouse_getxy;
    input->set_mouse_xy = NULL;
    input->get_mouse_button = mouse_getbutton;
    input->set_mouse_range = NULL;
    input->suspend_mouse= NULL;
    input->resume_mouse = NULL;

    input->update_keyboard = keyboard_update;
    input->get_keyboard_state = keyboard_getstate;
    input->suspend_keyboard = NULL;
    input->resume_keyboard = NULL;
    input->set_leds = NULL;

    input->wait_event = wait_event;

    init_code_map ();

    return TRUE;
}
Ejemplo n.º 2
0
BOOL InitQVFBInput (INPUT* input, const char* mdev, const char* mtype)
{
    char file [50];
    int display;

#ifdef _INCORE_RES
    display = 0;
#else
    /* get display number */
    if (GetMgEtcIntValue ("qvfb", "display", &display) < 0)
        return FALSE;
#endif

#if 0
    /* open mouse pipe */
    sprintf (file, QT_VFB_MOUSE_PIPE, display);
    if ((mouse_fd = open (file, O_RDWR | O_NONBLOCK)) < 0) {
        fprintf (stderr, "QVFB IAL engine: can not open mouse pipe.\n");
        return FALSE;
    }
    else {
        char buf[2];
        /* clear pending input */
        while (read (mouse_fd, buf, 1) > 0) { }

        /* clear O_NDELAY flag */
        fcntl (mouse_fd, F_SETFL, 0);
    }
    /* open keyboard pipe */
    sprintf (file, QT_VFB_KEYBOARD_PIPE, display);
    if ((kbd_fd = open (file, O_RDWR | O_NONBLOCK)) < 0) {
        fprintf (stderr, "QVFB IAL engine: can not open keyboard pipe.\n");
        return FALSE;
    }
    else {
        char buf[2];
        /* clear pending input */
        while (read (kbd_fd, buf, 1) > 0) { }

        /* clear O_NDELAY flag */
        fcntl (kbd_fd, F_SETFL, 0);
    }

#else
    /* open mouse pipe */
    sprintf (file, QT_VFB_MOUSE_PIPE, display);
    if ((mouse_fd = open (file, O_RDONLY)) < 0) {
        fprintf (stderr, "QVFB IAL engine: can not open mouse pipe.\n");
        return FALSE;
    }
    /* open keyboard pipe */
    sprintf (file, QT_VFB_KEYBOARD_PIPE, display);
    if ((kbd_fd = open (file, O_RDONLY)) < 0) {
        fprintf (stderr, "QVFB IAL engine: can not open keyboard pipe.\n");
        return FALSE;
    }
#endif

    input->update_mouse = mouse_update;
    input->get_mouse_xy = mouse_getxy;
    input->set_mouse_xy = NULL;
    input->get_mouse_button = mouse_getbutton;
    input->set_mouse_range = NULL;
    input->suspend_mouse= NULL;
    input->resume_mouse = NULL;

    input->update_keyboard = keyboard_update;
    input->get_keyboard_state = keyboard_getstate;
    input->suspend_keyboard = NULL;
    input->resume_keyboard = NULL;
    input->set_leds = NULL;

    input->wait_event = wait_event;

    init_code_map ();

    return TRUE;
}