From b08ddf00dd15676793727dcfc1bda10237f48d29 Mon Sep 17 00:00:00 2001 From: Pere Pujal i Carabantes Date: Mon, 19 Jan 2015 23:47:24 +0100 Subject: [PATCH] Keyboard input seems to work, even dead keys, not tested IM, onscreen keyboard not working... --- src/im.c | 15 +++++++-------- src/onscreen_keyboard.c | 2 +- src/tuxpaint.c | 14 ++------------ 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/src/im.c b/src/im.c index 4e7b783c1..5a5e732de 100644 --- a/src/im.c +++ b/src/im.c @@ -676,11 +676,12 @@ static int im_event_c(IM_DATA* im, SDL_Event event) case SDLK_BACKSPACE: im->s[0] = L'\b'; break; case SDLK_TAB: im->s[0] = L'\t'; break; case SDLK_RETURN: im->s[0] = L'\r'; break; - default: strncpy(im->s , event.text.text, 16); + default: mbstowcs(im->s , event.text.text, 16); + //default: wcsncpy(im->s , event.text.text, 16); } //im->s[1] = L'\0'; - printf("im->s %s, event.text.text %s\n", im->s, event.text.text); + printf("im->s %ls, event.text.text %s\n", im->s, event.text.text); im->buf[0] = L'\0'; return 0; @@ -708,8 +709,6 @@ static int im_event_c(IM_DATA* im, SDL_Event event) */ int im_read(IM_DATA* im, SDL_Event event) { - SDL_Keysym ks = event.key.keysym; - IM_EVENT_FN im_event_fp = NULL; int redraw = 0; @@ -932,7 +931,7 @@ static int im_event_zh_tw(IM_DATA* im, SDL_Event event) default: /* English mode */ if(cm.section == SEC_ENGLISH) { -strncpy(im->s , event.text.text, 16); + mbstowcs(im->s , event.text.text, 16); // im->s[0] = event.text.text[0]; // im->s[1] = L'\0'; im->buf[0] = L'\0'; @@ -1121,7 +1120,7 @@ static int im_event_th(IM_DATA* im, SDL_Event event) /* English mode */ if(cm.section == SEC_ENGLISH) { // im->s[0] = event.text.text[0]; - strncpy(im->s , event.text.text, 16); + mbstowcs(im->s , event.text.text, 16); //im->s[1] = L'\0'; im->buf[0] = L'\0'; } @@ -1309,7 +1308,7 @@ static int im_event_ja(IM_DATA* im, SDL_Event event) default: /* English mode */ if(cm.section == SEC_ENGLISH) { -strncpy(im->s , event.text.text, 16); + mbstowcs(im->s , event.text.text, 16); // im->s[0] = event.text.text[0]; // im->s[1] = L'\0'; im->buf[0] = L'\0'; @@ -1520,7 +1519,7 @@ static int im_event_ko(IM_DATA* im, SDL_Event event) default: /* English mode */ if(cm.section == SEC_ENGLISH) { -strncpy(im->s , event.text.text, 16); + mbstowcs(im->s , event.text.text, 16); // im->s[0] = event.text.text[0]; // im->s[1] = L'\0'; im->buf[0] = L'\0'; diff --git a/src/onscreen_keyboard.c b/src/onscreen_keyboard.c index 33f67246f..5f2166a16 100644 --- a/src/onscreen_keyboard.c +++ b/src/onscreen_keyboard.c @@ -3,7 +3,7 @@ #endif #include "onscreen_keyboard.h" -//#define DEBUG_OSK_COMPOSEMAP +#define DEBUG_OSK_COMPOSEMAP static SDL_Color def_bgcolor = {255, 255, 255, 255}; static SDL_Color def_fgcolor = {0, 0, 0, 0}; diff --git a/src/tuxpaint.c b/src/tuxpaint.c index 0d46f54fe..d9dc68c23 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -899,7 +899,7 @@ static void SDL_UpdateRect(SDL_Surface * screen, Sint32 x, Sint32 y, Sint32 w, S SDL_UpdateTexture(texture, NULL, screen->pixels, screen->pitch); - // FIXME docs says one should clear the renderer, however this means a refresh of the whole thing. + // NOTE docs says one should clear the renderer, however this means a refresh of the whole thing. // SDL_RenderClear(renderer); // SDL_RenderCopy(renderer, texture, NULL, NULL); SDL_RenderCopy(renderer, texture, &r, &r); @@ -8164,16 +8164,6 @@ static unsigned draw_colors(unsigned action) SDL_BlitSurface((colors_state == COLORSEL_ENABLE) ? img_color_btns[i + (i == cur_color) * NUM_COLORS] : img_color_btn_off, NULL, screen, &dest); - - // SDL_BlitSurface(img_paintwell, NULL, screen, &dest); - SDL_Rect rectt; - rectt.x = 50; - rectt.y = 50; - rectt.w = 50; - rectt.h = 50; - SDL_BlitSurface(img_color_btns[6], NULL, screen, &rectt); - rectt.y = 200; - SDL_BlitSurface(img_color_btns[6 + NUM_COLORS], NULL, screen, &rectt); #else dest.w = color_button_w; dest.h = color_button_h; @@ -17084,7 +17074,7 @@ static void handle_active(SDL_Event * event) { if (event->window.event == SDL_WINDOWEVENT_EXPOSED) { - if (fullscreen) + // if (fullscreen) SDL_Flip(screen); } if (event->window.event == SDL_WINDOWEVENT_FOCUS_GAINED)