99#include " Buffer.hpp"
1010#include " Inputs.hpp"
1111
12- sw::Input_buffer event_buffer;
12+ // sw::Input_buffer event_buffer;
1313
1414SW_GRAPH_MODULE_EXPORT char current_key_flags[sw::Keyboard::LAST];
1515SW_GRAPH_MODULE_EXPORT char previous_key_flags[sw::Keyboard::LAST];
1616
1717SW_GRAPH_MODULE_EXPORT char current_mouse_flags[sw::MouseBtn::Button_last];
1818SW_GRAPH_MODULE_EXPORT char previous_mouse_flags[sw::MouseBtn::Button_last];
1919
20+ SW_GRAPH_MODULE_EXPORT sw::Vector2f current_mouse_position;
21+ SW_GRAPH_MODULE_EXPORT sw::Vector2f previous_mouse_position;
22+
23+ SW_GRAPH_MODULE_EXPORT sw::Vector2f current_mouse_scroll;
24+ SW_GRAPH_MODULE_EXPORT sw::Vector2f previous_mouse_scroll;
25+
2026GLFWwindow *sw::Window::UpdateWindow ()
2127{
2228 for (int i = 0 ; i < sw::Keyboard::LAST; ++i)
2329 previous_key_flags[i] = current_key_flags[i];
2430 for (int i = 0 ; i < sw::MouseBtn::Button_last; ++i)
2531 previous_mouse_flags[i] = current_mouse_flags[i];
26- event_buffer.clear ();
32+
33+ previous_mouse_position = current_mouse_position;
34+ previous_mouse_scroll = current_mouse_scroll;
35+ // event_buffer.clear();
2736 glfwSwapBuffers (m_window);
2837 return (m_window);
2938}
@@ -54,20 +63,27 @@ void sw::Window::mouse_button_callback(GLFWwindow*, int button, int action, int)
5463
5564void sw::Window::position_callback (GLFWwindow*, double xpos, double ypos)
5665{
66+ /*
5767 std::pair<int,int> kys{};
5868 std::pair<double,double> ipt{xpos,ypos};
5969 sw::Type tpe = sw::Position;
6070
6171 event_buffer.push(tpe, kys, ipt);
72+ */
73+
74+ current_mouse_position = {xpos, ypos};
6275}
6376
6477void sw::Window::scroll_callback (GLFWwindow*, double x, double y)
6578{
79+ /*
6680 std::pair<int,int> kys{};
6781 std::pair<double,double> ipt{x,y};
6882 sw::Type tpe = sw::Scroll;
6983
7084 event_buffer.push(tpe, kys, ipt);
85+ */
86+ current_mouse_scroll = {x, y};
7187}
7288
7389void sw::Window::resizeCallBack (GLFWwindow *window, int width, int height)
@@ -134,26 +150,44 @@ bool sw::isMouseButtonUp(const int &btn)
134150 return !sw::isMouseButtonDown (btn);
135151}
136152
153+ // DEPRECATED DO NOT USE
137154bool sw::mouseMoved ()
138155{
156+ /*
139157 const auto &tmp = event_buffer.get();
140158
141159 for (size_t i = 0; i < event_buffer.getIdx(); ++i)
142160 {
143161 if (tmp[i].m_t == sw::Position)
144162 return true;
145- }
163+ }*/
146164 return false ;
147165}
148166
149- bool sw::mouseScrolled ( const std::pair< double , double > &evt )
167+ sw::Vector2f sw::getMouseScroll ( void )
150168{
169+ /*
151170 const auto& tmp = event_buffer.get();
152171
153172 for (size_t i = 0; i < event_buffer.getIdx(); ++i)
154173 {
155174 if (tmp[i].m_t == sw::Scroll && tmp[i].m_os == evt)
156175 return true;
157176 }
158- return false ;
177+ */
178+ return current_mouse_scroll;
179+ }
180+
181+ sw::Vector2f sw::getMousePosition (void )
182+ {
183+ /*
184+ const auto& tmp = event_buffer.get();
185+
186+ for (size_t i = 0; i < event_buffer.getIdx(); ++i)
187+ {
188+ if (tmp[i].m_t == sw::Scroll && tmp[i].m_os == evt)
189+ return true;
190+ }
191+ */
192+ return current_mouse_position;
159193}
0 commit comments