Skip to content

Commit

Permalink
Merge pull request #13 from MonashDeepNeuron/fix_input_delay_(some_ma…
Browse files Browse the repository at this point in the history
…chines)

Fix input delay (some machines)
  • Loading branch information
Kevin-Duignan committed May 7, 2024
2 parents 12ec598 + 77c304f commit aa10027
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 27 deletions.
45 changes: 19 additions & 26 deletions headers/gui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,35 +44,28 @@ class gui {

auto check_event() -> sf::Event
{
sf::Event event {};

if (!window.isOpen() || !window.pollEvent(event)) {
// Return an empty event if the window is closed or
// there are no more events
return sf::Event();
}

// not part of event manager since it deals with
// the window, not the fluids.
if (event.type == sf::Event::Closed) {
window.close();
}
sf::Event event;
while (window.pollEvent(event)) { // while there are events in the queue
// Handle the event
if (event.type == sf::Event::Closed) {
window.close();
}

if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::C) {
// Toggle to the next draw type
switch (current_draw_type) {
case draw_type::GREY:
current_draw_type = draw_type::HSV;
break;
case draw_type::HSV:
current_draw_type = draw_type::VEL;
break;
case draw_type::VEL:
current_draw_type = draw_type::GREY;
break;
if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::C) {
// Toggle to the next draw type
switch (current_draw_type) {
case draw_type::GREY:
current_draw_type = draw_type::HSV;
break;
case draw_type::HSV:
current_draw_type = draw_type::VEL;
break;
case draw_type::VEL:
current_draw_type = draw_type::GREY;
break;
}
}
}

return event;
}
auto update_display(std::array<float, BUFFER_SIZE>& data) -> void
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ auto main() -> int
while (fluid_gui.is_open()) {

// Check for events and handle them
[[maybe_unused]] auto event = fluid_gui.check_event();
fluid_gui.check_event();

// event_mouse_click = my_event_manager.handle_event(event);
event_mouse_click = my_event_manager.check_left_mouse_button();
Expand Down

0 comments on commit aa10027

Please sign in to comment.