From bf29a6837c095ee6e8f0083f10ecb6077409a7c7 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Mon, 11 Jun 2018 00:46:14 +0200 Subject: [PATCH] remove references to SDL_GetModState(); changed word Key_modifiers(SDLMod mod); to word Get_Key_modifiers(void); --- src/Makefile.dep | 9 +++++---- src/brush_ops.c | 11 +++-------- src/input.c | 8 ++++---- src/keyboard.c | 7 ++++--- src/keyboard.h | 10 ++-------- src/operatio.c | 9 +++------ src/windows.c | 3 ++- 7 files changed, 23 insertions(+), 34 deletions(-) diff --git a/src/Makefile.dep b/src/Makefile.dep index 1842c4a0..c5448d8d 100644 --- a/src/Makefile.dep +++ b/src/Makefile.dep @@ -3,7 +3,7 @@ $(OBJDIR)/brush.o: brush.c global.h struct.h const.h graph.h misc.h errors.h \ windows.h screen.h brush.h tiles.h $(OBJDIR)/brush_ops.o: brush_ops.c brush.h struct.h const.h buttons.h loadsave.h \ gfx2surface.h engine.h global.h graph.h misc.h operatio.h pages.h \ - screen.h windows.h + screen.h windows.h keyboard.h $(OBJDIR)/buttons.o: buttons.c const.h struct.h global.h misc.h graph.h engine.h \ readline.h filesel.h loadsave.h gfx2surface.h init.h buttons.h \ operatio.h pages.h palette.h errors.h readini.h saveini.h shade.h io.h \ @@ -42,7 +42,7 @@ $(OBJDIR)/init.o: init.c buttons.h struct.h const.h loadsave.h gfx2surface.h \ $(OBJDIR)/input.o: input.c global.h struct.h const.h keyboard.h screen.h windows.h \ errors.h misc.h buttons.h loadsave.h gfx2surface.h input.h keycodes.h $(OBJDIR)/io.o: io.c struct.h const.h io.h realpath.h unicode.h global.h -$(OBJDIR)/keyboard.o: keyboard.c global.h struct.h const.h keyboard.h +$(OBJDIR)/keyboard.o: keyboard.c global.h struct.h const.h keyboard.h keycodes.h $(OBJDIR)/layers.o: layers.c const.h struct.h global.h windows.h engine.h pages.h \ screen.h input.h keycodes.h help.h misc.h readline.h graph.h $(OBJDIR)/libraw2crtc.o: libraw2crtc.c const.h global.h struct.h loadsave.h \ @@ -70,7 +70,7 @@ $(OBJDIR)/op_c.o: op_c.c op_c.h struct.h const.h colorred.h errors.h global.h \ engine.h windows.h $(OBJDIR)/operatio.o: operatio.c const.h struct.h global.h misc.h engine.h graph.h \ operatio.h buttons.h loadsave.h gfx2surface.h pages.h errors.h screen.h \ - brush.h windows.h input.h keycodes.h special.h tiles.h + brush.h windows.h input.h keycodes.h special.h tiles.h keyboard.h $(OBJDIR)/pages.o: pages.c global.h struct.h const.h pages.h errors.h loadsave.h \ gfx2surface.h misc.h windows.h tiles.h graph.h $(OBJDIR)/palette.o: palette.c const.h struct.h global.h misc.h engine.h readline.h \ @@ -119,6 +119,7 @@ $(OBJDIR)/transform.o: transform.c global.h struct.h const.h transform.h engine. loadsave.h gfx2surface.h pages.h tiles.h $(OBJDIR)/unicode.o: unicode.c unicode.h struct.h const.h $(OBJDIR)/version.o: version.c +$(OBJDIR)/win32screen.o: win32screen.c screen.h struct.h const.h global.h $(OBJDIR)/windows.o: windows.c windows.h struct.h const.h engine.h errors.h \ global.h graph.h input.h keycodes.h misc.h op_c.h colorred.h readline.h \ - screen.h palette.h unicode.h + screen.h palette.h unicode.h keyboard.h diff --git a/src/brush_ops.c b/src/brush_ops.c index a1aa895b..341f9e96 100644 --- a/src/brush_ops.c +++ b/src/brush_ops.c @@ -37,6 +37,7 @@ #include "pages.h" #include "screen.h" #include "windows.h" +#include "keyboard.h" #if defined(__VBCC__) || defined(__GP2X__) || defined(__WIZ__) || defined(__CAANOO__) #define M_PI 3.141592653589793238462643 @@ -961,11 +962,8 @@ void Rotate_brush_1_5(void) // On corrige les coordonnées de la ligne si la touche shift est appuyée... cursor_x = Paintbrush_X; cursor_y = Paintbrush_Y; -#if defined(USE_SDL) || defined(USE_SDL2) - if(SDL_GetModState() & KMOD_SHIFT) + if(Get_Key_modifiers() & MOD_SHIFT) Clamp_coordinates_regular_angle(Brush_rotation_center_X,Brush_rotation_center_Y,&cursor_x,&cursor_y); - // TODO : portable -#endif if ( (cursor_x!=old_x) || (cursor_y!=old_y) || (prev_state!=2) ) { @@ -1035,11 +1033,8 @@ void Rotate_brush_0_5(void) // On corrige les coordonnées de la ligne si la touche shift est appuyée... cursor_x = Paintbrush_X; cursor_y = Paintbrush_Y; -#if defined(USE_SDL) || defined(USE_SDL2) - if(SDL_GetModState() & KMOD_SHIFT) + if(Get_Key_modifiers() & MOD_SHIFT) Clamp_coordinates_regular_angle(Brush_rotation_center_X,Brush_rotation_center_Y,&cursor_x,&cursor_y); - // TODO -#endif if ((cursor_x!=old_x) || (cursor_y!=old_y) || (prev_state!=3)) { diff --git a/src/input.c b/src/input.c index e8b473a1..c7d15223 100644 --- a/src/input.c +++ b/src/input.c @@ -344,7 +344,7 @@ int Handle_mouse_click(SDL_MouseButtonEvent event) break; case SDL_BUTTON_MIDDLE: - Key = KEY_MOUSEMIDDLE|Key_modifiers(SDL_GetModState()); + Key = KEY_MOUSEMIDDLE|Get_Key_modifiers(); // TODO: repeat system maybe? return 0; @@ -352,11 +352,11 @@ int Handle_mouse_click(SDL_MouseButtonEvent event) // Look for SDL_MOUSEWHEEL events. #if defined(USE_SDL) case SDL_BUTTON_WHEELUP: - Key = KEY_MOUSEWHEELUP|Key_modifiers(SDL_GetModState()); + Key = KEY_MOUSEWHEELUP|Get_Key_modifiers(); return 0; case SDL_BUTTON_WHEELDOWN: - Key = KEY_MOUSEWHEELDOWN|Key_modifiers(SDL_GetModState()); + Key = KEY_MOUSEWHEELDOWN|Get_Key_modifiers(); return 0; #endif @@ -703,7 +703,7 @@ int Handle_joystick_press(SDL_JoyButtonEvent event) break; } - Key = (KEY_JOYBUTTON+event.button)|Key_modifiers(SDL_GetModState()); + Key = (KEY_JOYBUTTON+event.button)|Get_Key_modifiers(); // TODO: systeme de répétition return Move_cursor_with_constraints(); diff --git a/src/keyboard.c b/src/keyboard.c index 5c9a5ed0..82d9ac8e 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -330,9 +330,10 @@ word Key_for_scancode(word scancode) } // Convertit des modificateurs de touches SDL en modificateurs GrafX2 -word Key_modifiers(SDLMod mod) +word Get_Key_modifiers(void) { word modifiers=0; + SDLMod mod = SDL_GetModState(); if (mod & KMOD_CTRL ) modifiers|=MOD_CTRL; @@ -371,7 +372,7 @@ word Keysym_to_keycode(SDL_keysym keysym) // Normally I should test keysym.mod here, but on windows the implementation // is buggy: if you release a modifier key, the following keys (when they repeat) // still name the original modifiers. - mod=Key_modifiers(SDL_GetModState()); + mod = Get_Key_modifiers(); // SDL_GetModState() seems to get the right up-to-date info. key_code |= mod; @@ -768,7 +769,7 @@ word Key_for_scancode(word scancode) { return scancode; } -word Key_modifiers(SDL_Keymod mod) +word Get_Key_modifiers(void) { return 0; } diff --git a/src/keyboard.h b/src/keyboard.h index 11cddcdc..3cc7fdc1 100644 --- a/src/keyboard.h +++ b/src/keyboard.h @@ -79,13 +79,7 @@ word Key_for_scancode(word scancode); const char * Key_name(word key); /*! - Gets the modifiers in our format from the SDL_Mod information. + Gets the Key modifiers in our format Returns a combination of ::MOD_SHIFT, ::MOD_ALT, ::MOD_CTRL - @param mod SDL modifiers state */ -#if defined(USE_SDL) -word Key_modifiers(SDLMod mod); -#elif defined(USE_SDL2) -word Key_modifiers(SDL_Keymod mod); -#endif - +word Get_Key_modifiers(void); diff --git a/src/operatio.c b/src/operatio.c index 46ad2d17..8bfe4c21 100644 --- a/src/operatio.c +++ b/src/operatio.c @@ -39,6 +39,7 @@ #include "input.h" #include "special.h" #include "tiles.h" +#include "keyboard.h" // PI is NOT part of math.h according to C standards... #if defined(__GP2X__) || defined(__VBCC__) @@ -520,10 +521,8 @@ void Line_12_5(void) cursor_y = Paintbrush_Y; // On corrige les coordonnées de la ligne si la touche shift est appuyée... -#if defined(USE_SDL) || defined(USE_SDL2) - if(SDL_GetModState() & KMOD_SHIFT) + if(Get_Key_modifiers() & MOD_SHIFT) Clamp_coordinates_regular_angle(start_x,start_y,&cursor_x,&cursor_y); -#endif // On vient de bouger if ((cursor_x!=end_x) || (cursor_y!=end_y)) @@ -3808,10 +3807,8 @@ void Grad_rectangle_12_9(void) cursor_x = Paintbrush_X; cursor_y = Paintbrush_Y; // On corrige les coordonnées de la ligne si la touche shift est appuyée... -#if defined(USE_SDL) || defined(USE_SDL2) - if(SDL_GetModState() & KMOD_SHIFT) + if(Get_Key_modifiers() & MOD_SHIFT) Clamp_coordinates_regular_angle(start_x,start_y,&cursor_x,&cursor_y); -#endif if ((cursor_x!=end_x) || (cursor_y!=end_y)) { diff --git a/src/windows.c b/src/windows.c index f697c658..2846b48b 100644 --- a/src/windows.c +++ b/src/windows.c @@ -50,6 +50,7 @@ #include "palette.h" #include "unicode.h" #include "keycodes.h" +#include "keyboard.h" T_Toolbar_button Buttons_Pool[NB_BUTTONS]; T_Menu_Bar Menu_bars[MENUBAR_COUNT] = @@ -1854,7 +1855,7 @@ void Compute_paintbrush_coordinates(void) // Operations that implement it #if defined(USE_SDL) || defined(USE_SDL2) default: - if (Snap_axis==0 && (SDL_GetModState() & KMOD_SHIFT)) + if (Snap_axis==0 && (Get_Key_modifiers() & MOD_SHIFT)) { // Start "Snap axis" mode Snap_axis=1;