Debugged keyboard input. You can now change the picture size.

git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@80 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Adrien Destugues 2008-07-30 18:43:43 +00:00
parent 6f9b6c977d
commit 9093f3c09c
5 changed files with 31 additions and 27 deletions

View File

@ -1388,6 +1388,7 @@ void Bouton_Resol(void)
Readline(62,37,Chaine,4,1);
Largeur_choisie=atoi(Chaine);
// On corrige les dimensions
DEBUG("Valide",0);
if (Largeur_choisie==0)
{
Largeur_choisie=1;

View File

@ -647,9 +647,11 @@ void Scroll_picture(short Decalage_X,short Decalage_Y)
UNIMPLEMENTED
}
byte Get_key(void)
word Get_key(void)
{
SDL_Event event;
SDL_Event event;
Attendre_fin_de_click(); // On prend le controle de la boucle d'évènements, donc il ne faut pas qu'on rate la fin de click !
SDL_EnableUNICODE(SDL_ENABLE); // On a besoin du caractère
@ -660,7 +662,13 @@ byte Get_key(void)
{
// On retourne en mode standard pour la gestion normale
SDL_EnableUNICODE(SDL_DISABLE);
return (byte)(event.key.keysym.unicode);
if (event.key.keysym.unicode <= 127 && event.key.keysym.unicode > 31)
return event.key.keysym.unicode; // Pas de souci, on est en ASCII standard
else
{
// Sinon c'est une touche spéciale, on retourne son scancode
return event.key.keysym.sym;
}
}
}
}

View File

@ -25,7 +25,7 @@ void Wait_VBL(void);
void Tempo_jauge(byte Vitesse);
dword Round_div(dword Numerateur,dword Diviseur);
word Palette_Compter_nb_couleurs_utilisees(dword * Tableau);
byte Get_key(void);
word Get_key(void);
void Pixel_dans_ecran_courant (word X,word Y,byte Couleur);
void Pixel_dans_brosse (word X,word Y,byte Couleur);

View File

@ -25,5 +25,5 @@ int filelength(int fichier)
void itoa(int source,char* dest, int longueur)
{
printf("itoa non implémenté!\n");
snprintf(dest,longueur,"%d",source);
}

View File

@ -100,7 +100,7 @@ byte Readline(word Pos_X,word Pos_Y,char * Chaine,byte Taille_maxi,byte Type_sai
char Chaine_initiale[256];
byte Position;
byte Taille;
char Touche_lue=0;
word Touche_lue=0;
byte Touche_autorisee;
@ -120,16 +120,12 @@ byte Readline(word Pos_X,word Pos_Y,char * Chaine,byte Taille_maxi,byte Type_sai
Rafficher_toute_la_chaine(Pos_X,Pos_Y,Chaine,Position);
while ((Touche_lue!=13) && (Touche_lue!=27))
while ((Touche_lue!=SDLK_RETURN) && (Touche_lue!=SDLK_ESCAPE))
{
Touche_lue=Get_key();
switch (Touche_lue)
{
case 0 :
Touche_lue=Get_key();
switch (Touche_lue)
{
case 83 : // Suppr.
case SDLK_DELETE : // Suppr.
if (Position<Taille)
{
Supprimer_caractere(Chaine,Position);
@ -139,8 +135,8 @@ byte Readline(word Pos_X,word Pos_Y,char * Chaine,byte Taille_maxi,byte Type_sai
Taille_maxi*(Menu_Facteur_X<<3),(Menu_Facteur_Y<<3),COULEUR_FOND);
Rafficher_toute_la_chaine(Pos_X,Pos_Y,Chaine,Position);
}
break;
case 75 : // Gauche
break;
case SDLK_LEFT : // Gauche
if (Position)
{
// Effacement de la chaŒne
@ -149,12 +145,12 @@ byte Readline(word Pos_X,word Pos_Y,char * Chaine,byte Taille_maxi,byte Type_sai
Taille_maxi*(Menu_Facteur_X<<3),(Menu_Facteur_Y<<3),COULEUR_FOND);
Rafficher_toute_la_chaine(Pos_X,Pos_Y,Chaine,--Position);
}
break;
case 77 : // Droite
break;
case SDLK_RIGHT : // Droite
if ((Position<Taille) && (Position<Taille_maxi-1))
Rafficher_toute_la_chaine(Pos_X,Pos_Y,Chaine,++Position);
break;
case 71 : // Home
break;
case SDLK_HOME : // Home
if (Position)
{
// Effacement de la chaŒne
@ -163,13 +159,12 @@ byte Readline(word Pos_X,word Pos_Y,char * Chaine,byte Taille_maxi,byte Type_sai
Taille_maxi*(Menu_Facteur_X<<3),(Menu_Facteur_Y<<3),COULEUR_FOND);
Rafficher_toute_la_chaine(Pos_X,Pos_Y,Chaine,Position=0);
}
break;
case 79 : // End
break;
case SDLK_END : // End
if ((Position<Taille) && (Position<Taille_maxi-1))
Rafficher_toute_la_chaine(Pos_X,Pos_Y,Chaine,Position=(Taille<Taille_maxi)?Taille:Taille-1);
}
break;
case 8 :
break;
case SDLK_BACKSPACE :
if (Position)
{
Supprimer_caractere(Chaine,--Position);
@ -180,14 +175,14 @@ byte Readline(word Pos_X,word Pos_Y,char * Chaine,byte Taille_maxi,byte Type_sai
Rafficher_toute_la_chaine(Pos_X,Pos_Y,Chaine,Position);
}
break;
case 13 :
case SDLK_RETURN :
if ( (Type_saisie!=2) || (Chaine_valide(Chaine)) )
break;
// Si on tait en saisie de nom de fichier et qu'il y ait une erreur
// dans la chaŒne
Erreur(0); // On flash en rouge & ...
Touche_lue=27; // ... on simule l'appuie sur la touche [Esc]
case 27 :
Touche_lue=SDLK_ESCAPE; // ... on simule l'appuie sur la touche [Esc]
case SDLK_ESCAPE :
// On restaure la chaine initiale
strcpy(Chaine,Chaine_initiale);
Taille=strlen(Chaine);
@ -254,5 +249,5 @@ byte Readline(word Pos_X,word Pos_Y,char * Chaine,byte Taille_maxi,byte Type_sai
else
Print_dans_fenetre(Pos_X,Pos_Y,Chaine,COULEUR_TEXTE,COULEUR_FOND);
return (Touche_lue==13);
return (Touche_lue==SDLK_RETURN);
}