<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>[A5] Joystick Input (lag) vs Keyboard input (no lag)</title>
		<link>http://www.allegro.cc/forums/view/616627</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Sun, 04 Dec 2016 15:40:29 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I have a problem with joystick/gamepad input, I tested with many gamepad (logitech , x360, ...)</p><p>I always have a lag with gamepad controller. you can test the test program :<br /><a href="https://www.allegro.cc/files/attachment/610655">https://www.allegro.cc/files/attachment/610655</a></p><p><span class="remote-thumbnail"><span class="json">{"name":"827681screenshotmugenEngine.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/f\/c\/fc0afba584383ee01f0f5e00e73ea5a8.png","w":2560,"h":1440,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/f\/c\/fc0afba584383ee01f0f5e00e73ea5a8"}</span><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/f/c/fc0afba584383ee01f0f5e00e73ea5a8-240.jpg" alt="827681screenshotmugenEngine.png" width="240" height="135" /></span></p><p>I don&#39;t know why, how do you get the Joystick input ? I want to say the best way, with the best performance.</p><p>Control: </p><p>Keyboard : Arrow key (UP , DOWN , LEFT , RIGHT)<br />GamePad  : POV (UP , DOWN , LEFT , RIGHT)</p><p>NOTE : use joyToKey ( <a href="http://joytokey.net/en/download">http://joytokey.net/en/download</a> )for control Keyboard &amp; Gamepad at the same time, for test the synchronisation.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SilverTES)</author>
		<pubDate>Sun, 04 Dec 2016 06:44:45 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>In my own code I just check the events (Allegro 5) like I do for keyboard and mouse.  Code inside my event loop looks similar to...</p><div class="source-code snippet"><div class="inner"><pre>   <span class="k1">else</span> <span class="k1">if</span><span class="k2">(</span>event.type <span class="k3">=</span><span class="k3">=</span> ALLEGRO_EVENT_JOYSTICK_BUTTON_UP<span class="k2">)</span> <span class="k2">{</span>
      <span class="k1">if</span><span class="k2">(</span>event.joystick.button <span class="k3">=</span><span class="k3">=</span> <span class="n">0</span><span class="k2">)</span> done <span class="k3">=</span> <span class="k1">true</span><span class="k2">;</span>  <span class="c">// Button 0 = A (green, like pressing ENTER)</span>
      <span class="k1">if</span><span class="k2">(</span>event.joystick.button <span class="k3">=</span><span class="k3">=</span> <span class="n">1</span><span class="k2">)</span> <span class="k1">return</span> <span class="k1">true</span><span class="k2">;</span>  <span class="c">// Button 1 = B (red, used like pressing ESC)</span>
      <span class="c">// Button 7 = Start (unused here)</span>
   <span class="k2">}</span>

   <span class="k1">else</span> <span class="k1">if</span><span class="k2">(</span>event.type <span class="k3">=</span><span class="k3">=</span> ALLEGRO_EVENT_JOYSTICK_AXIS<span class="k2">)</span> <span class="k2">{</span>
      done <span class="k3">=</span> <span class="k1">true</span><span class="k2">;</span>
   <span class="k2">}</span>

   <span class="k1">else</span> <span class="k1">if</span><span class="k2">(</span>event.type <span class="k3">=</span><span class="k3">=</span> ALLEGRO_EVENT_JOYSTICK_CONFIGURATION<span class="k2">)</span> <span class="k2">{</span>
      <a href="http://www.allegro.cc/manual/al_reconfigure_joysticks"><span class="a">al_reconfigure_joysticks</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>

<span class="c">//... etc...</span>
</pre></div></div><p>

Though right now, I have this commented out.  I had it in my Deluxe Pacman 2 game code, but there was a reason why I removed support for joysticks and I honestly cannot remember why.  Could be a problem with it, I forget now.  I&#39;ll have to check my notes.  (checked notes)Yeah, there seemed to be some sort of bug with the joystick support in Allegro 5 which I couldn&#39;t resolved.  In my notes I noted that the digital input is flaky and I was getting random crashes.  I ended up removing joystick support.  I think the digital input was laggy or something and other problems I forget now, it&#39;s been a while.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Neil Roy)</author>
		<pubDate>Sun, 04 Dec 2016 13:36:37 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>In my case, I use al_get_joystick_state(_joystick[0],  &amp;_joyState) for getting joystick state, I already used joystick event and I have the same lag.</p><p>Well, it&#39;s possible to use another library for manage joystick input,<br />Maybe use directInput directly ?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SilverTES)</author>
		<pubDate>Sun, 04 Dec 2016 15:40:29 +0000</pubDate>
	</item>
</rss>
