Backport OSK keyboard debug change to master

Allow for an "OSK_DEBUG" to be set, to show only debug
from `onscreen_keyboard.c`, and nowhere else.
This commit is contained in:
Bill Kendrick 2022-05-20 00:25:32 -07:00
parent ff05e91f39
commit 2b5b6132ab

View file

@ -20,8 +20,13 @@
(See COPYING.txt)
*/
#include "debug.h"
#include "onscreen_keyboard.h"
//#ifdef DEBUG
#define OSK_DEBUG
//#endif
#include "SDL_rotozoom.h"
#include "SDL_gfxBlitFunc.h"
#if !defined(_SDL_rotozoom_h) || !defined(_SDL_gfxBlitFunc_h)
@ -102,7 +107,7 @@ struct osk_keyboard *osk_create(char * layout_name, SDL_Surface * canvas,
fprintf(stderr, "Loaded the default layout instead.\n");
}
#ifdef DEBUG
#ifdef OSK_DEBUG
printf("w %i, h %i\n", layout->width, layout->height);
#endif
@ -115,7 +120,7 @@ struct osk_keyboard *osk_create(char * layout_name, SDL_Surface * canvas,
float max_w, max_h;
float scale_w, scale_h;
#ifdef DEBUG
#ifdef OSK_DEBUG
printf("%d x %d layout of %d x %d buttons won't fit within %d x %d pixel area...\n",
layout->width, layout->height,
BLANK_button_up->w, BLANK_button_up->h,
@ -125,7 +130,7 @@ struct osk_keyboard *osk_create(char * layout_name, SDL_Surface * canvas,
max_w = (float) layout_avail_width / (float) layout->width;
max_h = (float) layout_avail_height / (float) layout->height;
#ifdef DEBUG
#ifdef OSK_DEBUG
printf("...want (%d / %d) x (%d x %d) = %.2f x %.2f buttons...\n",
layout_avail_width, layout->width,
layout_avail_height, layout->height,
@ -140,7 +145,7 @@ struct osk_keyboard *osk_create(char * layout_name, SDL_Surface * canvas,
scale_w = (float) max_w / (float) BLANK_button_up->w;
scale_h = (float) max_h / (float) BLANK_button_up->h;
#ifdef DEBUG
#ifdef OSK_DEBUG
printf("...so scaling by w=%.2f & h=%.2f\n",
scale_w, scale_h);
#endif
@ -247,7 +252,7 @@ static struct osk_layout *load_layout(on_screen_keyboard * keyboard, char *layou
layout = malloc(sizeof(osk_layout));
layout->name = NULL;
hlayout_loaded = 0;
#ifdef DEBUG
#ifdef OSK_DEBUG
printf("load_layout %s\n", layout_name);
#endif
filename = malloc(sizeof(char) * 255);
@ -301,7 +306,7 @@ static struct osk_layout *load_layout(on_screen_keyboard * keyboard, char *layou
sscanf(line, "%s %s", key, value);
if (strcmp("layout", key) == 0 && !hlayout_loaded)
{
#ifdef DEBUG
#ifdef OSK_DEBUG
printf("layout found: %s\n", value);
#endif
@ -310,14 +315,14 @@ static struct osk_layout *load_layout(on_screen_keyboard * keyboard, char *layou
}
else if (strncmp("keymap", key, 6) == 0)
{
#ifdef DEBUG
#ifdef OSK_DEBUG
printf("keymap found: %s\n", value);
#endif
load_keymap(layout, value);
}
else if (strncmp("composemap", key, 10) == 0)
{
#ifdef DEBUG
#ifdef OSK_DEBUG
printf("composemap found: %s\n", value);
#endif
load_composemap(layout, value);
@ -332,7 +337,7 @@ static struct osk_layout *load_layout(on_screen_keyboard * keyboard, char *layou
keyboard->keyboard_list = strdup(value);
}
#ifdef DEBUG
#ifdef OSK_DEBUG
printf("key %s, value %s\n", key, value);
#endif
key[0] = '\0';
@ -425,7 +430,7 @@ void load_hlayout(osk_layout * layout, char *hlayout_name)
layout->width = width;
layout->height = height;
#ifdef DEBUG
#ifdef OSK_DEBUG
printf("w %i, h %i\n", layout->width, layout->height);
#endif
allocated = 1;
@ -444,7 +449,7 @@ void load_hlayout(osk_layout * layout, char *hlayout_name)
else if (strncmp(line, "FONTPATH", 8) == 0)
{
#ifdef DEBUG
#ifdef OSK_DEBUG
printf("linefont %s\n", line);
#endif
sscanf(line, "%s %s", key, fontpath);
@ -453,7 +458,7 @@ void load_hlayout(osk_layout * layout, char *hlayout_name)
}
else if (strncmp(line, "FGCOLOR", 5) == 0)
{
#ifdef DEBUG
#ifdef OSK_DEBUG
printf("linefont %s\n", line);
#endif
sscanf(line, "%s %i %i %i", key, &r, &g, &b);
@ -467,7 +472,7 @@ void load_hlayout(osk_layout * layout, char *hlayout_name)
}
else if (strncmp(line, "BGCOLOR", 5) == 0)
{
#ifdef DEBUG
#ifdef OSK_DEBUG
printf("linefont %s\n", line);
#endif
sscanf(line, "%s %i %i %i", key, &r, &g, &b);
@ -799,13 +804,13 @@ static void print_composemap(osk_composenode * composemap, char *sp)
space = malloc(sizeof(char) * 255);
#ifdef DEBUG
#ifdef OSK_DEBUG
printf("%ls, ", composemap->keysym);
printf("%d ==> ", composemap->size);
#endif
if (composemap->size == 0)
{
#ifdef DEBUG
#ifdef OSK_DEBUG
printf("result %ls\n", composemap->result);
#endif
return;
@ -818,7 +823,7 @@ static void print_composemap(osk_composenode * composemap, char *sp)
{
sprintf(space, " ");
}
#ifdef DEBUG
#ifdef OSK_DEBUG
printf("%s", space);
#endif
@ -1682,7 +1687,7 @@ struct osk_keyboard *osk_clicked(on_screen_keyboard * keyboard, int x, int y)
wchar_t *ks;
on_screen_keyboard *new_keyboard;
#ifdef DEBUG
#ifdef OSK_DEBUG
printf("list: %s\n", keyboard->keyboard_list);
#endif
@ -1707,7 +1712,7 @@ struct osk_keyboard *osk_clicked(on_screen_keyboard * keyboard, int x, int y)
aux_list = strdup(keyboard->keyboard_list);
aux_list_ptr = aux_list;
#ifdef DEBUG
#ifdef OSK_DEBUG
printf("auxlist: %s\n", aux_list);
printf("kn %s\n", keyboard->name);
#endif
@ -1800,7 +1805,7 @@ struct osk_keyboard *osk_clicked(on_screen_keyboard * keyboard, int x, int y)
mbsrtowcs(wkeysym, (const char **)&keysym, strlen(keysym) + 1, NULL);
#ifdef DEBUG
#ifdef OSK_DEBUG
printf("wkeysym %ls %i\n\n", wkeysym, (int)wcslen(wkeysym));
#endif
@ -1813,7 +1818,7 @@ struct osk_keyboard *osk_clicked(on_screen_keyboard * keyboard, int x, int y)
set_key(NULL, &keyboard->keymodifiers.compose, 0);
ks = keyboard->composed;
#ifdef DEBUG
#ifdef OSK_DEBUG
printf("keysym found %ls\n", ks);
#endif
@ -1852,7 +1857,7 @@ struct osk_keyboard *osk_clicked(on_screen_keyboard * keyboard, int x, int y)
{
if (keyboard->composing == keyboard->layout->composemap)
{
#ifdef DEBUG
#ifdef OSK_DEBUG
printf("compose sequence resetted\n");
#endif
set_key(NULL, &keyboard->keymodifiers.compose, 0);
@ -1862,7 +1867,7 @@ struct osk_keyboard *osk_clicked(on_screen_keyboard * keyboard, int x, int y)
else
{
set_key(key, &keyboard->keymodifiers.compose, 0);
#ifdef DEBUG
#ifdef OSK_DEBUG
printf("still composing\n");
#endif
set_dead_sticks(key, keyboard);