NativeApp: add System_GetPropertyFloat all the places

This commit is contained in:
李通洲 2020-01-06 01:04:07 +08:00
parent 0a2aa2c3af
commit 55bb58e13e
No known key found for this signature in database
GPG Key ID: 185E60A519A7E290
14 changed files with 113 additions and 66 deletions

View File

@ -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

View File

@ -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<double>(g_Config.iFrameSkip) / 100.00) );
} else {
frameSkipNum = ceil( flips * (static_cast<double>(g_Config.iFrameSkip) / 100.00) );
} else {
// Use the set number of frames to skip
frameSkipNum = g_Config.iFrameSkip;
frameSkipNum = g_Config.iFrameSkip;
}
return frameSkipNum;
}

View File

@ -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) {

View File

@ -42,7 +42,7 @@
#include <string.h>
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 = ".";

View File

@ -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);

View File

@ -96,7 +96,7 @@ PPSSPP_UWPMain::PPSSPP_UWPMain(App ^app, const std::shared_ptr<DX::DeviceResourc
if (g_Config.memStickDirectory.back() != '/')
g_Config.memStickDirectory += "/";
// 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.
InitSysDirectories();
@ -328,7 +328,7 @@ void UWPGraphicsContext::Shutdown() {
}
void UWPGraphicsContext::SwapInterval(int interval) {
}
std::string System_GetProperty(SystemProperty prop) {
@ -357,8 +357,6 @@ 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:
{
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}\"";

View File

@ -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<MINMAXINFO *>(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);
}

View File

@ -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);

View File

@ -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)

View File

@ -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<std::string> __cameraGetDeviceList();

View File

@ -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<std::string> 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++) {

View File

@ -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]));
}
}

View File

@ -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;
}

View File

@ -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)-1)) * (1.0f / (1<<BITSPERQUARTER));
// Extract quarter bits
// Extract quarter bits
int quarter = phasein >> BITSPERQUARTER;
// Recognize quarter
if (!quarter) {