void _gmouseInit(void) { // GINPUT_MOUSE_DRIVER_LIST is defined - create each driver instance #if defined(GINPUT_MOUSE_DRIVER_LIST) { int i; extern GDriverVMTList GINPUT_MOUSE_DRIVER_LIST; static const struct GDriverVMT const * dclist[] = {GINPUT_MOUSE_DRIVER_LIST}; for(i = 0; i < sizeof(dclist)/sizeof(dclist[0]); i++) { if (!(dclist[i]->flags & GMOUSE_VFLG_DYNAMICONLY)) gdriverRegister(dclist[i], GDISP); } } // One and only one mouse #else { extern GDriverVMTList GMOUSEVMT_OnlyOne; if (!(GMOUSEVMT_OnlyOne->flags & GMOUSE_VFLG_DYNAMICONLY)) gdriverRegister(GMOUSEVMT_OnlyOne, GDISP); } #endif }
void _gmouseInit(void) { // GINPUT_MOUSE_DRIVER_LIST is defined - create each driver instance #if defined(GINPUT_MOUSE_DRIVER_LIST) { int i; typedef const GMouseVMT const GMOUSEVMTLIST[1]; extern GMOUSEVMTLIST GINPUT_MOUSE_DRIVER_LIST; static const GMouseVMT * const dclist[] = {GINPUT_MOUSE_DRIVER_LIST}; for(i = 0; i < sizeof(dclist)/sizeof(dclist[0]); i++) { if (!(dclist[i]->d.flags & GMOUSE_VFLG_DYNAMICONLY)) gdriverRegister(&dclist[i]->d, GDISP); } } // One and only one mouse #else { // extern const GMouseVMT const GMOUSEVMT_OnlyOne[1]; const GMouseVMT const GMOUSEVMT_OnlyOne[1]; if (!(GMOUSEVMT_OnlyOne->d.flags & GMOUSE_VFLG_DYNAMICONLY)) gdriverRegister(&GMOUSEVMT_OnlyOne->d, GDISP); } #endif }
void _gkeyboardInit(void) { // GINPUT_KEYBOARD_DRIVER_LIST is defined - create each driver instance #if defined(GINPUT_KEYBOARD_DRIVER_LIST) { int i; typedef const GKeyboardVMT const GKEYBOARDVMTLIST[1]; extern GKEYBOARDVMTLIST GINPUT_KEYBOARD_DRIVER_LIST; static const GKeyboardVMT * const dclist[] = {GINPUT_KEYBOARD_DRIVER_LIST}; for(i = 0; i < sizeof(dclist)/sizeof(dclist[0]); i++) { if (!(dclist[i]->d.flags & GKEYBOARD_VFLG_DYNAMICONLY)) gdriverRegister(&dclist[i]->d, 0); } } // One and only one mouse #else { extern const GKeyboardVMT const GKEYBOARDVMT_OnlyOne[1]; if (!(GKEYBOARDVMT_OnlyOne->d.flags & GKEYBOARD_VFLG_DYNAMICONLY)) gdriverRegister(&GKEYBOARDVMT_OnlyOne->d, 0); } #endif }
LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { winPriv * priv; char buf[132]; // Initialise the window thread and the window class (if it hasn't been done already) if (!QReady) { HANDLE hth; // Create the draw mutex drawMutex = CreateMutex(0, FALSE, 0); // Create the thread if (!(hth = CreateThread(0, 0, WindowThread, 0, CREATE_SUSPENDED, 0))) return FALSE; SetThreadPriority(hth, THREAD_PRIORITY_ABOVE_NORMAL); ResumeThread(hth); CloseHandle(hth); // Wait for our thread to be ready while (!QReady) Sleep(1); } // Initialise the GDISP structure g->g.Orientation = GDISP_ROTATE_0; g->g.Powermode = powerOn; g->g.Backlight = 100; g->g.Contrast = 50; g->g.Width = GDISP_SCREEN_WIDTH; g->g.Height = GDISP_SCREEN_HEIGHT; // Turn on toggles for the first GINPUT_TOGGLE_CONFIG_ENTRIES windows #if GINPUT_NEED_TOGGLE if (g->controllerdisplay < GINPUT_TOGGLE_CONFIG_ENTRIES) g->flags |= GDISP_FLG_HASTOGGLE; #endif // Create a private area for this window priv = gfxAlloc(sizeof(winPriv)); assert(priv != 0); memset(priv, 0, sizeof(winPriv)); g->priv = priv; #if GDISP_HARDWARE_STREAM_WRITE || GDISP_HARDWARE_STREAM_READ // Initialise with an invalid window g->flags &= ~GDISP_FLG_WSTREAM; #endif g->board = 0; // no board interface for this controller // Create the window in the message thread PostThreadMessage(winThreadId, WM_USER, (WPARAM)g->controllerdisplay, (LPARAM)g); // Wait for the window creation to complete (for safety) while(!(((volatile GDisplay *)g)->flags & GDISP_FLG_READY)) Sleep(1); // Create the associated mouse #if GINPUT_NEED_MOUSE priv->mouse = (GMouse *)gdriverRegister((const GDriverVMT const *)GMOUSE_DRIVER_VMT, g); #endif sprintf(buf, APP_NAME " - %u", g->systemdisplay+1); SetWindowText(priv->hwnd, buf); ShowWindow(priv->hwnd, SW_SHOW); UpdateWindow(priv->hwnd); return TRUE; }
LLDSPEC bool_t gdisp_lld_init(GDisplay *g) { XSizeHints *pSH; XSetWindowAttributes xa; XTextProperty WindowTitle; char * WindowTitleText; xPriv *priv; if (!initdone) { gfxThreadHandle hth; initdone = TRUE; #if GFX_USE_OS_LINUX || GFX_USE_OS_OSX XInitThreads(); #endif dis = XOpenDisplay(0); scr = DefaultScreen(dis); cxt = XUniqueContext(); wmDelete = XInternAtom(dis, "WM_DELETE_WINDOW", False); XSetIOErrorHandler(FatalXIOError); #if GDISP_FORCE_24BIT if (!XMatchVisualInfo(dis, scr, 24, TrueColor, &vis)) { fprintf(stderr, "Your display has no TrueColor mode\n"); XCloseDisplay(dis); return FALSE; } cmap = XCreateColormap(dis, RootWindow(dis, scr), vis.visual, AllocNone); #else vis.visual = CopyFromParent; vis.depth = DefaultDepth(dis, scr); cmap = DefaultColormap(dis, scr); #endif fprintf(stderr, "Running GFX Window in %d bit color\n", vis.depth); if (!(hth = gfxThreadCreate(waXThread, sizeof(waXThread), HIGH_PRIORITY, ThreadX, 0))) { fprintf(stderr, "Cannot start X Thread\n"); XCloseDisplay(dis); exit(0); } #if GFX_USE_OS_LINUX || GFX_USE_OS_OSX pthread_detach(hth); #endif gfxThreadClose(hth); } g->priv = gfxAlloc(sizeof(xPriv)); priv = (xPriv *)g->priv; g->board = 0; // No board interface for this driver xa.colormap = cmap; xa.border_pixel = 0xFFFFFF; xa.background_pixel = 0x000000; priv->win = XCreateWindow(dis, RootWindow(dis, scr), 16, 16, GDISP_SCREEN_WIDTH, GDISP_SCREEN_HEIGHT, 0, vis.depth, InputOutput, vis.visual, CWBackPixel|CWColormap|CWBorderPixel, &xa); XSync(dis, TRUE); XSaveContext(dis, priv->win, cxt, (XPointer)g); XSetWMProtocols(dis, priv->win, &wmDelete, 1); { char buf[132]; sprintf(buf, "uGFX - %u", g->systemdisplay+1); WindowTitleText = buf; XStringListToTextProperty(&WindowTitleText, 1, &WindowTitle); XSetWMName(dis, priv->win, &WindowTitle); XSetWMIconName(dis, priv->win, &WindowTitle); XSync(dis, TRUE); } pSH = XAllocSizeHints(); pSH->flags = PSize | PMinSize | PMaxSize; pSH->min_width = pSH->max_width = pSH->base_width = GDISP_SCREEN_WIDTH; pSH->min_height = pSH->max_height = pSH->base_height = GDISP_SCREEN_HEIGHT; XSetWMNormalHints(dis, priv->win, pSH); XFree(pSH); XSync(dis, TRUE); priv->pix = XCreatePixmap(dis, priv->win, GDISP_SCREEN_WIDTH, GDISP_SCREEN_HEIGHT, vis.depth); XSync(dis, TRUE); priv->gc = XCreateGC(dis, priv->win, 0, 0); XSetBackground(dis, priv->gc, BlackPixel(dis, scr)); XSync(dis, TRUE); // Create the associated mouse before the map #if GINPUT_NEED_MOUSE priv->mouse = (GMouse *)gdriverRegister((const GDriverVMT const *)GMOUSE_DRIVER_VMT, g); #endif XSelectInput(dis, priv->win, StructureNotifyMask); XMapWindow(dis, priv->win); // Wait for the window creation to complete (for safety) while(!(((volatile GDisplay *)g)->flags & GDISP_FLG_READY)) gfxSleepMilliseconds(100); /* Initialise the GDISP structure to match */ g->g.Orientation = GDISP_ROTATE_0; g->g.Powermode = powerOn; g->g.Backlight = 100; g->g.Contrast = 50; g->g.Width = GDISP_SCREEN_WIDTH; g->g.Height = GDISP_SCREEN_HEIGHT; return TRUE; }