Skip to content
Snippets Groups Projects
Verified Commit 020e3dad authored by Tobias Frisch's avatar Tobias Frisch
Browse files

[#60] Initialized events as locked properly and added missing events to locking

parent e421c263
No related branches found
No related tags found
1 merge request!65Resolve "Kamera - Steuerung mittels Controller"
Pipeline #25935 passed
......@@ -27,7 +27,7 @@ namespace vkcv {
private:
std::vector< event_function<T...> > m_functions;
uint32_t m_id_counter;
std::mutex m_mutex;
std::mutex m_mutex;
public:
......@@ -75,17 +75,21 @@ namespace vkcv {
* locks the event so its function handles won't be called
*/
void lock() {
m_mutex.lock();
m_mutex.lock();
}
/**
* unlocks the event so its function handles can be called after locking
*/
void unlock() {
m_mutex.unlock();
m_mutex.unlock();
}
event() = default;
explicit event(bool locked = false) {
if (locked) {
lock();
}
}
event(const event &other) = delete;
......
......@@ -11,16 +11,18 @@ namespace vkcv {
static std::vector<GLFWwindow*> s_Windows;
Window::Window(GLFWwindow *window)
: m_window(window) {
Window::Window(GLFWwindow *window) :
m_window(window),
e_mouseButton(true),
e_mouseMove(true),
e_mouseScroll(true),
e_resize(true),
e_key(true),
e_char(true),
e_gamepad(true)
{
glfwSetWindowUserPointer(m_window, this);
this->e_mouseButton.lock();
this->e_mouseMove.lock();
this->e_resize.lock();
this->e_key.lock();
this->e_mouseScroll.lock();
// combine Callbacks with Events
glfwSetMouseButtonCallback(m_window, Window::onMouseButtonEvent);
glfwSetCursorPosCallback(m_window, Window::onMouseMoveEvent);
......@@ -63,9 +65,10 @@ namespace vkcv {
window->e_mouseButton.unlock();
window->e_mouseMove.unlock();
window->e_mouseScroll.unlock();
window->e_resize.unlock();
window->e_key.unlock();
window->e_mouseScroll.unlock();
window->e_char.unlock();
window->e_gamepad.unlock();
}
......@@ -77,9 +80,10 @@ namespace vkcv {
window->e_mouseButton.lock();
window->e_mouseMove.lock();
window->e_mouseScroll.lock();
window->e_resize.lock();
window->e_key.lock();
window->e_mouseScroll.lock();
window->e_char.lock();
window->e_gamepad.lock();
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment