Beispiel #1
0
static int DefaultInternalResolution() {
	// Auto on Windows, 2x on large screens, 1x elsewhere.
#if defined(USING_WIN_UI)
	return 0;
#else
	int longestDisplaySide = std::max(System_GetPropertyInt(SYSPROP_DISPLAY_XRES), System_GetPropertyInt(SYSPROP_DISPLAY_YRES));
	return longestDisplaySide >= 1000 ? 2 : 1;
#endif
}
Beispiel #2
0
StereoResampler::StereoResampler()
		: m_bufsize(MAX_SAMPLES_DEFAULT)
	  , m_lowwatermark(LOW_WATERMARK_DEFAULT)
		, m_input_sample_rate(44100)
		, m_indexW(0)
		, m_indexR(0)
		, m_numLeftI(0.0f)
		, m_frac(0)
		, underrunCount_(0)
		, overrunCount_(0)
		, sample_rate_(0.0f)
		, lastBufSize_(0) {
	// Need to have space for the worst case in case it changes.
	m_buffer = new int16_t[MAX_SAMPLES_EXTRA * 2]();

	// 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;

	// If framerate is "close"...
	if (refresh != 60.0f && refresh > 50.0f && refresh < 70.0f) {
		SetInputSampleRate((int)(44100 * (refresh / 60.0f)));
	}

	UpdateBufferSize();
}
Beispiel #3
0
int NativeMix(short *audio, int num_samples)
{
    int sample_rate = System_GetPropertyInt(SYSPROP_AUDIO_SAMPLE_RATE);
    num_samples = __AudioMix(audio, num_samples, sample_rate > 0 ? sample_rate : 44100);

	return num_samples;
}
Beispiel #4
0
static int DefaultAndroidHwScale() {
#ifdef ANDROID
	// Get the real resolution as passed in during startup, not dp_xres and stuff
	int xres = System_GetPropertyInt(SYSPROP_DISPLAY_XRES);
	int yres = System_GetPropertyInt(SYSPROP_DISPLAY_YRES);

	if (xres < 960) {
		// Smaller than the PSP*2, let's go native.
		return 0;
	} else if (xres <= 480 * 3) {  // 720p xres
		// Small-ish screen, we should default to 2x
		return 2 + 1;
	} else {
		// Large or very large screen. Default to 3x psp resolution.
		return 3 + 1;
	}
	return 0;
#else
	return 1;
#endif
}
Beispiel #5
0
StereoResampler::StereoResampler()
	: m_dma_mixer(this, 44100)
{
	// 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;

	// If framerate is "close"...
	if (refresh != 60.0f && refresh > 50.0f && refresh < 70.0f) {
		m_dma_mixer.SetInputSampleRate((int)(44100 * (refresh / 60.0f)));
	}
}
Beispiel #6
0
static bool DefaultShowTouchControls() {
	int deviceType = System_GetPropertyInt(SYSPROP_DEVICE_TYPE);
	if (deviceType == DEVICE_TYPE_MOBILE) {
		std::string name = System_GetProperty(SYSPROP_NAME);
		if (KeyMap::HasBuiltinController(name)) {
			return false;
		} else {
			return true;
		}
	} else if (deviceType == DEVICE_TYPE_TV) {
		return false;
	} else if (deviceType == DEVICE_TYPE_DESKTOP) {
		return false;
	} else {
		return false;
	}
}
Beispiel #7
0
	RECT DetermineWindowRectangle() {
		const int virtualScreenWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN);
		const int virtualScreenHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN);
		const int virtualScreenX = GetSystemMetrics(SM_XVIRTUALSCREEN);
		const int virtualScreenY = GetSystemMetrics(SM_YVIRTUALSCREEN);
		const int currentScreenWidth = GetSystemMetrics(SM_CXSCREEN);
		const int currentScreenHeight = GetSystemMetrics(SM_CYSCREEN);

		bool resetPositionX = true;
		bool resetPositionY = true;

		if (g_Config.iWindowWidth > 0 && g_Config.iWindowHeight > 0 && !g_Config.bFullScreen) {
			bool visibleHorizontally = ((g_Config.iWindowX + g_Config.iWindowWidth) >= virtualScreenX) &&
				((g_Config.iWindowX + g_Config.iWindowWidth) < (virtualScreenWidth + g_Config.iWindowWidth));

			bool visibleVertically = ((g_Config.iWindowY + g_Config.iWindowHeight) >= virtualScreenY) &&
				((g_Config.iWindowY + g_Config.iWindowHeight) < (virtualScreenHeight + g_Config.iWindowHeight));

			if (visibleHorizontally)
				resetPositionX = false;
			if (visibleVertically)
				resetPositionY = false;
		}

		// Try to workaround #9563.
		if (!resetPositionY && g_Config.iWindowY < 0) {
			g_Config.iWindowY = 0;
		}

		int windowWidth = g_Config.iWindowWidth;
		int windowHeight = g_Config.iWindowHeight;

		// First, get the w/h right.
		if (windowWidth <= 0 || windowHeight <= 0) {
			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);
			int scale = (int)ceil(2.0 / dpi_scale);

			GetWindowSizeAtResolution(scale * (portrait ? 272 : 480), scale * (portrait ? 480 : 272), &windowWidth, &windowHeight);
		}

		// Then center if necessary. One dimension at a time.
		// Max is to make sure that if we end up making the window bigger than the screen (which is not ideal), the top left
		// corner, and thus the menu etc, will be visible. Also potential workaround for #9563.
		int x = g_Config.iWindowX;
		int y = g_Config.iWindowY;
		if (resetPositionX) {
			x = std::max(0, (currentScreenWidth - windowWidth) / 2);
		}
		if (resetPositionY) {
			y = std::max(0, (currentScreenHeight - windowHeight) / 2);
		}

		RECT rc;
		rc.left = x;
		rc.right = rc.left + windowWidth;
		rc.top = y;
		rc.bottom = rc.top + windowHeight;
		return rc;
	}