Ce programme sert à rien :p mais aide à comprendre le fonctionnement INPUT sur GBA.
Programmé avec Visual HAM (sorte de Visual C++ 6 plus simple que DevKit Advance pour la programmation sur GBA).
Source / Exemple :
//////////////////////////////////////////
// INPUT BY NEO_00110010101 //
// neo_00110010101@hotmail.com //
//////////////////////////////////////////
// Toujours le même début ;-)
#include <mygba.h>
// Fonction: main()
int main()
{
// Variable
bool bouton_presse = 0;
// Initialisation de HAMlib
ham_Init();
// Initialisation du système d'affichage de texte en BGMODE 0
ham_InitText(0);
// On écrit des trucs :
ham_DrawText(0,19,"neo_00110010101");
ham_DrawText(0,0,"Press any button");
ham_DrawText(0,1,"-------------------------------");
ham_DrawText(0,2,"RIGHT");
ham_DrawText(0,3,"LEFT");
ham_DrawText(0,4,"UP");
ham_DrawText(0,5,"DOWN");
ham_DrawText(0,6,"A");
ham_DrawText(0,7,"B");
ham_DrawText(0,8,"SELECT");
ham_DrawText(0,9,"START");
ham_DrawText(0,10,"L");
ham_DrawText(0,11,"R");
ham_DrawText(20,16,"started :");
ham_DrawText(20,17,"22/01/2004");
ham_DrawText(20,18,"finished :");
ham_DrawText(20,19,"24/01/2004");
ham_DrawText(0,14,"------------------------------");
ham_DrawText(0,15,"Button pressed :");
// Boucle jusqu'à ce qu'un bouton soit pressé
while(bouton_presse == 0)
{
// On regarde s'il y a un bouton pressé
if (F_CTRLINPUT_UP_PRESSED)
{
// Si oui, on affiche "1" et "UP" (La flèche du haut du pad)
ham_DrawText(8,4,"1");
ham_DrawText(0,16,"UP");
}
// Sinon, on affiche "0" et des espaces pour effacer la zone où est écrit UP/DOWN etc...
else
{
ham_DrawText(8,4,"0");
ham_DrawText(0,16," ");
}
if (F_CTRLINPUT_DOWN_PRESSED) // Même chose pour la flèche du bas du pad
{
ham_DrawText(8,5,"1");
ham_DrawText(0,16,"DOWN");
}
else
{
ham_DrawText(8,5,"0");
}
if (F_CTRLINPUT_LEFT_PRESSED) // Pour la gauche
{
ham_DrawText(8,3,"1");
ham_DrawText(0,16,"LEFT");
}
else
{
ham_DrawText(8,3,"0");
}
if (F_CTRLINPUT_RIGHT_PRESSED) // Pour la droite
{
ham_DrawText(8,2,"1");
ham_DrawText(0,16,"RIGHT");
}
else
{
ham_DrawText(8,2,"0");
}
if (F_CTRLINPUT_A_PRESSED) // Pour le bouton A
{
ham_DrawText(8,6,"1");
ham_DrawText(0,16,"A");
}
else
{
ham_DrawText(8,6,"0");
}
if (F_CTRLINPUT_B_PRESSED)// Pour le B
{
ham_DrawText(8,7,"1");
ham_DrawText(0,16,"B");
}
else
{
ham_DrawText(8,7,"0");
}
if (F_CTRLINPUT_SELECT_PRESSED) // Pour le bouton SELECT
{
ham_DrawText(8,8,"1");
ham_DrawText(0,16,"SELECT");
}
else
{
ham_DrawText(8,8,"0");
}
if (F_CTRLINPUT_START_PRESSED) // Pour le bouton START
{
ham_DrawText(8,9,"1");
ham_DrawText(0,16,"START");
}
else
{
ham_DrawText(8,9,"0");
}
if (F_CTRLINPUT_L_PRESSED) // Pour la gachette L
{
ham_DrawText(8,10,"1");
ham_DrawText(0,16,"L");
}
else
{
ham_DrawText(8,10,"0");
}
if (F_CTRLINPUT_R_PRESSED) // Pour la gachette R
{
ham_DrawText(8,11,"1");
ham_DrawText(0,16,"R");
}
else
{
ham_DrawText(8,11,"0");
}
}
return 0;
} // Fin de la fonction main()
Conclusion :
Ce programme affiche aussi le nom de la touche pressée mais je l'ai fait d'une telle manière que ça clignote parfois ... à améliorer :)
et puis il date ce programme !
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.