USB joystick woes

Stumped again! I’ve copied the joystick example from the online library reference to a new project in VC#2010 Express. Added the GHI System and GHI USBHost references. When I debug, it exits with code zero.

Here’s the last couple lines of the output:

The debugging target runtime is loading the application assemblies and starting execution.
Ready.

‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.1\Assemblies\le\mscorlib.dll’
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.1\Assemblies\le\Microsoft.SPOT.Native.dll’
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.1\Assemblies\le\Microsoft.SPOT.Hardware.dll’
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\GHI Electronics\GHI NETMF v4.1 SDK\Assemblies\le\GHIElectronics.NETMF.System.dll’
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\GHI Electronics\GHI NETMF v4.1 SDK\Assemblies\le\GHIElectronics.NETMF.USBHost.dll’
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files (x86)\GHI Electronics\GHI NETMF v4.1 SDK\Assemblies\le\FEZDomino_GHIElectronics.NETMF.FEZ.dll’
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Users\Dave\AppData\Local\Temporary Projects\FEZ Domino Joystick\bin\Debug\le\FEZ Domino Application.exe’, Symbols loaded.
The thread ‘’ (0x2) has exited with code 0 (0x0).

Any help would be greatly appreciated!

If you use MFDeploy to get back the version number, what do you see?

ClrInfo.targetFrameworkVersion: 4.1.2821.0
SolutionReleaseInfo.solutionVersion: 4.1.1.0
SolutionReleaseInfo.solutionVendorInfo: GHI Electronics, LLC
SoftwareVersion.BuildDate: Aug 9 2010
SoftwareVersion.CompilerVersion: 310739

Does it exit on a blink LED program?!

did you try stepping in the code? I mean F10 not F5 on VS2010

Why is this wrong? It’s ok?

You have this code:


public static void Main()
{
// Subscribe to USBH event.
USBHostController.DeviceConnectedEvent += DeviceConnectedEvent;
// Sleep forever
Thread.Sleep(Timeout.Infinite);
}

Why means it “stops” (infinite sleep), until you connect a joystick. Then the DeviceConnectedEvent gets fired.

See my attachment below.
Note: if I totally misunderstood you, and there is something else wrong, please ignore this post.

Ahh! Your on to something Foekie!

It turns out my dusty Saitek Cyborg Evo Force joystick won’t work unless I power it with the 24VDC supply it came with. I’ll try it with the supply later today. Was assuming it need the supply for the force feedback only. You know what they say about assuming…

How many buttons can be used with the GHI joystick class. My joystick has a total of 12 buttons. Has a hat and a thrust control. I see there is a hat implementation but what about the thrust control? The joystick also has the twist of the handle control. Would that be sensed also by FEZ yet?

Let me know if it works :wink:

I have found with my joystick (logitech 3d PRO) that I could use this:

Buttons: 8 (I have 12 too)
Hat: (what’s this? the analogue joystick thing?)
Thrust: did not work
Twist: no (mine has a twistable joystick)

I do not know if this is joystick dependable or if it’s the driver.
Let me know what works for you and what does not. :wink:

look at output window, it will tell you why it existed. Probably you have old assemblies or something.
Go to Visual Studio ->View tab->Output.
If you are using express you need to do this first. Tools->Settings->Expert Settings

I can confirm the throttle doesn’t work on my 3D pro, either. Any possibility of a fix?

I’m pleased to report my joystick works with FEZ Domino now that it is powered! All 12 buttons are detected also! XY of the normal stick motion is detected. No thrust, stick twist, or the hat(little joystick on the stick near the trigger buttons).

Anyone know how to implement the thrust, stick twist, and hat? I should be good for now with what’s implemented. Tinkering to make a Halloween prop(s).

You can use all 12 buttons?
Chris, can you use all 12 buttons?

[quote]No thrust, stick twist, or the hat(little joystick on the stick near the trigger buttons).

Anyone know how to implement the thrust, stick twist, and hat? I should be good for now with what’s implemented. [/quote]

Unfortunately I do not know how to implement this. This is a USB thing, and you need good knowledge of USB. I hate to say that I do not have this knowledge, yet :wall:

Maybe Gus or Mike can help us? :whistle:

I have all 12 buttons, just not throttle.

Check the XY2 readings. The throttle might be just these reading on some joysticks.

Already checked. It’s not there.

We have a joystick with throttle and it reports the values on XY2…
For us to add this, we have to look in different joysticks with throttle. We will look into this.

Ok, I now have the hat switch readable. Still no throttle. Here is the code I have so far. I commented out the joystick as it is VERY sensitive and creates alot of posts to the debug output.


using System;
using System.Threading;

using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;

using GHIElectronics.NETMF.FEZ;
using GHIElectronics.NETMF.USBHost;

namespace FEZ_Domino_Joystick
{
    public class Program
    {
        static USBH_Joystick j;
               
        public static void Main()
        {
            // Subscribe to USBH event.
            USBHostController.DeviceConnectedEvent += DeviceConnectedEvent;
            
            // Sleep forever
            Thread.Sleep(Timeout.Infinite);
        }

        static void DeviceConnectedEvent(USBH_Device device)
        {
            if (device.TYPE == USBH_DeviceType.Joystick)
            {
                Debug.Print("Joystick Connected");
                j = new USBH_Joystick(device);
                j.JoystickXYMove += JoystickXYMove;
                j.JoystickButtonDown += JoystickButtonDown;
                j.JoystickXY2Move += JoystickXY2Move;
                j.HatSwitchPress += HatSwitch;
            }
        }

        static void JoystickButtonDown(USBH_Joystick sender, USBH_JoystickEventArgs args)
        {
            Debug.Print("Button Pressed: " + args.ChangedButton);
        }
        
        static void JoystickXYMove(USBH_Joystick sender, USBH_JoystickEventArgs args)
        {
           // Debug.Print("(x, y) = (" + sender.Cursor.X + ", " + sender.Cursor.Y + ")");
        }

        static void JoystickXY2Move(USBH_Joystick sender, USBH_JoystickEventArgs args)
        {
            Debug.Print("(x, y) = (" + sender.Cursor2.X + ", " + sender.Cursor2.Y + ")");
        }

        static void HatSwitch(USBH_Joystick sender, USBH_JoystickEventArgs args)
        {          
            Debug.Print("Hat " + sender.HatSwitch +  " Pressed." );
        }
    
    }

}

Curiously, it reports 15 for when the hat goes back to center. Goes from 0 to 7 when going around the hat and then 15 when back to center.

Since I was already messing around with USB stuff, I thought I’d hook up my Logitech Force3DPro.

It has 12 buttons, of which only 8 (0-7) get reported using the Button Up/Button Down events - note that since there are two events, one could “chord” the buttons if needed.

The hat reported positions 0-7, but returned 8 (not 15 like logictechs’ joystick) when returning to center.

Yaw (twist) is reported on the Y part of XY2, varying from -512 to 512.

Does the Force3D throttle work?

Sorry, I should have explicitly mentioned that no, the throttle values are not reported on the Force3DPro.

Chris, I had only 8 buttons. Anyway. I will try it out, working with the joystick anyway now. I will report back.