[Bugfix] FS#12436 cache mode strings prior to font disable

by checking string len we can cache the USB hid mode strings

I guess if the user doesn't have enough glyphs they might still
might not get the whole thing but this appears to work with
50 glyphs and the referenced russian language selected

remove call to  GUI_EVENT_ACTIONUPDATE it is now counterproductive

Change-Id: Ica96ed39c7d002fde2d1888e78d2ea18e7c1d61a
This commit is contained in:
William Wilgus 2025-03-08 14:04:42 -05:00 committed by Solomon Peachy
parent ecc72c0df9
commit dccda8c76f
3 changed files with 16 additions and 4 deletions

View file

@ -191,6 +191,13 @@ static void usb_screen_fix_viewports(struct screen *screen,
logo->y = parent->y;
title->y = parent->y + logo->height;
}
int i =0, langid = LANG_USB_KEYPAD_MODE;
while (langid >= 0) /* ensure the USB mode strings get cached */
{
font_getstringsize(str(langid), NULL, NULL, title->font);
langid = keypad_mode_name_get(i++);
}
}
#endif
}
@ -229,7 +236,7 @@ static void usb_screens_draw(struct usb_screen_vps_t *usb_screen_vps_ar)
usb_screen_vps->title.flags |= VP_FLAG_ALIGN_CENTER;
snprintf(modestring, sizeof(modestring), "%s: %s",
str(LANG_USB_KEYPAD_MODE),
str(keypad_mode_name_get()));
str(keypad_mode_name_get(usb_keypad_mode)));
screen->puts_scroll(0, 0, modestring);
}
#endif /* USB_ENABLE_HID */
@ -278,9 +285,12 @@ void gui_usb_screen_run(bool early_usb)
usb_screen_fix_viewports(screen, &usb_screen_vps_ar[i]);
}
#if 0 /* handled in usb_screen_fix_viewports() */
/* update the UI before disabling fonts, this maximizes the propability
* that font cache lookups succeed during USB */
send_event(GUI_EVENT_ACTIONUPDATE, NULL);
#endif
if(!early_usb)
{
/* The font system leaves the .fnt fd's open, so we need for force close them all */

View file

@ -219,7 +219,9 @@ int get_hid_usb_action(void)
return action;
}
int keypad_mode_name_get(void)
int keypad_mode_name_get(unsigned int mode)
{
return hid_key_mappings[usb_keypad_mode]->lang_name;
if (mode >= ARRAYLEN(hid_key_mappings))
return -1;
return hid_key_mappings[mode]->lang_name;
}

View file

@ -23,6 +23,6 @@
int get_hid_usb_action(void);
int keypad_mode_name_get(void);
int keypad_mode_name_get(unsigned int mode);
#endif