<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>DirectInput joystick bug</title>
		<link>http://www.allegro.cc/forums/view/507375</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Sun, 17 Jul 2005 19:51:25 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>While toying around with Allegro&#39;s joystick routines with JOY_TYPE_AUTODETECT under Windows, I discovered that I couldn&#39;t actually utilize all the axes/sliders on my joystick (a Saitek X-36) - to be specific, Allegro didn&#39;t report Rotary #2.</p><p>After digging around in the sources, I <i>thought</i> I had found the cause of it:
</p><div class="source-code snippet"><div class="inner"><pre><span class="c">/* From joystick.h */</span>

<span class="p">#define MAX_JOYSTICKS            8</span>
<span class="p">#define MAX_JOYSTICK_AXIS        3</span>
<span class="p">#define MAX_JOYSTICK_STICKS      5</span>
<span class="p">#define MAX_JOYSTICK_BUTTONS     32</span>
</pre></div></div><p>
Since my joystick was being reported as having 5 sticks, I thought I was running into the hardcoded limit and changed MAX_JOYSTICK_STICKS to a higher value, but to no avail. So I did some more testing, and discovered that the problem is with JOY_TYPE_DIRECTX (the default) and not with JOY_TYPE_WIN32.</p><p>With JOY_TYPE_DIRECTX the joystick gets this layout:
</p><div class="source-code snippet"><div class="inner"><pre>Stick <span class="n">0</span><span class="k2">:</span>
   Axis <span class="n">0</span><span class="k2">:</span> X Axis
   Axis <span class="n">1</span><span class="k2">:</span> Y Axis
Stick <span class="n">1</span><span class="k2">:</span>
   Axis <span class="n">0</span><span class="k2">:</span> Rudder
Stick <span class="n">2</span><span class="k2">:</span>
   Axis <span class="n">0</span><span class="k2">:</span> Throttle
Stick <span class="n">3</span><span class="k2">:</span>
   Axis <span class="n">0</span><span class="k2">:</span> Rotary #<span class="n">1</span>
Stick <span class="n">4</span><span class="k2">:</span>
   Axis <span class="n">0</span><span class="k2">:</span> Main POV hat X
   Axis <span class="n">1</span><span class="k2">:</span> Main POV hat Y

<span class="k3">+</span> <span class="n">26</span> buttons
</pre></div></div><p>
Rotary #2 (identical to Rotary #1) is nowhere to be seen.</p><p>And with JOY_TYPE_WIN32:
</p><div class="source-code snippet"><div class="inner"><pre>Stick <span class="n">0</span><span class="k2">:</span>
   Axis <span class="n">0</span><span class="k2">:</span> X Axis
   Axis <span class="n">1</span><span class="k2">:</span> Y Axis
   Axis <span class="n">2</span><span class="k2">:</span> Throttle
Stick <span class="n">1</span><span class="k2">:</span>
   Axis <span class="n">0</span><span class="k2">:</span> Rudder
Stick <span class="n">2</span><span class="k2">:</span>
   Axis <span class="n">0</span><span class="k2">:</span> Rotary #<span class="n">1</span>
Stick <span class="n">3</span><span class="k2">:</span>
   Axis <span class="n">0</span><span class="k2">:</span> Rotary #<span class="n">2</span>
Stick <span class="n">4</span><span class="k2">:</span>
   Axis <span class="n">0</span><span class="k2">:</span> Main POV hat X
   Axis <span class="n">1</span><span class="k2">:</span> Main POV hat Y

<span class="k3">+</span> <span class="n">26</span> buttons
</pre></div></div><p>

Since I figure most people probably haven&#39;t tested Allegro&#39;s joystick input with more complex joysticks, I feel I may have run into an obscure Allegro bug here... <br />Any devs or people who can stand looking at DirectX code who can look into this? <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /></p><p>In any case: is there a reason for MAX_JOYSTICK_STICKS to be set at 5?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (gnolam)</author>
		<pubDate>Sun, 10 Jul 2005 23:45:45 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;d recommend posting to the developers list or asking someone here to do so.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Chris Katko)</author>
		<pubDate>Mon, 11 Jul 2005 01:50:05 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Don&#39;t worry, I&#39;ve seen it, and I&#39;m sure Peter and Elias will see it too if they haven&#39;t already.<br />Personally, I&#39;m not in a position where I can do much about this though - I don&#39;t use Windows very often and my gamepad doesn&#39;t work in Windows anyway (at least, I haven&#39;t tried to get it to work yet, too little incentive to do so).</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>is there a reason for MAX_JOYSTICK_STICKS to be set at 5?</p></div></div><p>
I think not. This, I think, is completely arbitrary.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Mon, 11 Jul 2005 01:58:33 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Sorry for the delay.  I think the problem is in object_enum_callback() in src/win/wjoydx.c.  I suspect the missing axis falls under GUID_RxAxis or GUID_RyAxis which is not being tested for there.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Wang)</author>
		<pubDate>Sun, 17 Jul 2005 19:51:25 +0000</pubDate>
	</item>
</rss>
