Main Site Documentation

Using USB Client as Joystick or Mouse in 4.3


#1

I’m trying to use USB Client Joystick.

The initialization does not throw an exception anymore like in Beta 3.
But it does not work.

If I follow the samples from here:
https://www.ghielectronics.com/docs/20/usb-client
nothing happens on my PC.
It does not even recognize that a device is connected (not even an unknown).

When I change the init code to this:

private static void InitJoystick()
{
   var controllers = UsbController.GetControllers();
   if (controllers.Length > 0)
   {
      controllers[0].Start();
      _mouse = new Mouse();
      //_joystick = new Joystick();
   }
}

like I saw in the forums shortly, my PC recognized a new device, which shows up as “USB-Device/G120” in device manager and as unspecified device named G120 in Devices and printers.
The device Description in Device Manager is “GHI NETMF Interface”.
This is the same for Mouse and Joystick.
For the Mouse I once got an Mouse and Pointer device in Device Manager called “Microsoft Serial Ballpoint” (or similar), but it had an orange exclamation mark. Since I got it only once, I don’t know what the problem was.

Any ideas?

btw.
of course I do deploy and debugging over serial.
And I use a Cobra II Net.


#2

@ Reinhard Ostermeier - We can reproduce the issue but we don’t have a fix at this time. We’ll let you know when we know more.


#3

@ Reinhard Ostermeier -

There is problem with Keyboard that is just fixed, other usbclient types should work fine in latest firmware.

Please refer https://www.ghielectronics.com/docs/20/usb-client (this page is updated) or run an example code below:

static void TestMouse()
        {
            Mouse mouse = new Mouse();
            Controller.ActiveDevice = mouse;
            while (Controller.State != UsbController.PortState.Running)
            {
                Debug.Print("Waiting to connect to PC...");
                Thread.Sleep(1000);
            }

            int posx = 20;
            int posy = 20;
            while (true)
            {
                if (button.Read() == false)
                {
                    posx += 20;
                    posy += 10;
                    Thread.Sleep(500);
                }

                mouse.MoveCursorTo(posx, posy);
            }

        }

#4

@ Dat - I’ll give it a try over the Weekend.


#5

Controller.ActiveDevice doesn’t exist.


#6

@ Mr. John Smith - I just verified that it does for USBClient. Do you have the proper GHI.Usb assembly? It should be 4.3.5.0 for the latest.