A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd

[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

authored by

William Wilgus and committed by
Solomon Peachy
dccda8c7 ecc72c0d

+16 -4
+11 -1
apps/gui/usb_screen.c
··· 191 191 logo->y = parent->y; 192 192 title->y = parent->y + logo->height; 193 193 } 194 + 195 + int i =0, langid = LANG_USB_KEYPAD_MODE; 196 + while (langid >= 0) /* ensure the USB mode strings get cached */ 197 + { 198 + font_getstringsize(str(langid), NULL, NULL, title->font); 199 + langid = keypad_mode_name_get(i++); 200 + } 194 201 } 195 202 #endif 196 203 } ··· 229 236 usb_screen_vps->title.flags |= VP_FLAG_ALIGN_CENTER; 230 237 snprintf(modestring, sizeof(modestring), "%s: %s", 231 238 str(LANG_USB_KEYPAD_MODE), 232 - str(keypad_mode_name_get())); 239 + str(keypad_mode_name_get(usb_keypad_mode))); 233 240 screen->puts_scroll(0, 0, modestring); 234 241 } 235 242 #endif /* USB_ENABLE_HID */ ··· 278 285 usb_screen_fix_viewports(screen, &usb_screen_vps_ar[i]); 279 286 } 280 287 288 + #if 0 /* handled in usb_screen_fix_viewports() */ 281 289 /* update the UI before disabling fonts, this maximizes the propability 282 290 * that font cache lookups succeed during USB */ 283 291 send_event(GUI_EVENT_ACTIONUPDATE, NULL); 292 + #endif 293 + 284 294 if(!early_usb) 285 295 { 286 296 /* The font system leaves the .fnt fd's open, so we need for force close them all */
+4 -2
apps/usb_keymaps.c
··· 219 219 return action; 220 220 } 221 221 222 - int keypad_mode_name_get(void) 222 + int keypad_mode_name_get(unsigned int mode) 223 223 { 224 - return hid_key_mappings[usb_keypad_mode]->lang_name; 224 + if (mode >= ARRAYLEN(hid_key_mappings)) 225 + return -1; 226 + return hid_key_mappings[mode]->lang_name; 225 227 }
+1 -1
apps/usb_keymaps.h
··· 23 23 24 24 int get_hid_usb_action(void); 25 25 26 - int keypad_mode_name_get(void); 26 + int keypad_mode_name_get(unsigned int mode); 27 27 28 28 #endif