Created a FileDropped event for when a file is dropped onto the client by the OS
This commit is contained in:
@@ -0,0 +1,16 @@
|
|||||||
|
#ifndef EFileDropped_h__
|
||||||
|
#define EFileDropped_h__
|
||||||
|
|
||||||
|
#include "EventBroker.h"
|
||||||
|
|
||||||
|
namespace Events
|
||||||
|
{
|
||||||
|
|
||||||
|
struct FileDropped : Event
|
||||||
|
{
|
||||||
|
std::string Path;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
#include "ELockMouse.h"
|
#include "ELockMouse.h"
|
||||||
#include "EGamepadAxis.h"
|
#include "EGamepadAxis.h"
|
||||||
#include "EGamepadButton.h"
|
#include "EGamepadButton.h"
|
||||||
|
#include "EFileDropped.h"
|
||||||
|
|
||||||
class InputManager
|
class InputManager
|
||||||
{
|
{
|
||||||
@@ -71,6 +72,8 @@ private:
|
|||||||
static void GLFWCharCallback(GLFWwindow* window, unsigned int c);
|
static void GLFWCharCallback(GLFWwindow* window, unsigned int c);
|
||||||
static std::vector<std::pair<double, double>> GLFWScrollCallbackQueue;
|
static std::vector<std::pair<double, double>> GLFWScrollCallbackQueue;
|
||||||
static void GLFWScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
|
static void GLFWScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
|
||||||
|
static std::vector<std::string> GLFWDropCallbackQueue;
|
||||||
|
static void GLFWDropCallback(GLFWwindow* window, int count, const char* paths[]);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
std::vector<unsigned int> InputManager::GLFWCharCallbackQueue;
|
std::vector<unsigned int> InputManager::GLFWCharCallbackQueue;
|
||||||
std::vector<std::pair<double, double>> InputManager::GLFWScrollCallbackQueue;
|
std::vector<std::pair<double, double>> InputManager::GLFWScrollCallbackQueue;
|
||||||
|
std::vector<std::string> InputManager::GLFWDropCallbackQueue;
|
||||||
|
|
||||||
void InputManager::Initialize()
|
void InputManager::Initialize()
|
||||||
{
|
{
|
||||||
@@ -10,6 +11,7 @@ void InputManager::Initialize()
|
|||||||
//m_LastGamepadButtonState = std::array<GamepadButtonState, XUSER_MAX_COUNT>();
|
//m_LastGamepadButtonState = std::array<GamepadButtonState, XUSER_MAX_COUNT>();
|
||||||
glfwSetCharCallback(m_GLFWWindow, &InputManager::GLFWCharCallback);
|
glfwSetCharCallback(m_GLFWWindow, &InputManager::GLFWCharCallback);
|
||||||
glfwSetScrollCallback(m_GLFWWindow, &InputManager::GLFWScrollCallback);
|
glfwSetScrollCallback(m_GLFWWindow, &InputManager::GLFWScrollCallback);
|
||||||
|
glfwSetDropCallback(m_GLFWWindow, &InputManager::GLFWDropCallback);
|
||||||
|
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_ELockMouse, &InputManager::OnLockMouse);
|
EVENT_SUBSCRIBE_MEMBER(m_ELockMouse, &InputManager::OnLockMouse);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EUnlockMouse, &InputManager::OnUnlockMouse);
|
EVENT_SUBSCRIBE_MEMBER(m_EUnlockMouse, &InputManager::OnUnlockMouse);
|
||||||
@@ -95,6 +97,14 @@ void InputManager::Update(double dt)
|
|||||||
}
|
}
|
||||||
GLFWScrollCallbackQueue.clear();
|
GLFWScrollCallbackQueue.clear();
|
||||||
|
|
||||||
|
// File drop
|
||||||
|
for (auto& path : GLFWDropCallbackQueue) {
|
||||||
|
Events::FileDropped e;
|
||||||
|
e.Path = path;
|
||||||
|
m_EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
GLFWDropCallbackQueue.clear();
|
||||||
|
|
||||||
// // Lock mouse while holding LMB
|
// // Lock mouse while holding LMB
|
||||||
// if (m_CurrentMouseState[GLFW_MOUSE_BUTTON_LEFT])
|
// if (m_CurrentMouseState[GLFW_MOUSE_BUTTON_LEFT])
|
||||||
// {
|
// {
|
||||||
@@ -229,6 +239,14 @@ void InputManager::GLFWScrollCallback(GLFWwindow* window, double xoffset, double
|
|||||||
GLFWScrollCallbackQueue.push_back(std::make_pair(xoffset, yoffset));
|
GLFWScrollCallbackQueue.push_back(std::make_pair(xoffset, yoffset));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void InputManager::GLFWDropCallback(GLFWwindow* window, int count, const char* paths[])
|
||||||
|
{
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
GLFWDropCallbackQueue.push_back(std::string(paths[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool InputManager::OnLockMouse(const Events::LockMouse &event)
|
bool InputManager::OnLockMouse(const Events::LockMouse &event)
|
||||||
{
|
{
|
||||||
m_MouseLocked = true;
|
m_MouseLocked = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user