<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>
<channel>
	<title>Archives des contrôles des touches - Custom Protocol</title>
	<atom:link href="https://www.customprotocol.com/tags/controles-des-touches/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.customprotocol.com/tags/controles-des-touches/</link>
	<description>Site d&#039;hack-tualité et de tutoriels sur la customisation de consoles et appareils (homebrews, plugins, émulation...)</description>
	<lastBuildDate>Sun, 14 Dec 2014 18:30:03 +0000</lastBuildDate>
	<language>fr-CA</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>Programmer en Lua&#160;-&#160;Débutant&#160;-&#160;Cours n°5&#160;: Les touches de la PSP</title>
		<link>https://www.customprotocol.com/programmation/programmer-en-lua-debutant-cours-n5-les-touches-de-la-psp/</link>
					<comments>https://www.customprotocol.com/programmation/programmer-en-lua-debutant-cours-n5-les-touches-de-la-psp/#comments</comments>
		
		<dc:creator><![CDATA[Applelo]]></dc:creator>
		<pubDate>Sun, 14 Dec 2014 18:30:03 +0000</pubDate>
				<category><![CDATA[Cours Lua]]></category>
		<category><![CDATA[Programmation]]></category>
		<category><![CDATA[Tutoriels Programmation]]></category>
		<category><![CDATA[contrôles des touches]]></category>
		<category><![CDATA[Lua]]></category>
		<guid isPermaLink="false">https://www.customprotocol.com/?post_type=it_programmation&#038;p=890</guid>
					<description><![CDATA[<p>Un cours pour apprendre à contrôler les touches en Lua sur PSP.</p>
<p>L’article <a rel="nofollow" href="https://www.customprotocol.com/programmation/programmer-en-lua-debutant-cours-n5-les-touches-de-la-psp/">Programmer en Lua&nbsp;-&nbsp;Débutant&nbsp;-&nbsp;Cours n°5&nbsp;: Les touches de la PSP</a> est apparu en premier sur <a rel="nofollow" href="https://www.customprotocol.com">Custom Protocol</a>.</p>
]]></description>
										<content:encoded><![CDATA[<blockquote>
<p><em>Vous visitez actuellement un de nos cours pour programmer en Lua. Pour voir la liste des cours disponibles sur le site, <a title="Programmer en Lua" href="https://www.customprotocol.com/programmation/dev-lua-programmer-en-lua/" target="_blank" rel="noopener noreferrer">cliquez ici</a>.</em></p>
</blockquote>
<p>Nous allons apprendre dans ce cours à maitriser les touches de la PSP, ce qui va nous permettre de créer vos propres programmes de manière guidé (bientôt dans un Travail Pratique). Nous n'en sommes pas encore là, mais si vous persévérez, je suis sur que vous allez y arriver sans problème, en suivant bien le cours que nous allons aborder&#8239;;)</p>
<p>Tout d'abord, il va falloir stocker du texte, on pourrait créer des variables mais nous allons réutiliser le cours d'avant pour pouvoir réaliser notre programme. Nous allons donc utiliser des tables qui contiendront des informations par rapport à la touche pour ensuite les afficher sur l'écran de la PSP. Par exemple, je reste appuyé sur la touche croix, donc ma PSP affichera que j'appuie sur la touche croix.</p>
<p>Donc on crée une table contenant toutes les informations nécessaires...</p>
<pre class="lang:lua decode:true" title="Etape 1">table&nbsp;=&nbsp;{}--Création d'une table regroupant toutes les infos suivantes
table[1]&nbsp;=&nbsp;"Appuie sur la touche Croix"
table[2]&nbsp;=&nbsp;"Appuie sur la touche Triangle"
table[3]&nbsp;=&nbsp;"Appuie sur la touche Carré"
table[4]&nbsp;=&nbsp;"Appuie sur la touche Rond"
table[5]&nbsp;=&nbsp;"Appuie sur la touche Haut"
table[6]&nbsp;=&nbsp;"Appuie sur la touche Droite"
table[7]&nbsp;=&nbsp;"Appuie sur la touche Gauche"
table[8]&nbsp;=&nbsp;"Appuie sur la touche Bas"
table[9]&nbsp;=&nbsp;"Appuie sur la touche R"
table[10]&nbsp;=&nbsp;"Appuie sur la touche L"
table[11]&nbsp;=&nbsp;"Appuie sur la touche START"
table[12]&nbsp;=&nbsp;"Appuie sur la touche SELECT"</pre>
<p> Nous n'aborderons pas le stick analogique qui sera abordé dans un cours pour réaliser un menu avec curseur.</p>
<p>Très bien maintenant nous pouvons mettre notre <strong>boucle while true do.</strong></p>
<pre class="lang:lua decode:true " title="Etape 2">while true do</pre>
<p> Et nous allons rajouter ensuite la fonction suivante qui va permettre de lire les boutons qui sont actionnés dans le programme à chaque début de la boucle.</p>
<pre class="lang:lua decode:true" title="Etape 3">buttons.read()--Lecture des touches actionnées
</pre>
<p>Maintenant nous allons utiliser pour la première fois <strong>une condition</strong>. Nous voulons afficher tel texte pour tel touche de la PSP, donc si je reste appuyer sur la touche croix alors j'affiche le texte "Appuie sur la touche Croix".</p>
<p>Ce qui donnera en Lua&nbsp;:</p>
<pre class="lang:lua decode:true " title="Etape 4">if buttons.held.cross then--Si je reste appuyé sur la touche croix alors
 screen.print(5,10,table[1])--J'affiche le texte adéquat
end--Fin de la condition</pre>
<p>Puis on fait la même chose pour toute les touches de la PSP.</p>
<pre class="lang:lua decode:true" title="Etape 5">if buttons.held.triangle then--Si je reste appuyé sur la touche triangle alors
  screen.print(5,20,table[2])--J'affiche le texte
end--Fin de la condition
if buttons.held.square then--Si je reste appuyé sur la touche carré alors
  screen.print(5,30,table[3])--J'affiche le texte
end--Fin de la condition
if buttons.held.circle then--Si je reste appuyé sur la touche rond alors
  screen.print(5,40,table[4])--J'affiche le texte
end--Fin de la condition
if buttons.held.up then--Si je reste appuyé sur la touche haut alors
  screen.print(5,50,table[5])--J'affiche le texte
end--Fin de la condition
if buttons.held.right then--Si je reste appuyé sur la touche droite alors
  screen.print(5,60,table[6])--J'affiche le texte
end--Fin de la condition
if buttons.held.left then--Si je reste appuyé sur la touche gauche alors
  screen.print(5,70,table[7])--J'affiche le texte
end--Fin de la condition
if buttons.held.down then--Si je reste appuyé sur la touche bas alors
  screen.print(5,80,table[8])--J'affiche le texte
end--Fin de la condition
if buttons.held.r then--Si je reste appuyé sur la touche R alors
  screen.print(5,90,table[9])--J'affiche le texte
end--Fin de la condition
if buttons.held.l then--Si je reste appuyé sur la touche L alors
  screen.print(5,100,table[10])--J'affiche le texte
end--Fin de la condition
if buttons.held.start then--Si je reste appuyé sur la touche Start alors
  screen.print(5,110,table[11])--J'affiche le texte
end--Fin de la condition
if buttons.held.select then--Si je reste appuyé sur la touche Sélect alors
  screen.print(5,120,table[12])--J'affiche le texte
end--Fin de la condition</pre>
<p>Voilà maintenant il ne reste plus qu'à <strong>rafraichir l'écran</strong> à chaque fin de tour de notre boucle et fermer la <strong>boucle while true do.</strong></p>
<pre class="lang:lua decode:true" title="Etape 6">screen.flip()--Rafraichissement de l'écran
end--Fin de la boucle</pre>
<p> Voilà normalement vous devez obtenir ceci&nbsp;:</p>
<p style="text-align: center;"> <a href="https://www.customprotocol.com/medias/2014/12/screen-cours-5-debutant.png"><img fetchpriority="high" decoding="async" class="alignnone size-medium wp-image-1008" src="https://www.customprotocol.com/medias/2014/12/screen-cours-5-debutant-300x170.png" alt="screen-cours-5-débutant" width="300" height="170" srcset="https://www.customprotocol.com/medias/2014/12/screen-cours-5-debutant-300x170.png 300w, https://www.customprotocol.com/medias/2014/12/screen-cours-5-debutant-370x210.png 370w, https://www.customprotocol.com/medias/2014/12/screen-cours-5-debutant-270x153.png 270w, https://www.customprotocol.com/medias/2014/12/screen-cours-5-debutant.png 480w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>Voilà le code en entier:</p>
<pre class="lang:lua decode:true" title="Récapitulons">table&nbsp;=&nbsp;{}--Création d'une table regroupant toutes les infos suivantes
table[1]&nbsp;=&nbsp;"Appuie sur la touche Croix"
table[2]&nbsp;=&nbsp;"Appuie sur la touche Triangle"
table[3]&nbsp;=&nbsp;"Appuie sur la touche Carré"
table[4]&nbsp;=&nbsp;"Appuie sur la touche Rond"
table[5]&nbsp;=&nbsp;"Appuie sur la touche Haut"
table[6]&nbsp;=&nbsp;"Appuie sur la touche Droite"
table[7]&nbsp;=&nbsp;"Appuie sur la touche Gauche"
table[8]&nbsp;=&nbsp;"Appuie sur la touche Bas"
table[9]&nbsp;=&nbsp;"Appuie sur la touche R"
table[10]&nbsp;=&nbsp;"Appuie sur la touche L"
table[11]&nbsp;=&nbsp;"Appuie sur la touche START"
table[12]&nbsp;=&nbsp;"Appuie sur la touche SELECT"
while true do--Début de la boucle
	
	buttons.read()--Lecture des touches actionnées
	
	if buttons.held.cross then--Si je reste appuyé sur la touche croix alors
		screen.print(5,10,table[1])--J'affiche le texte adéquat
	end--Fin de la condition
	
	if buttons.held.triangle then--Si je reste appuyé sur la touche triangle alors
	  screen.print(5,20,table[2])--J'affiche le texte
	end--Fin de la condition
	
	if buttons.held.square then--Si je reste appuyé sur la touche carré alors
	  screen.print(5,30,table[3])--J'affiche le texte
	end--Fin de la condition
	
	if buttons.held.circle then--Si je reste appuyé sur la touche rond alors
	  screen.print(5,40,table[4])--J'affiche le texte
	end--Fin de la condition
	
	if buttons.held.up then--Si je reste appuyé sur la touche haut alors
	  screen.print(5,50,table[5])--J'affiche le texte
	end--Fin de la condition
	
	if buttons.held.right then--Si je reste appuyé sur la touche droite alors
	  screen.print(5,60,table[6])--J'affiche le texte
	end--Fin de la condition
	
	if buttons.held.left then--Si je reste appuyé sur la touche gauche alors
	  screen.print(5,70,table[7])--J'affiche le texte
	end--Fin de la condition
	
	if buttons.held.down then--Si je reste appuyé sur la touche bas alors
	  screen.print(5,80,table[8])--J'affiche le texte
	end--Fin de la condition
	
	if buttons.held.r then--Si je reste appuyé sur la touche R alors
	  screen.print(5,90,table[9])--J'affiche le texte
	end--Fin de la condition
	
	if buttons.held.l then--Si je reste appuyé sur la touche L alors
	  screen.print(5,100,table[10])--J'affiche le texte
	end--Fin de la condition
	
	if buttons.held.start then--Si je reste appuyé sur la touche Start alors
	  screen.print(5,110,table[11])--J'affiche le texte
	end--Fin de la condition
	
	if buttons.held.select then--Si je reste appuyé sur la touche Sélect alors
	  screen.print(5,120,table[12])--J'affiche le texte
	end--Fin de la condition
	
	screen.flip()--Rafraichie l'écran
	
end--Fin de la boucle while
		</pre>
<p>Maintenant que vous savez utiliser les touches de votre PSP, vous allez pouvoir commencer sérieusement à penser à des projets mais pour cela, il faudra encore apprendre de nouvelle chose&nbsp;<img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /> </p>
<p>L’article <a rel="nofollow" href="https://www.customprotocol.com/programmation/programmer-en-lua-debutant-cours-n5-les-touches-de-la-psp/">Programmer en Lua&nbsp;-&nbsp;Débutant&nbsp;-&nbsp;Cours n°5&nbsp;: Les touches de la PSP</a> est apparu en premier sur <a rel="nofollow" href="https://www.customprotocol.com">Custom Protocol</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.customprotocol.com/programmation/programmer-en-lua-debutant-cours-n5-les-touches-de-la-psp/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>

