From 4d86b8a0c1f2d2ff8b46530e2728a44d46a8b5b3 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Thu, 31 May 2018 16:44:04 +0200 Subject: [PATCH] change all references to SDLK_xxxxx to KEY_xxxx + some fixes --- src/Makefile | 5 + src/Makefile.dep | 112 +++++------ src/SFont.c | 2 + src/buttons.c | 107 +++++----- src/buttons_effects.c | 62 +++--- src/engine.c | 12 +- src/factory.c | 8 +- src/fileformats.c | 1 + src/filesel.c | 22 +-- src/help.c | 30 +-- src/hotkeys.c | 392 ++++++++++++++++++------------------- src/init.c | 2 +- src/input.c | 11 ++ src/input.h | 18 +- src/io.c | 2 + src/keyboard.c | 133 +++++++------ src/keyboard.h | 3 + src/keycodes.h | 202 +++++++++++++++++++ src/layers.c | 4 +- src/loadrecoil.c | 2 + src/loadsave.c | 2 +- src/main.c | 4 + src/misc.c | 8 +- src/miscfileformats.c | 5 +- src/operatio.c | 4 + src/palette.c | 52 ++--- src/readline.c | 36 ++-- src/shade.c | 54 ++--- src/transform.c | 12 +- src/windows.c | 22 ++- tools/generate_keycodes.py | 76 +++++++ 31 files changed, 863 insertions(+), 542 deletions(-) create mode 100755 tools/generate_keycodes.py diff --git a/src/Makefile b/src/Makefile index b286cf83..b9a3c97f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -64,6 +64,11 @@ endif # Video / input API used API ?= sdl +# At the moment support for TTF requires SDL or SDL2 + ifneq (sdl,$(findstring sdl,$(API))) + NOTTF = 1 + endif + ### PLATFORM DETECTION AND CONFIGURATION ### PLATFORMOBJ = diff --git a/src/Makefile.dep b/src/Makefile.dep index 9b49d69a..1842c4a0 100644 --- a/src/Makefile.dep +++ b/src/Makefile.dep @@ -1,104 +1,104 @@ -$(OBJDIR)/SFont.o: SFont.c SFont.h +$(OBJDIR)/SFont.o: SFont.c $(OBJDIR)/brush.o: brush.c global.h struct.h const.h graph.h misc.h errors.h \ - windows.h sdlscreen.h brush.h tiles.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 \ - sdlscreen.h windows.h + screen.h windows.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 \ - help.h text.h sdlscreen.h windows.h brush.h input.h special.h tiles.h \ - setup.h unicode.h + help.h text.h screen.h windows.h brush.h input.h keycodes.h special.h \ + tiles.h setup.h unicode.h $(OBJDIR)/buttons_effects.o: buttons_effects.c brush.h struct.h const.h buttons.h \ - loadsave.h gfx2surface.h engine.h global.h graph.h help.h input.h misc.h \ - pages.h readline.h sdlscreen.h windows.h tiles.h + loadsave.h gfx2surface.h engine.h global.h graph.h help.h input.h \ + keycodes.h misc.h pages.h readline.h screen.h windows.h tiles.h $(OBJDIR)/colorred.o: colorred.c colorred.h struct.h const.h $(OBJDIR)/engine.o: engine.c const.h struct.h global.h graph.h misc.h special.h \ - buttons.h loadsave.h gfx2surface.h operatio.h shade.h errors.h \ - sdlscreen.h windows.h brush.h input.h engine.h pages.h layers.h \ - factory.h io.h pxsimple.h oldies.h + buttons.h loadsave.h gfx2surface.h operatio.h shade.h errors.h screen.h \ + windows.h brush.h input.h keycodes.h engine.h pages.h layers.h factory.h \ + io.h pxsimple.h oldies.h $(OBJDIR)/factory.o: factory.c brush.h struct.h const.h buttons.h loadsave.h \ gfx2surface.h engine.h errors.h filesel.h global.h graph.h io.h misc.h \ - pages.h readline.h sdlscreen.h windows.h palette.h input.h help.h \ - realpath.h setup.h tiles.h + pages.h readline.h screen.h windows.h palette.h input.h keycodes.h \ + help.h realpath.h setup.h tiles.h $(OBJDIR)/fileformats.o: fileformats.c errors.h global.h struct.h const.h \ loadsave.h gfx2surface.h misc.h io.h pages.h windows.h fileformats.h $(OBJDIR)/filesel.o: filesel.c const.h struct.h global.h misc.h errors.h io.h \ - windows.h sdlscreen.h loadsave.h gfx2surface.h mountlist.h engine.h \ - readline.h input.h help.h unicode.h filesel.h + windows.h screen.h loadsave.h gfx2surface.h mountlist.h engine.h \ + readline.h input.h keycodes.h help.h unicode.h filesel.h $(OBJDIR)/gfx2surface.o: gfx2surface.c gfx2surface.h struct.h const.h errors.h $(OBJDIR)/graph.o: graph.c global.h struct.h const.h engine.h buttons.h loadsave.h \ - gfx2surface.h pages.h errors.h sdlscreen.h graph.h misc.h pxsimple.h \ + gfx2surface.h pages.h errors.h screen.h graph.h misc.h pxsimple.h \ pxtall.h pxwide.h pxdouble.h pxtriple.h pxwide2.h pxtall2.h pxtall3.h \ - pxquad.h windows.h input.h brush.h tiles.h + pxquad.h windows.h input.h keycodes.h brush.h tiles.h $(OBJDIR)/help.o: help.c const.h struct.h global.h misc.h engine.h helpfile.h \ - help.h sdlscreen.h text.h keyboard.h windows.h input.h hotkeys.h \ + help.h screen.h text.h keyboard.h windows.h input.h keycodes.h hotkeys.h \ errors.h pages.h factory.h -$(OBJDIR)/hotkeys.o: hotkeys.c struct.h const.h global.h hotkeys.h +$(OBJDIR)/hotkeys.o: hotkeys.c struct.h const.h global.h hotkeys.h keycodes.h $(OBJDIR)/init.o: init.c buttons.h struct.h const.h loadsave.h gfx2surface.h \ errors.h global.h graph.h init.h io.h factory.h help.h hotkeys.h \ keyboard.h misc.h mountlist.h operatio.h palette.h setup.h transform.h \ windows.h layers.h special.h -$(OBJDIR)/input.o: input.c global.h struct.h const.h keyboard.h sdlscreen.h \ - windows.h errors.h misc.h buttons.h loadsave.h gfx2surface.h input.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)/layers.o: layers.c const.h struct.h global.h windows.h engine.h pages.h \ - sdlscreen.h input.h help.h misc.h readline.h graph.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 \ gfx2surface.h $(OBJDIR)/loadrecoil.o: loadrecoil.c struct.h const.h global.h loadsave.h \ gfx2surface.h io.h errors.h recoil.h $(OBJDIR)/loadsave.o: loadsave.c buttons.h struct.h const.h loadsave.h \ gfx2surface.h errors.h global.h io.h misc.h graph.h op_c.h colorred.h \ - pages.h palette.h windows.h engine.h brush.h setup.h filesel.h unicode.h \ - fileformats.h + pages.h palette.h screen.h windows.h engine.h brush.h setup.h filesel.h \ + unicode.h fileformats.h $(OBJDIR)/main.o: main.c const.h struct.h global.h graph.h misc.h init.h buttons.h \ - loadsave.h gfx2surface.h engine.h pages.h sdlscreen.h errors.h readini.h \ + loadsave.h gfx2surface.h engine.h pages.h screen.h errors.h readini.h \ saveini.h io.h text.h setup.h windows.h brush.h palette.h realpath.h \ - input.h help.h filesel.h -$(OBJDIR)/misc.o: misc.c struct.h const.h sdlscreen.h global.h errors.h buttons.h \ - loadsave.h gfx2surface.h engine.h misc.h keyboard.h windows.h palette.h \ - input.h graph.h pages.h + input.h keycodes.h help.h filesel.h +$(OBJDIR)/misc.o: misc.c struct.h const.h global.h errors.h buttons.h loadsave.h \ + gfx2surface.h engine.h misc.h keyboard.h screen.h windows.h palette.h \ + input.h keycodes.h graph.h pages.h $(OBJDIR)/miscfileformats.o: miscfileformats.c engine.h struct.h const.h errors.h \ - global.h io.h libraw2crtc.h loadsave.h gfx2surface.h misc.h sdlscreen.h \ - windows.h oldies.h pages.h fileformats.h + global.h io.h libraw2crtc.h loadsave.h gfx2surface.h misc.h screen.h \ + windows.h oldies.h pages.h keycodes.h fileformats.h $(OBJDIR)/mountlist.o: mountlist.c mountlist.h $(OBJDIR)/oldies.o: oldies.c struct.h const.h global.h errors.h misc.h palette.h \ pages.h windows.h layers.h $(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 \ - sdlscreen.h brush.h windows.h input.h special.h tiles.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 $(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 \ - buttons.h loadsave.h gfx2surface.h pages.h help.h sdlscreen.h errors.h \ - op_c.h colorred.h windows.h input.h palette.h shade.h + buttons.h loadsave.h gfx2surface.h pages.h help.h screen.h errors.h \ + op_c.h colorred.h windows.h input.h keycodes.h palette.h shade.h $(OBJDIR)/pversion.o: pversion.c -$(OBJDIR)/pxdouble.o: pxdouble.c global.h struct.h const.h sdlscreen.h misc.h \ - graph.h pxdouble.h pxwide.h -$(OBJDIR)/pxquad.o: pxquad.c global.h struct.h const.h sdlscreen.h misc.h graph.h \ +$(OBJDIR)/pxdouble.o: pxdouble.c global.h struct.h const.h screen.h misc.h graph.h \ + pxdouble.h pxwide.h +$(OBJDIR)/pxquad.o: pxquad.c global.h struct.h const.h screen.h misc.h graph.h \ pxquad.h -$(OBJDIR)/pxsimple.o: pxsimple.c global.h struct.h const.h sdlscreen.h misc.h \ - graph.h pxsimple.h -$(OBJDIR)/pxtall.o: pxtall.c global.h struct.h const.h sdlscreen.h misc.h graph.h \ +$(OBJDIR)/pxsimple.o: pxsimple.c global.h struct.h const.h screen.h misc.h graph.h \ + pxsimple.h +$(OBJDIR)/pxtall.o: pxtall.c global.h struct.h const.h screen.h misc.h graph.h \ pxtall.h pxsimple.h -$(OBJDIR)/pxtall2.o: pxtall2.c global.h struct.h const.h sdlscreen.h misc.h graph.h \ +$(OBJDIR)/pxtall2.o: pxtall2.c global.h struct.h const.h screen.h misc.h graph.h \ pxtall2.h -$(OBJDIR)/pxtall3.o: pxtall3.c global.h struct.h const.h sdlscreen.h misc.h graph.h \ +$(OBJDIR)/pxtall3.o: pxtall3.c global.h struct.h const.h screen.h misc.h graph.h \ pxtall3.h -$(OBJDIR)/pxtriple.o: pxtriple.c global.h struct.h const.h sdlscreen.h misc.h \ - graph.h pxtriple.h -$(OBJDIR)/pxwide.o: pxwide.c global.h struct.h const.h sdlscreen.h misc.h graph.h \ +$(OBJDIR)/pxtriple.o: pxtriple.c global.h struct.h const.h screen.h misc.h graph.h \ + pxtriple.h +$(OBJDIR)/pxwide.o: pxwide.c global.h struct.h const.h screen.h misc.h graph.h \ pxwide.h -$(OBJDIR)/pxwide2.o: pxwide2.c global.h struct.h const.h sdlscreen.h misc.h graph.h \ +$(OBJDIR)/pxwide2.o: pxwide2.c global.h struct.h const.h screen.h misc.h graph.h \ pxwide2.h $(OBJDIR)/readini.o: readini.c const.h errors.h global.h struct.h misc.h readini.h \ setup.h realpath.h io.h windows.h -$(OBJDIR)/readline.o: readline.c const.h struct.h global.h misc.h errors.h \ - sdlscreen.h readline.h windows.h input.h engine.h unicode.h +$(OBJDIR)/readline.o: readline.c const.h struct.h global.h misc.h errors.h screen.h \ + readline.h windows.h input.h keycodes.h engine.h unicode.h $(OBJDIR)/realpath.o: realpath.c $(OBJDIR)/recoil.o: recoil.c recoil.h $(OBJDIR)/saveini.o: saveini.c const.h global.h struct.h readini.h io.h errors.h \ @@ -107,18 +107,18 @@ $(OBJDIR)/sdlscreen.o: sdlscreen.c global.h struct.h const.h sdlscreen.h errors. misc.h $(OBJDIR)/setup.o: setup.c struct.h const.h io.h setup.h $(OBJDIR)/shade.o: shade.c global.h struct.h const.h graph.h engine.h errors.h \ - misc.h readline.h help.h sdlscreen.h windows.h input.h shade.h + misc.h readline.h help.h screen.h windows.h input.h keycodes.h shade.h $(OBJDIR)/special.o: special.c const.h struct.h global.h graph.h engine.h windows.h \ special.h pages.h misc.h buttons.h loadsave.h gfx2surface.h -$(OBJDIR)/text.o: text.c SFont.h struct.h const.h global.h sdlscreen.h io.h \ - errors.h windows.h misc.h setup.h -$(OBJDIR)/tiles.o: tiles.c struct.h const.h global.h graph.h sdlscreen.h engine.h \ - windows.h input.h misc.h tiles.h +$(OBJDIR)/text.o: text.c struct.h const.h global.h io.h errors.h windows.h misc.h \ + setup.h +$(OBJDIR)/tiles.o: tiles.c struct.h const.h global.h graph.h screen.h engine.h \ + windows.h input.h keycodes.h misc.h tiles.h $(OBJDIR)/transform.o: transform.c global.h struct.h const.h transform.h engine.h \ - sdlscreen.h windows.h input.h help.h misc.h readline.h buttons.h \ + screen.h windows.h input.h keycodes.h help.h misc.h readline.h buttons.h \ 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)/windows.o: windows.c windows.h struct.h const.h engine.h errors.h \ - global.h graph.h input.h misc.h op_c.h colorred.h readline.h sdlscreen.h \ - palette.h unicode.h + global.h graph.h input.h keycodes.h misc.h op_c.h colorred.h readline.h \ + screen.h palette.h unicode.h diff --git a/src/SFont.c b/src/SFont.c index 23de8ce0..92b22073 100644 --- a/src/SFont.c +++ b/src/SFont.c @@ -25,6 +25,7 @@ GERMANY karlb@gmx.net */ +#if defined(USE_SDL) || defined(USE_SDL2) #include #include @@ -222,3 +223,4 @@ void SFont_WriteCenter(SDL_Surface *Surface, const SFont_Font *Font, y, text); } */ +#endif diff --git a/src/buttons.c b/src/buttons.c index 96fff253..2bb42974 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -79,6 +79,7 @@ #include "tiles.h" #include "setup.h" #include "unicode.h" +#include "keycodes.h" #if defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__) #include @@ -109,7 +110,7 @@ void Bouton_***(void) Open_window(310,190,"***"); - Window_set_normal_button(103,137,80,14,"OK",0,1,SDLK_RETURN); // 1 + Window_set_normal_button(103,137,80,14,"OK",0,1,KEY_RETURN); // 1 Window_set_scroller_button(18,44,88,16,4,0); // 2 Update_window_area(0,0,Window_width, Window_height); @@ -137,13 +138,13 @@ void Message_out_of_memory(void) Print_in_window(8,20,"Please consult the manual",MC_Black,MC_Light); Print_in_window(24,28,"to know how to obtain",MC_Black,MC_Light); Print_in_window(36,36,"more memory space.",MC_Black,MC_Light); - Window_set_normal_button(60,53,40,14,"OK",1,1,SDLK_RETURN); // 1 + Window_set_normal_button(60,53,40,14,"OK",1,1,KEY_RETURN); // 1 Update_window_area(0,0,Window_width, Window_height); Display_cursor(); do clicked_button=Window_clicked_button(); - while ((clicked_button<=0) && (Key!=KEY_ESC) && (Key!=SDLK_o)); + while ((clicked_button<=0) && (Key!=KEY_ESC) && (Key!=KEY_o)); if(clicked_button<=0) Key=0; Close_window(); @@ -613,8 +614,8 @@ byte Button_Quit_local_function(void) // On commence par afficher la fenêtre de QUIT Open_window(160,84,"Quit ?"); Window_set_normal_button(20,20,120,14,"Stay",0,1,KEY_ESC); // 1 - Window_set_normal_button(20,40,120,14,"Save & quit",1,1,SDLK_s); // 2 - Window_set_normal_button(20,60,120,14,"Discard (Quit)",1,1,SDLK_d);// 3 + Window_set_normal_button(20,40,120,14,"Save & quit",1,1,KEY_s); // 2 + Window_set_normal_button(20,60,120,14,"Discard (Quit)",1,1,KEY_d);// 3 Update_window_area(0,0,Window_width, Window_height); Display_cursor(); @@ -1035,11 +1036,11 @@ void Button_Settings(int btn) Open_window(307,182,"Settings"); // Button Reload - Window_set_normal_button( 6,163, 51,14,"Reload" ,1,1,SDLK_r); // 1 + Window_set_normal_button( 6,163, 51,14,"Reload" ,1,1,KEY_r); // 1 // Button Auto-save - Window_set_normal_button( 73,163,107,14,"Auto-save: ",1,1,SDLK_a); // 2 + Window_set_normal_button( 73,163,107,14,"Auto-save: ",1,1,KEY_a); // 2 // Button Save - Window_set_normal_button(183,163, 51,14,"Save" ,1,1,SDLK_s); // 3 + Window_set_normal_button(183,163, 51,14,"Save" ,1,1,KEY_s); // 3 // Button Close Window_set_normal_button(250,163, 51,14,"Close" ,0,1,KEY_ESC); // 4 @@ -1165,7 +1166,7 @@ void Button_Settings(int btn) else if (Is_shortcut(Key,0x100+BUTTON_SETTINGS)) clicked_button=4; } - while ( (clicked_button!=4) && (Key!=SDLK_RETURN) ); + while ( (clicked_button!=4) && (Key!=KEY_RETURN) ); // Checks on change if (Config.Show_hidden_directories!=selected_config.Show_hidden_directories @@ -1327,7 +1328,7 @@ void Button_Skins(int btn) Print_in_window( 172, 59,"Cursor:" ,MC_Black,MC_Light); // Ok button - Window_set_normal_button(6, 120, 51, 14, "OK", 0, 1, SDLK_RETURN); // 1 + Window_set_normal_button(6, 120, 51, 14, "OK", 0, 1, KEY_RETURN); // 1 // List of skins skin_list = Window_set_list_button( @@ -1346,7 +1347,7 @@ void Button_Skins(int btn) Window_dropdown_add_item(font_dropdown,temp,Get_item_by_index(&Font_files_list,temp)->Short_name); // Cancel - Window_set_normal_button(61, 120, 51,14,"Cancel",0,1,SDLK_ESCAPE); // 6 + Window_set_normal_button(61, 120, 51,14,"Cancel",0,1,KEY_ESCAPE); // 6 // Dropdown list to choose cursor type cursor_dropdown = Window_set_dropdown_button(172, 69, 104, 11, 0, @@ -1488,7 +1489,7 @@ void Button_Skins(int btn) break; } } - while ( (clicked_button!=1) && (clicked_button !=6) && (Key != SDLK_ESCAPE)); + while ( (clicked_button!=1) && (clicked_button !=6) && (Key != KEY_ESCAPE)); if(clicked_button == 1) { @@ -1688,11 +1689,11 @@ void Button_Copy_page(int btn) Open_window(168,137,"Copy to spare page"); - Window_set_normal_button(10, 20,148,14,"Pixels + palette" , 0,1,SDLK_RETURN); // 1 - Window_set_normal_button(10, 37,148,14,"Pixels only" , 3,1,SDLK_x); // 2 - Window_set_normal_button(10, 54,148,14,"Palette only" , 1,1,SDLK_p); // 3 - Window_set_normal_button(10, 71,148,14,"Some colors only" , 6,1,SDLK_c); // 4 - Window_set_normal_button(10, 88,148,14,"Palette and remap",13,1,SDLK_r); // 5 + Window_set_normal_button(10, 20,148,14,"Pixels + palette" , 0,1,KEY_RETURN); // 1 + Window_set_normal_button(10, 37,148,14,"Pixels only" , 3,1,KEY_x); // 2 + Window_set_normal_button(10, 54,148,14,"Palette only" , 1,1,KEY_p); // 3 + Window_set_normal_button(10, 71,148,14,"Some colors only" , 6,1,KEY_c); // 4 + Window_set_normal_button(10, 88,148,14,"Palette and remap",13,1,KEY_r); // 5 Window_set_normal_button(44,114, 80,14,"Cancel" , 0,1,KEY_ESC); // 6 Update_window_area(0,0,Window_width, Window_height); @@ -1927,14 +1928,14 @@ void Button_Resolution(int btn) Print_in_window( 12, 21,"Picture size:" ,MC_Dark,MC_Light); Window_display_frame ( 8,17,195, 33); - Window_set_normal_button(223, 18,67,14,"OK" ,0,1,SDLK_RETURN); // 1 + Window_set_normal_button(223, 18,67,14,"OK" ,0,1,KEY_RETURN); // 1 Window_set_normal_button(223, 35,67,14,"Cancel" ,0,1,KEY_ESC); // 2 Print_in_window_underscore( 12, 37,"Width:",MC_Dark,MC_Light,1); - input_width_button=Window_set_input_button_s( 60, 35,4,SDLK_w); // 3 + input_width_button=Window_set_input_button_s( 60, 35,4,KEY_w); // 3 Print_in_window_underscore(108, 37,"Height:",MC_Dark,MC_Light,1); - input_button_height=Window_set_input_button_s(164, 35,4,SDLK_h); // 4 + input_button_height=Window_set_input_button_s(164, 35,4,KEY_h); // 4 Window_display_frame ( 8,72,283,110); Window_display_frame_in (37,84,228,84); @@ -2099,7 +2100,7 @@ void Button_Resolution(int btn) // Gestion des touches de déplacement dans la liste switch (Key) { - case SDLK_UP : // Haut + case KEY_UP : // Haut if (cursor_position>0) cursor_position--; else @@ -2108,7 +2109,7 @@ void Button_Resolution(int btn) Scroll_list_of_modes(list_start,cursor_position,&selected_mode); Key=0; break; - case SDLK_DOWN : // Bas + case KEY_DOWN : // Bas if (cursor_position<(MODELIST_LINES-1) && cursor_position<(Nb_video_modes-1)) cursor_position++; else @@ -2117,7 +2118,7 @@ void Button_Resolution(int btn) Scroll_list_of_modes(list_start,cursor_position,&selected_mode); Key=0; break; - case SDLK_PAGEUP : // PageUp + case KEY_PAGEUP : // PageUp if (cursor_position>0) cursor_position=0; else @@ -2130,7 +2131,7 @@ void Button_Resolution(int btn) Scroll_list_of_modes(list_start,cursor_position,&selected_mode); Key=0; break; - case SDLK_PAGEDOWN : // PageDown + case KEY_PAGEDOWN : // PageDown if (Nb_video_modesPages->Gradients->Range[Current_gradient].Mix); // 3 // Direction Window_set_normal_button(8,20,15,14, - (Main.backups->Pages->Gradients->Range[Current_gradient].Inverse)?"\033":"\032",0,1,SDLK_TAB); // 4 + (Main.backups->Pages->Gradients->Range[Current_gradient].Inverse)?"\033":"\032",0,1,KEY_TAB); // 4 // Technique - Window_set_normal_button(8,90,15,14,"",0,1,SDLK_TAB|MOD_SHIFT); // 5 + Window_set_normal_button(8,90,15,14,"",0,1,KEY_TAB|MOD_SHIFT); // 5 Draw_button_gradient_style(8,90,Main.backups->Pages->Gradients->Range[Current_gradient].Technique); - Window_set_normal_button(178,128,51,14,"OK",0,1,SDLK_RETURN); // 6 + Window_set_normal_button(178,128,51,14,"OK",0,1,KEY_RETURN); // 6 Window_set_normal_button(123,128,51,14,"Cancel",0,1,KEY_ESC); // 7 // Scrolling speed speed_scroller = Window_set_horizontal_scroller_button(99,111,130,106,1,Main.backups->Pages->Gradients->Range[Current_gradient].Speed); // 8 @@ -2743,8 +2744,8 @@ void Button_Gradients(int btn) if (!Mouse_K) switch (Key) { - case SDLK_BACKQUOTE : // Récupération d'une couleur derrière le menu - case SDLK_COMMA : + case KEY_BACKQUOTE : // Récupération d'une couleur derrière le menu + case KEY_COMMA : Get_color_behind_window(&color,&click); if (click) { @@ -4177,42 +4178,42 @@ void Button_Airbrush_menu(int btn) Open_window(226,170,"Spray"); Window_set_normal_button(110,148,51,14,"Cancel" ,0,1,KEY_ESC); // 1 - Window_set_normal_button(166,148,51,14,"OK" ,0,1,SDLK_RETURN); // 2 + Window_set_normal_button(166,148,51,14,"OK" ,0,1,KEY_RETURN); // 2 Window_set_scroller_button(178,62,74,50,1,49-Airbrush_multi_flow[selected_color]); // 3 Window_set_palette_button(7,56); // 4 - Window_set_normal_button( 8,148,83,14,"Mode: ",0,1,SDLK_TAB); // 5 + Window_set_normal_button( 8,148,83,14,"Mode: ",0,1,KEY_TAB); // 5 if (Airbrush_mode) Print_in_window(50,151," Mono",MC_Black,MC_Light); else Print_in_window(50,151,"Multi",MC_Black,MC_Light); - Window_set_normal_button(194, 62,19,14,"+1" ,0,1,SDLK_KP_PLUS); // 6 - Window_set_normal_button(194, 79,19,14,"-1" ,0,1,SDLK_KP_MINUS); // 7 - Window_set_normal_button(194, 96,19,14,"x2" ,0,1,SDLK_KP_MULTIPLY); // 8 - Window_set_normal_button(194,113,19,14,"\xf7""2" ,0,1,SDLK_KP_ENTER); // 9 + Window_set_normal_button(194, 62,19,14,"+1" ,0,1,KEY_KP_PLUS); // 6 + Window_set_normal_button(194, 79,19,14,"-1" ,0,1,KEY_KP_MINUS); // 7 + Window_set_normal_button(194, 96,19,14,"x2" ,0,1,KEY_KP_MULTIPLY); // 8 + Window_set_normal_button(194,113,19,14,"\xf7""2" ,0,1,KEY_KP_ENTER); // 9 - Window_set_normal_button( 8, 37,43,14,"Clear" ,1,1,SDLK_c); // 10 + Window_set_normal_button( 8, 37,43,14,"Clear" ,1,1,KEY_c); // 10 Print_in_window_underscore(142,25,"Size:" ,MC_Dark,MC_Light,1); - input_size_button = Window_set_input_button_s(186,23,3,SDLK_s); // 11 + input_size_button = Window_set_input_button_s(186,23,3,KEY_s); // 11 Num2str(Airbrush_size,str,3); Window_input_content(input_size_button,str); Print_in_window_underscore(142,39,"Delay:" ,MC_Dark,MC_Light,1); - input_delay_button = Window_set_input_button_s(194,37,2,SDLK_d); // 12 + input_delay_button = Window_set_input_button_s(194,37,2,KEY_d); // 12 Num2str(Airbrush_delay,str,2); Window_input_content(input_delay_button,str); Print_in_window_underscore( 27,24,"Mono-Flow:",MC_Dark,MC_Light,1); - input_flow_button = Window_set_input_button_s(111,22,2,SDLK_m); // 13 + input_flow_button = Window_set_input_button_s(111,22,2,KEY_m); // 13 Num2str(Airbrush_mono_flow,str,2); Window_input_content(input_flow_button,str); Print_in_window_underscore( 67,40,"Init:",MC_Dark,MC_Light,1); - input_init_button = Window_set_input_button_s(111,38,2,SDLK_i); // 14 + input_init_button = Window_set_input_button_s(111,38,2,KEY_i); // 14 Num2str(spray_init,str,2); Window_input_content(input_init_button,str); @@ -4426,8 +4427,8 @@ void Button_Airbrush_menu(int btn) if (!Mouse_K) switch (Key) { - case SDLK_BACKQUOTE : // Récupération d'une couleur derrière le menu - case SDLK_COMMA : + case KEY_BACKQUOTE : // Récupération d'une couleur derrière le menu + case KEY_COMMA : Get_color_behind_window(&color,&click); if (click) { @@ -4616,14 +4617,14 @@ void Button_Effects(int btn) Window_set_normal_button(C3, L2, 16,16,"",0,1,Config_Key[SPECIAL_GRID_MODE][0]); // 9 Window_set_normal_button(C3, L4, 16,16,"",0,1,Config_Key[SPECIAL_TILING_MODE][0]); // 10 - Window_set_normal_button(195,131, 68,14,"Close",0,1,SDLK_RETURN); // 11 - Window_set_normal_button(118,131, 68,14,"All off",0,1,SDLK_DELETE); // 12 + Window_set_normal_button(195,131, 68,14,"Close",0,1,KEY_RETURN); // 11 + Window_set_normal_button(118,131, 68,14,"All off",0,1,KEY_DELETE); // 12 // "Feedback" frame Window_display_frame_mono(C1-5,L1+8,90,88,MC_Dark); Window_rectangle(C1-1, L1+2, 78, 14, MC_Light); - Window_set_normal_button(C1+1,L1+2,14,14," ",0,1,SDLK_f); // 13 + Window_set_normal_button(C1+1,L1+2,14,14," ",0,1,KEY_f); // 13 Print_in_window(28,24,"Feedback",MC_Dark,MC_Light); Window_set_normal_button(C2, L4, 16,16,"",0,1,Config_Key[SPECIAL_FORMAT_CHECKER_MENU][0]); // 14 @@ -4974,19 +4975,19 @@ void Button_Text(int btn) // Texte saisi Print_in_window_underscore(6,20,"Text:",MC_Dark,MC_Light,1); - input_text_button = Window_set_input_button_s(48,18,29,SDLK_t); // 1 + input_text_button = Window_set_input_button_s(48,18,29,KEY_t); // 1 // TrueType options Window_display_frame_in(182,34,100,68); Print_in_window(199,31,"TrueType", MC_Dark, MC_Light); // AA - Window_set_normal_button(188,58,13,11,antialias?"X":" ",0,1,SDLK_a); // 2 + Window_set_normal_button(188,58,13,11,antialias?"X":" ",0,1,KEY_a); // 2 Print_in_window_underscore(206,60,"AntiAlias", MC_Dark, MC_Light,5); // Bold - Window_set_normal_button(188,72,13,11,is_bold?"X":" ",0,1,SDLK_b); // 3 + Window_set_normal_button(188,72,13,11,is_bold?"X":" ",0,1,KEY_b); // 3 Print_in_window_underscore(206,75,"Bold", MC_Dark, MC_Light,1); // Italic - Window_set_normal_button(188,86,13,11,is_italic?"X":" ",0,1,SDLK_i); // 4 + Window_set_normal_button(188,86,13,11,is_italic?"X":" ",0,1,KEY_i); // 4 Print_in_window_underscore(206,89,"Italic", MC_Dark, MC_Light,1); // Scroller des fontes @@ -4996,7 +4997,7 @@ void Button_Text(int btn) Window_display_frame_in(7, 33, 154, NB_FONTS*8+4); // Taille texte - input_size_button = Window_set_input_button_s(220,43,3,SDLK_s); // 7 + input_size_button = Window_set_input_button_s(220,43,3,KEY_s); // 7 Window_set_repeatable_button(202,43,13,11,"-",0,1,KEY_NONE); // 8 Window_set_repeatable_button(251,43,13,11,"+",0,1,KEY_NONE); // 9 @@ -5004,7 +5005,7 @@ void Button_Text(int btn) preview_button = Window_set_special_button(8,106,273,50,0); // 10 Window_display_frame_in(7, 105, 275, 52); - Window_set_normal_button(8,160,40,14,"OK",0,1,SDLK_RETURN); // 11 + Window_set_normal_button(8,160,40,14,"OK",0,1,KEY_RETURN); // 11 Window_set_normal_button(54,160,60,14,"Cancel",0,1,KEY_ESC); // 12 // List of fonts diff --git a/src/buttons_effects.c b/src/buttons_effects.c index 0b7a55f2..d8c8e895 100644 --- a/src/buttons_effects.c +++ b/src/buttons_effects.c @@ -60,17 +60,17 @@ void Menu_tag_colors(char * window_title, byte * table, byte * mode, byte can_ca Open_window(176,150,window_title); Window_set_palette_button(6,38); // 1 - Window_set_normal_button( 7, 19,78,14,"Clear" ,1,1,SDLK_c); // 2 - Window_set_normal_button(91, 19,78,14,"Invert",1,1,SDLK_i); // 3 + Window_set_normal_button( 7, 19,78,14,"Clear" ,1,1,KEY_c); // 2 + Window_set_normal_button(91, 19,78,14,"Invert",1,1,KEY_i); // 3 if (can_cancel) { - Window_set_normal_button(91,129,78,14,"OK" ,0,1,SDLK_RETURN); // 4 + Window_set_normal_button(91,129,78,14,"OK" ,0,1,KEY_RETURN); // 4 Window_set_normal_button( 7,129,78,14,"Cancel",0,1,KEY_ESC); // 5 // On enregistre la table dans un backup au cas où on ferait Cancel memcpy(backup_table,table,256); } else - Window_set_normal_button(49,129,78,14,"OK" ,0,1,SDLK_RETURN); // 4 + Window_set_normal_button(49,129,78,14,"OK" ,0,1,KEY_RETURN); // 4 // On affiche l'état actuel de la table for (index=0; index<=255; index++) @@ -122,8 +122,8 @@ void Menu_tag_colors(char * window_title, byte * table, byte * mode, byte can_ca if (!Mouse_K) switch (Key) { - case SDLK_BACKQUOTE : // Récupération d'une couleur derrière le menu - case SDLK_COMMA : + case KEY_BACKQUOTE : // Récupération d'une couleur derrière le menu + case KEY_COMMA : Get_color_behind_window(&color,&click); if (click) { @@ -232,7 +232,7 @@ void Button_Constraint_menu(void) Open_window(154,79,"8-bit constraints"); Window_set_normal_button(21,55,51,14,"Cancel",0,1,KEY_ESC); // 1 - Window_set_normal_button(82,55,51,14,"OK" ,0,1,SDLK_RETURN); // 2 + Window_set_normal_button(82,55,51,14,"OK" ,0,1,KEY_RETURN); // 2 label = "Constraints"; for (i = 0; i < sizeof(modes)/sizeof(modes[0]) ; i++) @@ -290,7 +290,7 @@ void Button_Tilemap_menu(void) Open_window(166,120,"Tilemap options"); Window_set_normal_button(6,102,51,14,"Cancel",0,1,KEY_ESC); // 1 - Window_set_normal_button(110,102,51,14,"OK" ,0,1,SDLK_RETURN); // 2 + Window_set_normal_button(110,102,51,14,"OK" ,0,1,KEY_RETURN); // 2 Print_in_window(24,21, "Detect mirrored",MC_Dark,MC_Light); Window_display_frame(5,17,155,56); @@ -432,7 +432,7 @@ void Button_Grid_menu(void) Open_window(149,118,"Grid"); Window_set_normal_button(12,92,51,14,"Cancel",0,1,KEY_ESC); // 1 - Window_set_normal_button(86,92,51,14,"OK" ,0,1,SDLK_RETURN); // 2 + Window_set_normal_button(86,92,51,14,"OK" ,0,1,KEY_RETURN); // 2 Print_in_window(11,26, "X:",MC_Dark,MC_Light); input_x_button = Window_set_input_button(29,24,3); // 3 @@ -624,7 +624,7 @@ void Button_Smooth_menu(void) Open_window(142,109,"Smooth"); Window_set_normal_button(82,59,53,14,"Cancel",0,1,KEY_ESC); // 1 - Window_set_normal_button(82,88,53,14,"OK" ,0,1,SDLK_RETURN); // 2 + Window_set_normal_button(82,88,53,14,"OK" ,0,1,KEY_RETURN); // 2 Window_display_frame(6,17,130,37); for (x=11,y=0; y<4; x+=31,y++) @@ -806,15 +806,15 @@ void Button_Colorize_menu(void) Print_in_window(16,23,"Opacity:",MC_Dark,MC_Light); Window_set_input_button(87,21,3); // 1 Print_in_window(117,23,"%",MC_Dark,MC_Light); - Window_set_normal_button(16,34,108,14,"Interpolate",1,1,SDLK_i); // 2 + Window_set_normal_button(16,34,108,14,"Interpolate",1,1,KEY_i); // 2 Window_display_frame(12,18,116,34); - Window_set_normal_button(16,54,108,14,"Additive" ,2,1,SDLK_d); // 3 - Window_set_normal_button(16,71,108,14,"Subtractive",1,1,SDLK_s); // 4 - Window_set_normal_button(16,88,108,14,"Alpha",1,1,SDLK_a); // 4 + Window_set_normal_button(16,54,108,14,"Additive" ,2,1,KEY_d); // 3 + Window_set_normal_button(16,71,108,14,"Subtractive",1,1,KEY_s); // 4 + Window_set_normal_button(16,88,108,14,"Alpha",1,1,KEY_a); // 4 Window_set_normal_button(16,111, 51,14,"Cancel" ,0,1,KEY_ESC); // 5 - Window_set_normal_button(73,111, 51,14,"OK" ,0,1,SDLK_RETURN); // 6 + Window_set_normal_button(73,111, 51,14,"OK" ,0,1,KEY_RETURN); // 6 Num2str(Colorize_opacity,str,3); Window_input_content(Window_special_button_list,str); @@ -906,7 +906,7 @@ void Button_Tiling_menu(void) Open_window(138,79,"Tiling"); Window_set_normal_button(13,55,51,14,"Cancel",0,1,KEY_ESC); // 1 - Window_set_normal_button(74,55,51,14,"OK" ,0,1,SDLK_RETURN); // 2 + Window_set_normal_button(74,55,51,14,"OK" ,0,1,KEY_RETURN); // 2 input_offset_x_button = Window_set_input_button(91,21,4); // 3 input_offset_y_button = Window_set_input_button(91,35,4); // 4 Print_in_window(12,23,"Offset X:",MC_Dark,MC_Light); @@ -1126,30 +1126,30 @@ void Button_Sieve_menu(void) Window_set_special_button(143,69,80,80,0); // 1 Window_set_normal_button(175,157,51,14,"Cancel",0,1,KEY_ESC); // 2 - Window_set_normal_button(230,157,51,14,"OK" ,0,1,SDLK_RETURN); // 3 + Window_set_normal_button(230,157,51,14,"OK" ,0,1,KEY_RETURN); // 3 - Window_set_normal_button( 8,157,51,14,"Clear" ,1,1,SDLK_c); // 4 - Window_set_normal_button( 63,157,51,14,"Invert",1,1,SDLK_i); // 5 + Window_set_normal_button( 8,157,51,14,"Clear" ,1,1,KEY_c); // 4 + Window_set_normal_button( 63,157,51,14,"Invert",1,1,KEY_i); // 5 - Window_set_normal_button( 8,46,131,14,"Get from brush" ,1,1,SDLK_g); // 6 - Window_set_normal_button(142,46,139,14,"Transfer to brush",1,1,SDLK_t); // 7 + Window_set_normal_button( 8,46,131,14,"Get from brush" ,1,1,KEY_g); // 6 + Window_set_normal_button(142,46,139,14,"Transfer to brush",1,1,KEY_t); // 7 - Window_set_normal_button(109,114,11,11,"\030",0,1,SDLK_UP|MOD_SHIFT); // 8 - Window_set_normal_button(109,138,11,11,"\031",0,1,SDLK_DOWN|MOD_SHIFT); // 9 - Window_set_normal_button( 97,126,11,11,"\033",0,1,SDLK_LEFT|MOD_SHIFT); // 10 - Window_set_normal_button(121,126,11,11,"\032",0,1,SDLK_RIGHT|MOD_SHIFT); // 11 - button_bg_color = Window_set_normal_button(109,126,11,11,"" ,0,1,SDLK_INSERT); // 12 + Window_set_normal_button(109,114,11,11,"\030",0,1,KEY_UP|MOD_SHIFT); // 8 + Window_set_normal_button(109,138,11,11,"\031",0,1,KEY_DOWN|MOD_SHIFT); // 9 + Window_set_normal_button( 97,126,11,11,"\033",0,1,KEY_LEFT|MOD_SHIFT); // 10 + Window_set_normal_button(121,126,11,11,"\032",0,1,KEY_RIGHT|MOD_SHIFT); // 11 + button_bg_color = Window_set_normal_button(109,126,11,11,"" ,0,1,KEY_INSERT); // 12 Window_rectangle(button_bg_color->Pos_X+2, button_bg_color->Pos_Y+2, 7, 7, (default_bg_color)?MC_White:MC_Black); - Window_set_repeatable_button(109, 69,11,11,"\030",0,1,SDLK_UP); // 13 - Window_set_repeatable_button(109, 93,11,11,"\031",0,1,SDLK_DOWN); // 14 - Window_set_repeatable_button( 97, 81,11,11,"\033",0,1,SDLK_LEFT); // 15 - Window_set_repeatable_button(121, 81,11,11,"\032",0,1,SDLK_RIGHT); // 16 + Window_set_repeatable_button(109, 69,11,11,"\030",0,1,KEY_UP); // 13 + Window_set_repeatable_button(109, 93,11,11,"\031",0,1,KEY_DOWN); // 14 + Window_set_repeatable_button( 97, 81,11,11,"\033",0,1,KEY_LEFT); // 15 + Window_set_repeatable_button(121, 81,11,11,"\032",0,1,KEY_RIGHT); // 16 for (index=0; index<12; index++) - Window_set_normal_button((index*23)+8,20,20,20,"",0,1,SDLK_F1+index); // 17 -> 28 + Window_set_normal_button((index*23)+8,20,20,20,"",0,1,KEY_F1+index); // 17 -> 28 Draw_preset_sieve_patterns(); origin_x=Window_pos_X+(Menu_factor_X*Window_special_button_list->Pos_X); diff --git a/src/engine.c b/src/engine.c index f4dd38a3..f9c098b1 100644 --- a/src/engine.c +++ b/src/engine.c @@ -3341,7 +3341,7 @@ short Window_clicked_button(void) // FIXME: Make only one list have the keyboard focus. if (1) { - if (Key==SDLK_UP && (list->Cursor_position+list->List_start)>0) + if (Key==KEY_UP && (list->Cursor_position+list->List_start)>0) { Key=0; Hide_cursor(); @@ -3361,7 +3361,7 @@ short Window_clicked_button(void) // Return the control ID of the list. return list->Number; } - if (Key==SDLK_DOWN && (list->Cursor_position+list->List_start)<(list->Scroller->Nb_elements-1)) + if (Key==KEY_DOWN && (list->Cursor_position+list->List_start)<(list->Scroller->Nb_elements-1)) { Key=0; Hide_cursor(); @@ -3381,7 +3381,7 @@ short Window_clicked_button(void) // Return the control ID of the list. return list->Number; } - if (Key==SDLK_HOME && (list->Cursor_position!=0 || list->List_start!=0)) + if (Key==KEY_HOME && (list->Cursor_position!=0 || list->List_start!=0)) { Key=0; Hide_cursor(); @@ -3397,7 +3397,7 @@ short Window_clicked_button(void) // Return the control ID of the list. return list->Number; } - if (Key==SDLK_END && (list->Cursor_position+list->List_start)<(list->Scroller->Nb_elements-1)) + if (Key==KEY_END && (list->Cursor_position+list->List_start)<(list->Scroller->Nb_elements-1)) { Key=0; Hide_cursor(); @@ -3417,7 +3417,7 @@ short Window_clicked_button(void) // Return the control ID of the list. return list->Number; } - if (Key==SDLK_PAGEDOWN && (list->Cursor_position+list->List_start)<(list->Scroller->Nb_elements-1)) + if (Key==KEY_PAGEDOWN && (list->Cursor_position+list->List_start)<(list->Scroller->Nb_elements-1)) { Key=0; Hide_cursor(); @@ -3447,7 +3447,7 @@ short Window_clicked_button(void) // Return the control ID of the list. return list->Number; } - if (Key==SDLK_PAGEUP && (list->Cursor_position+list->List_start)>0) + if (Key==KEY_PAGEUP && (list->Cursor_position+list->List_start)>0) { Key=0; Hide_cursor(); diff --git a/src/factory.c b/src/factory.c index 98b6e656..b3be10ba 100644 --- a/src/factory.c +++ b/src/factory.c @@ -1087,7 +1087,7 @@ int L_InputBox(lua_State* L) control[0]=0; // OK - Window_set_normal_button( 7, 25 + 17 * nb_settings, 51,14,"OK" , 0,1,SDLK_RETURN); + Window_set_normal_button( 7, 25 + 17 * nb_settings, 51,14,"OK" , 0,1,KEY_RETURN); control[Window_nb_buttons] = CONTROL_OK; // Cancel @@ -1488,7 +1488,7 @@ int L_WaitInput(lua_State* L) } lua_pushboolean(L, moved ? 1 : 0); - lua_pushinteger(L, (Key == KEY_ESC) ? SDLK_ESCAPE : Key); + lua_pushinteger(L, (Key == KEY_ESC) ? KEY_ESCAPE : Key); lua_pushinteger(L, Mouse_X); lua_pushinteger(L, Mouse_Y); lua_pushinteger(L, Mouse_K); @@ -2669,7 +2669,7 @@ void Button_Brush_Factory(void) Scripts_selector.Nb_elements,10, 0); // 3 scriptlist = Window_set_list_button(scriptarea,scriptscroll,Draw_script_name, 0); // 4 - Window_set_normal_button(10, 161, 67, 14, "Run", 0, 1, SDLK_RETURN); // 5 + Window_set_normal_button(10, 161, 67, 14, "Run", 0, 1, KEY_RETURN); // 5 Window_display_frame_in(6, FILESEL_Y + 88, DESC_WIDTH*6+4, 4*8+2); // Descr. Window_set_special_button(7, FILESEL_Y + 89+24,DESC_WIDTH*6,8,0); // 6 @@ -2719,7 +2719,7 @@ void Button_Brush_Factory(void) do { clicked_button = Window_clicked_button(); - if (Key==SDLK_BACKSPACE && Config.Scripts_directory[0]!='\0') + if (Key==KEY_BACKSPACE && Config.Scripts_directory[0]!='\0') { // Make it select first entry (parent directory) scriptlist->List_start=0; diff --git a/src/fileformats.c b/src/fileformats.c index ee0a053d..9862d3e4 100644 --- a/src/fileformats.c +++ b/src/fileformats.c @@ -27,6 +27,7 @@ ///@file fileformats.c /// Saving and loading different picture formats. +#include #ifndef __no_pnglib__ #include #if !defined(PNG_HAVE_PLTE) diff --git a/src/filesel.c b/src/filesel.c index 4f4e59b7..1cc883d1 100644 --- a/src/filesel.c +++ b/src/filesel.c @@ -1573,7 +1573,7 @@ byte Button_Load_or_Save(T_Selector_settings *settings, byte load, T_IO_Context Open_window(310,200,"Load palette"); else Open_window(310,200,"Load brush"); - Window_set_normal_button(198,180,51,14,"Load",0,1,SDLK_RETURN); // 1 + Window_set_normal_button(198,180,51,14,"Load",0,1,KEY_RETURN); // 1 } else { @@ -1585,7 +1585,7 @@ byte Button_Load_or_Save(T_Selector_settings *settings, byte load, T_IO_Context Open_window(310,200,"Save palette"); else assert(0); - Window_set_normal_button(198,180,51,14,"Save",0,1,SDLK_RETURN); // 1 + Window_set_normal_button(198,180,51,14,"Save",0,1,KEY_RETURN); // 1 if (Selector->Format_filter<=FORMAT_ALL_FILES) // Correction du *.* { Selector->Format_filter=context->Format; @@ -1605,7 +1605,7 @@ byte Button_Load_or_Save(T_Selector_settings *settings, byte load, T_IO_Context } Window_set_normal_button(253,180,51,14,"Cancel",0,1,KEY_ESC); // 2 - Window_set_normal_button(7,180,51,14,"Delete",0,1,SDLK_DELETE); // 3 + Window_set_normal_button(7,180,51,14,"Delete",0,1,KEY_DELETE); // 3 // Frame autour des infos sur le fichier de dessin Window_display_frame_in(6, 44,299, 37); @@ -2117,43 +2117,43 @@ byte Button_Load_or_Save(T_Selector_settings *settings, byte load, T_IO_Context switch (Key) { - case SDLK_UNKNOWN : break; - case SDLK_DOWN : // Bas + case KEY_UNKNOWN : break; + case KEY_DOWN : // Bas Reset_quicksearch(); Hide_cursor(); Selector_scroll_down(&Selector->Position,&Selector->Offset); Scroll_fileselector(file_scroller); Key=0; break; - case SDLK_UP : // Haut + case KEY_UP : // Haut Reset_quicksearch(); Hide_cursor(); Selector_scroll_up(&Selector->Position,&Selector->Offset); Scroll_fileselector(file_scroller); Key=0; break; - case SDLK_PAGEDOWN : // PageDown + case KEY_PAGEDOWN : // PageDown Reset_quicksearch(); Hide_cursor(); Selector_page_down(&Selector->Position,&Selector->Offset,9); Scroll_fileselector(file_scroller); Key=0; break; - case SDLK_PAGEUP : // PageUp + case KEY_PAGEUP : // PageUp Reset_quicksearch(); Hide_cursor(); Selector_page_up(&Selector->Position,&Selector->Offset,9); Scroll_fileselector(file_scroller); Key=0; break; - case SDLK_END : // End + case KEY_END : // End Reset_quicksearch(); Hide_cursor(); Selector_end(&Selector->Position,&Selector->Offset); Scroll_fileselector(file_scroller); Key=0; break; - case SDLK_HOME : // Home + case KEY_HOME : // Home Reset_quicksearch(); Hide_cursor(); Selector_home(&Selector->Position,&Selector->Offset); @@ -2174,7 +2174,7 @@ byte Button_Load_or_Save(T_Selector_settings *settings, byte load, T_IO_Context Scroll_fileselector(file_scroller); Key=0; break; - case SDLK_BACKSPACE : // Backspace + case KEY_BACKSPACE : // Backspace Reset_quicksearch(); // Si le choix ".." est bien en tête des propositions... if (Filelist.Nb_elements && !strcmp(Filelist.First->Full_name,PARENT_DIR)) diff --git a/src/help.c b/src/help.c index 201603ea..9fba15d6 100644 --- a/src/help.c +++ b/src/help.c @@ -158,7 +158,7 @@ void Window_set_shortcut(int action_id) Open_window(302,131,"Keyboard shortcut"); Window_set_normal_button(181,111,55,14,"Cancel",0,1,KEY_ESC); // 1 - Window_set_normal_button(241,111,55,14,"OK",0,1,SDLK_RETURN); // 2 + Window_set_normal_button(241,111,55,14,"OK",0,1,KEY_RETURN); // 2 Window_set_normal_button(6,111,111,14,"Reset default",0,1,KEY_NONE); // 3 @@ -259,7 +259,7 @@ void Window_set_shortcut(int action_id) break; } } - while ((clicked_button!=1) && (clicked_button!=2) && (Key!=SDLK_RETURN)); + while ((clicked_button!=1) && (clicked_button!=2) && (Key!=KEY_RETURN)); Key=0; Close_window(); Display_cursor(); @@ -532,11 +532,11 @@ void Window_help(int section, const char *sub_section) scroller=Window_set_scroller_button(290,18,130,nb_lines, 16,Help_position); // 2 - Window_set_normal_button( 9,154, 6*8,14,"About" ,1,1,SDLK_a); // 3 + Window_set_normal_button( 9,154, 6*8,14,"About" ,1,1,KEY_a); // 3 - Window_set_normal_button( 9+6*8+4,154, 8*8,14,"License",1,1,SDLK_l); // 4 - Window_set_normal_button( 9+6*8+4+8*8+4,154, 5*8,14,"Help",1,1,SDLK_h); // 5 - Window_set_normal_button(9+6*8+4+8*8+4+5*8+4,154, 8*8,14,"Credits",1,1,SDLK_c); // 6 + Window_set_normal_button( 9+6*8+4,154, 8*8,14,"License",1,1,KEY_l); // 4 + Window_set_normal_button( 9+6*8+4+8*8+4,154, 5*8,14,"Help",1,1,KEY_h); // 5 + Window_set_normal_button(9+6*8+4+8*8+4+5*8+4,154, 8*8,14,"Credits",1,1,KEY_c); // 6 Window_set_special_button(9,18,272,130,0); // 7 @@ -603,19 +603,19 @@ void Window_help(int section, const char *sub_section) // Gestion des touches de déplacement dans la liste switch (Key) { - case SDLK_UP : // Haut + case KEY_UP : // Haut if (Help_position>0) Help_position--; Scroll_help(scroller); Key=0; break; - case SDLK_DOWN : // Bas + case KEY_DOWN : // Bas if (Help_position15) Help_position-=15; else @@ -631,7 +631,7 @@ void Window_help(int section, const char *sub_section) Scroll_help(scroller); Key=0; break; - case SDLK_PAGEDOWN : // PageDown + case KEY_PAGEDOWN : // PageDown if (nb_lines>16) { if (Help_position16) { Help_position=nb_lines-16; @@ -670,7 +670,7 @@ void Window_help(int section, const char *sub_section) if (Is_shortcut(Key,0x100+BUTTON_HELP)) clicked_button=1; } - while ((clicked_button!=1) && (Key!=SDLK_RETURN)); + while ((clicked_button!=1) && (Key!=KEY_RETURN)); Key=0; Close_window(); @@ -884,9 +884,9 @@ void Button_Stats(int btn) if (Is_shortcut(Key,0x200+BUTTON_HELP)) clicked_button=1; } - while ( (clicked_button!=1) && (Key!=SDLK_RETURN) ); + while ( (clicked_button!=1) && (Key!=KEY_RETURN) ); - if(Key==SDLK_RETURN)Key=0; + if(Key==KEY_RETURN)Key=0; Close_window(); Unselect_button(btn); diff --git a/src/hotkeys.c b/src/hotkeys.c index 8ba6ac0c..5c1e9ab6 100644 --- a/src/hotkeys.c +++ b/src/hotkeys.c @@ -19,12 +19,10 @@ You should have received a copy of the GNU General Public License along with Grafx2; if not, see */ -#if defined(USE_SDL) || defined(USE_SDL2) -#include -#endif #include "struct.h" #include "global.h" #include "hotkeys.h" +#include "keycodes.h" #if defined(__VBCC__) || defined(_MSC_VER) #define false 0 @@ -38,7 +36,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "magnify and normal mode.", "", false, - SDLK_UP, // HAUT + KEY_UP, // HAUT 0}, {1, "Scroll down", @@ -46,7 +44,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "magnify and normal mode.", "", false, - SDLK_DOWN, // BAS + KEY_DOWN, // BAS 0}, {2, "Scroll left", @@ -54,7 +52,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "both in magnify and normal mode.", "", false, - SDLK_LEFT, // GAUCHE + KEY_LEFT, // GAUCHE 0}, {3, "Scroll right", @@ -62,7 +60,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "both in magnify and normal mode.", "", false, - SDLK_RIGHT, // DROITE + KEY_RIGHT, // DROITE 0}, #ifdef GCWZERO #define FAST_MOD MOD_CTRL @@ -75,7 +73,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "picture fast, either in magnify and", "normal mode.", true, - SDLK_UP|FAST_MOD, // Shift + Up + KEY_UP|FAST_MOD, // Shift + Up 0}, {5, "Faster scroll down", @@ -83,7 +81,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "picture fast, either in magnify and", "normal mode.", true, - SDLK_DOWN|FAST_MOD, // Shift + Down + KEY_DOWN|FAST_MOD, // Shift + Down 0}, {6, "Faster scroll left", @@ -91,7 +89,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "picture fast, either in magnify and", "normal mode.", true, - SDLK_LEFT|FAST_MOD, // Shift + Left + KEY_LEFT|FAST_MOD, // Shift + Left 0}, {7, "Faster scroll right", @@ -99,7 +97,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "picture fast, either in magnify and", "normal mode.", true, - SDLK_RIGHT|FAST_MOD, // Shift + Right + KEY_RIGHT|FAST_MOD, // Shift + Right 0}, #undef FAST_MOD {8, @@ -108,7 +106,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "picture pixel by pixel, either in", "magnify and normal mode.", true, - SDLK_UP|MOD_ALT, // Alt + Haut + KEY_UP|MOD_ALT, // Alt + Haut 0}, {9, "Slower scroll down", @@ -116,7 +114,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "picture pixel by pixel, either in", "magnify and normal mode.", true, - SDLK_DOWN|MOD_ALT, // Alt + Bas + KEY_DOWN|MOD_ALT, // Alt + Bas 0}, {10, "Slower scroll left", @@ -124,7 +122,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "picture pixel by pixel, either in", "magnify and normal mode.", true, - SDLK_LEFT|MOD_ALT, // Alt + Gauche + KEY_LEFT|MOD_ALT, // Alt + Gauche 0}, {11, "Slower scroll right", @@ -132,7 +130,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "picture pixel by pixel, either in", "magnify and normal mode.", true, - SDLK_RIGHT|MOD_ALT, // Alt + Droite + KEY_RIGHT|MOD_ALT, // Alt + Droite 0}, {12, "Move mouse cursor 1 pixel up", @@ -141,9 +139,9 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "when you want ultra-high precision.", true, #ifdef GCWZERO - SDLK_UNKNOWN, + KEY_UNKNOWN, #else - SDLK_UP|MOD_CTRL, // Ctrl + Haut + KEY_UP|MOD_CTRL, // Ctrl + Haut #endif 0}, {13, @@ -153,9 +151,9 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "when you want ultra-high precision.", true, #ifdef GCWZERO - SDLK_UNKNOWN, + KEY_UNKNOWN, #else - SDLK_DOWN|MOD_CTRL, // Ctrl + Bas + KEY_DOWN|MOD_CTRL, // Ctrl + Bas #endif 0}, {14, @@ -165,9 +163,9 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "when you want ultra-high precision.", true, #ifdef GCWZERO - SDLK_UNKNOWN, + KEY_UNKNOWN, #else - SDLK_LEFT|MOD_CTRL, // Ctrl + Gauche + KEY_LEFT|MOD_CTRL, // Ctrl + Gauche #endif 0}, {15, @@ -177,9 +175,9 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "when you want ultra-high precision.", true, #ifdef GCWZERO - SDLK_UNKNOWN, + KEY_UNKNOWN, #else - SDLK_RIGHT|MOD_CTRL, // Ctrl + Droite + KEY_RIGHT|MOD_CTRL, // Ctrl + Droite #endif 0}, {16, @@ -189,9 +187,9 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "when you want ultra-high precision.", true, #ifdef GCWZERO - SDLK_SPACE, // Space + KEY_SPACE, // Space #else - SDLK_SPACE|MOD_CTRL, // Ctrl + Space + KEY_SPACE|MOD_CTRL, // Ctrl + Space #endif 0}, {17, @@ -201,9 +199,9 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "when you want ultra-high precision.", true, #ifdef GCWZERO - SDLK_BACKSPACE, // R-shoulderpad + KEY_BACKSPACE, // R-shoulderpad #else - SDLK_SPACE|MOD_SHIFT, // Shift + Space + KEY_SPACE|MOD_SHIFT, // Shift + Space #endif 0}, {18, @@ -212,7 +210,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "them back.", "", false, - SDLK_F10, // F10 + KEY_F10, // F10 0}, {19, "Show/hide cursor", @@ -220,7 +218,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "This only works on the \"small cross\"", "and \"hand\" cursors.", true, - SDLK_F9, // F9 + KEY_F9, // F9 0}, {20, "Set paintbrush to 1 pixel", @@ -228,7 +226,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "\"single-pixel-brush\".", "", true, - SDLK_DELETE, // Del + KEY_DELETE, // Del 0}, {21, "Paintbrush choice", @@ -236,7 +234,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "paintbrush out of 24 predefined", "ones.", true, - SDLK_F4, // F4 + KEY_F4, // F4 0}, {22, "Monochrome brush", @@ -244,7 +242,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "into a single colored one. All non-", "transparent colors are set to FG.", true, - SDLK_F4|MOD_SHIFT, // Shift + F4 + KEY_F4|MOD_SHIFT, // Shift + F4 0}, {23, "Freehand drawing", @@ -252,7 +250,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "classical freehand one.", "", true, - SDLK_d, // D + KEY_d, // D 0}, {24, "Switch freehand drawing mode", @@ -260,7 +258,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "discontinuous, point by point,", "and contour fill", true, - SDLK_d|MOD_SHIFT, // Shift + D + KEY_d|MOD_SHIFT, // Shift + D 0}, {25, "Continuous freehand drawing", @@ -268,7 +266,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "freehand drawing mode.", "", true, - SDLK_d|MOD_CTRL, // Ctrl + D + KEY_d|MOD_CTRL, // Ctrl + D 0}, {26, "Line", @@ -276,7 +274,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "", "", true, - SDLK_l, // L + KEY_l, // L 0}, {27, "Knotted lines", @@ -284,7 +282,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "This mode can also be called", "\"Polyline\".", true, - SDLK_l|MOD_SHIFT, // Shift + L + KEY_l|MOD_SHIFT, // Shift + L 0}, {28, "Spray", @@ -292,7 +290,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "randomly in the picture.", "", true, - SDLK_a, // A (Q en AZERTY) + KEY_a, // A (Q en AZERTY) 0}, {29, "Spray menu", @@ -300,7 +298,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "configure the spray flow and size.", "", true, - SDLK_a|MOD_SHIFT, // Shift + A + KEY_a|MOD_SHIFT, // Shift + A 0}, {30, "Flood-fill", @@ -308,7 +306,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "picture made of pixels of the same", "color.", true, - SDLK_f, // F + KEY_f, // F 0}, {124, "Replace color", @@ -316,7 +314,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "the clicked color to the fore-color", "or the back-color.", true, - SDLK_f|MOD_SHIFT, // Shift + F + KEY_f|MOD_SHIFT, // Shift + F 0}, {31, "Bezier's curves", @@ -324,7 +322,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "", "", true, - SDLK_i, // I + KEY_i, // I 0}, {32, "Bezier's curve with 3 or 4 points", @@ -332,7 +330,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "want to draw Bezier's curves with", "3 or 4 points.", true, - SDLK_i|MOD_SHIFT, // Shift + I + KEY_i|MOD_SHIFT, // Shift + I 0}, {33, "Empty rectangle", @@ -340,7 +338,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "the brush.", "", true, - SDLK_r, // R + KEY_r, // R 0}, {34, "Filled rectangle", @@ -348,7 +346,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "rectangle.", "", true, - SDLK_r|MOD_SHIFT, // Shift + R + KEY_r|MOD_SHIFT, // Shift + R 0}, {35, "Empty circle", @@ -356,7 +354,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "the brush.", "", true, - SDLK_c, // C + KEY_c, // C 0}, {36, "Empty ellipse", @@ -364,7 +362,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "the brush.", "", true, - SDLK_c|MOD_CTRL, // Ctrl + C + KEY_c|MOD_CTRL, // Ctrl + C 0}, {37, "Filled circle", @@ -372,7 +370,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "", "", true, - SDLK_c|MOD_SHIFT, // Shift + C + KEY_c|MOD_SHIFT, // Shift + C 0}, {38, "Filled ellipse", @@ -380,7 +378,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "", "", true, - SDLK_c|MOD_SHIFT|MOD_CTRL, // Shift + Ctrl + C + KEY_c|MOD_SHIFT|MOD_CTRL, // Shift + Ctrl + C 0}, {39, "Empty polygon", @@ -388,7 +386,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "the brush.", "", true, - SDLK_n, // N + KEY_n, // N 0}, {40, "Empty \"polyform\"", @@ -396,7 +394,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "polygon using the brush.", "", true, - SDLK_n|MOD_CTRL, // Ctrl + N + KEY_n|MOD_CTRL, // Ctrl + N 0}, {41, "Filled polygon", @@ -404,7 +402,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "", "", true, - SDLK_n|MOD_SHIFT, // Shift + N + KEY_n|MOD_SHIFT, // Shift + N 0}, {42, "Filled \"polyform\"", @@ -412,7 +410,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "polygon.", "", true, - SDLK_n|MOD_SHIFT|MOD_CTRL, // Shift + Ctrl + N + KEY_n|MOD_SHIFT|MOD_CTRL, // Shift + Ctrl + N 0}, {43, "Rectangle with gradation", @@ -420,7 +418,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "a color gradation.", "", true, - SDLK_r|MOD_ALT, // Alt + R + KEY_r|MOD_ALT, // Alt + R 0}, {44, "Gradation menu", @@ -428,7 +426,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "color gradations are calculated.", "", true, - SDLK_g|MOD_ALT, // Alt + G + KEY_g|MOD_ALT, // Alt + G 0}, {45, "Sphere with gradation", @@ -436,7 +434,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "a color gradation.", "", true, - SDLK_c|MOD_ALT, // Alt + C + KEY_c|MOD_ALT, // Alt + C 0}, {46, "Ellipse with gradation", @@ -444,7 +442,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "with a color gradation.", "", true, - SDLK_c|MOD_SHIFT|MOD_ALT, // Shift + Alt + C + KEY_c|MOD_SHIFT|MOD_ALT, // Shift + Alt + C 0}, {47, "Adjust picture", @@ -452,11 +450,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "Around. What gets out from a side", "reappears on the other.", true, -#if defined(USE_SDL) - SDLK_KP5, // Kpad5 -#else - SDLK_KP_5, // Kpad5 -#endif + KEY_KP5, // Kpad5 0}, {48, "Picture effects", @@ -464,11 +458,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "", "", true, -#if defined(USE_SDL) - SDLK_KP5|MOD_SHIFT, // Shift + Kpad5 -#else - SDLK_KP_5|MOD_SHIFT, // Shift + Kpad5 -#endif + KEY_KP5|MOD_SHIFT, // Shift + Kpad5 0}, {49, "Drawing effects", @@ -476,7 +466,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "disable and configure the drawing", "effects.", true, - SDLK_e, // E + KEY_e, // E 0}, {50, "Shade mode", @@ -484,7 +474,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "", "", true, - SDLK_F5, // F5 + KEY_F5, // F5 0}, {51, "Shade menu", @@ -492,7 +482,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "", "", true, - SDLK_F5|MOD_SHIFT, // Shift + F5 + KEY_F5|MOD_SHIFT, // Shift + F5 0}, {131, "Quick-shade mode", @@ -500,7 +490,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "mode.", "", true, - SDLK_F5|MOD_CTRL, // Ctrl + F5 + KEY_F5|MOD_CTRL, // Ctrl + F5 0}, {132, "Quick-shade menu", @@ -508,7 +498,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "settings.", "", true, - SDLK_F5|MOD_SHIFT|MOD_CTRL, // Shift + Ctrl + F5 + KEY_F5|MOD_SHIFT|MOD_CTRL, // Shift + Ctrl + F5 0}, {52, "Stencil mode", @@ -516,7 +506,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "", "", true, - SDLK_F6, // F6 + KEY_F6, // F6 0}, {53, "Stencil menu", @@ -524,7 +514,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "settings.", "", true, - SDLK_F6|MOD_SHIFT, // Shift + F6 + KEY_F6|MOD_SHIFT, // Shift + F6 0}, {54, "Mask mode", @@ -532,7 +522,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "", "", true, - SDLK_F6|MOD_ALT, // Alt + F6 + KEY_F6|MOD_ALT, // Alt + F6 0}, {55, "Mask menu", @@ -540,7 +530,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "", "", true, - SDLK_F6|MOD_SHIFT|MOD_ALT, // Shift + Alt + F6 + KEY_F6|MOD_SHIFT|MOD_ALT, // Shift + Alt + F6 0}, {56, "Grid mode", @@ -548,7 +538,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "", "", true, - SDLK_g, // G + KEY_g, // G 0}, {57, "Grid menu", @@ -556,7 +546,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "the grid used by Grid mode.", "", true, - SDLK_g|MOD_SHIFT, // Shift + G + KEY_g|MOD_SHIFT, // Shift + G 0}, {58, "Sieve mode", @@ -564,7 +554,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "", "", true, - SDLK_g|MOD_CTRL, // Ctrl + G + KEY_g|MOD_CTRL, // Ctrl + G 0}, {59, "Sieve menu", @@ -572,7 +562,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "the sieve.", "", true, - SDLK_g|MOD_SHIFT|MOD_CTRL, // Shift + Ctrl + G + KEY_g|MOD_SHIFT|MOD_CTRL, // Shift + Ctrl + G 0}, {60, "Invert sieve", @@ -580,7 +570,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "Sieve menu.", "", true, - SDLK_g|MOD_CTRL|MOD_ALT, // Ctrl + Alt + G + KEY_g|MOD_CTRL|MOD_ALT, // Ctrl + Alt + G 0}, {61, "Colorize mode", @@ -588,7 +578,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "mode.", "", true, - SDLK_F7, // F7 + KEY_F7, // F7 0}, {62, "Colorize menu", @@ -596,7 +586,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "opacity percentage for Colorize", "mode.", true, - SDLK_F7|MOD_SHIFT, // Shift + F7 + KEY_F7|MOD_SHIFT, // Shift + F7 0}, {63, "Smooth mode", @@ -604,7 +594,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "mode.", "", true, - SDLK_F8, // F8 + KEY_F8, // F8 0}, {123, "Smooth menu", @@ -612,7 +602,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "the Smooth matrix.", "", true, - SDLK_F8|MOD_SHIFT, // Shift + F8 + KEY_F8|MOD_SHIFT, // Shift + F8 0}, {64, "Smear mode", @@ -620,7 +610,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "", "", true, - SDLK_F8|MOD_ALT, // Alt + F8 + KEY_F8|MOD_ALT, // Alt + F8 0}, {65, "Tiling mode", @@ -628,7 +618,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "mode.", "", true, - SDLK_b|MOD_ALT, // Alt + B + KEY_b|MOD_ALT, // Alt + B 0}, {66, "Tiling menu", @@ -636,7 +626,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "the origin of the tiling.", "", true, - SDLK_b|MOD_SHIFT|MOD_ALT, // Shift + Alt + B + KEY_b|MOD_SHIFT|MOD_ALT, // Shift + Alt + B 0}, {206, "Tilemap mode", @@ -660,9 +650,9 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "within a rectangle.", "", true, - SDLK_b, // B + KEY_b, // B #if defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__) - SDLK_C|MOD_META // Right-Amiga + C + KEY_C|MOD_META // Right-Amiga + C #else 0 #endif @@ -673,7 +663,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "within a freehand polygon.", "", true, - SDLK_b|MOD_CTRL, // Ctrl + B + KEY_b|MOD_CTRL, // Ctrl + B 0}, {69, "Get previous brush back", @@ -681,7 +671,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "", "", true, - SDLK_b|MOD_SHIFT, // Shift + B + KEY_b|MOD_SHIFT, // Shift + B 0}, {70, "Horizontal brush flipping", @@ -689,7 +679,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "", "", true, - SDLK_x, // X + KEY_x, // X 0}, {71, "Vertical brush flipping", @@ -697,7 +687,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "", "", true, - SDLK_y, // Y + KEY_y, // Y 0}, {72, "90\xb0 brush rotation", @@ -705,7 +695,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "(counter-clockwise).", "", true, - SDLK_z, // Z (W en AZERTY) + KEY_z, // Z (W en AZERTY) 0}, {73, "180\xb0 brush rotation", @@ -713,7 +703,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "180\xb0.", "", true, - SDLK_z|MOD_SHIFT, // Shift + Z + KEY_z|MOD_SHIFT, // Shift + Z 0}, {74, "Strech brush", @@ -721,7 +711,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "user-defined brush.", "", true, - SDLK_s, // S + KEY_s, // S 0}, {75, "Distort brush", @@ -729,7 +719,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "user-defined brush.", "", true, - SDLK_s|MOD_SHIFT, // Shift + S + KEY_s|MOD_SHIFT, // Shift + S 0}, {76, "Outline brush", @@ -737,7 +727,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "with the fore color.", "", true, - SDLK_o, // O + KEY_o, // O 0}, {77, "Nibble brush", @@ -745,7 +735,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "user-defined brush.This does the", "opposite of the Outline option.", true, - SDLK_o|MOD_SHIFT, // Shift + O + KEY_o|MOD_SHIFT, // Shift + O 0}, {78, "Get colors from brush", @@ -753,7 +743,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "are used in the brush.", "", true, - SDLK_F11, // F11 + KEY_F11, // F11 0}, {79, "Recolorize brush", @@ -761,7 +751,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "order to get a brush which looks as", "if it was grabbed in the spare page.", true, - SDLK_F12, // F12 + KEY_F12, // F12 0}, {80, "Rotate by any angle", @@ -769,7 +759,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "you can define.", "", true, - SDLK_w, // W (Z en AZERTY) + KEY_w, // W (Z en AZERTY) 0}, {81, "Pipette", @@ -777,7 +767,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "pixel in the picture into the", "foreground or background color.", true, - SDLK_BACKQUOTE, // `~ (Key sous le Esc - ² en AZERTY) + KEY_BACKQUOTE, // `~ (Key sous le Esc - ² en AZERTY) 0}, {82, "Swap foreground/background colors", @@ -785,7 +775,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "colors.", "", true, - SDLK_BACKQUOTE|MOD_SHIFT, // Shift + `~ + KEY_BACKQUOTE|MOD_SHIFT, // Shift + `~ 0}, {83, "Magnifier mode", @@ -793,7 +783,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "", "", true, - SDLK_m, // M (, ? sur AZERTY) + KEY_m, // M (, ? sur AZERTY) KEY_MOUSEMIDDLE}, {84, "Zoom factor menu", @@ -801,7 +791,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "magnifying factor.", "", true, - SDLK_m|MOD_SHIFT, // Shift + M + KEY_m|MOD_SHIFT, // Shift + M 0}, {85, "Zoom in", @@ -809,7 +799,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "", "", true, - SDLK_KP_PLUS, // Grey + + KEY_KP_PLUS, // Grey + KEY_MOUSEWHEELUP}, {86, "Zoom out", @@ -817,7 +807,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "", "", true, - SDLK_KP_MINUS, // Grey - + KEY_KP_MINUS, // Grey - KEY_MOUSEWHEELDOWN}, {87, "Brush effects menu", @@ -825,7 +815,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "different effects on the", "user-defined brush.", true, - SDLK_b|MOD_CTRL|MOD_ALT, // Ctrl + Alt + B + KEY_b|MOD_CTRL|MOD_ALT, // Ctrl + Alt + B 0}, {88, "Text", @@ -833,7 +823,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "type in a character string and", "render it as a brush.", true, - SDLK_t, // T + KEY_t, // T 0}, {89, "Screen resolution menu", @@ -841,7 +831,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "the screen resolution and image", "dimensions.", true, - SDLK_RETURN, // Enter + KEY_RETURN, // Enter 0}, {90, "\"Safety\" resolution", @@ -849,7 +839,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "mode that should work everywhere:", "usually a 640x400 window.", false, - SDLK_RETURN|MOD_SHIFT, // Shift + Enter + KEY_RETURN|MOD_SHIFT, // Shift + Enter 0}, {91, "Help and credits", @@ -858,9 +848,9 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "or contextual help.", true, #ifdef GCWZERO - SDLK_TAB, // L-Shoulderpad + KEY_TAB, // L-Shoulderpad #else - SDLK_F1, // F1 + KEY_F1, // F1 #endif 0}, {92, @@ -869,7 +859,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "useful information.", "", true, - SDLK_F1|MOD_SHIFT, // Shift + F1 + KEY_F1|MOD_SHIFT, // Shift + F1 0}, {93, "Jump to spare page", @@ -878,9 +868,9 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "", true, #ifdef GCWZERO - SDLK_UNKNOWN, + KEY_UNKNOWN, #else - SDLK_TAB, // Tab + KEY_TAB, // Tab #endif 0}, {94, @@ -889,7 +879,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "", "", true, - SDLK_TAB|MOD_SHIFT, // Shift + Tab + KEY_TAB|MOD_SHIFT, // Shift + Tab 0}, {95, "Save picture as...", @@ -897,9 +887,9 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "you to save your picture with a new", "path-name.", true, - SDLK_F2, // F2 + KEY_F2, // F2 #if defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__) - SDLK_A|MOD_META // Right-Amiga + A + KEY_A|MOD_META // Right-Amiga + A #else 0 #endif @@ -910,9 +900,9 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "name you gave it.", "", true, - SDLK_F2|MOD_SHIFT, // Shift + F2 + KEY_F2|MOD_SHIFT, // Shift + F2 #if defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__) - SDLK_S|MOD_META // Right-Amiga + S + KEY_S|MOD_META // Right-Amiga + S #else 0 #endif @@ -923,9 +913,9 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "you to load a new picture.", "", true, - SDLK_F3, // F3 + KEY_F3, // F3 #if defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__) - SDLK_O|MOD_META // Right-Amiga + O + KEY_O|MOD_META // Right-Amiga + O #else 0 #endif @@ -936,7 +926,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "allows you to cancel modifications", "made since last saving.", true, - SDLK_F3|MOD_SHIFT, // Shift + F3 + KEY_F3|MOD_SHIFT, // Shift + F3 0}, {99, "Save brush", @@ -944,7 +934,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "you to save your current", "user-defined brush.", true, - SDLK_F2|MOD_CTRL, // Ctrl + F2 + KEY_F2|MOD_CTRL, // Ctrl + F2 0}, {100, "Load brush", @@ -952,7 +942,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "you to load a brush.", "", true, - SDLK_F3|MOD_CTRL, // Ctrl + F3 + KEY_F3|MOD_CTRL, // Ctrl + F3 0}, {101, "Settings", @@ -960,7 +950,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "modify some parameters of the", "program.", true, - SDLK_F10|MOD_SHIFT, // Shift + F10 + KEY_F10|MOD_SHIFT, // Shift + F10 0}, {102, "Undo (Oops!)", @@ -968,14 +958,14 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "modified the picture.", "", true, - SDLK_u, // U + KEY_u, // U // Secondary shortcut is button I on the Caanoo, L on the Wiz, unset on others #if defined (__CAANOO__) (KEY_JOYBUTTON+JOY_BUTTON_I) #elif defined (__WIZ__) (KEY_JOYBUTTON+JOY_BUTTON_L) #elif defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__) - SDLK_Z|MOD_META // Right-Amiga + Z + KEY_Z|MOD_META // Right-Amiga + Z #else 0 #endif @@ -987,7 +977,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "", "", true, - SDLK_u|MOD_SHIFT, // Shift + U + KEY_u|MOD_SHIFT, // Shift + U // Secondary shortcut is button II on the Caanoo, R on the Wiz, unset on others #if defined (__CAANOO__) (KEY_JOYBUTTON+JOY_BUTTON_II) @@ -1004,7 +994,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "removes the current page from the", "list of \"Undo\" pages.", true, - SDLK_DELETE|MOD_SHIFT, // Shift + Suppr + KEY_DELETE|MOD_SHIFT, // Shift + Suppr 0}, {104, "Clear page", @@ -1013,9 +1003,9 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "a layered image.", true, #ifdef GCWZERO - SDLK_UNKNOWN, // BackSpace + KEY_UNKNOWN, // BackSpace #else - SDLK_BACKSPACE, // BackSpace + KEY_BACKSPACE, // BackSpace #endif 0}, {105, @@ -1024,7 +1014,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "current backcolor.", "", true, - SDLK_BACKSPACE|MOD_SHIFT, // Shift + BackSpace + KEY_BACKSPACE|MOD_SHIFT, // Shift + BackSpace 0}, {106, "Quit program", @@ -1032,14 +1022,14 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "If modifications were not saved,", "confirmation is asked.", false, - SDLK_q, // Q (A en AZERTY) + KEY_q, // Q (A en AZERTY) // Secondary shortcut is button Home on the Caanoo, Menu on the Wiz, unset on others #if defined (__CAANOO__) (KEY_JOYBUTTON+JOY_BUTTON_HOME) #elif defined (__WIZ__) (KEY_JOYBUTTON+JOY_BUTTON_MENU) #eif defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__) - SDLK_Q|MOD_META // Right-Amiga + Q + KEY_Q|MOD_META // Right-Amiga + Q #else 0 #endif @@ -1052,7 +1042,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "modify the current palette.", "", true, - SDLK_p, // P + KEY_p, // P 0}, {125, "Secondary palette menu", @@ -1060,7 +1050,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "define color series and some tagged", "colors.", true, - SDLK_p|MOD_SHIFT, // Shift + P + KEY_p|MOD_SHIFT, // Shift + P 0}, {130, "Exclude colors menu", @@ -1068,7 +1058,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "define the colors you don't want to", "use in Smooth and Transparency", true, - SDLK_p|MOD_CTRL, // Ctrl + P + KEY_p|MOD_CTRL, // Ctrl + P 0}, {108, "Scroll palette to the left", @@ -1076,7 +1066,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "the left, column by column.", "", true, - SDLK_PAGEUP, // PgUp + KEY_PAGEUP, // PgUp 0}, {109, "Scroll palette to the right", @@ -1084,7 +1074,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "the right, column by column.", "", true, - SDLK_PAGEDOWN, // PgDn + KEY_PAGEDOWN, // PgDn 0}, {110, "Scroll palette to the left faster", @@ -1092,7 +1082,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "the left, 8 columns by 8 columns.", "", true, - SDLK_PAGEUP|MOD_SHIFT, // Shift + PgUp + KEY_PAGEUP|MOD_SHIFT, // Shift + PgUp 0}, {111, "Scroll palette to the right faster", @@ -1100,7 +1090,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "the right, 8 columns by 8 columns.", "", true, - SDLK_PAGEDOWN|MOD_SHIFT, // Shift + PgDn + KEY_PAGEDOWN|MOD_SHIFT, // Shift + PgDn 0}, {112, "Center brush attachment point", @@ -1108,11 +1098,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "user-defined brush to its center.", "", true, -#if defined(USE_SDL) - SDLK_KP5|MOD_CTRL, // Ctrl + 5 (pavé numérique) -#else - SDLK_KP_5|MOD_CTRL, // Ctrl + 5 (pavé numérique) -#endif + KEY_KP5|MOD_CTRL, // Ctrl + 5 (pavé numérique) 0}, {113, "Top-left brush attachment point", @@ -1120,7 +1106,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "user-defined brush to its top-left", "corner.", true, - SDLK_HOME|MOD_CTRL, // Ctrl + 7 + KEY_HOME|MOD_CTRL, // Ctrl + 7 0}, {114, "Top-right brush attachment point", @@ -1128,7 +1114,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "user-defined brush to its top-right", "corner.", true, - SDLK_PAGEUP|MOD_CTRL, // Ctrl + 9 + KEY_PAGEUP|MOD_CTRL, // Ctrl + 9 0}, {115, "Bottom-left brush attachment point", @@ -1136,7 +1122,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "user-defined brush to its", "bottom-left corner.", true, - SDLK_END|MOD_CTRL, // Ctrl + 1 + KEY_END|MOD_CTRL, // Ctrl + 1 0}, {116, "Bottom-right brush attachment point", @@ -1144,7 +1130,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "user-defined brush to its", "bottom-right corner.", true, - SDLK_PAGEDOWN|MOD_CTRL, // Ctrl + 3 + KEY_PAGEDOWN|MOD_CTRL, // Ctrl + 3 0}, {117, "Next foreground color", @@ -1153,9 +1139,9 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "", true, #ifdef GCWZERO - SDLK_RIGHT|MOD_SHIFT, + KEY_RIGHT|MOD_SHIFT, #else - SDLK_RIGHTBRACKET, // ] (0x en AZERTY) + KEY_RIGHTBRACKET, // ] (0x en AZERTY) #endif 0}, {118, @@ -1165,9 +1151,9 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "", true, #ifdef GCWZERO - SDLK_LEFT|MOD_SHIFT, + KEY_LEFT|MOD_SHIFT, #else - SDLK_LEFTBRACKET, // [ (^ en AZERTY) + KEY_LEFTBRACKET, // [ (^ en AZERTY) #endif 0}, {119, @@ -1177,9 +1163,9 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "", true, #ifdef GCWZERO - SDLK_DOWN|MOD_SHIFT, + KEY_DOWN|MOD_SHIFT, #else - SDLK_RIGHTBRACKET|MOD_SHIFT, // Shift + ] + KEY_RIGHTBRACKET|MOD_SHIFT, // Shift + ] #endif 0}, {120, @@ -1189,9 +1175,9 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "", true, #ifdef GCWZERO - SDLK_UP|MOD_SHIFT, + KEY_UP|MOD_SHIFT, #else - SDLK_LEFTBRACKET|MOD_SHIFT, // Shift + [ + KEY_LEFTBRACKET|MOD_SHIFT, // Shift + [ #endif 0}, {126, @@ -1200,7 +1186,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "in the user-defined color series.", "", true, - SDLK_EQUALS, // "=+" + KEY_EQUALS, // "=+" 0}, {127, "Previous user-defined forecolor", @@ -1208,7 +1194,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "previous in the user-defined color", "series.", true, - SDLK_MINUS, // "-_" (")°" en AZERTY + KEY_MINUS, // "-_" (")°" en AZERTY 0}, {128, "Next user-defined backcolor", @@ -1216,7 +1202,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "in the user-defined color series.", "", true, - SDLK_EQUALS|MOD_SHIFT, // Shift + "=+" + KEY_EQUALS|MOD_SHIFT, // Shift + "=+" 0}, {129, "Previous user-defined backcolor", @@ -1224,7 +1210,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "previous in the user-defined color", "series.", true, - SDLK_MINUS|MOD_SHIFT, // Shift + "-_" (")°" en AZERTY + KEY_MINUS|MOD_SHIFT, // Shift + "-_" (")°" en AZERTY 0}, {121, "Shrink paintbrush", @@ -1232,7 +1218,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "if it is special circle or square.", "", true, - SDLK_COMMA, // , < (;. en AZERTY) + KEY_COMMA, // , < (;. en AZERTY) 0}, {122, "Enlarge paintbrush", @@ -1240,7 +1226,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "if it is special circle or square.", "", true, - SDLK_PERIOD, // .> (:/ en AZERTY) + KEY_PERIOD, // .> (:/ en AZERTY) 0}, {134, "Effects off", @@ -1248,7 +1234,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "is the same as the 'All off' button", "in the Effects screen", true, - SDLK_e|MOD_SHIFT, // Shift-E + KEY_e|MOD_SHIFT, // Shift-E 0}, {135, "Transparency 10%", @@ -1256,7 +1242,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "opacity at 10%.", "", true, - SDLK_1, // 1 + KEY_1, // 1 0}, {136, "Transparency 20%", @@ -1264,7 +1250,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "opacity at 20%.", "", true, - SDLK_2, // 2 + KEY_2, // 2 0}, {137, "Transparency 30%", @@ -1272,7 +1258,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "opacity at 30%.", "", true, - SDLK_3, // 3 + KEY_3, // 3 0}, {138, "Transparency 40%", @@ -1280,7 +1266,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "opacity at 40%.", "", true, - SDLK_4, // 4 + KEY_4, // 4 0}, {139, "Transparency 50%", @@ -1288,7 +1274,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "opacity at 50%.", "", true, - SDLK_5, // 5 + KEY_5, // 5 0}, {140, "Transparency 60%", @@ -1296,7 +1282,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "opacity at 60%.", "", true, - SDLK_6, // 6 + KEY_6, // 6 0}, {141, "Transparency 70%", @@ -1304,7 +1290,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "opacity at 70%.", "", true, - SDLK_7, // 7 + KEY_7, // 7 0}, {142, "Transparency 80%", @@ -1312,7 +1298,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "opacity at 80%.", "", true, - SDLK_8, // 8 + KEY_8, // 8 0}, {143, "Transparency 90%", @@ -1320,7 +1306,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "opacity at 90%.", "", true, - SDLK_9, // 9 + KEY_9, // 9 0}, {144, "Transparency 0%", @@ -1328,7 +1314,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "opacity at 0%.", "", true, - SDLK_0, // 0 + KEY_0, // 0 0}, {145, "Zoom 1:1", @@ -1336,7 +1322,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "", "", true, - SDLK_1|MOD_CTRL, /* Ctrl + 1 */ + KEY_1|MOD_CTRL, /* Ctrl + 1 */ 0}, {146, "Zoom 2:1", @@ -1344,7 +1330,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "factor to 2:1", "", true, - SDLK_2|MOD_CTRL, /* Ctrl + 2 */ + KEY_2|MOD_CTRL, /* Ctrl + 2 */ 0}, {147, "Zoom 3:1", @@ -1352,7 +1338,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "factor to 3:1", "", true, - SDLK_3|MOD_CTRL, /* Ctrl + 3 */ + KEY_3|MOD_CTRL, /* Ctrl + 3 */ 0}, {148, "Zoom 4:1", @@ -1360,7 +1346,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "factor to 4:1", "", true, - SDLK_4|MOD_CTRL, /* Ctrl + 4 */ + KEY_4|MOD_CTRL, /* Ctrl + 4 */ 0}, {149, "Zoom 5:1", @@ -1368,7 +1354,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "factor to 5:1", "", true, - SDLK_5|MOD_CTRL, /* Ctrl + 5 */ + KEY_5|MOD_CTRL, /* Ctrl + 5 */ 0}, {150, "Zoom 6:1", @@ -1376,7 +1362,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "factor to 6:1", "", true, - SDLK_6|MOD_CTRL, /* Ctrl + 6 */ + KEY_6|MOD_CTRL, /* Ctrl + 6 */ 0}, {151, "Zoom 8:1", @@ -1384,7 +1370,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "factor to 8:1", "", true, - SDLK_7|MOD_CTRL, /* Ctrl + 7 */ + KEY_7|MOD_CTRL, /* Ctrl + 7 */ 0}, {152, "Zoom 10:1", @@ -1392,7 +1378,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "factor to 10:1", "", true, - SDLK_8|MOD_CTRL, /* Ctrl + 8 */ + KEY_8|MOD_CTRL, /* Ctrl + 8 */ 0}, {153, "Zoom 12:1", @@ -1440,7 +1426,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "the magnified view. Grid cells match", "the size ", true, - SDLK_g|MOD_SHIFT|MOD_ALT, // Shift + Alt + G, + KEY_g|MOD_SHIFT|MOD_ALT, // Shift + Alt + G, 0}, {159, "Select layer 1", @@ -1576,7 +1562,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "active one. The new layer is filled", "with transparent color.", true, - SDLK_INSERT|MOD_ALT, // Alt + Insert + KEY_INSERT|MOD_ALT, // Alt + Insert 0}, {209, "Duplicate layer", @@ -1592,7 +1578,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "You can't delete the last", "layer.", true, - SDLK_DELETE|MOD_ALT, // Alt + Delete + KEY_DELETE|MOD_ALT, // Alt + Delete 0}, {177, "Merge a layer", @@ -1600,7 +1586,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "the one directly below it.", "", true, - SDLK_END|MOD_ALT, // Alt + End + KEY_END|MOD_ALT, // Alt + End 0}, {178, "Swap layer (up)", @@ -1608,7 +1594,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "up the stack. No effect if already", "on top.", true, - SDLK_PAGEUP|MOD_ALT, // Alt + PageUp + KEY_PAGEUP|MOD_ALT, // Alt + PageUp 0}, {179, "Swap layer (down)", @@ -1616,7 +1602,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "down the stack. No effect if already", "on bottom.", true, - SDLK_PAGEDOWN|MOD_ALT, // Alt + PageDown + KEY_PAGEDOWN|MOD_ALT, // Alt + PageDown 0}, {180, "Layers menu", @@ -1624,7 +1610,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "to layers and image transparency.", "", true, - SDLK_HOME|MOD_ALT, // Alt + Home + KEY_HOME|MOD_ALT, // Alt + Home 0}, {181, "Brush factory", @@ -1648,7 +1634,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "by doubling width and height.", "", true, - SDLK_h|MOD_SHIFT, // Shift+H + KEY_h|MOD_SHIFT, // Shift+H 0}, {184, "Double brush width", @@ -1656,7 +1642,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "by doubling its width.", "", true, - SDLK_x|MOD_SHIFT, // Shift+X + KEY_x|MOD_SHIFT, // Shift+X 0}, {185, "Double brush height", @@ -1664,7 +1650,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "by doubling its height.", "", true, - SDLK_y|MOD_SHIFT, // Shift+Y + KEY_y|MOD_SHIFT, // Shift+Y 0}, {186, "Halve brush size", @@ -1672,7 +1658,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "by halving its width and height", "", true, - SDLK_h, // H + KEY_h, // H 0}, {187, "Run script #1", @@ -1760,7 +1746,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "cycling, if the current image has", "cycling colors. (See gradient menu)", true, - SDLK_BACKQUOTE|MOD_CTRL, // Ctrl + `~ + KEY_BACKQUOTE|MOD_CTRL, // Ctrl + `~ 0}, {198, "Format checker", @@ -1833,9 +1819,9 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "pan the view.", true, #ifdef GCWZERO - SDLK_F1, // Space + KEY_F1, // Space #else - SDLK_SPACE, // Space + KEY_SPACE, // Space #endif 0}, {209, @@ -1844,7 +1830,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "", "", true, - SDLK_KP_PLUS|MOD_SHIFT, // Shift++ + KEY_KP_PLUS|MOD_SHIFT, // Shift++ KEY_MOUSEWHEELUP|MOD_SHIFT}, {210, "Zoom out more", @@ -1852,7 +1838,7 @@ T_Key_config ConfigKey[NB_SHORTCUTS] = { "", "", true, - SDLK_KP_MINUS|MOD_SHIFT, // Shift+- + KEY_KP_MINUS|MOD_SHIFT, // Shift+- KEY_MOUSEWHEELDOWN|MOD_SHIFT}, }; diff --git a/src/init.c b/src/init.c index b094aa62..481315bf 100644 --- a/src/init.c +++ b/src/init.c @@ -52,7 +52,7 @@ #if defined(__WIN32__) #include // GetLogicalDrives(), GetDriveType(), DRIVE_* #endif -#ifndef __GP2X__ +#if !defined(__GP2X__) && defined(USE_SDL) #include #endif #if defined (__MINT__) diff --git a/src/input.c b/src/input.c index 48ff4b0c..5f9cf6f3 100644 --- a/src/input.c +++ b/src/input.c @@ -20,8 +20,11 @@ along with Grafx2; if not, see */ +#include +#if defined(USE_SDL) || defined(USE_SDL2) #include #include +#endif #ifdef __WIN32__ #include @@ -50,7 +53,9 @@ #if defined(USE_SDL) void Handle_window_resize(SDL_ResizeEvent event); #endif +#if defined(USE_SDL) || defined(USE_SDL2) void Handle_window_exit(SDL_QuitEvent event); +#endif static int Color_cycling(void); // public Globals (available as extern) @@ -302,6 +307,7 @@ void Handle_window_resize(SDL_ResizeEvent event) } #endif +#if defined(USE_SDL) || defined(USE_SDL2) void Handle_window_exit(SDL_QuitEvent event) { (void)event, // unused @@ -381,6 +387,7 @@ int Handle_mouse_release(SDL_MouseButtonEvent event) return Move_cursor_with_constraints(); } +#endif // Keyboard management @@ -599,6 +606,7 @@ int Handle_key_release(SDL_KeyboardEvent event) // Joystick management +#if defined(USE_SDL) || defined(USE_SDL2) int Handle_joystick_press(SDL_JoyButtonEvent event) { if (event.button == Joybutton_shift) @@ -805,6 +813,7 @@ void Handle_joystick_movement(SDL_JoyAxisEvent event) Directional_down=1; } } +#endif // Attempts to move the mouse cursor by the given deltas (may be more than 1 pixel at a time) int Cursor_displace(short delta_x, short delta_y) @@ -861,6 +870,7 @@ int Directional_acceleration(int msec) int Get_input(int sleep_time) { +#if defined(USE_SDL) || defined(USE_SDL2) SDL_Event event; int user_feedback_required = 0; // Flag qui indique si on doit arrêter de traiter les évènements ou si on peut enchainer @@ -1091,6 +1101,7 @@ int Get_input(int sleep_time) // Nothing significant happened if (sleep_time) SDL_Delay(sleep_time); +#endif return 0; } diff --git a/src/input.h b/src/input.h index 427d4356..bc47758d 100644 --- a/src/input.h +++ b/src/input.h @@ -26,6 +26,11 @@ /// pointing device, ie: the GP2X. ////////////////////////////////////////////////////////////////////////////// +#ifndef INPUT_H_INCLUDED +#define INPUT_H_INCLUDED + +#include "keycodes.h" + /// /// This is the keyboard/mouse/joystick input polling function. /// Returns 1 if a significant changed occurred, such as a mouse button pressed @@ -70,18 +75,19 @@ extern int Snap_axis_origin_Y; extern char * Drop_file_name; #if defined __HAIKU__ - #define SHORTCUT_COPY (SDLK_c|MOD_ALT) + #define SHORTCUT_COPY (KEY_c|MOD_ALT) #elif defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__) - #define SHORTCUT_COPY (SDLK_c|MOD_META) + #define SHORTCUT_COPY (KEY_c|MOD_META) #else - #define SHORTCUT_COPY (SDLK_c|MOD_CTRL) + #define SHORTCUT_COPY (KEY_c|MOD_CTRL) #endif #if defined __HAIKU__ - #define SHORTCUT_PASTE (SDLK_v|MOD_ALT) + #define SHORTCUT_PASTE (KEY_v|MOD_ALT) #elif defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__) - #define SHORTCUT_PASTE (SDLK_v|MOD_META) + #define SHORTCUT_PASTE (KEY_v|MOD_META) #else - #define SHORTCUT_PASTE (SDLK_v|MOD_CTRL) + #define SHORTCUT_PASTE (KEY_v|MOD_CTRL) #endif +#endif diff --git a/src/io.c b/src/io.c index 0f66cdde..e564d7ee 100644 --- a/src/io.c +++ b/src/io.c @@ -53,7 +53,9 @@ #else #include #endif +#if defined(USE_SDL) || defined(USE_SDL2) #include +#endif #include "struct.h" #include "io.h" diff --git a/src/keyboard.c b/src/keyboard.c index c51c148d..5f73ed55 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -20,11 +20,15 @@ You should have received a copy of the GNU General Public License along with Grafx2; if not, see */ +#include #include #include +#if defined(USE_SDL) #include +#endif #include "global.h" #include "keyboard.h" +#include "keycodes.h" #if defined(__macosx__) // Apple's "command" character is not present in the ANSI table, so we @@ -373,6 +377,7 @@ word Keysym_to_keycode(SDL_keysym keysym) key_code |= mod; return key_code; } +#endif const char * Key_name(word key) { @@ -391,59 +396,61 @@ const char * Key_name(word key) { SDLK_PAUSE , "Power-Down" }, { SDLK_ESCAPE , "SELECT" }, #else - { SDLK_BACKSPACE , "Backspace" }, - { SDLK_TAB , "Tab" }, - { SDLK_CLEAR , "Clear" }, - { SDLK_RETURN , "Return" }, - { SDLK_PAUSE , "Pause" }, - { SDLK_ESCAPE , "Esc" }, + { KEY_BACKSPACE , "Backspace" }, + { KEY_TAB , "Tab" }, + { KEY_CLEAR , "Clear" }, + { KEY_RETURN , "Return" }, + { KEY_PAUSE , "Pause" }, + { KEY_ESCAPE , "Esc" }, #endif - { SDLK_DELETE , "Del" }, - { SDLK_KP0 , "KP 0" }, - { SDLK_KP1 , "KP 1" }, - { SDLK_KP2 , "KP 2" }, - { SDLK_KP3 , "KP 3" }, - { SDLK_KP4 , "KP 4" }, - { SDLK_KP5 , "KP 5" }, - { SDLK_KP6 , "KP 6" }, - { SDLK_KP7 , "KP 7" }, - { SDLK_KP8 , "KP 8" }, - { SDLK_KP9 , "KP 9" }, - { SDLK_KP_PERIOD , "KP ." }, - { SDLK_KP_DIVIDE , "KP /" }, - { SDLK_KP_MULTIPLY, "KP *" }, - { SDLK_KP_MINUS , "KP -" }, - { SDLK_KP_PLUS , "KP +" }, - { SDLK_KP_ENTER , "KP Enter" }, - { SDLK_KP_EQUALS , "KP =" }, - { SDLK_UP , "Up" }, - { SDLK_DOWN , "Down" }, - { SDLK_RIGHT , "Right" }, - { SDLK_LEFT , "Left" }, - { SDLK_INSERT , "Ins" }, - { SDLK_HOME , "Home" }, - { SDLK_END , "End" }, - { SDLK_PAGEUP , "PgUp" }, - { SDLK_PAGEDOWN , "PgDn" }, - { SDLK_F1 , "F1" }, - { SDLK_F2 , "F2" }, - { SDLK_F3 , "F3" }, - { SDLK_F4 , "F4" }, - { SDLK_F5 , "F5" }, - { SDLK_F6 , "F6" }, - { SDLK_F7 , "F7" }, - { SDLK_F8 , "F8" }, - { SDLK_F9 , "F9" }, - { SDLK_F10 , "F10" }, - { SDLK_F11 , "F11" }, - { SDLK_F12 , "F12" }, + { KEY_DELETE , "Del" }, + { KEY_KP0 , "KP 0" }, + { KEY_KP1 , "KP 1" }, + { KEY_KP2 , "KP 2" }, + { KEY_KP3 , "KP 3" }, + { KEY_KP4 , "KP 4" }, + { KEY_KP5 , "KP 5" }, + { KEY_KP6 , "KP 6" }, + { KEY_KP7 , "KP 7" }, + { KEY_KP8 , "KP 8" }, + { KEY_KP9 , "KP 9" }, + { KEY_KP_PERIOD , "KP ." }, + { KEY_KP_DIVIDE , "KP /" }, + { KEY_KP_MULTIPLY, "KP *" }, + { KEY_KP_MINUS , "KP -" }, + { KEY_KP_PLUS , "KP +" }, + { KEY_KP_ENTER , "KP Enter" }, + { KEY_KP_EQUALS , "KP =" }, + { KEY_UP , "Up" }, + { KEY_DOWN , "Down" }, + { KEY_RIGHT , "Right" }, + { KEY_LEFT , "Left" }, + { KEY_INSERT , "Ins" }, + { KEY_HOME , "Home" }, + { KEY_END , "End" }, + { KEY_PAGEUP , "PgUp" }, + { KEY_PAGEDOWN , "PgDn" }, + { KEY_F1 , "F1" }, + { KEY_F2 , "F2" }, + { KEY_F3 , "F3" }, + { KEY_F4 , "F4" }, + { KEY_F5 , "F5" }, + { KEY_F6 , "F6" }, + { KEY_F7 , "F7" }, + { KEY_F8 , "F8" }, + { KEY_F9 , "F9" }, + { KEY_F10 , "F10" }, + { KEY_F11 , "F11" }, + { KEY_F12 , "F12" }, +#if defined(USE_SDL) { SDLK_F13 , "F13" }, { SDLK_F14 , "F14" }, { SDLK_F15 , "F15" }, - { SDLK_NUMLOCK , "NumLock" }, - { SDLK_CAPSLOCK , "CapsLck" }, - { SDLK_SCROLLOCK , "ScrlLock" }, - { SDLK_RSHIFT , "RShift" }, +#endif + { KEY_NUMLOCK , "NumLock" }, + { KEY_CAPSLOCK , "CapsLck" }, + { KEY_SCROLLOCK , "ScrlLock" }, + { KEY_RSHIFT , "RShift" }, #ifdef GCWZERO { SDLK_LSHIFT , "X" }, { SDLK_RCTRL , "RCtrl" }, @@ -451,12 +458,13 @@ const char * Key_name(word key) { SDLK_RALT , "RAlt" }, { SDLK_LALT , "B" }, #else - { SDLK_LSHIFT , "LShift" }, - { SDLK_RCTRL , "RCtrl" }, - { SDLK_LCTRL , "LCtrl" }, - { SDLK_RALT , "RAlt" }, - { SDLK_LALT , "LAlt" }, + { KEY_LSHIFT , "LShift" }, + { KEY_RCTRL , "RCtrl" }, + { KEY_LCTRL , "LCtrl" }, + { KEY_RALT , "RAlt" }, + { KEY_LALT , "LAlt" }, #endif +#if defined(USE_SDL) { SDLK_RMETA , "RMeta" }, { SDLK_LMETA , "LMeta" }, { SDLK_LSUPER , "LWin" }, @@ -471,6 +479,7 @@ const char * Key_name(word key) { SDLK_POWER , "Power" }, { SDLK_EURO , "Euro" }, { SDLK_UNDO , "Undo" }, +#endif { KEY_MOUSEMIDDLE, "Mouse3" }, { KEY_MOUSEWHEELUP, "WheelUp" }, { KEY_MOUSEWHEELDOWN, "WheelDown" } @@ -480,7 +489,7 @@ const char * Key_name(word key) static char buffer[41]; buffer[0] = '\0'; - if (key == SDLK_UNKNOWN) + if (key == KEY_UNKNOWN) return "None"; #ifdef GCWZERO @@ -605,12 +614,14 @@ const char * Key_name(word key) sprintf(buffer+strlen(buffer), "'%c'", toupper(key)); return buffer; } +#if defined(USE_SDL) || defined(USE_SDL2) // Touches 'World' if (key>=SDLK_WORLD_0 && key <= SDLK_WORLD_95) { sprintf(buffer+strlen(buffer), "w%d", key - SDLK_WORLD_0); return buffer; } +#endif // Touches au libellé connu for (index=0; index < (long)sizeof(key_labels)/(long)sizeof(T_key_label);index++) @@ -627,6 +638,7 @@ const char * Key_name(word key) } +#if defined(USE_SDL) // Obtient le caractère ANSI tapé, à partir d'un keysym. // (Valeur 32 à 255) // Renvoie 0 s'il n'y a pas de caractère associé (shift, backspace, etc) @@ -750,18 +762,19 @@ word Keysym_to_ANSI(SDL_keysym keysym) // Sinon c'est une touche spéciale, on retourne son scancode return keysym.sym; } -#else +#elif defined(USE_SDL2) // SDL2 TODO word Key_for_scancode(word scancode) { return scancode; } -const char * Key_name(word key) -{ - return "Unknown"; -} word Key_modifiers(SDL_Keymod mod) { return 0; } +#else +word Key_for_scancode(word scancode) +{ + return scancode; +} #endif diff --git a/src/keyboard.h b/src/keyboard.h index 8a71c3fc..11cddcdc 100644 --- a/src/keyboard.h +++ b/src/keyboard.h @@ -39,8 +39,11 @@ ////////////////////////////////////////////////////////////////////////////// #if defined(USE_SDL) #include +#elif defined(USE_SDL2) +#include #endif + /*! Convert an SDL keysym to an ANSI/ASCII character. This is used to type text and numeric values in input boxes. diff --git a/src/keycodes.h b/src/keycodes.h index 0bcf94fa..cb4ea340 100644 --- a/src/keycodes.h +++ b/src/keycodes.h @@ -26,4 +26,206 @@ #include #endif +#if defined(USE_SDL) +#define K2K(x) (x) +#elif defined(USE_SDL2) +#define K2K(x) ((((x) & 0x40000000) >> 19) | ((x) & 0x1FF)) +#endif + +/* generated lists */ +#if defined(USE_SDL) || defined(USE_SDL2) +// KEY definitions for SDL and SDL2 +#define KEY_UNKNOWN K2K(SDLK_UNKNOWN) +#define KEY_ESCAPE K2K(SDLK_ESCAPE) +#define KEY_RETURN K2K(SDLK_RETURN) +#define KEY_BACKSPACE K2K(SDLK_BACKSPACE) +#define KEY_TAB K2K(SDLK_TAB) +#define KEY_UP K2K(SDLK_UP) +#define KEY_DOWN K2K(SDLK_DOWN) +#define KEY_LEFT K2K(SDLK_LEFT) +#define KEY_RIGHT K2K(SDLK_RIGHT) +#define KEY_LEFTBRACKET K2K(SDLK_LEFTBRACKET) +#define KEY_RIGHTBRACKET K2K(SDLK_RIGHTBRACKET) +#define KEY_INSERT K2K(SDLK_INSERT) +#define KEY_DELETE K2K(SDLK_DELETE) +#define KEY_COMMA K2K(SDLK_COMMA) +#define KEY_BACKQUOTE K2K(SDLK_BACKQUOTE) +#define KEY_PAGEUP K2K(SDLK_PAGEUP) +#define KEY_PAGEDOWN K2K(SDLK_PAGEDOWN) +#define KEY_HOME K2K(SDLK_HOME) +#define KEY_END K2K(SDLK_END) +#define KEY_KP_PLUS K2K(SDLK_KP_PLUS) +#define KEY_KP_MINUS K2K(SDLK_KP_MINUS) +#define KEY_KP_MULTIPLY K2K(SDLK_KP_MULTIPLY) +#define KEY_KP_ENTER K2K(SDLK_KP_ENTER) +#define KEY_EQUALS K2K(SDLK_EQUALS) +#define KEY_MINUS K2K(SDLK_MINUS) +#define KEY_PERIOD K2K(SDLK_PERIOD) +#define KEY_CAPSLOCK K2K(SDLK_CAPSLOCK) +#define KEY_CLEAR K2K(SDLK_CLEAR) +#define KEY_SPACE K2K(SDLK_SPACE) +#define KEY_0 K2K(SDLK_0) +#define KEY_1 K2K(SDLK_1) +#define KEY_2 K2K(SDLK_2) +#define KEY_3 K2K(SDLK_3) +#define KEY_4 K2K(SDLK_4) +#define KEY_5 K2K(SDLK_5) +#define KEY_6 K2K(SDLK_6) +#define KEY_7 K2K(SDLK_7) +#define KEY_8 K2K(SDLK_8) +#define KEY_9 K2K(SDLK_9) +#define KEY_a K2K(SDLK_a) +#define KEY_b K2K(SDLK_b) +#define KEY_c K2K(SDLK_c) +#define KEY_d K2K(SDLK_d) +#define KEY_e K2K(SDLK_e) +#define KEY_f K2K(SDLK_f) +#define KEY_g K2K(SDLK_g) +#define KEY_h K2K(SDLK_h) +#define KEY_i K2K(SDLK_i) +#define KEY_j K2K(SDLK_j) +#define KEY_k K2K(SDLK_k) +#define KEY_l K2K(SDLK_l) +#define KEY_m K2K(SDLK_m) +#define KEY_n K2K(SDLK_n) +#define KEY_o K2K(SDLK_o) +#define KEY_p K2K(SDLK_p) +#define KEY_q K2K(SDLK_q) +#define KEY_r K2K(SDLK_r) +#define KEY_s K2K(SDLK_s) +#define KEY_t K2K(SDLK_t) +#define KEY_u K2K(SDLK_u) +#define KEY_v K2K(SDLK_v) +#define KEY_w K2K(SDLK_w) +#define KEY_x K2K(SDLK_x) +#define KEY_y K2K(SDLK_y) +#define KEY_z K2K(SDLK_z) +#if defined(USE_SDL) +#define KEY_KP0 K2K(SDLK_KP0) +#define KEY_KP1 K2K(SDLK_KP1) +#define KEY_KP2 K2K(SDLK_KP2) +#define KEY_KP3 K2K(SDLK_KP3) +#define KEY_KP4 K2K(SDLK_KP4) +#define KEY_KP5 K2K(SDLK_KP5) +#define KEY_KP6 K2K(SDLK_KP6) +#define KEY_KP7 K2K(SDLK_KP7) +#define KEY_KP8 K2K(SDLK_KP8) +#define KEY_KP9 K2K(SDLK_KP9) +#else +#define KEY_KP0 K2K(SDLK_KP_0) +#define KEY_KP1 K2K(SDLK_KP_1) +#define KEY_KP2 K2K(SDLK_KP_2) +#define KEY_KP3 K2K(SDLK_KP_3) +#define KEY_KP4 K2K(SDLK_KP_4) +#define KEY_KP5 K2K(SDLK_KP_5) +#define KEY_KP6 K2K(SDLK_KP_6) +#define KEY_KP7 K2K(SDLK_KP_7) +#define KEY_KP8 K2K(SDLK_KP_8) +#define KEY_KP9 K2K(SDLK_KP_9) +#endif +#define KEY_F1 K2K(SDLK_F1) +#define KEY_F2 K2K(SDLK_F2) +#define KEY_F3 K2K(SDLK_F3) +#define KEY_F4 K2K(SDLK_F4) +#define KEY_F5 K2K(SDLK_F5) +#define KEY_F6 K2K(SDLK_F6) +#define KEY_F7 K2K(SDLK_F7) +#define KEY_F8 K2K(SDLK_F8) +#define KEY_F9 K2K(SDLK_F9) +#define KEY_F10 K2K(SDLK_F10) +#define KEY_F11 K2K(SDLK_F11) +#define KEY_F12 K2K(SDLK_F12) +// end of KEY definitions for SDL and SDL2 +#else +// KEY definitions for others +#define KEY_UNKNOWN 0 +#define KEY_ESCAPE 1 +#define KEY_RETURN 2 +#define KEY_BACKSPACE 3 +#define KEY_TAB 4 +#define KEY_UP 5 +#define KEY_DOWN 6 +#define KEY_LEFT 7 +#define KEY_RIGHT 8 +#define KEY_LEFTBRACKET 9 +#define KEY_RIGHTBRACKET 10 +#define KEY_INSERT 11 +#define KEY_DELETE 12 +#define KEY_COMMA 13 +#define KEY_BACKQUOTE 14 +#define KEY_PAGEUP 15 +#define KEY_PAGEDOWN 16 +#define KEY_HOME 17 +#define KEY_END 18 +#define KEY_KP_PLUS 19 +#define KEY_KP_MINUS 20 +#define KEY_KP_MULTIPLY 21 +#define KEY_KP_ENTER 22 +#define KEY_EQUALS 23 +#define KEY_MINUS 24 +#define KEY_PERIOD 25 +#define KEY_CAPSLOCK 26 +#define KEY_CLEAR 27 +#define KEY_SPACE 28 +#define KEY_0 29 +#define KEY_1 30 +#define KEY_2 31 +#define KEY_3 32 +#define KEY_4 33 +#define KEY_5 34 +#define KEY_6 35 +#define KEY_7 36 +#define KEY_8 37 +#define KEY_9 38 +#define KEY_a 39 +#define KEY_b 40 +#define KEY_c 41 +#define KEY_d 42 +#define KEY_e 43 +#define KEY_f 44 +#define KEY_g 45 +#define KEY_h 46 +#define KEY_i 47 +#define KEY_j 48 +#define KEY_k 49 +#define KEY_l 50 +#define KEY_m 51 +#define KEY_n 52 +#define KEY_o 53 +#define KEY_p 54 +#define KEY_q 55 +#define KEY_r 56 +#define KEY_s 57 +#define KEY_t 58 +#define KEY_u 59 +#define KEY_v 60 +#define KEY_w 61 +#define KEY_x 62 +#define KEY_y 63 +#define KEY_z 64 +#define KEY_KP0 65 +#define KEY_KP1 66 +#define KEY_KP2 67 +#define KEY_KP3 68 +#define KEY_KP4 69 +#define KEY_KP5 70 +#define KEY_KP6 71 +#define KEY_KP7 72 +#define KEY_KP8 73 +#define KEY_KP9 74 +#define KEY_F1 75 +#define KEY_F2 76 +#define KEY_F3 77 +#define KEY_F4 78 +#define KEY_F5 79 +#define KEY_F6 80 +#define KEY_F7 81 +#define KEY_F8 82 +#define KEY_F9 83 +#define KEY_F10 84 +#define KEY_F11 85 +#define KEY_F12 86 +// end of KEY definitions for others +#endif + #endif diff --git a/src/layers.c b/src/layers.c index 8531bfaa..12b19253 100644 --- a/src/layers.c +++ b/src/layers.c @@ -263,7 +263,7 @@ void Button_Layer_menu(void) Window_set_normal_button(95, 54, 15,13,"" , 0,1,KEY_NONE); // 2 Draw_transparent_background(transparent_background); - Window_set_normal_button( 7, 78, 51,14,"OK" , 0,1,SDLK_RETURN); // 3 + Window_set_normal_button( 7, 78, 51,14,"OK" , 0,1,KEY_RETURN); // 3 Window_set_normal_button(63, 78, 51,14,"Cancel", 0,1,KEY_ESC); // 4 Update_window_area(0,0,Window_width, Window_height); @@ -489,7 +489,7 @@ void Button_Anim_time(void) Print_in_window(24,73,"Add to all frames",MC_Black,MC_Light); Window_set_normal_button(7, 70, 13,13,"" , 0,1,KEY_NONE); // 4 - Window_set_normal_button( 7, 92, 51,14,"OK" , 0,1,SDLK_RETURN); // 5 + Window_set_normal_button( 7, 92, 51,14,"OK" , 0,1,KEY_RETURN); // 5 Window_set_normal_button(63, 92, 51,14,"Cancel", 0,1,KEY_ESC); // 6 Update_window_area(0,0,Window_width, Window_height); diff --git a/src/loadrecoil.c b/src/loadrecoil.c index 9d5d5795..5ee4afaa 100644 --- a/src/loadrecoil.c +++ b/src/loadrecoil.c @@ -18,6 +18,8 @@ along with Grafx2; if not, see */ +#include +#include #ifdef _MSC_VER #include #if _MSC_VER < 1900 diff --git a/src/loadsave.c b/src/loadsave.c index 06163ff4..1d00168e 100644 --- a/src/loadsave.c +++ b/src/loadsave.c @@ -1120,6 +1120,7 @@ void Load_SDL_Image(T_IO_Context *context) SDL_FreeSurface(surface); } +#endif /// /// Load an arbitrary Surface. @@ -1155,7 +1156,6 @@ T_GFX2_Surface * Load_surface(char *full_name, T_Gradient_array *gradients) return bmp; } -#endif /// Saves an image. diff --git a/src/main.c b/src/main.c index f9921fbb..52c403ac 100644 --- a/src/main.c +++ b/src/main.c @@ -205,7 +205,9 @@ void Error_function(int error_code, const char *filename, int line_number, const break; } +#if defined(USE_SDL) || defined(USE_SDL2) SDL_Quit(); +#endif exit(error_code); } } @@ -1138,7 +1140,9 @@ void Program_shutdown(void) iconv_close(cd_utf16_inv); #endif +#if defined(USE_SDL) || defined(USE_SDL2) SDL_Quit(); +#endif #if defined(__GP2X__) || defined(__WIZ__) || defined(__CAANOO__) chdir("/usr/gp2x"); diff --git a/src/misc.c b/src/misc.c index c31a0299..98e79fef 100644 --- a/src/misc.c +++ b/src/misc.c @@ -58,8 +58,8 @@ word Count_used_colors(dword* usage) { int nb_pixels = 0; - Uint8* current_pixel; - Uint8 color; + byte* current_pixel; + byte color; word nb_colors = 0; int i; int layer; @@ -100,7 +100,7 @@ word Count_used_colors(dword* usage) word Count_used_colors_screen_area(dword* usage, word start_x, word start_y, word width, word height) { - Uint8 color; + byte color; word x, y; word nb_colors = 0; int i; @@ -135,7 +135,7 @@ word Count_used_colors_screen_area(dword* usage, word start_x, word start_y, word Count_used_colors_area(dword* usage, word start_x, word start_y, word width, word height) { - Uint8 color; + byte color; word x, y; word nb_colors = 0; int i; diff --git a/src/miscfileformats.c b/src/miscfileformats.c index 0423fd2b..48875bf2 100644 --- a/src/miscfileformats.c +++ b/src/miscfileformats.c @@ -43,6 +43,7 @@ #include "windows.h" #include "oldies.h" #include "pages.h" +#include "keycodes.h" #include "fileformats.h" //////////////////////////////////// PAL //////////////////////////////////// @@ -2645,8 +2646,8 @@ int Save_C64_window(byte *saveWhat, byte *loadAddr) }; Open_window(200,120,"c64 settings"); - Window_set_normal_button(110,100,80,15,"Save",1,1,SDLK_RETURN); // 1 - Window_set_normal_button(10,100,80,15,"Cancel",1,1,SDLK_ESCAPE); // 2 + Window_set_normal_button(110,100,80,15,"Save",1,1,KEY_RETURN); // 1 + Window_set_normal_button(10,100,80,15,"Cancel",1,1,KEY_ESCAPE); // 2 Print_in_window(13,18,"Data:",MC_Dark,MC_Light); what=Window_set_dropdown_button(10,28,90,15,70,what_label[*saveWhat],1, 0, 1, LEFT_SIDE,0); // 3 diff --git a/src/operatio.c b/src/operatio.c index d998ee84..46ad2d17 100644 --- a/src/operatio.c +++ b/src/operatio.c @@ -520,8 +520,10 @@ 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) 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)) @@ -3806,8 +3808,10 @@ 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) 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/palette.c b/src/palette.c index 3df22754..02013a8c 100644 --- a/src/palette.c +++ b/src/palette.c @@ -933,7 +933,7 @@ int Window_Histogram(unsigned char block_start, unsigned char block_end, dword* } Open_window(263, 150, "Histogram"); - Window_set_normal_button(120, 130, 42, 14, "Close",-1,1,SDLK_RETURN); + Window_set_normal_button(120, 130, 42, 14, "Close",-1,1,KEY_RETURN); Print_in_window(6, 17, "Color:", MC_Dark, MC_Light); Print_in_window(110+12*8, 17, "Pixels", MC_Dark, MC_Light); @@ -1200,12 +1200,12 @@ void Button_Palette(int btn) Num2str(Fore_color, str, 3); Print_in_window(COLOR_X, COLOR_Y, str, MC_Black, MC_Light); - Window_set_normal_button(C4_X,L3,C4_W,14,"Merge" ,1,1,SDLK_m); // 5 - Window_set_normal_button(C2_X,L3,C2_W,14,"Gray" ,1,1,SDLK_g); // 6 - Window_set_normal_button(C1_X,L1,C1_W,14,"Swap" ,2,1,SDLK_w); // 7 - Window_set_normal_button(C2_X,L1,C2_W,14,"X-Swap" ,1,1,SDLK_x); // 8 - Window_set_normal_button(C3_X,L1,C3_W,14,"Copy" ,1,1,SDLK_c); // 9 - Window_set_normal_button(C3_X,L3,C3_W,14,"Spread" ,4,1,SDLK_e); // 10 + Window_set_normal_button(C4_X,L3,C4_W,14,"Merge" ,1,1,KEY_m); // 5 + Window_set_normal_button(C2_X,L3,C2_W,14,"Gray" ,1,1,KEY_g); // 6 + Window_set_normal_button(C1_X,L1,C1_W,14,"Swap" ,2,1,KEY_w); // 7 + Window_set_normal_button(C2_X,L1,C2_W,14,"X-Swap" ,1,1,KEY_x); // 8 + Window_set_normal_button(C3_X,L1,C3_W,14,"Copy" ,1,1,KEY_c); // 9 + Window_set_normal_button(C3_X,L3,C3_W,14,"Spread" ,4,1,KEY_e); // 10 reduce_dropdown = Window_set_dropdown_button(89, L4, 83, 14, 84, "Reduce", 0, 0, 1, RIGHT_SIDE|LEFT_SIDE, 0); // 11 @@ -1219,22 +1219,22 @@ void Button_Palette(int btn) Window_dropdown_add_item(reduce_dropdown, 2, "to 2"); Window_dropdown_add_item(reduce_dropdown, 0, "Other"); - Window_set_normal_button( 5,178,35,14,"Undo" ,1,1,SDLK_u); // 12 + Window_set_normal_button( 5,178,35,14,"Undo" ,1,1,KEY_u); // 12 Window_set_normal_button(122,178,51,14,"Cancel",0,1,KEY_ESC); // 13 - Window_set_normal_button(177,178,35,14,"OK" ,0,1,SDLK_RETURN); // 14 + Window_set_normal_button(177,178,35,14,"OK" ,0,1,KEY_RETURN); // 14 - Window_set_normal_button(C4_X,L2,C4_W,14,"Used",4,1,SDLK_d); // 15 - Window_set_normal_button(C1_X,L4,83,14,"Zap unused",0,1,SDLK_DELETE);//16 + Window_set_normal_button(C4_X,L2,C4_W,14,"Used",4,1,KEY_d); // 15 + Window_set_normal_button(C1_X,L4,83,14,"Zap unused",0,1,KEY_DELETE);//16 - Window_set_repeatable_button(BUTTON_PLUS_X, BUTTON_PLUS_Y,12,11,"+",0,1,SDLK_KP_PLUS); // 17 - Window_set_repeatable_button(BUTTON_MINUS_X,BUTTON_MINUS_Y,12,11,"-",0,1,SDLK_KP_MINUS); // 18 + Window_set_repeatable_button(BUTTON_PLUS_X, BUTTON_PLUS_Y,12,11,"+",0,1,KEY_KP_PLUS); // 17 + Window_set_repeatable_button(BUTTON_MINUS_X,BUTTON_MINUS_Y,12,11,"-",0,1,KEY_KP_MINUS); // 18 - Window_set_normal_button(C1_X,L3,C1_W,14,"Neg" ,1,1,SDLK_n); // 19 - Window_set_normal_button(C1_X,L2,C1_W,14,"Flip" ,1,1,SDLK_f); // 20 - Window_set_normal_button(C2_X,L2,C2_W,14,"X-Flip" ,5,1,SDLK_i); // 21 + Window_set_normal_button(C1_X,L3,C1_W,14,"Neg" ,1,1,KEY_n); // 19 + Window_set_normal_button(C1_X,L2,C1_W,14,"Flip" ,1,1,KEY_f); // 20 + Window_set_normal_button(C2_X,L2,C2_W,14,"X-Flip" ,5,1,KEY_i); // 21 // Button without outline (RGB/HSL switch) - Window_set_normal_button(NUMERIC_BOX_X,14,81,11,"" ,0,1,SDLK_h); // 22 + Window_set_normal_button(NUMERIC_BOX_X,14,81,11,"" ,0,1,KEY_h); // 22 Window_display_frame_mono(NUMERIC_BOX_X-1,14-1,81+2,11+2,MC_Light); sort_dropdown = Window_set_dropdown_button(C3_X, L2, C3_W, 14, 80, " Sort", 0, @@ -1247,10 +1247,10 @@ void Button_Palette(int btn) // Button without outline Window_display_frame_mono(NUMERIC_BOX_X-1,NUMERIC_BOX_Y-1,NUMERIC_BOX_W+2,NUMERIC_BOX_H+2,MC_Light); - Window_set_normal_button(C4_X,L1,C4_W,14,"Histo",4,1,SDLK_t);// 25 + Window_set_normal_button(C4_X,L1,C4_W,14,"Histo",4,1,KEY_t);// 25 - Window_set_normal_button( 44,178,35,14,"Load" ,1,1,SDLK_l); // 26 - Window_set_normal_button( 83,178,35,14,"Save" ,1,1,SDLK_s); // 27 + Window_set_normal_button( 44,178,35,14,"Load" ,1,1,KEY_l); // 26 + Window_set_normal_button( 83,178,35,14,"Save" ,1,1,KEY_s); // 27 // Dessin des petits effets spéciaux pour les boutons [+] et [-] Draw_thingumajig(BUTTON_PLUS_X-5, BUTTON_PLUS_Y,MC_White,-1); @@ -2703,7 +2703,7 @@ void Button_Palette(int btn) Display_cursor(); Key=0; } - else if (Key == SDLK_BACKSPACE) + else if (Key == KEY_BACKSPACE) // Remise des couleurs du menu à l'état normal en essayant // de ne pas trop modifier l'image. { @@ -2899,9 +2899,9 @@ void Button_Secondary_palette(int btn) (void)btn; Open_window(218,146,"Palettes"); - Window_set_normal_button(10,20,180,14,"Colors for best match",12,1,SDLK_b); // 1 - Window_set_normal_button(10,37,180,14,"User's color series" ,14,1,SDLK_s); // 2 - Window_set_normal_button(155,126,53,14,"OK" , 0,1,SDLK_RETURN); // 3 + Window_set_normal_button(10,20,180,14,"Colors for best match",12,1,KEY_b); // 1 + Window_set_normal_button(10,37,180,14,"User's color series" ,14,1,KEY_s); // 2 + Window_set_normal_button(155,126,53,14,"OK" , 0,1,KEY_RETURN); // 3 Window_set_normal_button( 96,126,53,14,"Cancel" , 0,1,KEY_ESC); // 4 Window_display_frame(10,55,122,66); Print_in_window(18,59,"Palette layout",MC_Dark,MC_Light); @@ -2927,8 +2927,8 @@ void Button_Secondary_palette(int btn) Print_in_window(38,108,(palette_vertical)?"X":" ",MC_Black,MC_Light); Print_in_window(51,108,"Vertical",MC_Dark,MC_Light); - Window_set_normal_button(190,82,18,14,"x2" , 1,1,SDLK_x); // 9 - Window_set_normal_button(137,82,18,14,"\xf7""2" , 0,1,SDLK_w); // 10 + Window_set_normal_button(190,82,18,14,"x2" , 1,1,KEY_x); // 9 + Window_set_normal_button(137,82,18,14,"\xf7""2" , 0,1,KEY_w); // 10 gamma_slider = Window_set_horizontal_scroller_button(137,110,71,30, 1,Gamma*10);// 11 Num2str(Gamma*10,str,2); diff --git a/src/readline.c b/src/readline.c index 0f5c420f..6645236f 100644 --- a/src/readline.c +++ b/src/readline.c @@ -473,11 +473,11 @@ byte Readline_ex_unicode(word x_pos,word y_pos,char * str,word * str_unicode,byt static byte caps_lock=0; static const word keymapping[] = { - SDLK_CLEAR,SDLK_BACKSPACE,SDLK_RETURN,KEY_ESC, + KEY_CLEAR,KEY_BACKSPACE,KEY_RETURN,KEY_ESC, '0','1','2','3','4','5','6','7','8','9','.',',', 'Q','W','E','R','T','Y','U','I','O','P', 'A','S','D','F','G','H','J','K','L', - SDLK_CAPSLOCK,'Z','X','C','V','B','N','M',' ', + KEY_CAPSLOCK,'Z','X','C','V','B','N','M',' ', '-','+','*','/','|','\\', '(',')','{','}','[',']', '_','=','<','>','%','@', @@ -502,7 +502,7 @@ byte Readline_ex_unicode(word x_pos,word y_pos,char * str,word * str_unicode,byt #if defined(__ANDROID__) SDL_ANDROID_GetScreenKeyboardTextInput(str, max_size); - input_key = SDLK_RETURN; + input_key = KEY_RETURN; #else // Virtual keyboards if (Config.Use_virtual_keyboard==1 || @@ -667,7 +667,7 @@ byte Readline_ex_unicode(word x_pos,word y_pos,char * str,word * str_unicode,byt Hide_cursor(); } - while ((input_key!=SDLK_RETURN) && (input_key!=KEY_ESC)) + while ((input_key!=KEY_RETURN) && (input_key!=KEY_ESC)) { Display_cursor(); if (use_virtual_keyboard) @@ -678,11 +678,11 @@ byte Readline_ex_unicode(word x_pos,word y_pos,char * str,word * str_unicode,byt input_key=Key_ANSI; if (clicked_button==-1) - input_key=SDLK_RETURN; + input_key=KEY_RETURN; else if (clicked_button>0) { input_key=keymapping[clicked_button-1]; - if (input_key==SDLK_CAPSLOCK) + if (input_key==KEY_CAPSLOCK) { // toggle uppercase caps_lock=!caps_lock; @@ -690,14 +690,14 @@ byte Readline_ex_unicode(word x_pos,word y_pos,char * str,word * str_unicode,byt Print_in_window(8, 49,caps_lock?"\036":"\037", MC_Black,MC_Light); Display_cursor(); } - else if (input_key==SDLK_BACKSPACE) + else if (input_key==KEY_BACKSPACE) { // A little hack: the button for backspace will: // - backspace if the cursor is at end of string // - delete otherwise // It's needed for those input boxes that are completely full. if (position='A' && input_key<='Z' && !caps_lock) { @@ -712,7 +712,7 @@ byte Readline_ex_unicode(word x_pos,word y_pos,char * str,word * str_unicode,byt Get_input(20); input_key = (str_unicode == NULL) ? Key_ANSI : Key_UNICODE; if (Mouse_K) - input_key=SDLK_RETURN; + input_key=KEY_RETURN; // Handle paste request on CTRL+v if (Key == SHORTCUT_PASTE) @@ -778,7 +778,7 @@ byte Readline_ex_unicode(word x_pos,word y_pos,char * str,word * str_unicode,byt switch (input_key) { - case SDLK_DELETE : // Suppr. + case KEY_DELETE : // Suppr. if (position0) { // Effacement de la chaîne @@ -804,7 +804,7 @@ byte Readline_ex_unicode(word x_pos,word y_pos,char * str,word * str_unicode,byt goto affichage; } break; - case SDLK_RIGHT : // Droite + case KEY_RIGHT : // Droite if ((position 0) { @@ -860,7 +860,7 @@ byte Readline_ex_unicode(word x_pos,word y_pos,char * str,word * str_unicode,byt goto affichage; } break; - case SDLK_CLEAR : // Clear + case KEY_CLEAR : // Clear str[0]='\0'; if (str_unicode != NULL) str_unicode[0] = 0; @@ -868,7 +868,7 @@ byte Readline_ex_unicode(word x_pos,word y_pos,char * str,word * str_unicode,byt // Effacement de la chaîne Window_rectangle(x_pos,y_pos,visible_size<<3,8,BACKGROUND_COLOR); goto affichage; - case SDLK_RETURN : + case KEY_RETURN : break; case KEY_ESC : @@ -995,7 +995,7 @@ affichage: } Update_window_area(x_pos,y_pos,visible_size<<3,8); - return (input_key==SDLK_RETURN); + return (input_key==KEY_RETURN); } void Sprint_double(char *str, double value, byte decimal_places, byte min_positions) diff --git a/src/shade.c b/src/shade.c index 3ec1d1a1..083c5963 100644 --- a/src/shade.c +++ b/src/shade.c @@ -473,11 +473,11 @@ int Menu_shade(void) // Déclaration & tracé des boutons de sortie Window_set_normal_button(207,17,51,14,"Cancel",0,1,KEY_ESC); // 4 - Window_set_normal_button(261,17,43,14,"OK" ,0,1,SDLK_RETURN); // 5 + Window_set_normal_button(261,17,43,14,"OK" ,0,1,KEY_RETURN); // 5 // Déclaration & tracé des boutons de copie de shade - Window_set_normal_button(206,87,27,14,"Cpy" ,1,1,SDLK_c); // 6 - Window_set_normal_button(234,87,43,14,"Paste" ,1,1,SDLK_p); // 7 + Window_set_normal_button(206,87,27,14,"Cpy" ,1,1,KEY_c); // 6 + Window_set_normal_button(234,87,43,14,"Paste" ,1,1,KEY_p); // 7 // On tagge le bloc Tag_color_range(Fore_color,Fore_color); @@ -493,16 +493,16 @@ int Menu_shade(void) Display_all_shade(first_color,last_color,selection_start,selection_end); // Déclaration & tracé des boutons d'édition de shade - Window_set_normal_button( 6,107,27,14,"Ins" ,0,1,SDLK_INSERT); // 8 - Window_set_normal_button( 38,107,27,14,"Del" ,0,1,SDLK_DELETE); // 9 - Window_set_normal_button( 66,107,43,14,"Blank",1,1,SDLK_b); // 10 - Window_set_normal_button(110,107,27,14,"Inv" ,1,1,SDLK_i); // 11 - Window_set_normal_button(138,107,27,14,"Swp" ,1,1,SDLK_s); // 12 + Window_set_normal_button( 6,107,27,14,"Ins" ,0,1,KEY_INSERT); // 8 + Window_set_normal_button( 38,107,27,14,"Del" ,0,1,KEY_DELETE); // 9 + Window_set_normal_button( 66,107,43,14,"Blank",1,1,KEY_b); // 10 + Window_set_normal_button(110,107,27,14,"Inv" ,1,1,KEY_i); // 11 + Window_set_normal_button(138,107,27,14,"Swp" ,1,1,KEY_s); // 12 // Déclaration & tracé des boutons de taggage Print_in_window(268,123,"Disbl"/*"Dsabl"*/,MC_Dark,MC_Light); - Window_set_normal_button(274,133,27,14,"Set" ,0,1,SDLK_F1); // 13 - Window_set_normal_button(274,148,27,14,"Clr" ,0,1,SDLK_F2); // 14 + Window_set_normal_button(274,133,27,14,"Set" ,0,1,KEY_F1); // 13 + Window_set_normal_button(274,148,27,14,"Clr" ,0,1,KEY_F2); // 14 // Déclaration & tracé de la zone de saisie du pas Print_in_window(272,165,"Step",MC_Dark,MC_Light); @@ -511,12 +511,12 @@ int Menu_shade(void) Window_input_content(input_button,str); // Button Undo - Window_set_normal_button(170,107,35,14,"Undo",1,1,SDLK_u); // 16 + Window_set_normal_button(170,107,35,14,"Undo",1,1,KEY_u); // 16 // Button Clear - Window_set_normal_button(278,87,27,14,"Clr",0,1,SDLK_BACKSPACE); // 17 + Window_set_normal_button(278,87,27,14,"Clr",0,1,KEY_BACKSPACE); // 17 // Button Mode - Window_set_normal_button(244,107,60,14,"",0,1,SDLK_TAB); // 18 + Window_set_normal_button(244,107,60,14,"",0,1,KEY_TAB); // 18 // Affichage du n° de shade actif Num2str(Shade_current+1,str,1); @@ -884,11 +884,11 @@ int Menu_shade(void) if (!Mouse_K) switch (Key) { - case SDLK_LEFTBRACKET : // Décaler couleur dans palette vers la gauche - case SDLK_RIGHTBRACKET : // Décaler couleur dans palette vers la droite + case KEY_LEFTBRACKET : // Décaler couleur dans palette vers la gauche + case KEY_RIGHTBRACKET : // Décaler couleur dans palette vers la droite if (first_color==last_color) { - if (Key==SDLK_LEFTBRACKET) + if (Key==KEY_LEFTBRACKET) { first_color--; last_color--; @@ -910,15 +910,15 @@ int Menu_shade(void) Key=0; break; - case SDLK_UP : // Select Haut - case SDLK_DOWN : // Select Bas - case SDLK_LEFT : // Select Gauche - case SDLK_RIGHT : // Select Droite + case KEY_UP : // Select Haut + case KEY_DOWN : // Select Bas + case KEY_LEFT : // Select Gauche + case KEY_RIGHT : // Select Droite if (selection_start==selection_end) { switch (Key) { - case SDLK_UP : // Select Haut + case KEY_UP : // Select Haut if (selection_start>=64) { selection_start-=64; @@ -927,7 +927,7 @@ int Menu_shade(void) else selection_start=selection_end=0; break; - case SDLK_DOWN : // Select Bas + case KEY_DOWN : // Select Bas if (selection_start<448) { selection_start+=64; @@ -936,7 +936,7 @@ int Menu_shade(void) else selection_start=selection_end=511; break; - case SDLK_LEFT : // Select Gauche + case KEY_LEFT : // Select Gauche if (selection_start>0) { selection_start--; @@ -958,8 +958,8 @@ int Menu_shade(void) Key=0; break; - case SDLK_BACKQUOTE : // Récupération d'une couleur derrière le menu - case SDLK_COMMA : + case KEY_BACKQUOTE : // Récupération d'une couleur derrière le menu + case KEY_COMMA : Get_color_behind_window(&color,&click); if (click) { @@ -1058,9 +1058,9 @@ void Button_Quick_shade_menu(void) Open_window(142,56,"Quick-shade"); - Window_set_normal_button(76,36,60,14,"OK",0,1,SDLK_RETURN); // 1 + Window_set_normal_button(76,36,60,14,"OK",0,1,KEY_RETURN); // 1 Window_set_normal_button( 6,36,60,14,"Cancel",0,1,KEY_ESC); // 2 - Window_set_normal_button(76,18,60,14,"",0,1,SDLK_TAB); // 3 + Window_set_normal_button(76,18,60,14,"",0,1,KEY_TAB); // 3 Display_shade_mode(83,21,Quick_shade_loop); // Déclaration & tracé de la zone de saisie du pas diff --git a/src/transform.c b/src/transform.c index 69429c3c..97297840 100644 --- a/src/transform.c +++ b/src/transform.c @@ -119,8 +119,8 @@ void Button_Transform_menu(int btn) Window_set_normal_button(154,140, 54,14,"Cancel",0,1,KEY_ESC); // 1 Print_in_window( 9,114,"Mirror",MC_Dark,MC_Light); - Window_set_normal_button( 17,125, 27,14,"X\035" ,1,1,SDLK_x); // 2 - Window_set_normal_button( 17,140, 27,14,"Y\022" ,1,1,SDLK_y); // 3 + Window_set_normal_button( 17,125, 27,14,"X\035" ,1,1,KEY_x); // 2 + Window_set_normal_button( 17,140, 27,14,"Y\022" ,1,1,KEY_y); // 3 Print_in_window( 84,114,"Rotate",MC_Dark,MC_Light); Window_set_normal_button( 69,125, 37,14,"-90\xb0" ,0,1,KEY_NONE); // 4 @@ -128,7 +128,7 @@ void Button_Transform_menu(int btn) Window_set_normal_button( 69,140, 75,14,"180\xb0" ,0,1,KEY_NONE); // 6 Print_in_window( 87, 19,"Resize",MC_Dark,MC_Light); - Window_set_normal_button( 80, 86, 60,14,"RESIZE",1,1,SDLK_r); // 7 + Window_set_normal_button( 80, 86, 60,14,"RESIZE",1,1,KEY_r); // 7 Print_in_window( 51, 34,"New",MC_Dark,MC_Light); Print_in_window( 96, 34,"Old",MC_Dark,MC_Light); Print_in_window_underscore( 30, 44,"W:",MC_Dark,MC_Light,1); @@ -137,15 +137,15 @@ void Button_Transform_menu(int btn) Print_in_window( 80, 59,":",MC_Dark,MC_Light); Print_in_window_underscore( 44, 75,"Lock proportions",MC_Dark,MC_Light,1); - Window_set_normal_button( 28, 72, 13,13,ratio_is_locked?"X":" ",0,1,SDLK_l);// 8 + Window_set_normal_button( 28, 72, 13,13,ratio_is_locked?"X":" ",0,1,KEY_l);// 8 unit_button = Window_set_dropdown_button(128,50,69,11,69,unit_label[unit_index],1,0,1,LEFT_SIDE|RIGHT_SIDE,0);// 9 Window_dropdown_add_item(unit_button,UNIT_PIXELS,unit_label[UNIT_PIXELS]); Window_dropdown_add_item(unit_button,UNIT_PERCENT,unit_label[UNIT_PERCENT]); Window_dropdown_add_item(unit_button,UNIT_RATIO,unit_label[UNIT_RATIO]); - input_button[0] = Window_set_input_button_s(45,43,4,SDLK_w); // 10 + input_button[0] = Window_set_input_button_s(45,43,4,KEY_w); // 10 input_button[1] = Window_set_input_button(89,43,4); // 11 - input_button[2] = Window_set_input_button_s(45,58,4,SDLK_h); // 12 + input_button[2] = Window_set_input_button_s(45,58,4,KEY_h); // 12 input_button[3] = Window_set_input_button(89,58,4); // 13 Update_window_area(0,0,Window_width, Window_height); diff --git a/src/windows.c b/src/windows.c index 82a76d0e..f697c658 100644 --- a/src/windows.c +++ b/src/windows.c @@ -1355,8 +1355,8 @@ byte Confirmation_box(char * message) c++; } - Window_set_normal_button((window_width/3)-20 ,29+(nb_lines<<3),40,14,"Yes",1,1,SDLK_y); // 1 - Window_set_normal_button(((window_width<<1)/3)-20,29+(nb_lines<<3),40,14,"No" ,1,1,SDLK_n); // 2 + Window_set_normal_button((window_width/3)-20 ,29+(nb_lines<<3),40,14,"Yes",1,1,KEY_y); // 1 + Window_set_normal_button(((window_width<<1)/3)-20,29+(nb_lines<<3),40,14,"No" ,1,1,KEY_n); // 2 Update_window_area(0, 0, Window_width, Window_height); @@ -1365,7 +1365,7 @@ byte Confirmation_box(char * message) do { clicked_button=Window_clicked_button(); - if (Key==SDLK_RETURN) clicked_button=1; + if (Key==KEY_RETURN) clicked_button=1; if (Key==KEY_ESC) clicked_button=2; } while (clicked_button<=0); @@ -1397,8 +1397,8 @@ int Requester_window(char* message, int initial_value) sprintf(str, "%d", initial_value); Window_set_input_button(10, 37, 4); // 1 Print_in_window(11, 39, str, MC_Black, MC_Light); - Window_set_normal_button(60 ,37,40,14,"OK",1,1,SDLK_y); // 2 - Window_set_normal_button(130,37,60,14,"Cancel" ,1,1,SDLK_n); // 3 + Window_set_normal_button(60 ,37,40,14,"OK",1,1,KEY_y); // 2 + Window_set_normal_button(130,37,60,14,"Cancel" ,1,1,KEY_n); // 3 Update_window_area(0, 0, window_width, 60); Display_cursor(); @@ -1408,7 +1408,7 @@ int Requester_window(char* message, int initial_value) clicked_button = Window_clicked_button(); if (clicked_button == 1) Readline(11, 39, str, 4, INPUT_TYPE_INTEGER); - if (Key == SDLK_ESCAPE) clicked_button = 2; + if (Key == KEY_ESCAPE) clicked_button = 2; } while (clicked_button <= 0); @@ -1434,13 +1434,13 @@ void Warning_message(char * message) Open_window(window_width,60,"Warning!"); Print_in_window((window_width>>1)-(strlen(message)<<2),20,message,MC_Black,MC_Light); - Window_set_normal_button((window_width>>1)-20 ,37,40,14,"OK",1,1,SDLK_RETURN); // 1 + Window_set_normal_button((window_width>>1)-20 ,37,40,14,"OK",1,1,KEY_RETURN); // 1 Update_window_area(0,0,window_width,60); Display_cursor(); do clicked_button=Window_clicked_button(); - while ((clicked_button<=0) && (Key!=KEY_ESC) && (Key!=SDLK_o)); + while ((clicked_button<=0) && (Key!=KEY_ESC) && (Key!=KEY_o)); Key=0; Close_window(); @@ -1508,14 +1508,14 @@ void Verbose_message(const char *caption, const char * message ) message++; } - Window_set_normal_button(300/2-20,160-23,40,14,"OK",1,1,SDLK_RETURN); // 1 + Window_set_normal_button(300/2-20,160-23,40,14,"OK",1,1,KEY_RETURN); // 1 Update_window_area(0,0,Window_width,Window_height); Cursor_shape=CURSOR_SHAPE_ARROW; Display_cursor(); do clicked_button=Window_clicked_button(); - while ((clicked_button<=0) && (Key!=KEY_ESC) && (Key!=SDLK_o)); + while ((clicked_button<=0) && (Key!=KEY_ESC) && (Key!=KEY_o)); Key=0; Close_window(); @@ -1852,6 +1852,7 @@ void Compute_paintbrush_coordinates(void) Snap_axis=0; break; // Operations that implement it +#if defined(USE_SDL) || defined(USE_SDL2) default: if (Snap_axis==0 && (SDL_GetModState() & KMOD_SHIFT)) { @@ -1860,6 +1861,7 @@ void Compute_paintbrush_coordinates(void) Snap_axis_origin_X=Paintbrush_X; Snap_axis_origin_Y=Paintbrush_Y; } +#endif } if (Snap_axis==1) diff --git a/tools/generate_keycodes.py b/tools/generate_keycodes.py new file mode 100755 index 00000000..80ea4e2d --- /dev/null +++ b/tools/generate_keycodes.py @@ -0,0 +1,76 @@ +#!/usr/bin/env python +# (c) 2018 Thomas Bernard + +#import sys + +filename = '../src/keycodes.h' + +keys = ['UNKNOWN', + 'ESCAPE', 'RETURN', 'BACKSPACE', 'TAB', + 'UP', 'DOWN', 'LEFT', 'RIGHT', + 'LEFTBRACKET', 'RIGHTBRACKET', + 'INSERT', 'DELETE', 'COMMA', 'BACKQUOTE', + 'PAGEUP', 'PAGEDOWN', 'HOME', 'END', + 'KP_PLUS', 'KP_MINUS', 'KP_MULTIPLY', 'KP_ENTER', + 'EQUALS', 'MINUS', 'PERIOD', + 'CAPSLOCK', 'CLEAR', 'SPACE'] + +def keycode_def(section, key, index, sdl_key=None): + if section == 'SDL and SDL2': + if sdl_key is None: + sdl_key = key + return '#define KEY_%-12s K2K(SDLK_%s)\n' % (key, sdl_key) + else: + return '#define KEY_%-12s %d\n' % (key, index) + +def add_keycodes_defs(section, lines): + global keys + i = 0 + for key in keys: + lines.append(keycode_def(section, key, i)) + i = i + 1 + for j in range(10): + lines.append(keycode_def(section, chr(ord('0') + j), i)) + i = i + 1 + for j in range(26): + lines.append(keycode_def(section, chr(ord('a') + j), i)) + i = i + 1 + if section == 'SDL and SDL2': + lines.append('#if defined(USE_SDL)\n') + for j in range(10): + key = "KP%d" % (j) + lines.append(keycode_def(section, key, i)) + i = i + 1 + if section == 'SDL and SDL2': + lines.append('#else\n') + for j in range(10): + key = "KP%d" % (j) + sdl_key = 'KP_%d' % (j) + lines.append(keycode_def(section, key, 0, sdl_key)) + lines.append('#endif\n') + for j in range(1,13): + key = "F%d" % (j) + lines.append(keycode_def(section, key, i)) + i = i + 1 + +def update_keycodes(filename): + output = [] + with open(filename) as f: + skipping = False + for line in f: + if skipping: + if line.startswith('// end of KEY definitions'): + output.append(line) + skipping = False + else: + output.append(line) + if line.startswith('// KEY definitions for '): + section = line[23:].strip() + print 'section "%s"' % (section) + skipping = True + add_keycodes_defs(section, output) + with open(filename, "w") as f: + for line in output: + f.write(line) + +update_keycodes(filename)