From d616ed345b76973873fdd1d45e2f833d55760a97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Wed, 3 Jan 2018 21:58:37 -0800 Subject: [PATCH] entry: Drop file event for GLFW. --- examples/common/entry/entry_glfw.cpp | 30 +++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/examples/common/entry/entry_glfw.cpp b/examples/common/entry/entry_glfw.cpp index 27f602053..5e81dd9ae 100644 --- a/examples/common/entry/entry_glfw.cpp +++ b/examples/common/entry/entry_glfw.cpp @@ -276,7 +276,7 @@ namespace entry static void joystickCb(int _jid, int _action); // Based on cutef8 by Jeff Bezanson (Public Domain) - static uint8_t encodeUTF8(uint8_t _chars[4], unsigned int _scancode) + static uint8_t encodeUTF8(uint8_t _chars[4], uint32_t _scancode) { uint8_t length = 0; @@ -432,6 +432,7 @@ namespace entry glfwSetCursorPosCallback(m_windows[0], cursorPosCb); glfwSetMouseButtonCallback(m_windows[0], mouseButtonCb); glfwSetWindowSizeCallback(m_windows[0], windowSizeCb); + glfwSetDropCallback(m_windows[0], dropFileCb); glfwSetWindow(m_windows[0]); m_eventQueue.postSizeEvent(handle, ENTRY_DEFAULT_WIDTH, ENTRY_DEFAULT_HEIGHT); @@ -491,6 +492,7 @@ namespace entry glfwSetCursorPosCallback(window, cursorPosCb); glfwSetMouseButtonCallback(window, mouseButtonCb); glfwSetWindowSizeCallback(window, windowSizeCb); + glfwSetDropCallback(window, dropFileCb); m_windows[msg->m_handle.idx] = window; m_eventQueue.postSizeEvent(msg->m_handle, msg->m_width, msg->m_height); @@ -619,12 +621,13 @@ namespace entry return invalid; } - static void keyCb(GLFWwindow* _window, int _key, int _scancode, int _action, int _mods); - static void charCb(GLFWwindow* _window, unsigned int _scancode); + static void keyCb(GLFWwindow* _window, int32_t _key, int32_t _scancode, int32_t _action, int32_t _mods); + static void charCb(GLFWwindow* _window, uint32_t _scancode); static void scrollCb(GLFWwindow* _window, double _dx, double _dy); static void cursorPosCb(GLFWwindow* _window, double _mx, double _my); - static void mouseButtonCb(GLFWwindow* _window, int _button, int _action, int _mods); - static void windowSizeCb(GLFWwindow* _window, int _width, int _height); + static void mouseButtonCb(GLFWwindow* _window, int32_t _button, int32_t _action, int32_t _mods); + static void windowSizeCb(GLFWwindow* _window, int32_t _width, int32_t _height); + static void dropFileCb(GLFWwindow* _window, int32_t _count, const char** _filePaths); MainThreadEntry m_mte; bx::Thread m_thread; @@ -649,7 +652,7 @@ namespace entry Context s_ctx; - void Context::keyCb(GLFWwindow* _window, int _key, int _scancode, int _action, int _mods) + void Context::keyCb(GLFWwindow* _window, int32_t _key, int32_t _scancode, int32_t _action, int32_t _mods) { BX_UNUSED(_scancode); if (_key == GLFW_KEY_UNKNOWN) @@ -663,7 +666,7 @@ namespace entry s_ctx.m_eventQueue.postKeyEvent(handle, key, mods, down); } - void Context::charCb(GLFWwindow* _window, unsigned int _scancode) + void Context::charCb(GLFWwindow* _window, uint32_t _scancode) { WindowHandle handle = s_ctx.findHandle(_window); uint8_t chars[4]; @@ -700,7 +703,7 @@ namespace entry ); } - void Context::mouseButtonCb(GLFWwindow* _window, int _button, int _action, int _mods) + void Context::mouseButtonCb(GLFWwindow* _window, int32_t _button, int32_t _action, int32_t _mods) { BX_UNUSED(_mods); WindowHandle handle = s_ctx.findHandle(_window); @@ -716,12 +719,21 @@ namespace entry ); } - void Context::windowSizeCb(GLFWwindow* _window, int _width, int _height) + void Context::windowSizeCb(GLFWwindow* _window, int32_t _width, int32_t _height) { WindowHandle handle = s_ctx.findHandle(_window); s_ctx.m_eventQueue.postSizeEvent(handle, _width, _height); } + void Context::dropFileCb(GLFWwindow* _window, int32_t _count, const char** _filePaths) + { + WindowHandle handle = s_ctx.findHandle(_window); + for (int32_t ii = 0; ii < _count; ++ii) + { + s_ctx.m_eventQueue.postDropFileEvent(handle, _filePaths[ii]); + } + } + static void joystickCb(int _jid, int _action) { if (_jid >= ENTRY_CONFIG_MAX_GAMEPADS)