Fix virtual keyboard input and visual glitches

This commit is contained in:
Romain Graillot 2019-04-11 19:47:49 +02:00
parent da7b5d0b95
commit 72d87c0d2a

View File

@ -784,10 +784,6 @@ byte Readline_ex_unicode(word x_pos, word y_pos, char * str, word * str_unicode,
#endif #endif
Hide_cursor(); Hide_cursor();
// Effacement de la chaîne
Window_rectangle(x_pos,y_pos,visible_size<<3,8,BACKGROUND_COLOR);
Update_window_area(x_pos,y_pos,visible_size<<3,8);
// Mise à jour des variables se rapportant à la chaîne en fonction de la chaîne initiale // Mise à jour des variables se rapportant à la chaîne en fonction de la chaîne initiale
strcpy(initial_string,str); strcpy(initial_string,str);
if (str_unicode != NULL) if (str_unicode != NULL)
@ -824,7 +820,9 @@ byte Readline_ex_unicode(word x_pos, word y_pos, char * str, word * str_unicode,
Display_whole_string(window_x+(x_pos*Menu_factor_X),window_y+(y_pos*Menu_factor_Y),display_string,position - offset); Display_whole_string(window_x+(x_pos*Menu_factor_X),window_y+(y_pos*Menu_factor_Y),display_string,position - offset);
} }
Update_window_area(x_pos,y_pos,visible_size<<3,8); Update_rect(window_x+(x_pos*Menu_factor_X),window_y+(y_pos*Menu_factor_Y),
visible_size*(Menu_factor_X<<3),(Menu_factor_Y<<3));
Flush_update(); Flush_update();
if (Mouse_K) if (Mouse_K)
{ {
@ -842,6 +840,7 @@ byte Readline_ex_unicode(word x_pos, word y_pos, char * str, word * str_unicode,
clicked_button=Window_clicked_button(); clicked_button=Window_clicked_button();
input_char=0; input_char=0;
input_key = Key;
if (clicked_button==-1) if (clicked_button==-1)
input_key=KEY_RETURN; input_key=KEY_RETURN;
@ -1043,7 +1042,8 @@ byte Readline_ex_unicode(word x_pos, word y_pos, char * str, word * str_unicode,
size--; size--;
// Effacement de la chaîne // Effacement de la chaîne
Window_rectangle(x_pos,y_pos,visible_size<<3,8,BACKGROUND_COLOR); Screen_FillRect((window_x+(x_pos*Menu_factor_X))*Pixel_width, (window_y+(y_pos*Menu_factor_Y))*Pixel_height,
(visible_size*(Menu_factor_X<<3))*Pixel_width, (Menu_factor_Y<<3)*Pixel_height, BACKGROUND_COLOR);
goto affichage; goto affichage;
} }
break; break;
@ -1052,8 +1052,8 @@ byte Readline_ex_unicode(word x_pos, word y_pos, char * str, word * str_unicode,
{ {
// Effacement de la chaîne // Effacement de la chaîne
if (position==size) if (position==size)
Window_rectangle(x_pos,y_pos,visible_size<<3,8,BACKGROUND_COLOR); Screen_FillRect((window_x+(x_pos*Menu_factor_X))*Pixel_width, (window_y+(y_pos*Menu_factor_Y))*Pixel_height,
position--; (visible_size*(Menu_factor_X<<3))*Pixel_width, (Menu_factor_Y<<3)*Pixel_height, BACKGROUND_COLOR); position--;
if (offset > 0 && (position == 0 || position < (offset + 1))) if (offset > 0 && (position == 0 || position < (offset + 1)))
offset--; offset--;
goto affichage; goto affichage;
@ -1083,8 +1083,8 @@ byte Readline_ex_unicode(word x_pos, word y_pos, char * str, word * str_unicode,
{ {
// Effacement de la chaîne // Effacement de la chaîne
if (position==size) if (position==size)
Window_rectangle(x_pos,y_pos,visible_size<<3,8,BACKGROUND_COLOR); Screen_FillRect((window_x+(x_pos*Menu_factor_X))*Pixel_width, (window_y+(y_pos*Menu_factor_Y))*Pixel_height,
position = 0; (visible_size*(Menu_factor_X<<3))*Pixel_width, (Menu_factor_Y<<3)*Pixel_height, BACKGROUND_COLOR); position = 0;
offset = 0; offset = 0;
goto affichage; goto affichage;
} }
@ -1111,8 +1111,8 @@ byte Readline_ex_unicode(word x_pos, word y_pos, char * str, word * str_unicode,
Remove_character(str,position); Remove_character(str,position);
size--; size--;
// Effacement de la chaîne // Effacement de la chaîne
Window_rectangle(x_pos,y_pos,visible_size<<3,8,BACKGROUND_COLOR); Screen_FillRect((window_x+(x_pos*Menu_factor_X))*Pixel_width, (window_y+(y_pos*Menu_factor_Y))*Pixel_height,
goto affichage; (visible_size*(Menu_factor_X<<3))*Pixel_width, (Menu_factor_Y<<3)*Pixel_height, BACKGROUND_COLOR); goto affichage;
} }
break; break;
case KEY_CLEAR : // Clear case KEY_CLEAR : // Clear
@ -1121,8 +1121,8 @@ byte Readline_ex_unicode(word x_pos, word y_pos, char * str, word * str_unicode,
str_unicode[0] = 0; str_unicode[0] = 0;
position=offset=0; position=offset=0;
// Effacement de la chaîne // Effacement de la chaîne
Window_rectangle(x_pos,y_pos,visible_size<<3,8,BACKGROUND_COLOR); Screen_FillRect((window_x+(x_pos*Menu_factor_X))*Pixel_width, (window_y+(y_pos*Menu_factor_Y))*Pixel_height,
goto affichage; (visible_size*(Menu_factor_X<<3))*Pixel_width, (Menu_factor_Y<<3)*Pixel_height, BACKGROUND_COLOR); goto affichage;
case KEY_RETURN : case KEY_RETURN :
break; break;
@ -1138,7 +1138,6 @@ byte Readline_ex_unicode(word x_pos, word y_pos, char * str, word * str_unicode,
} }
break; break;
default : default :
#if !defined(USE_SDL2)
if (size<max_size && input_char != 0) if (size<max_size && input_char != 0)
{ {
// Si la touche était autorisée... // Si la touche était autorisée...
@ -1173,7 +1172,6 @@ byte Readline_ex_unicode(word x_pos, word y_pos, char * str, word * str_unicode,
goto affichage; goto affichage;
} // End du test d'autorisation de touche } // End du test d'autorisation de touche
} // End du test de place libre } // End du test de place libre
#endif
break; break;
affichage: affichage:
@ -1220,7 +1218,9 @@ affichage:
} }
#endif // defined(__ANDROID__) #endif // defined(__ANDROID__)
// Effacement de la chaîne // Effacement de la chaîne
Window_rectangle(x_pos,y_pos,visible_size<<3,8,BACKGROUND_COLOR); Screen_FillRect((window_x+(x_pos*Menu_factor_X))*Pixel_width, (window_y+(y_pos*Menu_factor_Y))*Pixel_height,
(visible_size*(Menu_factor_X<<3))*Pixel_width, (Menu_factor_Y<<3)*Pixel_height, BACKGROUND_COLOR);
// On raffiche la chaine correctement // On raffiche la chaine correctement
if (input_type==INPUT_TYPE_INTEGER) if (input_type==INPUT_TYPE_INTEGER)
{ {