Created a FileDropped event for when a file is dropped onto the client by the OS

This commit is contained in:
2015-12-17 13:26:12 +01:00
parent 8000654005
commit c1b9404e52
3 changed files with 37 additions and 0 deletions
+18
View File
@@ -2,6 +2,7 @@
std::vector<unsigned int> InputManager::GLFWCharCallbackQueue;
std::vector<std::pair<double, double>> InputManager::GLFWScrollCallbackQueue;
std::vector<std::string> InputManager::GLFWDropCallbackQueue;
void InputManager::Initialize()
{
@@ -10,6 +11,7 @@ void InputManager::Initialize()
//m_LastGamepadButtonState = std::array<GamepadButtonState, XUSER_MAX_COUNT>();
glfwSetCharCallback(m_GLFWWindow, &InputManager::GLFWCharCallback);
glfwSetScrollCallback(m_GLFWWindow, &InputManager::GLFWScrollCallback);
glfwSetDropCallback(m_GLFWWindow, &InputManager::GLFWDropCallback);
EVENT_SUBSCRIBE_MEMBER(m_ELockMouse, &InputManager::OnLockMouse);
EVENT_SUBSCRIBE_MEMBER(m_EUnlockMouse, &InputManager::OnUnlockMouse);
@@ -95,6 +97,14 @@ void InputManager::Update(double dt)
}
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
// 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));
}
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)
{
m_MouseLocked = true;