static int QVFB_VideoInit (_THIS, GAL_PixelFormat *vformat) { char file [50]; int display; key_t key; int shmid; struct GAL_PrivateVideoData* data = this->hidden; if (GetMgEtcIntValue ("qvfb", "display", &display) < 0) display = 0; sprintf (file, QT_VFB_MOUSE_PIPE, display); key = ftok (file, 'b'); shmid = shmget (key, 0, 0); if (shmid != -1) data->shmrgn = (unsigned char *)shmat (shmid, 0, 0); if ((int)data->shmrgn == -1 || data->shmrgn == NULL) { GAL_SetError ("NEWGAL>QVFB: Unable to attach to virtual FrameBuffer server.\n"); return -1; } data->hdr = (struct QVFbHeader *) data->shmrgn; vformat->BitsPerPixel = data->hdr->depth; switch (vformat->BitsPerPixel) { case 8: vformat->BytesPerPixel = 1; data->hdr->numcols = 256; break; case 12: vformat->BitsPerPixel = 16; vformat->BytesPerPixel = 2; vformat->Rmask = 0x00000F00; vformat->Gmask = 0x000000F0; vformat->Bmask = 0x0000000F; break; case 16: vformat->BytesPerPixel = 2; vformat->Rmask = 0x0000F800; vformat->Gmask = 0x000007E0; vformat->Bmask = 0x0000001F; break; case 32: vformat->BytesPerPixel = 4; vformat->Rmask = 0x00FF0000; vformat->Gmask = 0x0000FF00; vformat->Bmask = 0x000000FF; break; default: GAL_SetError ("NEWGAL>QVFB: Not supported depth: %d, " "please try to use Shadow NEWGAL engine with targetname qvfb.\n", vformat->BitsPerPixel); return -1; } return 0; }
/* QVFB driver bootstrap functions */ static int QVFB_Available (void) { char file [50]; int display; key_t key; int shmid; if (GetMgEtcIntValue ("qvfb", "display", &display) < 0) display = 0; sprintf (file, QT_VFB_MOUSE_PIPE, display); key = ftok (file, 'b'); shmid = shmget (key, 0, 0); return shmid != -1; }
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; }
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; }