diff --git a/gfx/common/dxgi_common.c b/gfx/common/dxgi_common.c
index a0436a2e1e..4b68a99ed1 100644
--- a/gfx/common/dxgi_common.c
+++ b/gfx/common/dxgi_common.c
@@ -13,15 +13,28 @@
* If not, see .
*/
+#include
+#include
#include
-#include
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
#include "dxgi_common.h"
+#include "../../configuration.h"
+#include "../../verbosity.h"
+#include "../../ui/ui_companion_driver.h"
+#include "../video_driver.h"
+#include "win32_common.h"
+
+#ifdef HAVE_DYNAMIC
+#include
HRESULT WINAPI CreateDXGIFactory1(REFIID riid, void** ppFactory)
{
static HRESULT(WINAPI * fp)(REFIID, void**);
-#ifdef HAVE_DYNAMIC
+
static dylib_t dxgi_dll;
if (!dxgi_dll)
@@ -32,15 +45,13 @@ HRESULT WINAPI CreateDXGIFactory1(REFIID riid, void** ppFactory)
if (!fp)
fp = (HRESULT(WINAPI*)(REFIID, void**))dylib_proc(dxgi_dll, "CreateDXGIFactory1");
-#else
- fp = CreateDXGIFactory1;
-#endif
if (!fp)
return TYPE_E_CANTLOADLIBRARY;
return fp(riid, ppFactory);
}
+#endif
DXGI_FORMAT* dxgi_get_format_fallback_list(DXGI_FORMAT format)
{
@@ -267,3 +278,55 @@ void dxgi_copy(
#ifdef _MSC_VER
#pragma warning(default : 4293)
#endif
+
+void dxgi_update_title(video_frame_info_t* video_info)
+{
+ const ui_window_t* window = ui_companion_driver_get_window_ptr();
+
+ if (video_info->fps_show)
+ {
+ MEMORYSTATUS stat;
+ char mem[128];
+
+ mem[0] = '\0';
+
+ GlobalMemoryStatus(&stat);
+ snprintf(
+ mem, sizeof(mem), "|| MEM: %.2f/%.2fMB", stat.dwAvailPhys / (1024.0f * 1024.0f),
+ stat.dwTotalPhys / (1024.0f * 1024.0f));
+ strlcat(video_info->fps_text, mem, sizeof(video_info->fps_text));
+ }
+
+ if (window)
+ {
+ char title[128];
+
+ title[0] = '\0';
+
+ video_driver_get_window_title(title, sizeof(title));
+
+ if (title[0])
+ window->set_title(&main_window, title);
+ }
+}
+
+void dxgi_input_driver(const char* name, const input_driver_t** input, void** input_data)
+{
+ settings_t* settings = config_get_ptr();
+
+#if _WIN32_WINNT >= 0x0501
+ /* winraw only available since XP */
+ if (string_is_equal(settings->arrays.input_driver, "raw"))
+ {
+ *input_data = input_winraw.init(name);
+ if (*input_data)
+ {
+ *input = &input_winraw;
+ return;
+ }
+ }
+#endif
+
+ *input_data = input_dinput.init(name);
+ *input = *input_data ? &input_dinput : NULL;
+}
diff --git a/gfx/common/dxgi_common.h b/gfx/common/dxgi_common.h
index e8a7b919df..7978604ea9 100644
--- a/gfx/common/dxgi_common.h
+++ b/gfx/common/dxgi_common.h
@@ -769,12 +769,16 @@ static INLINE HRESULT DXGICreateFactory(DXGIFactory* factory)
/* internal */
+#include "../video_driver.h"
+
#define DXGI_COLOR_RGBA(r, g, b, a) (((UINT32)(a) << 24) | ((UINT32)(b) << 16) | ((UINT32)(g) << 8) | ((UINT32)(r) << 0))
typedef enum {
DXGI_FORMAT_EX_A4R4G4B4_UNORM = 1000,
} DXGI_FORMAT_EX;
+RETRO_BEGIN_DECLS
+
DXGI_FORMAT* dxgi_get_format_fallback_list(DXGI_FORMAT format);
void dxgi_copy(
@@ -787,6 +791,11 @@ void dxgi_copy(
int dst_pitch,
void* dst_data);
+void dxgi_update_title(video_frame_info_t* video_info);
+void dxgi_input_driver(const char* name, const input_driver_t** input, void** input_data);
+
+RETRO_END_DECLS
+
#if 1
#include "../../performance_counters.h"
diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c
index c895c607d0..2b3ca65af7 100644
--- a/gfx/common/win32_common.c
+++ b/gfx/common/win32_common.c
@@ -569,7 +569,7 @@ static void win32_set_droppable(ui_window_win32_t *window, bool droppable)
DragAcceptFiles_func(window->hwnd, droppable);
}
-#ifdef HAVE_D3D
+#if defined(HAVE_D3D) || defined (HAVE_D3D10) || defined (HAVE_D3D11) || defined (HAVE_D3D12)
LRESULT CALLBACK WndProcD3D(HWND hwnd, UINT message,
WPARAM wparam, LPARAM lparam)
{
@@ -617,9 +617,13 @@ LRESULT CALLBACK WndProcD3D(HWND hwnd, UINT message,
#endif
#ifdef HAVE_DINPUT
- if (dinput && dinput_handle_message(dinput,
- message, wparam, lparam))
- return 0;
+ if (input_get_ptr() == &input_dinput)
+ {
+ void* input_data = input_get_data();
+ if (input_data && dinput_handle_message(input_data,
+ message, wparam, lparam))
+ return 0;
+ }
#endif
return DefWindowProc(hwnd, message, wparam, lparam);
}
diff --git a/gfx/drivers/d3d10.c b/gfx/drivers/d3d10.c
index d18b8a7618..275cd630b8 100644
--- a/gfx/drivers/d3d10.c
+++ b/gfx/drivers/d3d10.c
@@ -78,7 +78,6 @@ d3d10_gfx_init(const video_info_t* video, const input_driver_t** input, void** i
MONITORINFOEX current_mon;
HMONITOR hm_to_use;
settings_t* settings = config_get_ptr();
- gfx_ctx_input_t inp = { input, input_data };
d3d10_video_t* d3d10 = (d3d10_video_t*)calloc(1, sizeof(*d3d10));
if (!d3d10)
@@ -105,7 +104,7 @@ d3d10_gfx_init(const video_info_t* video, const input_driver_t** input, void** i
goto error;
}
- gfx_ctx_d3d.input_driver(NULL, settings->arrays.input_joypad_driver, input, input_data);
+ dxgi_input_driver(settings->arrays.input_joypad_driver, input, input_data);
{
UINT flags = 0;
@@ -374,7 +373,7 @@ static bool d3d10_gfx_frame(
PERF_STOP();
if (msg && *msg)
- gfx_ctx_d3d.update_window_title(NULL, video_info);
+ dxgi_update_title(video_info);
return true;
}
diff --git a/gfx/drivers/d3d11.c b/gfx/drivers/d3d11.c
index d530a0a91b..2b513842a6 100644
--- a/gfx/drivers/d3d11.c
+++ b/gfx/drivers/d3d11.c
@@ -143,7 +143,6 @@ d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** i
MONITORINFOEX current_mon;
HMONITOR hm_to_use;
settings_t* settings = config_get_ptr();
- gfx_ctx_input_t inp = { input, input_data };
d3d11_video_t* d3d11 = (d3d11_video_t*)calloc(1, sizeof(*d3d11));
if (!d3d11)
@@ -170,7 +169,7 @@ d3d11_gfx_init(const video_info_t* video, const input_driver_t** input, void** i
goto error;
}
- gfx_ctx_d3d.input_driver(NULL, settings->arrays.input_joypad_driver, input, input_data);
+ dxgi_input_driver(settings->arrays.input_joypad_driver, input, input_data);
{
UINT flags = 0;
@@ -547,7 +546,7 @@ static bool d3d11_gfx_frame(
if (msg && *msg)
{
font_driver_render_msg(video_info, NULL, msg, NULL);
- gfx_ctx_d3d.update_window_title(NULL, video_info);
+ dxgi_update_title(video_info);
}
d3d11->sprites.enabled = false;
diff --git a/gfx/drivers/d3d12.c b/gfx/drivers/d3d12.c
index 20b2d09fc8..f1c48a1ad2 100644
--- a/gfx/drivers/d3d12.c
+++ b/gfx/drivers/d3d12.c
@@ -83,7 +83,6 @@ d3d12_gfx_init(const video_info_t* video, const input_driver_t** input, void** i
{
WNDCLASSEX wndclass = { 0 };
settings_t* settings = config_get_ptr();
- gfx_ctx_input_t inp = { input, input_data };
d3d12_video_t* d3d12 = (d3d12_video_t*)calloc(1, sizeof(*d3d12));
if (!d3d12)
@@ -100,7 +99,7 @@ d3d12_gfx_init(const video_info_t* video, const input_driver_t** input, void** i
goto error;
}
- gfx_ctx_d3d.input_driver(NULL, settings->arrays.input_joypad_driver, input, input_data);
+ dxgi_input_driver(settings->arrays.input_joypad_driver, input, input_data);
if (!d3d12_init_base(d3d12))
goto error;
@@ -292,7 +291,7 @@ static bool d3d12_gfx_frame(
PERF_STOP();
if (msg && *msg)
- gfx_ctx_d3d.update_window_title(NULL, video_info);
+ dxgi_update_title(video_info);
return true;
}