mirror of
https://github.com/libretro/RetroArch
synced 2025-03-28 08:37:41 +00:00
Create win32_get_metrics
This commit is contained in:
parent
1f23338ca4
commit
dc10606b23
@ -13,10 +13,8 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../../driver.h"
|
||||
#include "../../general.h"
|
||||
#include "win32_common.h"
|
||||
#include <string.h>
|
||||
|
||||
#if !defined(_XBOX) && defined(_WIN32)
|
||||
|
||||
@ -182,3 +180,39 @@ LRESULT win32_menu_loop(HWND owner, WPARAM wparam)
|
||||
return 0L;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool win32_get_metrics(void *data,
|
||||
enum display_metric_types type, float *value)
|
||||
{
|
||||
#ifdef _XBOX
|
||||
return false;
|
||||
#else
|
||||
HDC monitor = GetDC(NULL);
|
||||
int pixels_x = GetDeviceCaps(monitor, HORZRES);
|
||||
int pixels_y = GetDeviceCaps(monitor, VERTRES);
|
||||
int physical_width = GetDeviceCaps(monitor, HORZSIZE);
|
||||
int physical_height = GetDeviceCaps(monitor, VERTSIZE);
|
||||
|
||||
ReleaseDC(NULL, monitor);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case DISPLAY_METRIC_MM_WIDTH:
|
||||
*value = physical_width;
|
||||
break;
|
||||
case DISPLAY_METRIC_MM_HEIGHT:
|
||||
*value = physical_height;
|
||||
break;
|
||||
case DISPLAY_METRIC_DPI:
|
||||
/* 25.4 mm in an inch. */
|
||||
*value = 254 * pixels_x / physical_width / 10;
|
||||
break;
|
||||
case DISPLAY_METRIC_NONE:
|
||||
default:
|
||||
*value = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
@ -17,6 +17,11 @@
|
||||
#ifndef WIN32_COMMON_H__
|
||||
#define WIN32_COMMON_H__
|
||||
|
||||
#include <string.h>
|
||||
#include <boolean.h>
|
||||
#include "../../driver.h"
|
||||
#include "../video_context_driver.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -32,6 +37,9 @@ LRESULT win32_handle_keyboard_event(HWND hwnd, UINT message,
|
||||
LRESULT win32_menu_loop(HWND handle, WPARAM wparam);
|
||||
#endif
|
||||
|
||||
bool win32_get_metrics(void *data,
|
||||
enum display_metric_types type, float *value);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -495,37 +495,7 @@ static void gfx_ctx_d3d_swap_interval(void *data, unsigned interval)
|
||||
static bool gfx_ctx_d3d_get_metrics(void *data,
|
||||
enum display_metric_types type, float *value)
|
||||
{
|
||||
#ifdef _XBOX
|
||||
return false;
|
||||
#else
|
||||
HDC monitor = GetDC(NULL);
|
||||
int pixels_x = GetDeviceCaps(monitor, HORZRES);
|
||||
int pixels_y = GetDeviceCaps(monitor, VERTRES);
|
||||
int physical_width = GetDeviceCaps(monitor, HORZSIZE);
|
||||
int physical_height = GetDeviceCaps(monitor, VERTSIZE);
|
||||
|
||||
ReleaseDC(NULL, monitor);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case DISPLAY_METRIC_MM_WIDTH:
|
||||
*value = physical_width;
|
||||
break;
|
||||
case DISPLAY_METRIC_MM_HEIGHT:
|
||||
*value = physical_height;
|
||||
break;
|
||||
case DISPLAY_METRIC_DPI:
|
||||
/* 25.4 mm in an inch. */
|
||||
*value = 254 * pixels_x / physical_width / 10;
|
||||
break;
|
||||
case DISPLAY_METRIC_NONE:
|
||||
default:
|
||||
*value = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
#endif
|
||||
return win32_get_metrics(data, type, value);
|
||||
}
|
||||
|
||||
const gfx_ctx_driver_t gfx_ctx_d3d = {
|
||||
|
@ -667,34 +667,7 @@ static gfx_ctx_proc_t gfx_ctx_wgl_get_proc_address(const char *symbol)
|
||||
static bool gfx_ctx_wgl_get_metrics(void *data,
|
||||
enum display_metric_types type, float *value)
|
||||
{
|
||||
bool ret = true;
|
||||
HDC monitor = GetDC(NULL);
|
||||
int pixels_x = GetDeviceCaps(monitor, HORZRES);
|
||||
int pixels_y = GetDeviceCaps(monitor, VERTRES);
|
||||
int physical_width = GetDeviceCaps(monitor, HORZSIZE);
|
||||
int physical_height = GetDeviceCaps(monitor, VERTSIZE);
|
||||
|
||||
ReleaseDC(NULL, monitor);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case DISPLAY_METRIC_MM_WIDTH:
|
||||
*value = physical_width;
|
||||
break;
|
||||
case DISPLAY_METRIC_MM_HEIGHT:
|
||||
*value = physical_height;
|
||||
break;
|
||||
case DISPLAY_METRIC_DPI:
|
||||
/* 25.4 mm in an inch. */
|
||||
*value = 254 * pixels_x / physical_width / 10;
|
||||
break;
|
||||
case DISPLAY_METRIC_NONE:
|
||||
default:
|
||||
*value = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return win32_get_metrics(data, type, value);
|
||||
}
|
||||
|
||||
static bool gfx_ctx_wgl_bind_api(void *data,
|
||||
|
@ -86,11 +86,15 @@ CHEATS
|
||||
/*============================================================
|
||||
UI COMMON CONTEXT
|
||||
============================================================ */
|
||||
#if defined(_WIN32) && !defined(_XBOX)
|
||||
#if defined(_WIN32)
|
||||
#include "../gfx/common/win32_common.c"
|
||||
|
||||
#ifndef _XBOX
|
||||
#include "../gfx/drivers_wm/win32_dwm_common.c"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*============================================================
|
||||
VIDEO CONTEXT
|
||||
============================================================ */
|
||||
|
Loading…
x
Reference in New Issue
Block a user