shithub: m8c

Download patch

ref: b9961cc0f835caff6f0231e5c509beaaa52a0a32
parent: 3043cbc786b77f3924aedadaf29a2d7847ac32ef
author: Jonne Kokkonen <jonne.kokkonen@gmail.com>
date: Wed Apr 19 18:06:12 EDT 2023

fixes #106: add timer to reset messages on window resize

--- a/input.c
+++ b/input.c
@@ -4,6 +4,7 @@
 #include <SDL.h>
 #include <stdio.h>
 
+#include "SDL_timer.h"
 #include "config.h"
 #include "input.h"
 #include "render.h"
@@ -392,8 +393,12 @@
   case SDL_WINDOWEVENT:
     if (event.window.event == SDL_WINDOWEVENT_RESIZED)
     {
-      SDL_Log("Resizing window...");
-      key = (input_msg_s){special, msg_reset_display};
+      static uint32_t ticks_window_resized = 0;
+      if (SDL_GetTicks() - ticks_window_resized > 500) {
+        SDL_Log("Resizing window...");
+        key = (input_msg_s){special, msg_reset_display};
+        ticks_window_resized = SDL_GetTicks();
+      }
     }
     break;
 
--- a/input.h
+++ b/input.h
@@ -5,6 +5,7 @@
 #define INPUT_H_
 
 #include <stdint.h>
+#include "config.h"
 
 typedef enum input_buttons_t {
     INPUT_UP,
@@ -38,6 +39,6 @@
 
 int initialize_game_controllers();
 void close_game_controllers();
-input_msg_s get_input_msg();
+input_msg_s get_input_msg(config_params_s *conf);
 
-#endif
\ No newline at end of file
+#endif
--