forked from len0rd/rockbox
simulator: Adjust scaling using keyboard shortcuts
Press 0-3 to to adjust current zoom level to 50% (0), 100% (1), 200% (2), or 300% (3). Press 4 to switch between "best" (linear) and nearest pixel sampling. Change-Id: Id10d361659855a0ad9c97e6b341f498f72709ef5
This commit is contained in:
parent
759cbf4e5f
commit
7aaa722a5d
3 changed files with 55 additions and 22 deletions
|
@ -351,6 +351,30 @@ static void button_event(int key, bool pressed)
|
|||
switch (key)
|
||||
{
|
||||
#ifdef SIMULATOR
|
||||
case SDLK_0:
|
||||
display_zoom = 0.5;
|
||||
case SDLK_1:
|
||||
display_zoom = display_zoom ?: 1;
|
||||
case SDLK_2:
|
||||
display_zoom = display_zoom ?: 2;
|
||||
case SDLK_3:
|
||||
display_zoom = display_zoom ?: 3;
|
||||
case SDLK_4:
|
||||
if (pressed)
|
||||
{
|
||||
display_zoom = 0;
|
||||
return;
|
||||
}
|
||||
if (!display_zoom)
|
||||
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY,
|
||||
strcmp(SDL_GetHint(SDL_HINT_RENDER_SCALE_QUALITY) ?:
|
||||
"best", "best") ? "best": "nearest");
|
||||
|
||||
sdl_window_needs_update();
|
||||
#if !defined(__WIN32) && !defined (__APPLE__)
|
||||
button_queue_post(SDLK_UNKNOWN, 0); /* update window on main thread */
|
||||
#endif
|
||||
return;
|
||||
case USB_KEY:
|
||||
if (!pressed)
|
||||
{
|
||||
|
|
|
@ -65,19 +65,25 @@ static inline void sdl_render(void)
|
|||
#define SNAP_MARGIN 50
|
||||
int sdl_update_window(void)
|
||||
{
|
||||
int w, h;
|
||||
|
||||
if (!window_needs_update)
|
||||
return false;
|
||||
window_needs_update = false;
|
||||
|
||||
#if defined (__APPLE__) || defined(__WIN32) /* Constrain aspect ratio */
|
||||
sdl_get_window_dimensions(&w, &h);
|
||||
|
||||
if (!(SDL_GetWindowFlags(window) & (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_FULLSCREEN)))
|
||||
{
|
||||
float aspect_ratio;
|
||||
int w, h;
|
||||
|
||||
sdl_get_window_dimensions(&w, &h);
|
||||
aspect_ratio = (float) h / w;
|
||||
if (display_zoom)
|
||||
{
|
||||
SDL_SetWindowSize(window, display_zoom * w, display_zoom * h);
|
||||
}
|
||||
#if defined(__APPLE__) || defined(__WIN32)
|
||||
else /* Constrain aspect ratio on Windows and MacOS */
|
||||
{
|
||||
|
||||
float aspect_ratio = (float) h / w;
|
||||
int original_height = h;
|
||||
int original_width = w;
|
||||
|
||||
|
@ -96,6 +102,8 @@ int sdl_update_window(void)
|
|||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
display_zoom = 0;
|
||||
sdl_render();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -113,6 +113,7 @@ static void sdl_window_setup(void)
|
|||
panicf("%s", SDL_GetError());
|
||||
|
||||
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, display_zoom == 1 ? "best" : "nearest");
|
||||
display_zoom = 0; /* keeps track of user requesting a scale level change */
|
||||
SDL_RenderSetLogicalSize(sdlRenderer, width, height);
|
||||
|
||||
if ((gui_surface = SDL_CreateRGBSurface(0, width, height, depth,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue