From c86f7fbbd8a6c2c500034e16f7238d9a1bf1a608 Mon Sep 17 00:00:00 2001 From: "olimpieri.fabio" Date: Sun, 23 Nov 2014 11:03:29 +0000 Subject: [PATCH] Virtual Keyboard for 320X240 resolution --- Makefile.wii | 1 + images/kb_amiga_small.png | Bin 0 -> 2881 bytes src/gfx-sdl/sdlgfx.c | 14 ++++++-------- src/gui-sdl/VirtualKeyboard.c | 33 ++++++++++++++++++++++----------- src/gui-sdl/menu.c | 12 +++++++++++- src/targets/t-wii.h | 1 + 6 files changed, 41 insertions(+), 20 deletions(-) create mode 100644 images/kb_amiga_small.png diff --git a/Makefile.wii b/Makefile.wii index 368fc7b..54e0ec5 100644 --- a/Makefile.wii +++ b/Makefile.wii @@ -203,6 +203,7 @@ dist:uae.dol cp FreeMono.ttf $@/apps/uae/ cp README.Cloanto-Amiga_Forever $@/apps/uae/docs/ cp images/kb_amiga.png $@/apps/uae/images/ + cp images/kb_amiga_small.png $@/apps/uae/images/ cp uaerc.wii $@/uae/uaerc cp uaerc.smb $@/uae/ cp docs/configuration.txt $@/apps/uae/docs/ diff --git a/images/kb_amiga_small.png b/images/kb_amiga_small.png new file mode 100644 index 0000000000000000000000000000000000000000..55074ca1ed62f4ca551fc5afab212b086c883572 GIT binary patch literal 2881 zcmV-H3%>M;P)WFU8GbZ8()Nlj2>E@cM*01Bl^L_t(|+U=dej@&j3 zhCPG1<-vO2MRIPRqOZ_CMehlA&+UWd5+K>0ywD1=Es+#W$=?qYvy+Z2nxcMD5-Ht& z|Lfnk1pojpf;%bz06=;G008L$005*100594002OG000mGkM)m#{`?JX005@NAAkRc zrw0IFdJ6ymkRAX4KzaZG0Oc7JC%k@pegFIE^V9pkt$$0)r{6~^UwU3I9ec?bwT;rU zEzbiNC%tq;%}3YT(N=3{x$)*5)3dx*{$3rg^vsre(%GM+;LMpvu zi`>@lsL`=Sc>qj2J?WycwRhI)$!MpSrTRVJ|EzbE>R94wTFVcBiKmx(dFvYAXuDt* z(`!u!W9kJ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3R%hyYg`#*~YUMh;Jz6WN9f3U+8@cmZ zdA_}VA9bxJf-UwUoR#=SBD~T1@_iW$lDynCiMnS#ug6KpGlENY=4iv#J|jJ|uTq-66Wk`89a*&f;`x$misZXE zJ8MT+&y&Wvd6XH|CijT0`5D}M3ji2l31ln$taRkR>c9cdkwyY`ljlPOZ|-W-?op1W zw^##Kujy$>M{-AQiF8LhbP*hPKCMky*yYvGyB}$CZ*!X{{atG_rn|Sfv6Q|atQ}cKi6#erHo>Mv+@ z@A+A37H6xSAw%gId&Xb$doLNb%1dOh)QP73E!)CcuA_IJ{d_^wqowwgR7(EV81q&l zdCf>%`rhh&w0dtnWH|DoTD*WQ?_BH2?X_LrhOHj7rB19pPwRTMo@A=uy!~7H(hM+5 zL#t`DErZt(p2t+7#;DGaL82?~HLqNT+zuk?BvQR++S2T6fRA1ceALjI#oWB?p4XL< zQ9jbOtX~}&q^As93+G29oYr}?_+FCHLWVs%u~<@&>O@L5ntJy)jZ^N2Cch<(7 zCl0TGyxnf6j>>C15;C;QVCmI(%CJ?&qAj$$#Ur;x51SkbCRad$*f@KXmQLwBLODG3 zMcBxIp5B=t`W+dNA+8KldU_FF3>lCC8OA4_DB!>W005*100594002yY_cgtBkq-a> f@bmxxU=sWfm@bACycXWn00000NkvXXu0mjfiolH< literal 0 HcmV?d00001 diff --git a/src/gfx-sdl/sdlgfx.c b/src/gfx-sdl/sdlgfx.c index bb8c5d5..826b176 100644 --- a/src/gfx-sdl/sdlgfx.c +++ b/src/gfx-sdl/sdlgfx.c @@ -46,10 +46,8 @@ #include "inputdevice.h" #include "hotkeys.h" #include "sdlgfx.h" - -#ifdef USE_SDL #include "guidep/menu.h" -#endif + /* Uncomment for debugging output */ //#define DEBUG @@ -945,9 +943,9 @@ static int graphics_subinit (void) gui_message ("Unable to set video mode: %s\n", SDL_GetError ()); return 0; } else { -#ifdef USE_SDL + menu_init(screen); //GEKKO -#endif + /* Just in case we didn't get exactly what we asked for . . . */ fullscreen = ((screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN); is_hwsurface = ((screen->flags & SDL_HWSURFACE) == SDL_HWSURFACE); @@ -1112,6 +1110,9 @@ static void graphics_subshutdown (void) if (display != screen) SDL_FreeSurface (screen); } + + menu_deinit(); //GEKKO + display = screen = 0; mousehack = 0; @@ -1144,9 +1145,6 @@ void graphics_leave (void) graphics_subshutdown (); SDL_QuitSubSystem(SDL_INIT_VIDEO); dumpcustom (); -#ifdef USE_SDL - menu_deinit(); //GEKKO -#endif } void graphics_notify_state (int state) diff --git a/src/gui-sdl/VirtualKeyboard.c b/src/gui-sdl/VirtualKeyboard.c index 210a124..38216e9 100644 --- a/src/gui-sdl/VirtualKeyboard.c +++ b/src/gui-sdl/VirtualKeyboard.c @@ -24,6 +24,14 @@ #include "target.h" #include "gensound.h" +/* Uncomment for debugging output */ +//#define DEBUG_VK +#ifdef DEBUG_VK +#define DEBUG_LOG write_log +#else +#define DEBUG_LOG(...) do {} while(0) +#endif + static SDL_Surface *image_kbd, *tmp_surface ; static int vkb_is_init; //static int key_code; @@ -68,14 +76,15 @@ static int buttons_margins[KEY_ROWS][KEY_COLS+1] = { {28,63,95,329,361,396,515,567,593,620}, {14,80,146,212,278,344,411,476,543}}; - +extern int RATIO; void VirtualKeyboard_init(SDL_Surface *screen) { + if (vkb_is_init) return; + VirtualKeyboard.screen = screen; - VirtualKeyboard.x = 3; //Where to print the keyboard - VirtualKeyboard.y = 100; - vkb_is_init = -1; + VirtualKeyboard.x = 2/RATIO; //Where to print the keyboard + VirtualKeyboard.y = 100/RATIO; char kbd_image[255]; @@ -91,7 +100,7 @@ void VirtualKeyboard_init(SDL_Surface *screen) } #endif - strcat (kbd_image, KBDIMAGE); + if (RATIO == 1) strcat (kbd_image, KBDIMAGE); else strcat (kbd_image, KBDIMAGE_SMALL); tmp_surface=IMG_Load(kbd_image); @@ -102,19 +111,23 @@ void VirtualKeyboard_init(SDL_Surface *screen) memset(VirtualKeyboard.buf, 0, sizeof(VirtualKeyboard.buf)); vkb_is_init = 1; kbd_is_active=0; + DEBUG_LOG("Virtual keyboard is inited\n"); } void VirtualKeyboard_fini(void) { + if (!vkb_is_init) return; + SDL_FreeSurface (image_kbd); - vkb_is_init = -1; + vkb_is_init = 0; kbd_is_active = 0; + DEBUG_LOG("Virtual keyboard is finished\n"); } void draw_vk() { SDL_Rect dst_rect = {VirtualKeyboard.x, VirtualKeyboard.y, 0, 0}; - SDL_BlitSurface(image_kbd, NULL, VirtualKeyboard.screen, &dst_rect); + SDL_BlitSurface(image_kbd, NULL, VirtualKeyboard.screen, &dst_rect); } inline void flip_VKB() @@ -181,7 +194,7 @@ struct virtkey *get_key_internal() x = (xm-border_x); y = (ym-border_y); - i = get_index(x,y); + i = get_index(x*RATIO,y*RATIO); if (i==-1) continue; @@ -205,9 +218,7 @@ struct virtkey* virtkbd_get_key() { virtkey_t *key; - if (FULL_DISPLAY_X != 640) {msgInfo("Virtual Keyboard only with 640X480 res",4000,NULL);return NULL;} - - if (vkb_is_init != 1) return NULL; + if (!vkb_is_init) return NULL; pause_sound(); diff --git a/src/gui-sdl/menu.c b/src/gui-sdl/menu.c index e7b3fd8..30637e0 100644 --- a/src/gui-sdl/menu.c +++ b/src/gui-sdl/menu.c @@ -26,7 +26,13 @@ #include "options.h" #include "filesys.h" - +/* Uncomment for debugging output */ +//#define DEBUG_MENU +#ifdef DEBUG_MENU +#define DEBUG_LOG write_log +#else +#define DEBUG_LOG(...) do {} while(0) +#endif struct joyinfo { SDL_Joystick *joy; @@ -1159,10 +1165,13 @@ void menu_init(SDL_Surface *screen) real_screen = screen; VirtualKeyboard_init(screen); is_inited = 1; + DEBUG_LOG("Menu is inited\n"); } void menu_deinit(void) { + if (!is_inited) return; + is_inited = 0; VirtualKeyboard_fini(); @@ -1172,6 +1181,7 @@ void menu_deinit(void) TTF_CloseFont(menu_font10); TTF_Quit(); + DEBUG_LOG("Menu is finished\n"); } diff --git a/src/targets/t-wii.h b/src/targets/t-wii.h index b4b85dc..1ac42c6 100644 --- a/src/targets/t-wii.h +++ b/src/targets/t-wii.h @@ -24,6 +24,7 @@ #define USERFILENAME "/uae/uaerc.user" #define SAVEDFILENAME "/uae/uaerc.saved" #define KBDIMAGE "/apps/uae/images/kb_amiga.png" +#define KBDIMAGE_SMALL "/apps/uae/images/kb_amiga_small.png" #define DEFPRTNAME "lpr" #define DEFSERNAME "/dev/ttyS1"