GF_Err GAPI_Setup(GF_VideoOutput *dr, void *os_handle, void *os_display, Bool noover) { struct GXDisplayProperties gx = GXGetDisplayProperties(); RECT rc; GAPICTX(dr); gctx->hWnd = (HWND) os_handle; /*get keys in both 2D and 3D modes*/ gctx->keys = GXGetDefaultKeys(GX_NORMALKEYS); #if 0 /*FIXME - not supported in rasterizer*/ if (gx.ffFormat & kfDirect444) { gctx->pixel_format = GF_PIXEL_RGB_444; gctx->BPP = 2; gctx->bitsPP = 12; } else #endif if (gx.ffFormat & kfDirect555) { gctx->pixel_format = GF_PIXEL_RGB_555; gctx->BPP = 2; gctx->bits_per_pixel = 15; } else if (gx.ffFormat & kfDirect565) { gctx->pixel_format = GF_PIXEL_RGB_565; gctx->BPP = 2; gctx->bits_per_pixel = 16; } else if (gx.ffFormat & kfDirect888) { gctx->pixel_format = GF_PIXEL_RGB_24; gctx->BPP = 3; gctx->bits_per_pixel = 24; } else { return GF_NOT_SUPPORTED; } GAPI_SetupWindow(dr); if (!gctx->hWnd) return GF_IO_ERR; /*setup GX*/ if (!GXOpenDisplay(gctx->hWnd, 0L)) { MessageBox(NULL, _T("Cannot open display"), _T("GAPI Error"), MB_OK); return GF_IO_ERR; } GetClientRect(gctx->hWnd, &rc); gctx->backup_w = rc.right - rc.left; gctx->backup_h = rc.bottom - rc.top; return GAPI_InitBackBuffer(dr, gctx->backup_w, gctx->backup_h); }
DWORD WINAPI CreateWinCEWindow(LPVOID lpParam) { static MidpReentryData newSignal; static MidpEvent newMidpEvent; int screenSize = sizeof(gxj_pixel_type) * CHAM_WIDTH * CHAM_HEIGHT; /* IMPL_NOTE: Need a better way to load the library */ #ifdef CVM_PRELOAD_LIB instanceMain = LoadLibrary(TEXT("cvmi.dll")); #else #ifdef CVM_DEBUG instanceMain = LoadLibrary(TEXT("libmidp_g.dll")); #else instanceMain = LoadLibrary(TEXT("libmidp.dll")); #endif #endif gxj_system_screen_buffer.width = CHAM_WIDTH; gxj_system_screen_buffer.height = CHAM_HEIGHT; gxj_system_screen_buffer.alphaData = 0; gxj_system_screen_buffer.pixelData = (gxj_pixel_type *)midpMalloc(screenSize); memset(gxj_system_screen_buffer.pixelData, 0xff, screenSize); if (!init_windows(GetModuleHandle(NULL), SW_SHOW)) { REPORT_ERROR(LC_AMS, "init_gui() failed"); MessageBox(NULL, TEXT("Failed to start JWC"), TEXT("Bye"), MB_OK); } updateVisibleDesktop(); #if JWC_WINCE_USE_DIRECT_DRAW init_DirectDraw(); #else if (GXOpenDisplay(hwndMain, 0) == 0) { REPORT_ERROR(LC_HIGHUI, "GXOpenDisplay() failed"); } gxDispProps = GXGetDisplayProperties(); #endif createEditors(); #ifdef ENABLE_JSR_184 engine_initialize(); #endif MIDP_EVENT_INITIALIZE(newMidpEvent); while (1) { checkForSystemSignal(&newSignal, &newMidpEvent, 200); } }
extern "C" int GXOPENDISPLAY(HWND hWnd, DWORD dwFlags) { #ifndef _USE_GAPI_ if(!gx) return 0; //gx->OpenSound(); if(!gx->OpenGraphics()) { delete gx; gx = 0; return 0; } return TRUE; #else return GXOpenDisplay(hWnd,dwFlags); #endif }
static int Init(vout_display_t *vd, video_format_t *fmt, int width, int height) { vout_display_sys_t *sys = vd->sys; /* */ RECT *display = &sys->rect_display; display->left = 0; display->top = 0; #ifdef MODULE_NAME_IS_wingapi display->right = GXGetDisplayProperties().cxWidth; display->bottom = GXGetDisplayProperties().cyHeight; #else display->right = GetSystemMetrics(SM_CXSCREEN);; display->bottom = GetSystemMetrics(SM_CYSCREEN);; #endif /* Initialize an offscreen bitmap for direct buffer operations. */ /* */ HDC window_dc = GetDC(sys->hvideownd); /* */ #ifdef MODULE_NAME_IS_wingapi GXDisplayProperties gx_displayprop = GXGetDisplayProperties(); sys->i_depth = gx_displayprop.cBPP; #else sys->i_depth = GetDeviceCaps(window_dc, PLANES) * GetDeviceCaps(window_dc, BITSPIXEL); #endif /* */ msg_Dbg(vd, "GDI depth is %i", sys->i_depth); switch (sys->i_depth) { case 8: fmt->i_chroma = VLC_CODEC_RGB8; break; case 15: fmt->i_chroma = VLC_CODEC_RGB15; fmt->i_rmask = 0x7c00; fmt->i_gmask = 0x03e0; fmt->i_bmask = 0x001f; break; case 16: fmt->i_chroma = VLC_CODEC_RGB16; fmt->i_rmask = 0xf800; fmt->i_gmask = 0x07e0; fmt->i_bmask = 0x001f; break; case 24: fmt->i_chroma = VLC_CODEC_RGB24; fmt->i_rmask = 0x00ff0000; fmt->i_gmask = 0x0000ff00; fmt->i_bmask = 0x000000ff; break; case 32: fmt->i_chroma = VLC_CODEC_RGB32; fmt->i_rmask = 0x00ff0000; fmt->i_gmask = 0x0000ff00; fmt->i_bmask = 0x000000ff; break; default: msg_Err(vd, "screen depth %i not supported", sys->i_depth); return VLC_EGENERIC; } fmt->i_width = width; fmt->i_height = height; uint8_t *p_pic_buffer; int i_pic_pitch; #ifdef MODULE_NAME_IS_wingapi GXOpenDisplay(sys->hvideownd, GX_FULLSCREEN); EventThreadUpdateTitle(sys->event, VOUT_TITLE " (WinGAPI output)"); /* Filled by pool::lock() */ p_pic_buffer = NULL; i_pic_pitch = 0; #else /* Initialize offscreen bitmap */ BITMAPINFO *bi = &sys->bitmapinfo; memset(bi, 0, sizeof(BITMAPINFO) + 3 * sizeof(RGBQUAD)); if (sys->i_depth > 8) { ((DWORD*)bi->bmiColors)[0] = fmt->i_rmask; ((DWORD*)bi->bmiColors)[1] = fmt->i_gmask; ((DWORD*)bi->bmiColors)[2] = fmt->i_bmask;; } BITMAPINFOHEADER *bih = &sys->bitmapinfo.bmiHeader; bih->biSize = sizeof(BITMAPINFOHEADER); bih->biSizeImage = 0; bih->biPlanes = 1; bih->biCompression = (sys->i_depth == 15 || sys->i_depth == 16) ? BI_BITFIELDS : BI_RGB; bih->biBitCount = sys->i_depth; bih->biWidth = fmt->i_width; bih->biHeight = -fmt->i_height; bih->biClrImportant = 0; bih->biClrUsed = 0; bih->biXPelsPerMeter = 0; bih->biYPelsPerMeter = 0; i_pic_pitch = bih->biBitCount * bih->biWidth / 8; sys->off_bitmap = CreateDIBSection(window_dc, (BITMAPINFO *)bih, DIB_RGB_COLORS, &p_pic_buffer, NULL, 0); sys->off_dc = CreateCompatibleDC(window_dc); SelectObject(sys->off_dc, sys->off_bitmap); ReleaseDC(sys->hvideownd, window_dc); EventThreadUpdateTitle(sys->event, VOUT_TITLE " (WinGDI output)"); #endif /* */ picture_resource_t rsc; memset(&rsc, 0, sizeof(rsc)); #ifdef MODULE_NAME_IS_wingapi rsc.p_sys = malloc(sizeof(*rsc.p_sys)); if (!rsc.p_sys) return VLC_EGENERIC; rsc.p_sys->vd = vd; #endif rsc.p[0].p_pixels = p_pic_buffer; rsc.p[0].i_lines = fmt->i_height; rsc.p[0].i_pitch = i_pic_pitch;; picture_t *picture = picture_NewFromResource(fmt, &rsc); if (picture) { picture_pool_configuration_t cfg; memset(&cfg, 0, sizeof(cfg)); cfg.picture_count = 1; cfg.picture = &picture; #ifdef MODULE_NAME_IS_wingapi cfg.lock = Lock; cfg.unlock = Unlock; #endif sys->pool = picture_pool_NewExtended(&cfg); } else { free(rsc.p_sys); sys->pool = NULL; } UpdateRects(vd, NULL, NULL, true); return VLC_SUCCESS; }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd ) { LPTSTR wndname = _T("PocketStella"); WNDCLASS wc = { CS_HREDRAW | CS_VREDRAW, WindowProc, 0, 0, hInstance, NULL, NULL, (HBRUSH)GetStockObject(BLACK_BRUSH), NULL, wndname}; RegisterClass(&wc); hWnd = CreateWindow(wndname, wndname, WS_VISIBLE | WS_POPUP, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), NULL, NULL, hInstance, NULL); if (!hWnd) return 1; SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); /* backlight */ REG_bat = REG_ac = REG_disp = 2 * 60 * 60 * 1000; /* 2hrs should do it */ backlight_xchg(); SystemParametersInfo(SPI_GETBATTERYIDLETIMEOUT, 0, (void *) &bat_timeout, 0); SystemParametersInfo(SPI_SETBATTERYIDLETIMEOUT, 60 * 60 * 2, NULL, SPIF_SENDCHANGE); // pump the messages to get the window up MSG msg; while (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } LOGFONT f = {11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, _T("")}; HFONT hFnt = CreateFontIndirect(&f); HDC hDC = GetDC(hWnd); SelectObject(hDC, hFnt); RECT RWnd; GetClipBox(hDC, &RWnd); SetTextColor(hDC, 0xA0A0A0); SetBkColor(hDC, 0); DrawText(hDC, _T("PocketStella Initializing..."), -1, &RWnd, DT_CENTER | DT_VCENTER); ReleaseDC(hWnd, hDC); DeleteObject(hFnt); theOSystem = new OSystemWinCE(((string) getcwd()) + '\\'); SettingsWinCE theSettings(theOSystem); theOSystem->settings().loadConfig(); theOSystem->settings().validate(); bool loaddefaultkeys = (theOSystem->settings().getString("keymap") == EmptyString); theOSystem->create(); if (loaddefaultkeys) { // setup the default keybindings the first time we're run theOSystem->eventHandler().addKeyMapping(Event::JoystickZeroFire, kEmulationMode, SDLK_F1); theOSystem->eventHandler().addKeyMapping(Event::LauncherMode, kEmulationMode, SDLK_BACKSPACE); theOSystem->eventHandler().addKeyMapping(Event::ConsoleReset, kEmulationMode, SDLK_F6); theOSystem->eventHandler().addKeyMapping(Event::ConsoleSelect, kEmulationMode, SDLK_F5); theOSystem->eventHandler().addKeyMapping(Event::UIPgUp, kMenuMode, SDLK_LEFT); theOSystem->eventHandler().addKeyMapping(Event::UIPgDown, kMenuMode, SDLK_RIGHT); theOSystem->eventHandler().addKeyMapping(Event::UISelect, kMenuMode, SDLK_F1); theOSystem->eventHandler().addKeyMapping(Event::UICancel, kMenuMode, SDLK_BACKSPACE); } if ( !GXOpenDisplay(hWnd, GX_FULLSCREEN) || !GXOpenInput() ) { CleanUp(); return 1; } KeySetup(); string romfile = ((string) getcwd()) + ((string) "\\") + theSettings.getString("GameFilename"); if (!FilesystemNode::fileExists(romfile)) theOSystem->createLauncher(); else theOSystem->createConsole(romfile); theOSystem->mainLoop(); CleanUp(); return 0; }
static GF_Err GAPI_SetFullScreen(GF_VideoOutput *dr, Bool bOn, u32 *outWidth, u32 *outHeight) { Bool is_wide_scene = (bOn==2) ? 1 : 0; GF_Err e; GAPICTX(dr); if (!gctx) return GF_BAD_PARAM; if (is_wide_scene) bOn = 1; if (bOn == gctx->fullscreen) return GF_OK; #ifdef GPAC_USE_OGL_ES if (gctx->output_3d_type==1) { gctx->fullscreen = bOn; return GAPI_SetupOGL_ES(dr); } #endif gf_mx_p(gctx->mx); GAPI_ReleaseObjects(gctx); GXCloseDisplay(); e = GF_OK; if (bOn) { if (!GXOpenDisplay(GetParent(gctx->hWnd), 0L/*GX_FULLSCREEN*/)) { GXOpenDisplay(gctx->hWnd, 0L); gctx->fullscreen = 0; e = GF_IO_ERR; } else { gctx->fullscreen = 1; } } else { GXOpenDisplay(gctx->hWnd, 0L); gctx->fullscreen = 0; } landscape = 0; if (!e) { if (gctx->fullscreen) { gctx->backup_w = *outWidth; gctx->backup_h = *outHeight; if (is_wide_scene && (gctx->screen_w < gctx->screen_h)) landscape = 1; else if (!is_wide_scene && (gctx->screen_w > gctx->screen_h)) landscape = 1; else landscape = 0; if (landscape) { gctx->fs_w = gctx->screen_h; gctx->fs_h = gctx->screen_w; } else { gctx->fs_w = gctx->screen_w; gctx->fs_h = gctx->screen_h; } *outWidth = gctx->fs_w; *outHeight = gctx->fs_h; } else { *outWidth = gctx->backup_w; *outHeight = gctx->backup_h; } } gf_mx_v(gctx->mx); return e; }