mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-07 13:45:03 -05:00
keyboard: stretch dispalying of virtual keyboard to fit the screen width if possible.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24631 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
a583f7661f
commit
4c658f74a7
1 changed files with 17 additions and 1 deletions
|
|
@ -95,6 +95,7 @@
|
||||||
struct keyboard_parameters
|
struct keyboard_parameters
|
||||||
{
|
{
|
||||||
unsigned short kbd_buf[KBD_BUF_SIZE];
|
unsigned short kbd_buf[KBD_BUF_SIZE];
|
||||||
|
unsigned short max_line_len;
|
||||||
int default_lines;
|
int default_lines;
|
||||||
int nchars;
|
int nchars;
|
||||||
int font_w;
|
int font_w;
|
||||||
|
|
@ -156,7 +157,7 @@ static const unsigned char morse_codes[] = {
|
||||||
int load_kbd(unsigned char* filename)
|
int load_kbd(unsigned char* filename)
|
||||||
{
|
{
|
||||||
int fd, l;
|
int fd, l;
|
||||||
int i = 0;
|
int i = 0, line_len, max_line_len;
|
||||||
unsigned char buf[4];
|
unsigned char buf[4];
|
||||||
|
|
||||||
if (filename == NULL)
|
if (filename == NULL)
|
||||||
|
|
@ -169,6 +170,8 @@ int load_kbd(unsigned char* filename)
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
line_len = 0;
|
||||||
|
max_line_len = 0;
|
||||||
while (read(fd, buf, 1) == 1 && i < KBD_BUF_SIZE)
|
while (read(fd, buf, 1) == 1 && i < KBD_BUF_SIZE)
|
||||||
{
|
{
|
||||||
/* check how many bytes to read for this character */
|
/* check how many bytes to read for this character */
|
||||||
|
|
@ -198,6 +201,14 @@ int load_kbd(unsigned char* filename)
|
||||||
FOR_NB_SCREENS(l)
|
FOR_NB_SCREENS(l)
|
||||||
kbd_param[l].kbd_buf[i] = ch;
|
kbd_param[l].kbd_buf[i] = ch;
|
||||||
i++;
|
i++;
|
||||||
|
if (ch == '\n')
|
||||||
|
{
|
||||||
|
if (max_line_len < line_len)
|
||||||
|
max_line_len = line_len;
|
||||||
|
line_len = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
line_len++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -211,6 +222,7 @@ int load_kbd(unsigned char* filename)
|
||||||
/* initialize parameters */
|
/* initialize parameters */
|
||||||
pm->x = pm->y = pm->page = 0;
|
pm->x = pm->y = pm->page = 0;
|
||||||
pm->default_lines = 0;
|
pm->default_lines = 0;
|
||||||
|
pm->max_line_len = max_line_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -354,6 +366,7 @@ int kbd_input(char* text, int buflen)
|
||||||
"òóôõöø çðþýÿ ùúûü ¼½¾¬¶¨:;";
|
"òóôõöø çðþýÿ ùúûü ¼½¾¬¶¨:;";
|
||||||
|
|
||||||
pm->default_lines = 8;
|
pm->default_lines = 8;
|
||||||
|
pm->max_line_len = 26;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif /* LCD_WIDTH >= 160 && LCD_HEIGHT >= 96 */
|
#endif /* LCD_WIDTH >= 160 && LCD_HEIGHT >= 96 */
|
||||||
|
|
@ -374,6 +387,7 @@ int kbd_input(char* text, int buflen)
|
||||||
"òóôõöø çðþýÿ ùúûü";
|
"òóôõöø çðþýÿ ùúûü";
|
||||||
|
|
||||||
pm->default_lines = 4;
|
pm->default_lines = 4;
|
||||||
|
pm->max_line_len = 18;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (*p)
|
while (*p)
|
||||||
|
|
@ -882,6 +896,8 @@ static void kbd_calc_params(struct keyboard_parameters *pm,
|
||||||
/* calculate how many characters to put in a row. */
|
/* calculate how many characters to put in a row. */
|
||||||
icon_w = get_icon_width(sc->screen_type);
|
icon_w = get_icon_width(sc->screen_type);
|
||||||
sc_w = sc->getwidth();
|
sc_w = sc->getwidth();
|
||||||
|
if (pm->font_w < sc_w / pm->max_line_len)
|
||||||
|
pm->font_w = sc_w / pm->max_line_len;
|
||||||
pm->max_chars = sc_w / pm->font_w;
|
pm->max_chars = sc_w / pm->font_w;
|
||||||
pm->max_chars_text = (sc_w - icon_w * 2 - 2) / pm->text_w;
|
pm->max_chars_text = (sc_w - icon_w * 2 - 2) / pm->text_w;
|
||||||
if (pm->max_chars_text < 3 && icon_w > pm->text_w)
|
if (pm->max_chars_text < 3 && icon_w > pm->text_w)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue