diff --git a/src/Makefile b/src/Makefile index eb0c0ce4..dd40aa11 100644 --- a/src/Makefile +++ b/src/Makefile @@ -57,7 +57,7 @@ ifdef COMSPEC RMDIR = rmdir --ignore-fail-on-non-empty CP = cp BIN = ../bin/grafx2.exe - COPT = -W -Wall -Wdeclaration-after-statement -O$(OPTIM) -g -ggdb `sdl-config --cflags` $(TTFCOPT) $(JOYCOPT) $(VKEYCOPT) $(LUACOPT) + COPT = -W -Wall -Wdeclaration-after-statement -O$(OPTIM) -g -ggdb `sdl-config --cflags` $(TTFCOPT) $(JOYCOPT) $(LUACOPT) LOPT = `sdl-config --libs` -lSDL_image $(TTFLOPT) -lpng14 $(LUALOPT) LUALOPT = -llua CC = gcc @@ -268,7 +268,7 @@ endif LUACOPT = -I/resources/indexes/include LUALOPT = -llua BIN = ../bin/grafx2 - COPT = -W -Wall -Wdeclaration-after-statement -std=c99 -c -g `sdl-config --cflags` -I/resources/indexes/include/SDL $(TTFCOPT) $(LUACOPT) $(JOYCOPT) $(VKEYCOPT) -O$(OPTIM) + COPT = -W -Wall -Wdeclaration-after-statement -std=c99 -c -g `sdl-config --cflags` -I/resources/indexes/include/SDL $(TTFCOPT) $(LUACOPT) $(JOYCOPT) -O$(OPTIM) LOPT = `sdl-config --libs` -lSDL_image $(TTFLOPT) -lpng -lz $(LUALOPT) -lm CC = gcc OBJDIR = ../obj/syllable @@ -306,7 +306,7 @@ endif #cross compile an exec for the gp2x CC = /opt/open2x/gcc-4.1.1-glibc-2.3.6/arm-open2x-linux/bin/arm-open2x-linux-gcc BIN = ../bin/grafx2.gpe - COPT = -W -Wall -Wdeclaration-after-statement -pedantic -std=c99 -static -g -O$(OPTIM) -I/opt/open2x/gcc-4.1.1-glibc-2.3.6/include `/opt/open2x/gcc-4.1.1-glibc-2.3.6/bin/sdl-config --cflags` $(TTFCOPT) -D__GP2X__ $(TTFCOPT) $(JOYCOPT) $(VKEYCOPT) $(LUACOPT) + COPT = -W -Wall -Wdeclaration-after-statement -pedantic -std=c99 -static -g -O$(OPTIM) -I/opt/open2x/gcc-4.1.1-glibc-2.3.6/include `/opt/open2x/gcc-4.1.1-glibc-2.3.6/bin/sdl-config --cflags` $(TTFCOPT) -D__GP2X__ $(TTFCOPT) $(JOYCOPT) $(LUACOPT) LOPT = -static -lSDL_image `/opt/open2x/gcc-4.1.1-glibc-2.3.6/bin/sdl-config --static-libs` -ljpeg -lpng -lz -lm $(TTFLOPT) $(LUALOPT) OBJDIR = ../obj/gp2x NOTTF = 1 @@ -346,7 +346,7 @@ endif # Compiles a regular linux executable for the native platform BIN = ../bin/grafx2 - COPT = -W -Wall -Wdeclaration-after-statement -std=c99 -c -g `sdl-config --cflags` $(TTFCOPT) $(LUACOPT) $(JOYCOPT) $(VKEYCOPT) -O$(OPTIM) `pkg-config --cflags libpng` + COPT = -W -Wall -Wdeclaration-after-statement -std=c99 -c -g `sdl-config --cflags` $(TTFCOPT) $(LUACOPT) $(JOYCOPT) -O$(OPTIM) `pkg-config --cflags libpng` LOPT = `sdl-config --libs` -lSDL_image $(TTFLOPT) `pkg-config --libs libpng` $(LUALOPT) -lm CC = gcc OBJDIR = ../obj/unix @@ -417,13 +417,6 @@ ifeq ($(USE_JOYSTICK),1) JOYCOPT = -DUSE_JOYSTICK endif -#To enable virtual keyboard input (mouse-driven), make VIRT_KEY=1 -#This is automatically enabled on some platforms, but this -#switch allows you to test the virtual keyboard on any other platform. -ifeq ($(VIRT_KEY),1) - VKEYCOPT = -DVIRT_KEY -endif - ### And now for the real build rules ### .PHONY : all debug release clean depend zip version force install uninstall diff --git a/src/buttons.c b/src/buttons.c index fc236da8..7c549570 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -756,6 +756,13 @@ const T_Lookup Lookup_SwapButtons[] = { {NULL,-1}, }; +const T_Lookup Lookup_VirtualKeyboard[] = { + {"Auto",0}, + {"ON",1}, + {"OFF",2}, + {NULL,-1}, +}; + typedef struct { const char* Label; byte Type; // 0: label, 1+: setting (size in bytes) @@ -937,7 +944,7 @@ void Button_Settings(void) //{" horizontally:",1,&(selected_config.Mouse_sensitivity_index_x),1,4,0,Lookup_MouseSpeed}, //{" vertically:",1,&(selected_config.Mouse_sensitivity_index_y),1,4,0,Lookup_MouseSpeed}, {"Key to swap buttons:",2,&(selected_config.Swap_buttons),0,0,0,Lookup_SwapButtons}, - {"",0,NULL,0,0,0,NULL}, + {"Virtual keyboard",1,&(selected_config.Use_virtual_keyboard),0,2,0,Lookup_VirtualKeyboard}, {"",0,NULL,0,0,0,NULL}, {"",0,NULL,0,0,0,NULL}, diff --git a/src/helpfile.h b/src/helpfile.h index 60f12833..f62688dd 100644 --- a/src/helpfile.h +++ b/src/helpfile.h @@ -2473,6 +2473,15 @@ static const T_Help_table helptable_settings_details[] = HELP_TEXT ("controllers, such as touchscreens and") HELP_TEXT ("tablets.") HELP_TEXT ("") + HELP_BOLD (" Virtual keyboard") + HELP_TEXT ("This setting activates a graphical 'virtual") + HELP_TEXT ("keyboard' whenever you have to type text in") + HELP_TEXT ("a menu. It's designed for devices that don't") + HELP_TEXT ("provide a physical keyboard, such as tablet") + HELP_TEXT ("PCs and portable consoles. The default") + HELP_TEXT ("setting 'auto' means ON for a portable") + HELP_TEXT ("console and OFF for all others.") + HELP_TEXT ("") HELP_TITLE("EDITING") HELP_TEXT ("") HELP_TEXT ("") diff --git a/src/readini.c b/src/readini.c index fb175b5e..ba41f4bc 100644 --- a/src/readini.c +++ b/src/readini.c @@ -979,7 +979,13 @@ int Load_INI(T_Config * conf) conf->Tilemap_show_count=(values[0]!=0); } - + conf->Use_virtual_keyboard=0; + // Optional, enables virtual keyboard (>=2.4) + if (!Load_INI_get_values (file,buffer,"Use_virtual_keyboard",1,values)) + { + if (values[0]>=0 && values[0]<=2) + conf->Use_virtual_keyboard=values[0]; + } // Insert new values here diff --git a/src/readline.c b/src/readline.c index fd7b30de..adb3c4ed 100644 --- a/src/readline.c +++ b/src/readline.c @@ -51,11 +51,11 @@ #include #endif -// Virtual keyboard is mandatory on these platforms: +// Virtual keyboard is ON by default on these platforms: #if defined(__GP2X__) || defined(__WIZ__) || defined(__CAANOO__) - #ifndef VIRT_KEY - #define VIRT_KEY 1 - #endif + #define VIRT_KEY_DEFAULT_ON 1 +#else + #define VIRT_KEY_DEFAULT_ON 0 #endif #define TEXT_COLOR MC_Black @@ -369,7 +369,6 @@ byte Readline_ex(word x_pos,word y_pos,char * str,byte visible_size,byte max_siz word window_y=Window_pos_Y; byte offset=0; // index du premier caractère affiché -#ifdef VIRT_KEY // Virtual keyboard byte use_virtual_keyboard=0; static byte caps_lock=0; @@ -386,7 +385,6 @@ byte Readline_ex(word x_pos,word y_pos,char * str,byte visible_size,byte max_siz ':',';','`','\'','"','~', '!','?','^','&','#','$' }; -#endif // Si on a commencé à editer par un clic-droit, on vide la chaine. if (Mouse_K==RIGHT_SIDE) @@ -404,110 +402,112 @@ byte Readline_ex(word x_pos,word y_pos,char * str,byte visible_size,byte max_siz } // Virtual keyboards -#ifdef VIRT_KEY - if (input_type == INPUT_TYPE_STRING || input_type == INPUT_TYPE_FILENAME ) + if (Config.Use_virtual_keyboard==1 || + (VIRT_KEY_DEFAULT_ON && Config.Use_virtual_keyboard==0)) { - int x,y; - - Init_virtual_keyboard(y_pos, 320, 87); - - use_virtual_keyboard=1; - - // The order is important, see the array - - Window_set_normal_button( 7,67,43,15,"Clr", 0,1,KEY_NONE); - Window_set_normal_button( 51,67,43,15,"Del", 0,1,KEY_NONE); - Window_set_normal_button( 95,67,43,15,"OK", 0,1,KEY_NONE); - Window_set_normal_button(139,67,43,15,"Esc", 0,1,KEY_NONE); - Window_display_frame_in(5,65,179,19); - - Window_set_normal_button(193,63,17,19,"0", 0,1,KEY_NONE); - Window_set_normal_button(193,43,17,19,"1", 0,1,KEY_NONE); - Window_set_normal_button(211,43,17,19,"2", 0,1,KEY_NONE); - Window_set_normal_button(229,43,17,19,"3", 0,1,KEY_NONE); - Window_set_normal_button(193,23,17,19,"4", 0,1,KEY_NONE); - Window_set_normal_button(211,23,17,19,"5", 0,1,KEY_NONE); - Window_set_normal_button(229,23,17,19,"6", 0,1,KEY_NONE); - Window_set_normal_button(193, 3,17,19,"7", 0,1,KEY_NONE); - Window_set_normal_button(211, 3,17,19,"8", 0,1,KEY_NONE); - Window_set_normal_button(229, 3,17,19,"9", 0,1,KEY_NONE); - Window_set_normal_button(211,63,17,19,".", 0,1,KEY_NONE); - Window_set_normal_button(229,63,17,19,",", 0,1,KEY_NONE); - - Window_set_normal_button( 3, 3,18,19,"Q", 0,1,KEY_NONE); - Window_set_normal_button( 22, 3,18,19,"W", 0,1,KEY_NONE); - Window_set_normal_button( 41, 3,18,19,"E", 0,1,KEY_NONE); - Window_set_normal_button( 60, 3,18,19,"R", 0,1,KEY_NONE); - Window_set_normal_button( 79, 3,18,19,"T", 0,1,KEY_NONE); - Window_set_normal_button( 98, 3,18,19,"Y", 0,1,KEY_NONE); - Window_set_normal_button(117, 3,18,19,"U", 0,1,KEY_NONE); - Window_set_normal_button(136, 3,18,19,"I", 0,1,KEY_NONE); - Window_set_normal_button(155, 3,18,19,"O", 0,1,KEY_NONE); - Window_set_normal_button(174, 3,18,19,"P", 0,1,KEY_NONE); - - Window_set_normal_button( 12,23,18,19,"A", 0,1,KEY_NONE); - Window_set_normal_button( 31,23,18,19,"S", 0,1,KEY_NONE); - Window_set_normal_button( 50,23,18,19,"D", 0,1,KEY_NONE); - Window_set_normal_button( 69,23,18,19,"F", 0,1,KEY_NONE); - Window_set_normal_button( 88,23,18,19,"G", 0,1,KEY_NONE); - Window_set_normal_button(107,23,18,19,"H", 0,1,KEY_NONE); - Window_set_normal_button(126,23,18,19,"J", 0,1,KEY_NONE); - Window_set_normal_button(145,23,18,19,"K", 0,1,KEY_NONE); - Window_set_normal_button(164,23,18,19,"L", 0,1,KEY_NONE); - - Window_set_normal_button( 3,43,18,19,caps_lock?"\036":"\037", 0,1,KEY_NONE); - Window_set_normal_button( 22,43,18,19,"Z", 0,1,KEY_NONE); - Window_set_normal_button( 41,43,18,19,"X", 0,1,KEY_NONE); - Window_set_normal_button( 60,43,18,19,"C", 0,1,KEY_NONE); - Window_set_normal_button( 79,43,18,19,"V", 0,1,KEY_NONE); - Window_set_normal_button( 98,43,18,19,"B", 0,1,KEY_NONE); - Window_set_normal_button(117,43,18,19,"N", 0,1,KEY_NONE); - Window_set_normal_button(136,43,18,19,"M", 0,1,KEY_NONE); - Window_set_normal_button(155,43,18,19," ", 0,1,KEY_NONE); - - for (y=0; y<5; y++) + if (input_type == INPUT_TYPE_STRING || input_type == INPUT_TYPE_FILENAME ) { - for (x=0; x<6; x++) + int x,y; + + Init_virtual_keyboard(y_pos, 320, 87); + + use_virtual_keyboard=1; + + // The order is important, see the array + + Window_set_normal_button( 7,67,43,15,"Clr", 0,1,KEY_NONE); + Window_set_normal_button( 51,67,43,15,"Del", 0,1,KEY_NONE); + Window_set_normal_button( 95,67,43,15,"OK", 0,1,KEY_NONE); + Window_set_normal_button(139,67,43,15,"Esc", 0,1,KEY_NONE); + Window_display_frame_in(5,65,179,19); + + Window_set_normal_button(193,63,17,19,"0", 0,1,KEY_NONE); + Window_set_normal_button(193,43,17,19,"1", 0,1,KEY_NONE); + Window_set_normal_button(211,43,17,19,"2", 0,1,KEY_NONE); + Window_set_normal_button(229,43,17,19,"3", 0,1,KEY_NONE); + Window_set_normal_button(193,23,17,19,"4", 0,1,KEY_NONE); + Window_set_normal_button(211,23,17,19,"5", 0,1,KEY_NONE); + Window_set_normal_button(229,23,17,19,"6", 0,1,KEY_NONE); + Window_set_normal_button(193, 3,17,19,"7", 0,1,KEY_NONE); + Window_set_normal_button(211, 3,17,19,"8", 0,1,KEY_NONE); + Window_set_normal_button(229, 3,17,19,"9", 0,1,KEY_NONE); + Window_set_normal_button(211,63,17,19,".", 0,1,KEY_NONE); + Window_set_normal_button(229,63,17,19,",", 0,1,KEY_NONE); + + Window_set_normal_button( 3, 3,18,19,"Q", 0,1,KEY_NONE); + Window_set_normal_button( 22, 3,18,19,"W", 0,1,KEY_NONE); + Window_set_normal_button( 41, 3,18,19,"E", 0,1,KEY_NONE); + Window_set_normal_button( 60, 3,18,19,"R", 0,1,KEY_NONE); + Window_set_normal_button( 79, 3,18,19,"T", 0,1,KEY_NONE); + Window_set_normal_button( 98, 3,18,19,"Y", 0,1,KEY_NONE); + Window_set_normal_button(117, 3,18,19,"U", 0,1,KEY_NONE); + Window_set_normal_button(136, 3,18,19,"I", 0,1,KEY_NONE); + Window_set_normal_button(155, 3,18,19,"O", 0,1,KEY_NONE); + Window_set_normal_button(174, 3,18,19,"P", 0,1,KEY_NONE); + + Window_set_normal_button( 12,23,18,19,"A", 0,1,KEY_NONE); + Window_set_normal_button( 31,23,18,19,"S", 0,1,KEY_NONE); + Window_set_normal_button( 50,23,18,19,"D", 0,1,KEY_NONE); + Window_set_normal_button( 69,23,18,19,"F", 0,1,KEY_NONE); + Window_set_normal_button( 88,23,18,19,"G", 0,1,KEY_NONE); + Window_set_normal_button(107,23,18,19,"H", 0,1,KEY_NONE); + Window_set_normal_button(126,23,18,19,"J", 0,1,KEY_NONE); + Window_set_normal_button(145,23,18,19,"K", 0,1,KEY_NONE); + Window_set_normal_button(164,23,18,19,"L", 0,1,KEY_NONE); + + Window_set_normal_button( 3,43,18,19,caps_lock?"\036":"\037", 0,1,KEY_NONE); + Window_set_normal_button( 22,43,18,19,"Z", 0,1,KEY_NONE); + Window_set_normal_button( 41,43,18,19,"X", 0,1,KEY_NONE); + Window_set_normal_button( 60,43,18,19,"C", 0,1,KEY_NONE); + Window_set_normal_button( 79,43,18,19,"V", 0,1,KEY_NONE); + Window_set_normal_button( 98,43,18,19,"B", 0,1,KEY_NONE); + Window_set_normal_button(117,43,18,19,"N", 0,1,KEY_NONE); + Window_set_normal_button(136,43,18,19,"M", 0,1,KEY_NONE); + Window_set_normal_button(155,43,18,19," ", 0,1,KEY_NONE); + + for (y=0; y<5; y++) { - char label[2]=" "; - label[0]=keymapping[x+y*6+44]; - Window_set_normal_button(247+x*12, 3+y*16,11,15,label, 0,1,KEY_NONE); + for (x=0; x<6; x++) + { + char label[2]=" "; + label[0]=keymapping[x+y*6+44]; + Window_set_normal_button(247+x*12, 3+y*16,11,15,label, 0,1,KEY_NONE); + } } + + Update_window_area(0,0,Window_width, Window_height); + Display_cursor(); + } + else if (input_type == INPUT_TYPE_INTEGER || input_type == INPUT_TYPE_DECIMAL ) + { + Init_virtual_keyboard(y_pos, 215, 47); + + use_virtual_keyboard=1; + + // The order is important, see the array + + Window_set_normal_button( 7,27,43,15,"Clr", 0,1,KEY_NONE); + Window_set_normal_button( 51,27,43,15,"Del", 0,1,KEY_NONE); + Window_set_normal_button( 95,27,43,15,"OK", 0,1,KEY_NONE); + Window_set_normal_button(139,27,43,15,"Esc", 0,1,KEY_NONE); + Window_display_frame_in(5,25,179,19); + + Window_set_normal_button(174, 3,18,19,"0", 0,1,KEY_NONE); + Window_set_normal_button( 3, 3,18,19,"1", 0,1,KEY_NONE); + Window_set_normal_button( 22, 3,18,19,"2", 0,1,KEY_NONE); + Window_set_normal_button( 41, 3,18,19,"3", 0,1,KEY_NONE); + Window_set_normal_button( 60, 3,18,19,"4", 0,1,KEY_NONE); + Window_set_normal_button( 79, 3,18,19,"5", 0,1,KEY_NONE); + Window_set_normal_button( 98, 3,18,19,"6", 0,1,KEY_NONE); + Window_set_normal_button(117, 3,18,19,"7", 0,1,KEY_NONE); + Window_set_normal_button(136, 3,18,19,"8", 0,1,KEY_NONE); + Window_set_normal_button(155, 3,18,19,"9", 0,1,KEY_NONE); + Window_set_normal_button(193, 3,18,19,".", 0,1,KEY_NONE); + + Update_window_area(0,0,Window_width, Window_height); + Display_cursor(); } - - Update_window_area(0,0,Window_width, Window_height); - Display_cursor(); } - else if (input_type == INPUT_TYPE_INTEGER || input_type == INPUT_TYPE_DECIMAL ) - { - Init_virtual_keyboard(y_pos, 215, 47); - - use_virtual_keyboard=1; - - // The order is important, see the array - - Window_set_normal_button( 7,27,43,15,"Clr", 0,1,KEY_NONE); - Window_set_normal_button( 51,27,43,15,"Del", 0,1,KEY_NONE); - Window_set_normal_button( 95,27,43,15,"OK", 0,1,KEY_NONE); - Window_set_normal_button(139,27,43,15,"Esc", 0,1,KEY_NONE); - Window_display_frame_in(5,25,179,19); - - Window_set_normal_button(174, 3,18,19,"0", 0,1,KEY_NONE); - Window_set_normal_button( 3, 3,18,19,"1", 0,1,KEY_NONE); - Window_set_normal_button( 22, 3,18,19,"2", 0,1,KEY_NONE); - Window_set_normal_button( 41, 3,18,19,"3", 0,1,KEY_NONE); - Window_set_normal_button( 60, 3,18,19,"4", 0,1,KEY_NONE); - Window_set_normal_button( 79, 3,18,19,"5", 0,1,KEY_NONE); - Window_set_normal_button( 98, 3,18,19,"6", 0,1,KEY_NONE); - Window_set_normal_button(117, 3,18,19,"7", 0,1,KEY_NONE); - Window_set_normal_button(136, 3,18,19,"8", 0,1,KEY_NONE); - Window_set_normal_button(155, 3,18,19,"9", 0,1,KEY_NONE); - Window_set_normal_button(193, 3,18,19,".", 0,1,KEY_NONE); - - Update_window_area(0,0,Window_width, Window_height); - Display_cursor(); - } -#endif Keyboard_click_allowed = 0; Hide_cursor(); @@ -546,7 +546,6 @@ byte Readline_ex(word x_pos,word y_pos,char * str,byte visible_size,byte max_siz while ((input_key!=SDLK_RETURN) && (input_key!=KEY_ESC)) { Display_cursor(); -#ifdef VIRT_KEY if (use_virtual_keyboard) { int clicked_button; @@ -583,7 +582,6 @@ byte Readline_ex(word x_pos,word y_pos,char * str,byte visible_size,byte max_siz } } else -#endif { do { @@ -751,7 +749,6 @@ affichage: } // End du "while" Keyboard_click_allowed = 1; - #ifdef VIRT_KEY if (use_virtual_keyboard) { byte old_mouse_k = Mouse_K; @@ -759,7 +756,6 @@ affichage: Mouse_K=old_mouse_k; Input_sticky_control=0; } - #endif // Effacement de la chaîne Block(window_x+(x_pos*Menu_factor_X),window_y+(y_pos*Menu_factor_Y), diff --git a/src/saveini.c b/src/saveini.c index cb4f0cc4..0e250a91 100644 --- a/src/saveini.c +++ b/src/saveini.c @@ -717,6 +717,10 @@ int Save_INI(T_Config * conf) if ((return_code=Save_INI_set_values (old_file,new_file,buffer,"Tilemap_count",1,values,1))) goto Erreur_Retour; + values[0]=conf->Use_virtual_keyboard; + if ((return_code=Save_INI_set_values (old_file,new_file,buffer,"Use_virtual_keyboard",1,values,0))) + goto Erreur_Retour; + // Insert new values here diff --git a/src/struct.h b/src/struct.h index 1877d996..da1cc3a7 100644 --- a/src/struct.h +++ b/src/struct.h @@ -373,7 +373,7 @@ typedef struct byte Tilemap_allow_flipped_x; ///< Boolean, true if the Tilemap tool should detect x-flipped tiles. byte Tilemap_allow_flipped_y; ///< Boolean, true if the Tilemap tool should detect y-flipped tiles. byte Tilemap_show_count; ///< Boolean, true if the Tilemap tool should display tile count after analysis. - + byte Use_virtual_keyboard; ///< 0: Auto, 1: On, 2: Off } T_Config;