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:
parent
6f9b6c977d
commit
9093f3c09c
@ -1388,6 +1388,7 @@ void Bouton_Resol(void)
|
|||||||
Readline(62,37,Chaine,4,1);
|
Readline(62,37,Chaine,4,1);
|
||||||
Largeur_choisie=atoi(Chaine);
|
Largeur_choisie=atoi(Chaine);
|
||||||
// On corrige les dimensions
|
// On corrige les dimensions
|
||||||
|
DEBUG("Valide",0);
|
||||||
if (Largeur_choisie==0)
|
if (Largeur_choisie==0)
|
||||||
{
|
{
|
||||||
Largeur_choisie=1;
|
Largeur_choisie=1;
|
||||||
|
|||||||
14
divers.c
14
divers.c
@ -647,9 +647,11 @@ void Scroll_picture(short Decalage_X,short Decalage_Y)
|
|||||||
UNIMPLEMENTED
|
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
|
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
|
// On retourne en mode standard pour la gestion normale
|
||||||
SDL_EnableUNICODE(SDL_DISABLE);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
2
divers.h
2
divers.h
@ -25,7 +25,7 @@ void Wait_VBL(void);
|
|||||||
void Tempo_jauge(byte Vitesse);
|
void Tempo_jauge(byte Vitesse);
|
||||||
dword Round_div(dword Numerateur,dword Diviseur);
|
dword Round_div(dword Numerateur,dword Diviseur);
|
||||||
word Palette_Compter_nb_couleurs_utilisees(dword * Tableau);
|
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_ecran_courant (word X,word Y,byte Couleur);
|
||||||
void Pixel_dans_brosse (word X,word Y,byte Couleur);
|
void Pixel_dans_brosse (word X,word Y,byte Couleur);
|
||||||
|
|||||||
2
linux.c
2
linux.c
@ -25,5 +25,5 @@ int filelength(int fichier)
|
|||||||
|
|
||||||
void itoa(int source,char* dest, int longueur)
|
void itoa(int source,char* dest, int longueur)
|
||||||
{
|
{
|
||||||
printf("itoa non implémenté!\n");
|
snprintf(dest,longueur,"%d",source);
|
||||||
}
|
}
|
||||||
|
|||||||
39
readline.c
39
readline.c
@ -100,7 +100,7 @@ byte Readline(word Pos_X,word Pos_Y,char * Chaine,byte Taille_maxi,byte Type_sai
|
|||||||
char Chaine_initiale[256];
|
char Chaine_initiale[256];
|
||||||
byte Position;
|
byte Position;
|
||||||
byte Taille;
|
byte Taille;
|
||||||
char Touche_lue=0;
|
word Touche_lue=0;
|
||||||
byte Touche_autorisee;
|
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);
|
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();
|
Touche_lue=Get_key();
|
||||||
switch (Touche_lue)
|
switch (Touche_lue)
|
||||||
{
|
{
|
||||||
case 0 :
|
case SDLK_DELETE : // Suppr.
|
||||||
Touche_lue=Get_key();
|
|
||||||
switch (Touche_lue)
|
|
||||||
{
|
|
||||||
case 83 : // Suppr.
|
|
||||||
if (Position<Taille)
|
if (Position<Taille)
|
||||||
{
|
{
|
||||||
Supprimer_caractere(Chaine,Position);
|
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);
|
Taille_maxi*(Menu_Facteur_X<<3),(Menu_Facteur_Y<<3),COULEUR_FOND);
|
||||||
Rafficher_toute_la_chaine(Pos_X,Pos_Y,Chaine,Position);
|
Rafficher_toute_la_chaine(Pos_X,Pos_Y,Chaine,Position);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 75 : // Gauche
|
case SDLK_LEFT : // Gauche
|
||||||
if (Position)
|
if (Position)
|
||||||
{
|
{
|
||||||
// Effacement de la chaŒne
|
// 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);
|
Taille_maxi*(Menu_Facteur_X<<3),(Menu_Facteur_Y<<3),COULEUR_FOND);
|
||||||
Rafficher_toute_la_chaine(Pos_X,Pos_Y,Chaine,--Position);
|
Rafficher_toute_la_chaine(Pos_X,Pos_Y,Chaine,--Position);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 77 : // Droite
|
case SDLK_RIGHT : // Droite
|
||||||
if ((Position<Taille) && (Position<Taille_maxi-1))
|
if ((Position<Taille) && (Position<Taille_maxi-1))
|
||||||
Rafficher_toute_la_chaine(Pos_X,Pos_Y,Chaine,++Position);
|
Rafficher_toute_la_chaine(Pos_X,Pos_Y,Chaine,++Position);
|
||||||
break;
|
break;
|
||||||
case 71 : // Home
|
case SDLK_HOME : // Home
|
||||||
if (Position)
|
if (Position)
|
||||||
{
|
{
|
||||||
// Effacement de la chaŒne
|
// 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);
|
Taille_maxi*(Menu_Facteur_X<<3),(Menu_Facteur_Y<<3),COULEUR_FOND);
|
||||||
Rafficher_toute_la_chaine(Pos_X,Pos_Y,Chaine,Position=0);
|
Rafficher_toute_la_chaine(Pos_X,Pos_Y,Chaine,Position=0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 79 : // End
|
case SDLK_END : // End
|
||||||
if ((Position<Taille) && (Position<Taille_maxi-1))
|
if ((Position<Taille) && (Position<Taille_maxi-1))
|
||||||
Rafficher_toute_la_chaine(Pos_X,Pos_Y,Chaine,Position=(Taille<Taille_maxi)?Taille:Taille-1);
|
Rafficher_toute_la_chaine(Pos_X,Pos_Y,Chaine,Position=(Taille<Taille_maxi)?Taille:Taille-1);
|
||||||
}
|
break;
|
||||||
break;
|
case SDLK_BACKSPACE :
|
||||||
case 8 :
|
|
||||||
if (Position)
|
if (Position)
|
||||||
{
|
{
|
||||||
Supprimer_caractere(Chaine,--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);
|
Rafficher_toute_la_chaine(Pos_X,Pos_Y,Chaine,Position);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 13 :
|
case SDLK_RETURN :
|
||||||
if ( (Type_saisie!=2) || (Chaine_valide(Chaine)) )
|
if ( (Type_saisie!=2) || (Chaine_valide(Chaine)) )
|
||||||
break;
|
break;
|
||||||
// Si on ‚tait en saisie de nom de fichier et qu'il y ait une erreur
|
// Si on ‚tait en saisie de nom de fichier et qu'il y ait une erreur
|
||||||
// dans la chaŒne
|
// dans la chaŒne
|
||||||
Erreur(0); // On flash en rouge & ...
|
Erreur(0); // On flash en rouge & ...
|
||||||
Touche_lue=27; // ... on simule l'appuie sur la touche [Esc]
|
Touche_lue=SDLK_ESCAPE; // ... on simule l'appuie sur la touche [Esc]
|
||||||
case 27 :
|
case SDLK_ESCAPE :
|
||||||
// On restaure la chaine initiale
|
// On restaure la chaine initiale
|
||||||
strcpy(Chaine,Chaine_initiale);
|
strcpy(Chaine,Chaine_initiale);
|
||||||
Taille=strlen(Chaine);
|
Taille=strlen(Chaine);
|
||||||
@ -254,5 +249,5 @@ byte Readline(word Pos_X,word Pos_Y,char * Chaine,byte Taille_maxi,byte Type_sai
|
|||||||
else
|
else
|
||||||
Print_dans_fenetre(Pos_X,Pos_Y,Chaine,COULEUR_TEXTE,COULEUR_FOND);
|
Print_dans_fenetre(Pos_X,Pos_Y,Chaine,COULEUR_TEXTE,COULEUR_FOND);
|
||||||
|
|
||||||
return (Touche_lue==13);
|
return (Touche_lue==SDLK_RETURN);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user