FloatRect screenRect(Widget*) { DisplayInfo info; getDisplayInfo(info); return FloatRect(0, 0, info.width, info.height); }
int screenDepth(Widget*) { DisplayInfo info; getDisplayInfo(info); return info.depth; }
static String getAllSystemInfo() { String systemInfo; systemInfo << "Here are a few system statistics..." << newLine << newLine << "Time and date: " << Time::getCurrentTime().toString (true, true) << newLine << "System up-time: " << RelativeTime::milliseconds ((int64) Time::getMillisecondCounterHiRes()).getDescription() << newLine << "Compilation date: " << Time::getCompilationDate().toString (true, false) << newLine << newLine << "Operating system: " << SystemStats::getOperatingSystemName() << newLine << "Host name: " << SystemStats::getComputerName() << newLine << "Device type: " << SystemStats::getDeviceDescription() << newLine << "User logon name: " << SystemStats::getLogonName() << newLine << "Full user name: " << SystemStats::getFullUserName() << newLine << "User region: " << SystemStats::getUserRegion() << newLine << "User language: " << SystemStats::getUserLanguage() << newLine << "Display language: " << SystemStats::getDisplayLanguage() << newLine << newLine << "Number of CPUs: " << SystemStats::getNumCpus() << newLine << "Memory size: " << SystemStats::getMemorySizeInMegabytes() << " MB" << newLine << "CPU vendor: " << SystemStats::getCpuVendor() << newLine << "CPU speed: " << SystemStats::getCpuSpeedInMegaherz() << " MHz" << newLine << "CPU has MMX: " << (SystemStats::hasMMX() ? "yes" : "no") << newLine << "CPU has SSE: " << (SystemStats::hasSSE() ? "yes" : "no") << newLine << "CPU has SSE2: " << (SystemStats::hasSSE2() ? "yes" : "no") << newLine << "CPU has SSE3: " << (SystemStats::hasSSE3() ? "yes" : "no") << newLine << "CPU has 3DNOW: " << (SystemStats::has3DNow() ? "yes" : "no") << newLine << newLine << "Current working directory: " << File::getCurrentWorkingDirectory().getFullPathName() << newLine << "Current application file: " << File::getSpecialLocation (File::currentApplicationFile).getFullPathName() << newLine << "Current executable file: " << File::getSpecialLocation (File::currentExecutableFile) .getFullPathName() << newLine << "Invoked executable file: " << File::getSpecialLocation (File::invokedExecutableFile) .getFullPathName() << newLine << newLine << "User home folder: " << File::getSpecialLocation (File::userHomeDirectory) .getFullPathName() << newLine << "User desktop folder: " << File::getSpecialLocation (File::userDesktopDirectory) .getFullPathName() << newLine << "User documents folder: " << File::getSpecialLocation (File::userDocumentsDirectory) .getFullPathName() << newLine << "User application data folder: " << File::getSpecialLocation (File::userApplicationDataDirectory) .getFullPathName() << newLine << "User music folder: " << File::getSpecialLocation (File::userMusicDirectory) .getFullPathName() << newLine << "User movies folder: " << File::getSpecialLocation (File::userMoviesDirectory) .getFullPathName() << newLine << "User pictures folder: " << File::getSpecialLocation (File::userPicturesDirectory) .getFullPathName() << newLine << "Common application data folder: " << File::getSpecialLocation (File::commonApplicationDataDirectory).getFullPathName() << newLine << "Common documents folder: " << File::getSpecialLocation (File::commonDocumentsDirectory) .getFullPathName() << newLine << "Local temp folder: " << File::getSpecialLocation (File::tempDirectory) .getFullPathName() << newLine << newLine << "File System roots: " << getFileSystemRoots() << newLine << "Free space in home folder: " << File::descriptionOfSizeInBytes (File::getSpecialLocation (File::userHomeDirectory) .getBytesFreeOnVolume()) << newLine << newLine << getDisplayInfo() << newLine << "Network IP addresses: " << newLine << getIPAddressList() << newLine << "Network card MAC addresses: " << newLine << getMacAddressList() << newLine; DBG (systemInfo); return systemInfo; }
bool DisplayManagerWin::initialize() { DISPLAY_DEVICEW displayInfo; int displayId = 0; while (getDisplayInfo(displayId, displayInfo)) { if (displayInfo.StateFlags & (DISPLAY_DEVICE_ACTIVE | DISPLAY_DEVICE_ATTACHED)) { DEVMODEW modeInfo; int modeId = 0; // add the display DMDisplayPtr display = DMDisplayPtr(new DMDisplay); display->id = displayId; display->name = QString::fromWCharArray(displayInfo.DeviceString); displays[display->id] = DMDisplayPtr(display); m_displayAdapters[display->id] = QString::fromWCharArray(displayInfo.DeviceName); while (getModeInfo(displayId, modeId, modeInfo)) { // add the videomode to the display DMVideoModePtr videoMode = DMVideoModePtr(new DMVideoMode); videoMode->id = modeId; display->videoModes[videoMode->id] = videoMode; // setup mode information videoMode->height = modeInfo.dmPelsHeight; videoMode->width = modeInfo.dmPelsWidth; videoMode->refreshRate = modeInfo.dmDisplayFrequency; videoMode->bitsPerPixel = modeInfo.dmBitsPerPel; videoMode->interlaced = (modeInfo.dmDisplayFlags & DM_INTERLACED) ? true : false; // Windows just returns interger refresh rate so // let's fudge it if (videoMode->refreshRate == 59 || videoMode->refreshRate == 29 || videoMode->refreshRate == 23) videoMode->refreshRate = (float)(videoMode->refreshRate + 1) / 1.001f; modeId++; } } displayId++; } if (displays.size() == 0) { QLOG_DEBUG() << "No display found."; return false; } else return DisplayManager::initialize(); }
int DisplayManagerWin::getMainDisplay() { DISPLAY_DEVICEW displayInfo; int displayId = 0; while (getDisplayInfo(displayId, displayInfo)) { if (displayInfo.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) return displayId; displayId++; } return -1; }
/* * Purpose: * Setup the video display * * Parameters: * NONE * * Returns: * GDISPLAY structure with display, screen, width and height * complete * * History: * 21/02/2001 (Mike Bennett): Created */ GDISPLAY *createDisplay() { GDISPLAY *video; /* Create a display structure and set to defaults */ video = (GDISPLAY *)malloc(sizeof(GDISPLAY)); video->display = UNSETCHAR; video->dwidth = UNSETUINT; video->dheight = UNSETUINT; video->screen = UNSETINT; video->window = UNSETINT; video->gcontext = UNSETCHAR; video->font = UNSETCHAR; /* Open the display */ if(!(video->display = XOpenDisplay(XDisplayName(NULL)))) return NULL; video->screen = DefaultScreen(video->display); getDisplayInfo(video, GDISPLAY_WIDTH); getDisplayInfo(video, GDISPLAY_HEIGHT); return video; }
void listDisplays(std::wostream& out) { out << "List of all displays connected one day to your computer:" << std::endl; std::list<std::wstring> allKeys = getAllKeys(); for (std::list<std::wstring>::iterator it = allKeys.begin(); it != allKeys.end(); it++) { std::wstring achKey = *it; winDisplayInfo dinfo; getDisplayInfo(achKey,&dinfo); if ((dinfo.w > 0) && (dinfo.h > 0)) out << "windisplay:/" << achKey << " [" << dinfo.monitorName << ", " << dinfo.w << "x" << dinfo.h << " mm" << ", " << dinfo.resx << "x" << dinfo.resy << " pixels" << ", " << dinfo.ppi << " PPI" << ", " << dinfo.refreshRate << " Hz]" << std::endl; } }
bool DisplayManagerWin::initialize() { DISPLAY_DEVICEW displayInfo; int displayId = 0; m_displayAdapters.clear(); displays.clear(); while (getDisplayInfo(displayId, displayInfo)) { if (displayInfo.StateFlags & (DISPLAY_DEVICE_ACTIVE | DISPLAY_DEVICE_ATTACHED)) { DEVMODEW modeInfo; int modeId = 0; // add the display DMDisplayPtr display = DMDisplayPtr(new DMDisplay); display->id = displayId; display->name = QString::fromWCharArray(displayInfo.DeviceString); displays[display->id] = DMDisplayPtr(display); m_displayAdapters[display->id] = QString::fromWCharArray(displayInfo.DeviceName); while (getModeInfo(displayId, modeId, modeInfo)) { // add the videomode to the display DMVideoModePtr videoMode = DMVideoModePtr(new DMVideoMode); *videoMode = convertDevMode(modeInfo); videoMode->id = modeId; display->videoModes[videoMode->id] = videoMode; modeId++; } } displayId++; } if (displays.size() == 0) { QLOG_DEBUG() << "No display found."; return false; } else return DisplayManager::initialize(); }
DisplayDescriptorSet winDisplayDeviceManager::readAllFromRegistry() { DisplayDescriptorSet result; list<wstring> allKeys = getAllKeys(); for (list<wstring>::iterator it = allKeys.begin(); it != allKeys.end(); it++) { wstring achKey = *it; winDisplayInfo dinfo; getDisplayInfo(achKey,&dinfo); if ((dinfo.w > 0) && (dinfo.h > 0)) { DisplayDeviceDescriptor desc; desc.devURI = uriForDisplayId(achKey).asString(); desc.name = dinfo.monitorName; result.insert(desc); } } return result; }
//----------------------------------------------------------------------------- // Description: Called on window resize // Parameters: width - New width of window // height - New height of window // Returns: // Notes: Called by window class //----------------------------------------------------------------------------- void FWWindow::resize(int width, int height) { if(mInit && mUpdate) { // set rendering context in case it's not set setRenderingContext(); FWDisplayInfo &dispInfo = getDisplayInfo(); dispInfo.mWidth = width; dispInfo.mHeight = height; // refresh debug console if(mUseDebugConsole) FWDebugConsole::resize(dispInfo); // call application resize FWApplication::getApplication()->onSize(dispInfo); // we did clear the rendering context here // but removed it by popular request } }
bool winDisplayDeviceManager::ConvertDevice(HMONITOR hMon, DisplayDeviceDescriptor &desc) { MONITORINFOEX mInfo; mInfo.cbSize = sizeof(MONITORINFOEX); GetMonitorInfo(hMon,&mInfo); desc.width = mInfo.rcMonitor.right - mInfo.rcMonitor.left; desc.height = mInfo.rcMonitor.bottom - mInfo.rcMonitor.top; DISPLAY_DEVICE ddMon; ZeroMemory(&ddMon, sizeof(ddMon)); ddMon.cb = sizeof(ddMon); DWORD devMon = 0; while (EnumDisplayDevices(mInfo.szDevice, devMon, &ddMon, 0)) { if (ddMon.StateFlags & DISPLAY_DEVICE_ACTIVE) break; devMon++; } // DeviceID = 0x0042ebd4 L"MONITOR\\HWP2847\\{4d36e96e-e325-11ce-bfc1-08002be10318}\\0004" wstring displayId = ddMon.DeviceID; /* Remove MONITOR\\ */ displayId = displayId.substr(displayId.find(L"\\") + 1); /* Remove \\{4d36e96e-e325-11ce-bfc1-08002be10318}\\0004" */ displayId = displayId.substr(0, displayId.find(L"\\")); // Now displayId = HWP2847 winDisplayInfo dInfo; if (isdisplayIDvalid(displayId)) { getDisplayInfo(displayId, &dInfo); desc.devURI = uriForDisplayId(displayId).asString(); desc.name = dInfo.monitorName; return true; } return false; }
status_t BnSurfaceComposer::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { switch(code) { case CREATE_CONNECTION: { CHECK_INTERFACE(ISurfaceComposer, data, reply); sp<IBinder> b = createConnection()->asBinder(); reply->writeStrongBinder(b); } break; case CREATE_GRAPHIC_BUFFER_ALLOC: { CHECK_INTERFACE(ISurfaceComposer, data, reply); sp<IBinder> b = createGraphicBufferAlloc()->asBinder(); reply->writeStrongBinder(b); } break; case SET_TRANSACTION_STATE: { CHECK_INTERFACE(ISurfaceComposer, data, reply); size_t count = data.readInt32(); ComposerState s; Vector<ComposerState> state; state.setCapacity(count); for (size_t i=0 ; i<count ; i++) { s.read(data); state.add(s); } count = data.readInt32(); DisplayState d; Vector<DisplayState> displays; displays.setCapacity(count); for (size_t i=0 ; i<count ; i++) { d.read(data); displays.add(d); } uint32_t flags = data.readInt32(); setTransactionState(state, displays, flags); } break; case BOOT_FINISHED: { CHECK_INTERFACE(ISurfaceComposer, data, reply); bootFinished(); } break; case CAPTURE_SCREEN: { CHECK_INTERFACE(ISurfaceComposer, data, reply); sp<IBinder> display = data.readStrongBinder(); uint32_t reqWidth = data.readInt32(); uint32_t reqHeight = data.readInt32(); uint32_t minLayerZ = data.readInt32(); uint32_t maxLayerZ = data.readInt32(); sp<IMemoryHeap> heap; uint32_t w, h; PixelFormat f; status_t res = captureScreen(display, &heap, &w, &h, &f, reqWidth, reqHeight, minLayerZ, maxLayerZ); reply->writeStrongBinder(heap->asBinder()); reply->writeInt32(w); reply->writeInt32(h); reply->writeInt32(f); reply->writeInt32(res); } break; case AUTHENTICATE_SURFACE: { CHECK_INTERFACE(ISurfaceComposer, data, reply); sp<ISurfaceTexture> surfaceTexture = interface_cast<ISurfaceTexture>(data.readStrongBinder()); int32_t result = authenticateSurfaceTexture(surfaceTexture) ? 1 : 0; reply->writeInt32(result); } break; case CREATE_DISPLAY_EVENT_CONNECTION: { CHECK_INTERFACE(ISurfaceComposer, data, reply); sp<IDisplayEventConnection> connection(createDisplayEventConnection()); reply->writeStrongBinder(connection->asBinder()); return NO_ERROR; } break; case CREATE_DISPLAY: { CHECK_INTERFACE(ISurfaceComposer, data, reply); String8 displayName = data.readString8(); bool secure = bool(data.readInt32()); sp<IBinder> display(createDisplay(displayName, secure)); reply->writeStrongBinder(display); return NO_ERROR; } break; case GET_BUILT_IN_DISPLAY: { CHECK_INTERFACE(ISurfaceComposer, data, reply); int32_t id = data.readInt32(); sp<IBinder> display(getBuiltInDisplay(id)); reply->writeStrongBinder(display); return NO_ERROR; } break; case BLANK: { CHECK_INTERFACE(ISurfaceComposer, data, reply); sp<IBinder> display = data.readStrongBinder(); blank(display); } break; case UNBLANK: { CHECK_INTERFACE(ISurfaceComposer, data, reply); sp<IBinder> display = data.readStrongBinder(); unblank(display); } break; case GET_DISPLAY_INFO: { CHECK_INTERFACE(ISurfaceComposer, data, reply); DisplayInfo info; sp<IBinder> display = data.readStrongBinder(); status_t result = getDisplayInfo(display, &info); memcpy(reply->writeInplace(sizeof(DisplayInfo)), &info, sizeof(DisplayInfo)); reply->writeInt32(result); } break; default: return BBinder::onTransact(code, data, reply, flags); } return NO_ERROR; }
Common::Error SagaEngine::run() { setTotalPlayTime(0); // Assign default values to the config manager, in case settings are missing ConfMan.registerDefault("talkspeed", "255"); ConfMan.registerDefault("subtitles", "true"); _musicVolume = ConfMan.getInt("music_volume"); _subtitlesEnabled = ConfMan.getBool("subtitles"); _readingSpeed = getTalkspeed(); _copyProtection = ConfMan.getBool("copy_protection"); _musicWasPlaying = false; _isIHNMDemo = Common::File::exists("music.res"); _hasITESceneSubstitutes = Common::File::exists("boarhall.bbm"); if (_readingSpeed > 3) _readingSpeed = 0; switch (getGameId()) { case GID_ITE: _resource = new Resource_RSC(this); break; #ifdef ENABLE_IHNM case GID_IHNM: _resource = new Resource_RES(this); break; #endif #ifdef ENABLE_SAGA2 case GID_DINO: case GID_FTA2: _resource = new Resource_HRS(this); break; #endif } // Detect game and open resource files if (!initGame()) { GUIErrorMessage("Error loading game resources."); return Common::kUnknownError; } // Initialize engine modules // TODO: implement differences for SAGA2 _sndRes = new SndRes(this); _events = new Events(this); if (!isSaga2()) { _font = new Font(this); _sprite = new Sprite(this); _script = new SAGA1Script(this); } else { _script = new SAGA2Script(this); } _anim = new Anim(this); _interface = new Interface(this); // requires script module _scene = new Scene(this); _actor = new Actor(this); _palanim = new PalAnim(this); if (getGameId() == GID_ITE) { _isoMap = new IsoMap(this); _puzzle = new Puzzle(this); } // System initialization _previousTicks = _system->getMillis(); // Initialize graphics _gfx = new Gfx(this, _system, getDisplayInfo().width, getDisplayInfo().height); // Graphics driver should be initialized before console _console = new Console(this); // Graphics should be initialized before music _music = new Music(this, _mixer); _render = new Render(this, _system); if (!_render->initialized()) { return Common::kUnknownError; } // Initialize system specific sound _sound = new Sound(this, _mixer); if (!isSaga2()) { _interface->converseClear(); _script->setVerb(_script->getVerbType(kVerbWalkTo)); } _music->setVolume(_musicVolume, 1); if (!isSaga2()) { _gfx->initPalette(); } if (_voiceFilesExist) { if (getGameId() == GID_IHNM) { if (!ConfMan.hasKey("voices")) { _voicesEnabled = true; ConfMan.setBool("voices", true); } else { _voicesEnabled = ConfMan.getBool("voices"); } } else { _voicesEnabled = true; } } syncSoundSettings(); int msec = 0; _previousTicks = _system->getMillis(); if (ConfMan.hasKey("start_scene")) { _scene->changeScene(ConfMan.getInt("start_scene"), 0, kTransitionNoFade); } else if (ConfMan.hasKey("boot_param")) { if (getGameId() == GID_ITE) _interface->addToInventory(_actor->objIndexToId(0)); // Magic hat _scene->changeScene(ConfMan.getInt("boot_param"), 0, kTransitionNoFade); } else if (ConfMan.hasKey("save_slot")) { // Init the current chapter to 8 (character selection) for IHNM if (getGameId() == GID_IHNM) _scene->changeScene(-2, 0, kTransitionFade, 8); // First scene sets up palette _scene->changeScene(getStartSceneNumber(), 0, kTransitionNoFade); _events->handleEvents(0); // Process immediate events if (getGameId() == GID_ITE) _interface->setMode(kPanelMain); else _interface->setMode(kPanelChapterSelection); char *fileName = calcSaveFileName(ConfMan.getInt("save_slot")); load(fileName); syncSoundSettings(); } else { _framesEsc = 0; _scene->startScene(); } uint32 currentTicks; while (!shouldQuit()) { _console->onFrame(); if (_render->getFlags() & RF_RENDERPAUSE) { // Freeze time while paused _previousTicks = _system->getMillis(); } else { currentTicks = _system->getMillis(); // Timer has rolled over after 49 days if (currentTicks < _previousTicks) msec = 0; else { msec = currentTicks - _previousTicks; _previousTicks = currentTicks; } if (msec > MAX_TIME_DELTA) { msec = MAX_TIME_DELTA; } // Since Puzzle and forced text are actorless, we do them here if ((getGameId() == GID_ITE && _puzzle->isActive()) || _actor->isForcedTextShown()) { _actor->handleSpeech(msec); } else if (!_scene->isInIntro()) { if (_interface->getMode() == kPanelMain || _interface->getMode() == kPanelConverse || _interface->getMode() == kPanelCutaway || _interface->getMode() == kPanelNull || _interface->getMode() == kPanelChapterSelection) _actor->direct(msec); } _events->handleEvents(msec); _script->executeThreads(msec); } // Per frame processing _render->drawScene(); _system->delayMillis(10); } return Common::kNoError; }
std::wstring getMatchingRegistryKey(std::wstring displayName) { std::wstring res = L""; HKEY hKey; RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SYSTEM\\CurrentControlSet\\Enum\\DISPLAY"), 0, KEY_READ, &hKey); TCHAR achKey[MAX_KEY_LENGTH]; // buffer for subkey name DWORD cbName; // size of name string TCHAR achClass[MAX_PATH] = TEXT(""); // buffer for class name DWORD cchClassName = MAX_PATH; // size of class string DWORD cSubKeys=0; // number of subkeys DWORD cbMaxSubKey; // longest subkey size DWORD cchMaxClass; // longest class string DWORD cValues; // number of values for key DWORD cchMaxValue; // longest value name DWORD cbMaxValueData; // longest value data DWORD cbSecurityDescriptor; // size of security descriptor FILETIME ftLastWriteTime; // last write time DWORD i, retCode; // Get the class name and the value count. retCode = RegQueryInfoKey( hKey, // key handle achClass, // buffer for class name &cchClassName, // size of class string NULL, // reserved &cSubKeys, // number of subkeys &cbMaxSubKey, // longest subkey size &cchMaxClass, // longest class string &cValues, // number of values for this key &cchMaxValue, // longest value name &cbMaxValueData, // longest value data &cbSecurityDescriptor, // security descriptor &ftLastWriteTime); // last write time // Enumerate the subkeys, until RegEnumKeyEx fails. if (cSubKeys) { //std::cout << "Number of subkeys: " << cSubKeys <<std::endl; for (i=0; i<cSubKeys; i++) { cbName = MAX_KEY_LENGTH; retCode = RegEnumKeyEx(hKey, i, achKey, &cbName, NULL, NULL, NULL, &ftLastWriteTime); if (retCode == ERROR_SUCCESS) { winDisplayInfo dinfo; getDisplayInfo(achKey,&dinfo); if ((dinfo.w > 0) && (dinfo.h > 0)) if (matchStrings(displayName, std::string(dinfo.monitorName))) res = achKey; } } } RegCloseKey(hKey); return res; }
int main (int argc, char** argv){ connectX(); getDisplayInfo(); disconnectX(); }