From 4c53bdf4f998facf6aed4e2ed59c1fc1dda81f13 Mon Sep 17 00:00:00 2001 From: mudlord Date: Fri, 3 Jun 2016 09:14:53 +1000 Subject: [PATCH] add drag and drop --- gfx/common/win32_common.cpp | 31 ++++++++++++++++++++++++++++++- tasks/tasks_internal.h | 10 ++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/gfx/common/win32_common.cpp b/gfx/common/win32_common.cpp index d257521408..103268b9a0 100644 --- a/gfx/common/win32_common.cpp +++ b/gfx/common/win32_common.cpp @@ -19,6 +19,9 @@ #include "../../general.h" #include "../../verbosity.h" #include "win32_common.h" +#include "../../driver.h" +#include "../../runloop.h" +#include "../../tasks/tasks_internal.h" #if !defined(_XBOX) @@ -32,7 +35,7 @@ #include #include "../../retroarch.h" #include "../video_thread_wrapper.h" - +#include #ifndef _MSC_VER extern "C" { #endif @@ -159,6 +162,28 @@ static LRESULT CALLBACK WndProcCommon(bool *quit, HWND hwnd, UINT message, } break; + case WM_DROPFILES: + // Get the count of the files dropped + { + char szFilename[1024] = {0}; + if (DragQueryFile((HDROP)wparam, 0xFFFFFFFF, NULL, 0)) + { + content_ctx_info_t content_info = {0}; + // Get the path of a single file that has been dropped + DragQueryFile((HDROP)wparam, 0, szFilename, 1024); + task_push_content_load_default( + NULL, szFilename, + &content_info, + CORE_TYPE_PLAIN, + CONTENT_MODE_LOAD_CONTENT_WITH_CURRENT_CORE_FROM_COMPANION_UI, + NULL, NULL); + PostMessage(hwnd, WM_CLOSE, 0, 0); + } + // Release the memory that the system allocated for use in transferring file + // names to the application + DragFinish((HDROP)wparam); + } + break; case WM_CHAR: case WM_KEYDOWN: case WM_KEYUP: @@ -205,6 +230,7 @@ LRESULT CALLBACK WndProcD3D(HWND hwnd, UINT message, switch (message) { + case WM_DROPFILES: case WM_SYSCOMMAND: case WM_CHAR: case WM_KEYDOWN: @@ -224,6 +250,7 @@ LRESULT CALLBACK WndProcD3D(HWND hwnd, UINT message, LPCREATESTRUCT p_cs = (LPCREATESTRUCT)lparam; curD3D = p_cs->lpCreateParams; g_inited = true; + DragAcceptFiles(hwnd, true); } return 0; } @@ -242,6 +269,7 @@ LRESULT CALLBACK WndProcGL(HWND hwnd, UINT message, switch (message) { + case WM_DROPFILES: case WM_SYSCOMMAND: case WM_CHAR: case WM_KEYDOWN: @@ -259,6 +287,7 @@ LRESULT CALLBACK WndProcGL(HWND hwnd, UINT message, break; case WM_CREATE: create_graphics_context(hwnd, &g_quit); + DragAcceptFiles(hwnd, true); return 0; } diff --git a/tasks/tasks_internal.h b/tasks/tasks_internal.h index c16c895948..402681f273 100644 --- a/tasks/tasks_internal.h +++ b/tasks/tasks_internal.h @@ -26,6 +26,11 @@ #include "../core_type.h" #include "../runloop.h" + +#ifdef __cplusplus +extern "C" { +#endif + enum content_mode_load { CONTENT_MODE_LOAD_NONE = 0, @@ -130,4 +135,9 @@ bool take_screenshot(void); bool dump_to_file_desperate(const void *data, size_t size, unsigned type); + +#ifdef __cplusplus +} +#endif + #endif