From 767ba6e43f0d6d03e6968daac9b5323c0fd18b33 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Sat, 7 Sep 2024 06:14:15 +0300
Subject: [PATCH 28/28] sdl3: Replace SDL_Keysym with SDL_Keycode

See RM #836

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 client/gui-sdl3/gui_main.c    | 10 ++++++----
 client/gui-sdl3/gui_main.h    |  4 ++--
 client/gui-sdl3/mapctrl.c     |  2 +-
 client/gui-sdl3/mapctrl.h     |  2 +-
 client/gui-sdl3/widget.c      |  2 +-
 client/gui-sdl3/widget.h      |  2 +-
 client/gui-sdl3/widget_edit.c |  2 +-
 7 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/client/gui-sdl3/gui_main.c b/client/gui-sdl3/gui_main.c
index ac4d353d55..c71eb02574 100644
--- a/client/gui-sdl3/gui_main.c
+++ b/client/gui-sdl3/gui_main.c
@@ -223,7 +223,7 @@ static bool parse_options(int argc, char **argv)
 /**********************************************************************//**
   Main handler for key presses
 **************************************************************************/
-static Uint16 main_key_down_handler(SDL_Keysym key, void *data)
+static Uint16 main_key_down_handler(SDL_Keycode key, void *data)
 {
   static struct widget *pwidget;
 
@@ -304,7 +304,7 @@ static Uint16 main_key_down_handler(SDL_Keysym key, void *data)
 /**********************************************************************//**
   Main key release handler.
 **************************************************************************/
-static Uint16 main_key_up_handler(SDL_Keysym key, void *data)
+static Uint16 main_key_up_handler(SDL_Keycode key, void *data)
 {
   if (selected_widget) {
     unselect_widget_action();
@@ -312,6 +312,7 @@ static Uint16 main_key_up_handler(SDL_Keysym key, void *data)
 
   return ID_ERROR;
 }
+
 /**********************************************************************//**
   Main finger down handler.
 **************************************************************************/
@@ -340,6 +341,7 @@ static Uint16 main_finger_down_handler(SDL_TouchFingerEvent *touch_event,
   }
   return ID_ERROR;
 }
+
 /**********************************************************************//**
   Main finger release handler.
 **************************************************************************/
@@ -594,8 +596,8 @@ int FilterMouseMotionEvents(void *data, SDL_Event *event)
 **************************************************************************/
 Uint16 gui_event_loop(void *data,
                       void (*loop_action)(void *data),
-                      Uint16 (*key_down_handler)(SDL_Keysym key, void *data),
-                      Uint16 (*key_up_handler)(SDL_Keysym key, void *data),
+                      Uint16 (*key_down_handler)(SDL_Keycode key, void *data),
+                      Uint16 (*key_up_handler)(SDL_Keycode key, void *data),
                       Uint16 (*textinput_handler)(char *text, void *data),
                       Uint16 (*finger_down_handler)(SDL_TouchFingerEvent *touch_event, void *data),
                       Uint16 (*finger_up_handler)(SDL_TouchFingerEvent *touch_event, void *data),
diff --git a/client/gui-sdl3/gui_main.h b/client/gui-sdl3/gui_main.h
index 0bbac682c7..072adc062b 100644
--- a/client/gui-sdl3/gui_main.h
+++ b/client/gui-sdl3/gui_main.h
@@ -110,8 +110,8 @@ extern int MOVE_STEP_X, MOVE_STEP_Y;
 int FilterMouseMotionEvents(void *data, SDL_Event *event);
 
 Uint16 gui_event_loop(void *data, void (*loop_action)(void *data),
-                      Uint16 (*key_down_handler)(SDL_Keysym key, void *data),
-                      Uint16 (*key_up_handler)(SDL_Keysym key, void *data),
+                      Uint16 (*key_down_handler)(SDL_Keycode key, void *data),
+                      Uint16 (*key_up_handler)(SDL_Keycode key, void *data),
                       Uint16 (*textinput_handler)(char *text, void *data),
                       Uint16 (*finger_down_handler)(SDL_TouchFingerEvent *touch_event, void *data),
                       Uint16 (*finger_up_handler)(SDL_TouchFingerEvent *touch_event, void *data),
diff --git a/client/gui-sdl3/mapctrl.c b/client/gui-sdl3/mapctrl.c
index b0d5d4e8d4..a116c689e3 100644
--- a/client/gui-sdl3/mapctrl.c
+++ b/client/gui-sdl3/mapctrl.c
@@ -2438,7 +2438,7 @@ void button_up_on_map(struct mouse_button_behavior *button_behavior)
 /**********************************************************************//**
   Toggle map drawing stuff.
 **************************************************************************/
-bool map_event_handler(SDL_Keysym key)
+bool map_event_handler(SDL_Keycode key)
 {
   if (C_S_RUNNING == client_state()) {
     enum direction8 movedir = DIR8_MAGIC_MAX;
diff --git a/client/gui-sdl3/mapctrl.h b/client/gui-sdl3/mapctrl.h
index 7f732eeff7..183738cdcc 100644
--- a/client/gui-sdl3/mapctrl.h
+++ b/client/gui-sdl3/mapctrl.h
@@ -87,7 +87,7 @@ void enable_and_redraw_find_city_button(void);
 void enable_and_redraw_revolution_button(void);
 void enable_main_widgets(void);
 void disable_main_widgets(void);
-bool map_event_handler(SDL_Keysym key);
+bool map_event_handler(SDL_Keycode key);
 
 void finger_down_on_map(struct finger_behavior *finger_behavior);
 void finger_up_on_map(struct finger_behavior *finger_behavior);
diff --git a/client/gui-sdl3/widget.c b/client/gui-sdl3/widget.c
index b3a494470e..f4fe1aec07 100644
--- a/client/gui-sdl3/widget.c
+++ b/client/gui-sdl3/widget.c
@@ -246,7 +246,7 @@ struct widget *find_next_widget_at_pos(struct widget *start_widget,
   NOTE: This function ignores CapsLock and NumLock Keys.
 **************************************************************************/
 struct widget *find_next_widget_for_key(struct widget *start_widget,
-                                        SDL_Keysym key)
+                                        SDL_Keycode key)
 {
   struct widget *pwidget;
 
diff --git a/client/gui-sdl3/widget.h b/client/gui-sdl3/widget.h
index 42a756c923..63cdf113a5 100644
--- a/client/gui-sdl3/widget.h
+++ b/client/gui-sdl3/widget.h
@@ -203,7 +203,7 @@ void del_gui_list(struct widget *gui_list);
 void del_main_list(void);
 
 struct widget *find_next_widget_at_pos(struct widget *start_widget, int x, int y);
-struct widget *find_next_widget_for_key(struct widget *start_widget, SDL_Keysym key);
+struct widget *find_next_widget_for_key(struct widget *start_widget, SDL_Keycode key);
 
 struct widget *get_widget_pointer_from_id(const struct widget *gui_list,
                                           Uint16 id,
diff --git a/client/gui-sdl3/widget_edit.c b/client/gui-sdl3/widget_edit.c
index c68bf83359..cb16ce9383 100644
--- a/client/gui-sdl3/widget_edit.c
+++ b/client/gui-sdl3/widget_edit.c
@@ -416,7 +416,7 @@ int draw_edit(struct widget *pedit, Sint16 start_x, Sint16 start_y)
   NOTE: This functions can return NULL in 'edit_widget->string_utf8->text' but
         never free 'edit_widget->string_utf8' struct.
 **************************************************************************/
-static Uint16 edit_key_down(SDL_Keysym key, void *data)
+static Uint16 edit_key_down(SDL_Keycode key, void *data)
 {
   struct text_edit *edt = (struct text_edit *)data;
   struct utf8_char *input_chain_tmp;
-- 
2.45.2

