FEZ Cerbduino Bee errors with XBox360 controller

using latest freshly downloaded NETMF SDK for VS2013 and latest GHI stuff

using this snippet:
https://www.ghielectronics.com/community/codeshare/entry/939

using System;
using Microsoft.SPOT;
using GHI.Usb.Host;
using GHI.Usb.Descriptors;
using System.Threading;

namespace ControllerTest
{
	public class Program
	{
		static XBox360Controller gamepad;
		public static void Main()
		{
			Debug.Print(Resources.GetString(Resources.StringResources.String1));

			Controller.UnknownDeviceConnected += Controller_UnknownDeviceConnected;

			Controller.Start();

			

			Thread.Sleep(-1);
		}

		static void Controller_UnknownDeviceConnected(object sender, Controller.UnknownDeviceConnectedEventArgs e)
		{
			Debug.Print("Somethin connected");
			Debug.Print(e.Id + "  " + e.VendorId + "   " + e.ProductId + "   " + e.PortNumber);

			if (e.VendorId == XBox360Controller.VENDOR_ID && e.ProductId == XBox360Controller.PRODUCT_ID)
			{
				gamepad = new XBox360Controller(e);
				ThreadStart s = new ThreadStart(GamepadLoop);
				Thread t = new Thread(s);
				t.Start();
			}
		}

		static void GamepadLoop()
		{
			while (gamepad.Connected)
			{
				//gamepad.SetRumbleIntensity(gamepad.GetTriggerPosition(XBox360Controller.Trigger.Left), gamepad.GetTriggerPosition(XBox360Controller.Trigger.Right));
				Debug.Print(gamepad.GetTriggerPosition(XBox360Controller.Trigger.Left).ToString());
				Thread.Sleep(100);
			}
		}
	}
}

throws repeated

A first chance exception of type 'System.Exception' occurred in GHI.Usb.dll
0
0
Input Error: 2
0
A first chance exception of type 'System.Exception' occurred in GHI.Usb.dll
0
Input Error: 2
0
A first chance exception of type 'System.Exception' occurred in GHI.Usb.dll
0
0
Input Error: 2

@ MitchT - I haven’t run your code but Thread t = new Thread(s) goes out of scope when the Controller_UnknownDeviceConnected method finishes. You should declare is outside the method and static at that (or I could be mistaken).

mm, not quite how threads work heh.

also, the zeroes from my console quote are from the Debug.Print inside the GamepadLoop.

Yea, I know :slight_smile: About all of the above heh.

@ MitchT - I was able to reproduce the issue. We’ll take a look and let you know when we find out more.

<3 thanks.

Is there a firmware version, SDK version, or IDE combination in which your snippet works with the Cerb stuff in the mean time?

@ MitchT - Not that I know of.

@ MitchT - This should be fixed for the next SDK.

Can you share the bitbucket link for the fix? Our it’s it in the Cerb firmware?

@ devhammer - It’s in the firmware.