diff --git a/Core/Core.cpp b/Core/Core.cpp index 8d8ca89cd9..3f66794576 100644 --- a/Core/Core.cpp +++ b/Core/Core.cpp @@ -156,7 +156,7 @@ bool UpdateScreenScale(int width, int height) { g_dpi_scale_x = g_logical_dpi / g_dpi; g_dpi_scale_y = g_logical_dpi / g_dpi; #elif PPSSPP_PLATFORM(WINDOWS) && !PPSSPP_PLATFORM(UWP) - g_dpi = (float)System_GetPropertyInt(SYSPROP_DISPLAY_DPI); + g_dpi = System_GetPropertyFloat(SYSPROP_DISPLAY_DPI); g_dpi_scale_x = 96.0f / g_dpi; g_dpi_scale_y = 96.0f / g_dpi; #else diff --git a/Core/HLE/sceDisplay.cpp b/Core/HLE/sceDisplay.cpp index d1a2de1110..3e6b526a8f 100644 --- a/Core/HLE/sceDisplay.cpp +++ b/Core/HLE/sceDisplay.cpp @@ -435,8 +435,7 @@ static bool IsRunningSlow() { best = std::max(fpsHistory[index], best); } - // Note that SYSPROP_DISPLAY_REFRESH_RATE is multiplied by 1000. - return best < System_GetPropertyInt(SYSPROP_DISPLAY_REFRESH_RATE) * (1.0 / 1001.0); + return best < System_GetPropertyFloat(SYSPROP_DISPLAY_REFRESH_RATE) * 0.999; } return false; @@ -510,12 +509,12 @@ static void DoFrameDropLogging(float scaledTimestep) { static int CalculateFrameSkip() { int frameSkipNum; - if (g_Config.iFrameSkipType == 1) { + if (g_Config.iFrameSkipType == 1) { // Calculate the frames to skip dynamically using the set percentage of the current fps - frameSkipNum = ceil( flips * (static_cast(g_Config.iFrameSkip) / 100.00) ); - } else { + frameSkipNum = ceil( flips * (static_cast(g_Config.iFrameSkip) / 100.00) ); + } else { // Use the set number of frames to skip - frameSkipNum = g_Config.iFrameSkip; + frameSkipNum = g_Config.iFrameSkip; } return frameSkipNum; } diff --git a/Core/HW/StereoResampler.cpp b/Core/HW/StereoResampler.cpp index 8bf58c3f4c..3894e6d771 100644 --- a/Core/HW/StereoResampler.cpp +++ b/Core/HW/StereoResampler.cpp @@ -71,7 +71,7 @@ StereoResampler::StereoResampler() // Some Android devices are v-synced to non-60Hz framerates. We simply timestretch audio to fit. // TODO: should only do this if auto frameskip is off? - float refresh = System_GetPropertyInt(SYSPROP_DISPLAY_REFRESH_RATE) / 1000.0f; + float refresh = System_GetPropertyFloat(SYSPROP_DISPLAY_REFRESH_RATE); // If framerate is "close"... if (refresh != 60.0f && refresh > 50.0f && refresh < 70.0f) { diff --git a/Qt/QtMain.cpp b/Qt/QtMain.cpp index 83043c150e..f117d3a762 100644 --- a/Qt/QtMain.cpp +++ b/Qt/QtMain.cpp @@ -42,7 +42,7 @@ #include MainUI *emugl = nullptr; -static int refreshRate = 60000; +static float refreshRate = 60.f; static int browseFileEvent = -1; static int browseFolderEvent = -1; @@ -145,8 +145,6 @@ int System_GetPropertyInt(SystemProperty prop) { switch (prop) { case SYSPROP_AUDIO_SAMPLE_RATE: return 44100; - case SYSPROP_DISPLAY_REFRESH_RATE: - return refreshRate; case SYSPROP_DEVICE_TYPE: #if defined(__ANDROID__) return DEVICE_TYPE_MOBILE; @@ -166,14 +164,16 @@ int System_GetPropertyInt(SystemProperty prop) { } } -int System_GetPropertyFloat(SystemProperty prop) { +float System_GetPropertyFloat(SystemProperty prop) { switch (prop) { + case SYSPROP_DISPLAY_REFRESH_RATE: + return refreshRate; case SYSPROP_DISPLAY_LOGICAL_DPI: return QApplication::primaryScreen()->logicalDotsPerInch(); case SYSPROP_DISPLAY_DPI: return QApplication::primaryScreen()->physicalDotsPerInch(); default: - return System_GetPropertyInt(prop); + return -1; } } @@ -645,7 +645,7 @@ int main(int argc, char *argv[]) dp_xres = (int)(pixel_xres * g_dpi_scale_x); dp_yres = (int)(pixel_yres * g_dpi_scale_y); - refreshRate = (int)(screen->refreshRate() * 1000); + refreshRate = screen->refreshRate(); std::string savegame_dir = "."; std::string external_dir = "."; diff --git a/SDL/SDLMain.cpp b/SDL/SDLMain.cpp index e8bc75fc4d..548d588ea5 100644 --- a/SDL/SDLMain.cpp +++ b/SDL/SDLMain.cpp @@ -65,7 +65,7 @@ static int g_QuitRequested = 0; static int g_DesktopWidth = 0; static int g_DesktopHeight = 0; -static int g_RefreshRate = 60000; +static float g_RefreshRate = 60.f; int getDisplayNumber(void) { int displayNumber = 0; @@ -307,8 +307,6 @@ int System_GetPropertyInt(SystemProperty prop) { switch (prop) { case SYSPROP_AUDIO_SAMPLE_RATE: return 44100; - case SYSPROP_DISPLAY_REFRESH_RATE: - return g_RefreshRate; case SYSPROP_DEVICE_TYPE: #if defined(MOBILE_DEVICE) return DEVICE_TYPE_MOBILE; @@ -322,6 +320,15 @@ int System_GetPropertyInt(SystemProperty prop) { } } +float System_GetPropertyFloat(SystemProperty prop) { + switch (prop) { + case SYSPROP_DISPLAY_REFRESH_RATE: + return g_RefreshRate; + default: + return -1; + } +} + bool System_GetPropertyBool(SystemProperty prop) { switch (prop) { case SYSPROP_HAS_BACK_BUTTON: @@ -511,7 +518,7 @@ int main(int argc, char *argv[]) { } g_DesktopWidth = displayMode.w; g_DesktopHeight = displayMode.h; - g_RefreshRate = (int)(displayMode.refresh_rate * 1000); + g_RefreshRate = displayMode.refresh_rate; SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); diff --git a/UWP/PPSSPP_UWPMain.cpp b/UWP/PPSSPP_UWPMain.cpp index 1f77adf425..35739b4dc8 100644 --- a/UWP/PPSSPP_UWPMain.cpp +++ b/UWP/PPSSPP_UWPMain.cpp @@ -96,7 +96,7 @@ PPSSPP_UWPMain::PPSSPP_UWPMain(App ^app, const std::shared_ptrGetSampleRate() : -1; - case SYSPROP_DISPLAY_REFRESH_RATE: - return 60000; case SYSPROP_DEVICE_TYPE: { auto ver = Windows::System::Profile::AnalyticsInfo::VersionInfo; @@ -375,6 +373,15 @@ int System_GetPropertyInt(SystemProperty prop) { } } +float System_GetPropertyFloat(SystemProperty prop) { + switch (prop) { + case SYSPROP_DISPLAY_REFRESH_RATE: + return 60.f; + default: + return -1; + } +} + bool VulkanMayBeAvailable() { return false; } @@ -477,7 +484,7 @@ bool System_InputBoxGetWString(const wchar_t *title, const std::wstring &default std::string GetCPUBrandString() { Platform::String^ cpu_id = nullptr; Platform::String^ cpu_name = nullptr; - + // GUID_DEVICE_PROCESSOR: {97FADB10-4E33-40AE-359C-8BEF029DBDD0} Platform::String^ if_filter = L"System.Devices.InterfaceClassGuid:=\"{97FADB10-4E33-40AE-359C-8BEF029DBDD0}\""; diff --git a/Windows/MainWindow.cpp b/Windows/MainWindow.cpp index 2462568dba..3d835c9ea0 100644 --- a/Windows/MainWindow.cpp +++ b/Windows/MainWindow.cpp @@ -154,7 +154,7 @@ namespace MainWindow // Register classes - Main Window WNDCLASSEX wcex; memset(&wcex, 0, sizeof(wcex)); - wcex.cbSize = sizeof(WNDCLASSEX); + wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = 0; // Show in taskbar wcex.lpfnWndProc = (WNDPROC)WndProc; wcex.hInstance = hInstance; @@ -228,7 +228,7 @@ namespace MainWindow if (++g_Config.iInternalResolution > RESOLUTION_MAX) g_Config.iInternalResolution = 0; } - + // Taking auto-texture scaling into account if (g_Config.iTexScalingLevel == TEXSCALING_AUTO) setTexScalingMultiplier(0); @@ -329,7 +329,7 @@ namespace MainWindow dwStyle &= ~WS_POPUP; // Re-add caption and border styles. dwStyle |= WS_OVERLAPPEDWINDOW; - + // Put back the menu bar. ::SetMenu(hWnd, menu); } else { @@ -437,7 +437,7 @@ namespace MainWindow bool portrait = g_Config.IsPortrait(); // We want to adjust for DPI but still get an integer pixel scaling ratio. - double dpi_scale = 96.0 / System_GetPropertyInt(SYSPROP_DISPLAY_DPI); + double dpi_scale = 96.0 / System_GetPropertyFloat(SYSPROP_DISPLAY_DPI); int scale = (int)ceil(2.0 / dpi_scale); GetWindowSizeAtResolution(scale * (portrait ? 272 : 480), scale * (portrait ? 480 : 272), &windowWidth, &windowHeight); @@ -547,7 +547,7 @@ namespace MainWindow if (disasmWindow[0]) delete disasmWindow[0]; disasmWindow[0] = 0; - + #if PPSSPP_API(ANY_GL) DialogManager::RemoveDlg(geDebuggerWindow); if (geDebuggerWindow) @@ -682,7 +682,7 @@ namespace MainWindow } return 0; } - + LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_CREATE: @@ -691,7 +691,7 @@ namespace MainWindow RemoveMenu(GetMenu(hWnd), ID_OPTIONS_DIRECT3D11, MF_BYCOMMAND); } break; - + case WM_GETMINMAXINFO: { MINMAXINFO *minmax = reinterpret_cast(lParam); @@ -975,10 +975,10 @@ namespace MainWindow case WM_SYSCOMMAND: { switch (wParam) { - case SC_SCREENSAVE: + case SC_SCREENSAVE: return 0; case SC_MONITORPOWER: - return 0; + return 0; } return DefWindowProc(hWnd, message, wParam, lParam); } @@ -988,7 +988,7 @@ namespace MainWindow } return 0; } - + void Redraw() { InvalidateRect(hwndDisplay,0,0); } diff --git a/Windows/main.cpp b/Windows/main.cpp index 5ceb76d849..facf559935 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -126,7 +126,7 @@ std::string GetVideoCardDriverVersion() { } IWbemLocator *pIWbemLocator = NULL; - hr = CoCreateInstance(__uuidof(WbemLocator), NULL, CLSCTX_INPROC_SERVER, + hr = CoCreateInstance(__uuidof(WbemLocator), NULL, CLSCTX_INPROC_SERVER, __uuidof(IWbemLocator), (LPVOID *)&pIWbemLocator); if (FAILED(hr)) { CoUninitialize(); @@ -143,9 +143,9 @@ std::string GetVideoCardDriverVersion() { return retvalue; } - hr = CoSetProxyBlanket(pIWbemServices, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, + hr = CoSetProxyBlanket(pIWbemServices, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, NULL, RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, NULL,EOAC_DEFAULT); - + BSTR bstrWQL = SysAllocString(L"WQL"); BSTR bstrPath = SysAllocString(L"select * from Win32_VideoController"); IEnumWbemClassObject* pEnum; @@ -232,12 +232,8 @@ int System_GetPropertyInt(SystemProperty prop) { switch (prop) { case SYSPROP_AUDIO_SAMPLE_RATE: return winAudioBackend ? winAudioBackend->GetSampleRate() : -1; - case SYSPROP_DISPLAY_REFRESH_RATE: - return 60000; case SYSPROP_DEVICE_TYPE: return DEVICE_TYPE_DESKTOP; - case SYSPROP_DISPLAY_DPI: - return ScreenDPI(); case SYSPROP_DISPLAY_COUNT: return GetSystemMetrics(SM_CMONITORS); default: @@ -245,6 +241,17 @@ int System_GetPropertyInt(SystemProperty prop) { } } +float System_GetPropertyFloat(SystemProperty prop) { + switch (prop) { + case SYSPROP_DISPLAY_REFRESH_RATE: + return 60.f; + case SYSPROP_DISPLAY_DPI: + return (float)ScreenDPI(); + default: + return -1; + } +} + bool System_GetPropertyBool(SystemProperty prop) { switch (prop) { case SYSPROP_HAS_FILE_BROWSER: @@ -491,7 +498,7 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin LogManager::Init(); - // On Win32 it makes more sense to initialize the system directories here + // On Win32 it makes more sense to initialize the system directories here // because the next place it was called was in the EmuThread, and it's too late by then. g_Config.internalDataDirectory = W32Util::UserDocumentsPath(); InitSysDirectories(); @@ -589,7 +596,7 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin // - The -l switch is expected to show the log console, REGARDLESS of config settings. // - It should be possible to log to a file without showing the console. LogManager::GetInstance()->GetConsoleListener()->Init(showLog, 150, 120, "PPSSPP Debug Console"); - + if (debugLogLevel) LogManager::GetInstance()->SetAllLogLevels(LogTypes::LDEBUG); @@ -603,7 +610,7 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin HWND hwndMain = MainWindow::GetHWND(); HWND hwndDisplay = MainWindow::GetDisplayHWND(); - + //initialize custom controls CtrlDisAsmView::init(); CtrlMemView::init(); @@ -636,7 +643,7 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin { //hack to enable/disable menu command accelerate keys MainWindow::UpdateCommands(); - + //hack to make it possible to get to main window from floating windows with Esc if (msg.hwnd != hwndMain && msg.wParam == VK_ESCAPE) BringWindowToTop(hwndMain); diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp index dd8058df43..0ceace3732 100644 --- a/android/jni/app-android.cpp +++ b/android/jni/app-android.cpp @@ -303,8 +303,15 @@ int System_GetPropertyInt(SystemProperty prop) { return optimalSampleRate; case SYSPROP_AUDIO_OPTIMAL_FRAMES_PER_BUFFER: return optimalFramesPerBuffer; + default: + return -1; + } +} + +float System_GetPropertyFloat(SystemProperty prop) { + switch (prop) { case SYSPROP_DISPLAY_REFRESH_RATE: - return (int)(display_hz * 1000.0); + return display_hz; default: return -1; } @@ -682,7 +689,7 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeRenderer_displayRender(JNIEnv *env, hasSetThreadName = true; setCurrentThreadName("AndroidRender"); } - + if (useCPUThread) { // This is the "GPU thread". if (graphicsContext) diff --git a/ext/native/base/NativeApp.h b/ext/native/base/NativeApp.h index 188bcbaa52..f1f348acc7 100644 --- a/ext/native/base/NativeApp.h +++ b/ext/native/base/NativeApp.h @@ -148,7 +148,7 @@ enum SystemProperty { SYSPROP_SYSTEMVERSION, SYSPROP_DISPLAY_XRES, SYSPROP_DISPLAY_YRES, - SYSPROP_DISPLAY_REFRESH_RATE, // returns 1000*the refresh rate in Hz as it can be non-integer + SYSPROP_DISPLAY_REFRESH_RATE, SYSPROP_DISPLAY_LOGICAL_DPI, SYSPROP_DISPLAY_DPI, SYSPROP_DISPLAY_COUNT, @@ -174,7 +174,7 @@ enum SystemProperty { std::string System_GetProperty(SystemProperty prop); int System_GetPropertyInt(SystemProperty prop); -int System_GetPropertyFloat(SystemProperty prop); +float System_GetPropertyFloat(SystemProperty prop); bool System_GetPropertyBool(SystemProperty prop); std::vector __cameraGetDeviceList(); diff --git a/headless/Headless.cpp b/headless/Headless.cpp index 72c6620c6c..b92f36d6ba 100644 --- a/headless/Headless.cpp +++ b/headless/Headless.cpp @@ -74,6 +74,9 @@ std::string System_GetProperty(SystemProperty prop) { return ""; } int System_GetPropertyInt(SystemProperty prop) { return -1; } +float System_GetPropertyFloat(SystemProperty prop) { + return -1; +} bool System_GetPropertyBool(SystemProperty prop) { return false; } @@ -225,7 +228,7 @@ int main(int argc, const char* argv[]) const char *stateToLoad = 0; GPUCore gpuCore = GPUCORE_NULL; CPUCore cpuCore = CPUCore::JIT; - + std::vector testFilenames; const char *mountIso = 0; const char *mountRoot = 0; @@ -321,7 +324,7 @@ int main(int argc, const char* argv[]) LogManager::Init(); LogManager *logman = LogManager::GetInstance(); - + PrintfLogger *printfLogger = new PrintfLogger(); for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++) { diff --git a/ios/main.mm b/ios/main.mm index dfa1548296..eee92a0cad 100644 --- a/ios/main.mm +++ b/ios/main.mm @@ -80,8 +80,6 @@ int System_GetPropertyInt(SystemProperty prop) { switch (prop) { case SYSPROP_AUDIO_SAMPLE_RATE: return 44100; - case SYSPROP_DISPLAY_REFRESH_RATE: - return 60000; case SYSPROP_DEVICE_TYPE: return DEVICE_TYPE_MOBILE; default: @@ -89,6 +87,15 @@ int System_GetPropertyInt(SystemProperty prop) { } } +float System_GetPropertyFloat(SystemProperty prop) { + switch (prop) { + case SYSPROP_DISPLAY_REFRESH_RATE: + return 60.f; + default: + return -1; + } +} + bool System_GetPropertyBool(SystemProperty prop) { switch (prop) { case SYSPROP_HAS_BACK_BUTTON: @@ -139,7 +146,7 @@ BOOL SupportsTaptic() { return NO; } - + // http://www.mikitamanko.com/blog/2017/01/29/haptic-feedback-with-uifeedbackgenerator/ // use private API against UIDevice to determine the haptic stepping // 2 - iPhone 7 or above, full taptic feedback @@ -150,7 +157,7 @@ BOOL SupportsTaptic() } void Vibrate(int mode) { - + if(SupportsTaptic()) { PPSSPPUIApplication* app = (PPSSPPUIApplication*)[UIApplication sharedApplication]; @@ -165,10 +172,10 @@ void Vibrate(int mode) { { NSMutableDictionary *dictionary = [NSMutableDictionary dictionary]; NSArray *pattern = @[@YES, @30, @NO, @2]; - + dictionary[@"VibePattern"] = pattern; dictionary[@"Intensity"] = @2; - + AudioServicesPlaySystemSoundWithVibration(kSystemSoundID_Vibrate, nil, dictionary); } } @@ -180,15 +187,15 @@ int main(int argc, char *argv[]) fprintf(stderr, "Unable to cleanly obtain CS_DEBUGGED - probably not jailbroken. Attempting old method.\n"); ptrace(PTRACE_TRACEME, 0, 0, 0); } - + PROFILE_INIT(); - + @autoreleasepool { NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSString *bundlePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingString:@"/assets/"]; - + NativeInit(argc, (const char**)argv, documentsPath.UTF8String, bundlePath.UTF8String, NULL); - + return UIApplicationMain(argc, argv, NSStringFromClass([PPSSPPUIApplication class]), NSStringFromClass([AppDelegate class])); } } diff --git a/libretro/libretro.cpp b/libretro/libretro.cpp index 9335063608..11ddce7d24 100644 --- a/libretro/libretro.cpp +++ b/libretro/libretro.cpp @@ -322,10 +322,10 @@ void retro_init(void) { g_Config.bEnableSound = true; g_Config.bAudioResampler = false; g_Config.iCwCheatRefreshRate = 60; - + g_Config.iFirmwareVersion = PSP_DEFAULT_FIRMWARE; g_Config.iPSPModel = PSP_MODEL_SLIM; - + LogManager::Init(); host = new LibretroHost; @@ -730,7 +730,7 @@ bool retro_serialize(void *data, size_t size) { if (useEmuThread) { EmuThreadPause(); // Does nothing if already paused } - + SaveState::SaveStart state; assert(CChunkFileReader::MeasurePtr(state) <= size); bool retVal = CChunkFileReader::SavePtr((u8 *)data, state) == CChunkFileReader::ERROR_NONE; @@ -739,7 +739,7 @@ bool retro_serialize(void *data, size_t size) { EmuThreadStart(); sleep_ms(4); } - + return retVal; } @@ -786,8 +786,15 @@ int System_GetPropertyInt(SystemProperty prop) { switch (prop) { case SYSPROP_AUDIO_SAMPLE_RATE: return SAMPLERATE; + default: + return -1; + } +} + +float System_GetPropertyFloat(SystemProperty prop) { + switch (prop) { case SYSPROP_DISPLAY_REFRESH_RATE: - return 60000; + return 60.f; default: return -1; } diff --git a/unittest/UnitTest.cpp b/unittest/UnitTest.cpp index 8e0d47f122..e2b94af96a 100644 --- a/unittest/UnitTest.cpp +++ b/unittest/UnitTest.cpp @@ -55,6 +55,9 @@ std::string System_GetProperty(SystemProperty prop) { return ""; } int System_GetPropertyInt(SystemProperty prop) { return -1; } +float System_GetPropertyFloat(SystemProperty prop) { + return -1; +} bool System_GetPropertyBool(SystemProperty prop) { return false; } @@ -157,7 +160,7 @@ void fcs(float angle, float &sinout, float &cosout) { int phasein = angle * (1 << BITSPERQUARTER); // Modulo phase into quarter, convert to float 0..1 float modphase = (phasein & ((1<> BITSPERQUARTER; // Recognize quarter if (!quarter) {