~rabbits/uxn

6a927e4f2fbe6de6119bc1d83ca83c3543994f08 — Nathan Korth a month ago cf6697c
android: letterbox properly in landscape mode
1 files changed, 14 insertions(+), 4 deletions(-)

M src/uxnemu.c
M src/uxnemu.c => src/uxnemu.c +14 -4
@@ 176,13 176,23 @@ redraw(void)
#ifdef __ANDROID__
	gScrDst.x = 0;
	gScrDst.y = 0;
	if(gScrSize.y > gScrSize.x) { /* portrait */
	if(gScrSize.y > gScrSize.x) {
		/* Portrait - stick to top of screen and use full width.
		 * Ideally we should letterbox in all cases; this is a
		 * workaround because SDL doesn't tell us the keyboard height. */
		gScrDst.w = gScrSize.x;
		gScrDst.h = gScrSize.x * uxn_screen.height / uxn_screen.width;
	} else { /* landscape */
		gScrDst.h = gScrSize.y;
	} else {
		/* Landscape - do proper letterboxing */
		gScrDst.w = gScrSize.y * uxn_screen.width / uxn_screen.height;
		gScrDst.x = (gScrSize.x - gScrDst.w) / 2;
		if(gScrDst.w <= gScrSize.x) {
			gScrDst.h = gScrSize.y;
			gScrDst.x = (gScrSize.x - gScrDst.w) / 2;
		} else {
			gScrDst.w = gScrSize.x;
			gScrDst.h = gScrSize.x * uxn_screen.height / uxn_screen.width;
			gScrDst.y = (gScrSize.y - gScrDst.h) / 2;
		}
	}
	SDL_RenderCopy(gRenderer, gTexture, NULL, &gScrDst);
#else