From a07e65ffd3e4253a285ed569717bbf3ae0da6088 Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Sun, 25 Aug 2019 15:38:42 -0700 Subject: [PATCH] Cut out text input from SDL2 until it can be tested --- sc2/src/libs/input/sdl/input.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/sc2/src/libs/input/sdl/input.c b/sc2/src/libs/input/sdl/input.c index 8d9e7b447..ac19bdd87 100644 --- a/sc2/src/libs/input/sdl/input.c +++ b/sc2/src/libs/input/sdl/input.c @@ -33,13 +33,16 @@ static int kbdhead=0, kbdtail=0; static UniChar kbdbuf[KBDBUFSIZE]; static UniChar lastchar; +#ifdef SDL_MAJOR_VERSION == 1 static unsigned int num_keys = 0; static int *kbdstate = NULL; // Holds all SDL keys +1 for holding invalid values +#endif // Later versions of SDL use the text input API instead static volatile int *menu_vec; static int num_menu; // The last vector element is the character repeat "key" +// This is only used in SDL1 input but it's mostly harmless everywhere else #define KEY_MENU_ANY (num_menu - 1) static volatile int *flight_vec; static int num_templ; @@ -193,8 +196,10 @@ initKeyConfig (void) static void resetKeyboardState (void) { +#if SDL_MAJOR_VERSION == 1 memset (kbdstate, 0, sizeof (int) * num_keys); menu_vec[KEY_MENU_ANY] = 0; +#endif } void @@ -221,9 +226,11 @@ TFB_InitInput (int driver, int flags) (void)driver; (void)flags; +#if SDL_MAJOR_VERSION == 1 SDL_EnableUNICODE(1); (void)SDL_GetKeyState (&num_keys); kbdstate = (int *)HMalloc (sizeof (int) * (num_keys + 1)); +#endif #ifdef HAVE_JOYSTICK @@ -329,6 +336,8 @@ ProcessMouseEvent (const SDL_Event *e) } } +#if SDL_MAJOR_VERSION == 1 + static inline int is_numpad_char_event (const SDL_Event *Event) { @@ -397,6 +406,22 @@ ProcessInputEvent (const SDL_Event *Event) } } } +#else +void +ProcessInputEvent (const SDL_Event *Event) +{ + if (!InputInitialized) + return; + + ProcessMouseEvent (Event); + + /* TODO: Block numpad input when NUM_LOCK is on */ + VControl_HandleEvent (Event); + + /* TODO: Handle SDL_TEXTINPUT events */ +} + +#endif void TFB_ResetControls (void)