<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>[A5] Xbox360 Controller Trigger buttons = only one axis?</title>
		<link>http://www.allegro.cc/forums/view/615806</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Fri, 16 Oct 2015 11:58:29 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hello all,</p><p>I&#39;m using Allegro 5.0.10 and a Xbox360 USB Controller.<br />I&#39;m using <span class="source-code"><a href="http://www.allegro.cc/manual/al_get_joystick_state"><span class="a">al_get_joystick_state</span></a></span> to detects all inputs and store it in <span class="source-code"><a href="http://www.allegro.cc/manual/ALLEGRO_JOYSTICK_STATE"><span class="a">ALLEGRO_JOYSTICK_STATE</span></a></span> .<br />All this is perfect except that Left Trigger (LT analog button) works as 3rd axis (Axis[2] negative values 0.0 to -1.0) and Right Trigger (RT analog button) also works as 3rd axis (Axis[2] positive values 0.0 to +1.0).<br />Thus, when you hold LT and RT these 2 values compensate each other and the result is 0.0, just like none of the 2 buttons where input.</p><p>This seems to be a common problem shared on other game engine. For example :			</p><p><a href="http://answers.unity3d.com/questions/27878/triggers-on-the-360-controller-treated-as-one-axis.html">http://answers.unity3d.com/questions/27878/triggers-on-the-360-controller-treated-as-one-axis.html</a></p><p>The problem is:
</p><ul><li><p>I don&#39;t have a 9th or 10th axis like in this given thread.
</p></li><li><p>none of the 8 allegro sticks (_AL_MAX_JOYSTICK_STICKS) or 8*3 axes (_AL_MAX_JOYSTICK_AXES) are returning non-zero values. Yes I tested them all.</p></li></ul><p>Did any of you succeeded in detecting LT+RT input?</p><p>Thank you
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (anto80)</author>
		<pubDate>Sat, 10 Oct 2015 19:20:12 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>One way to fix this could be to use DirectInput correctly or, even better, XInput.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (RPG Hacker)</author>
		<pubDate>Sat, 10 Oct 2015 22:00:02 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/615806/1017142#target">RPG Hacker</a> said:</div><div class="quote"><p>One way to fix this could be to use DirectInput correctly or, even better, XInput. </p></div></div><p>
Sorry but I&#39;m not following you.<br />Could you be more specific? <br />Is your solution Allegro 5.0 standard?<br />Can you show some code?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (anto80)</author>
		<pubDate>Sat, 10 Oct 2015 22:22:22 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Allegro 5.1 had a lot of work done with joysticks, in particular with XInput. I&#39;d try 5.1 and see if it helps.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Sat, 10 Oct 2015 22:49:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/615806/1017142#target">RPG Hacker</a> said:</div><div class="quote"><p> One way to fix this could be to use DirectInput correctly or, even better, XInput. 
</p></div></div><p>When I set my Logitech F510 controller to XInput mode, LT and RT are treated as one axis. So I assume XInput wouldn&#39;t really help. In DirectInput mode, they are treated as buttons, not sticks. In both cases, Allegro 5.0 and the Game Controllers app that comes with Windows 8.1 give the same result.</p><p>I haven&#39;t tested with 5.1, can&#39;t be bothered to build it...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (torhu)</author>
		<pubDate>Sat, 10 Oct 2015 23:40:42 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>That&#39;s weird. Could that be a drivers issue? Or maybe they&#39;re even doing this intentionally. I don&#39;t know if there actually is a single XBOX 360 game where both triggers have to be used for different things at the same time.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (RPG Hacker)</author>
		<pubDate>Sun, 11 Oct 2015 03:27:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Has everyone missed the fact that this is by design?</p><p><a href="http://wiki.unity3d.com/index.php?title=Xbox360Controller">http://wiki.unity3d.com/index.php?title=Xbox360Controller</a></p><p>(see section: Axises)</p><p>Go to the Windows joystick calibration screen. It&#39;s only one axis because it&#39;s supposed to be a linked &quot;throttle and/or brake&quot; axis.</p><p>XInput may allow separate per this one:</p><p><a href="https://forums.dolphin-emu.org/Thread-l-and-r-trigger-problem">https://forums.dolphin-emu.org/Thread-l-and-r-trigger-problem</a></p><p>I know some Xbox games got around this limitation, but I&#39;ve never heard of how they did it.</p><p>[edit]
</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
If you only build your game for Windows, you may be interested in XInput.NET which allows full XBox 360 controller support. For an InputManager.asset file with four XBox 360 controllers mapped click here or with separate axises for triggers: click here
</p></div></div><p>

<b>Windows only</b></p><p>[edit]</p><p>Supposedily, you can download the Xbox 360 controller driver:</p><p><a href="https://www.microsoft.com/hardware/en-us/d/xbox-360-controller-for-windows">https://www.microsoft.com/hardware/en-us/d/xbox-360-controller-for-windows</a></p><p>And there&#39;s a config program to change whether or not the axies are linked. The point here is that it&#39;s not Allegro, and it&#39;s not a portable solution.</p><p>[edit]</p><p>Also, I forgot, don&#39;t forget to read Microsoft&#39;s insane &quot;official reason&quot;:</p><p><a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ee417014(v=vs.85).aspx">https://msdn.microsoft.com/en-us/library/windows/desktop/ee417014(v=vs.85).aspx</a>
</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
However, some functionality provided by XInput will be missing from the DirectInput implementation:</p><p> - The left and right trigger buttons will act as a single button, not independently<br /> - The vibration effects will not be available<br /> - Querying for headset devices will not be available</p><p><b>The combination of the left and right triggers in DirectInput is by design.</b> Games have always assumed that DirectInput device axes are centered when there is no user interaction with the device. However, the Xbox 360 controller was designed to register minimum value, not center, when the triggers are not being held. Older games would therefore assume user interaction.</p><p>The solution was to combine the triggers, setting one trigger to a positive direction and the other to a negative direction, so no user interaction is indicative to DirectInput of the &quot;control&quot; being at center.</p><p>In order to test the trigger values separately, you must use XInput.
</p></div></div><p>

Devs are <i>not happy</i> with their explanation. (see comment section)</p><p>[edit]</p><p>On the brightside, apparently users were so fed up they made their own driver:</p><p><a href="http://vba-m.com/forum/Thread-xbcd-0-2-7-release-info-updates-will-be-posted-here">http://vba-m.com/forum/Thread-xbcd-0-2-7-release-info-updates-will-be-posted-here</a></p><p>To bring back the functionality that Microsoft ruined. Let&#39;s see how the pro-Microsoft people here try and spin this as positive.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Chris Katko)</author>
		<pubDate>Sun, 11 Oct 2015 05:28:33 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>What are you using the triggers for?  What game mechanic?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Mark Oates)</author>
		<pubDate>Sun, 11 Oct 2015 06:42:35 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>in some cases, I had to hold both trigger and press another button while holding.</p><p>Hold LT+RT and press A, for example.</p><p>[Edit]<br />So I&#39;m skr**ed, right?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (anto80)</author>
		<pubDate>Mon, 12 Oct 2015 15:50:35 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>360 controllers were built specifically for XInput. They are able to interact with DirectInput through legacy support, but in doing so, certain things are not supported. One of those in particular being the ability to read the states of left and right triggers independently. Instead, they are reported as a single axis with one of the triggers going positive on the axis, the other trigger going negative. <u>This is by design and there are NO workarounds to this if you stick with using DirectInput.</u></p><p>Instead, either go up to the unstable Allegro 5.1.x branch which I believe supports XInput controllers directly (don&#39;t quote me on that, I use 5.0.x), or just code your own XInput support. XInput is extremely easy to use and using it directly will allow you to do things like rumble effects and reporting battery levels, things you can&#39;t do with a 360 controller if you stick with DirectInput. <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kris Asick)</author>
		<pubDate>Wed, 14 Oct 2015 00:23:10 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>This seems great!</p><p>Are there any Allegro examples which use XInput interaction?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (anto80)</author>
		<pubDate>Wed, 14 Oct 2015 02:09:06 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Using XInput is also great for providing default controls to players using an XBOX 360 Controller. Since that controller is probably the one being used by the most people for PC games, and since the buttons on the controller are known, you can not only provide good default controls for players using this controller, but you can also directly name the buttons on the controller. So instead of saying &quot;press button 1&quot; or &quot;move axis 3&quot; you could say &quot;press A&quot; or &quot;press right trigger&quot;.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (RPG Hacker)</author>
		<pubDate>Fri, 16 Oct 2015 11:58:29 +0000</pubDate>
	</item>
</rss>
