Main Site Documentation

USBHost mouse


#1

Hi,

I have sucessfully caught the connect event for the USB mouse and also caught the mouse wheel events. Can someone please tell me how I determine the direction of the mouse wheel. There does not seem to be mention of it in the documentation.

Thanks


#2

I think up it positive numbers and down is negative numbers.


#3

Mike,

Positive and negative numbers in what parameter?. As per the mouse examples given in various places, the handler called as a result of the wheel move event has parameters passed to the function. These parameters do not contain any documented members that carry wheel movement direction. Can you give me an example?

Thanks

Brett.


#4

Something like this:


{
    USBH_Mouse m;
    m.MouseWheel += new USBH_MouseEventHandler(m_MouseWheel);
}

static void m_MouseWheel(USBH_Mouse sender, USBH_MouseEventArgs args)
{
    int changeInwheel = args.DeltaPosition.ScrollWheelValue;
}


#5

Thanks Mike, all good.

The mouse I am using is actually a Logitech wireless mouse with a nano transciever that is actually connected to the FEZ. About every 3rd connection event I am getting a System.exception. I dont get this if I use a microsoft wired mouse. Do you have any suggestions?

Thanks again.


#6

Can you provide more info? Evevy third connection? are you unplugging and plugging it? Where do you get the exception exactly?
Maybe it needs more power. Power your device using a power supply


#7

Mike,

It most often ocurrs when the mouse is connected before boot or reset but it does still happen on insertion after boot.

The code:

static void DeviceConnectedEvent(USBH_Device device)
{
if (device.TYPE == USBH_DeviceType.Mouse)
{
Debug.Print(“Mouse Connected”);
mouse = new USBH_Mouse(device);

            //mouse.MouseMove += new USBH_MouseEventHandler(MouseMove);
            mouse.MouseDown += new USBH_MouseEventHandler(MouseDown);
            mouse.MouseUp += new USBH_MouseEventHandler(MouseUp);
            mouse.MouseWheel += new USBH_MouseEventHandler(MouseWheel);
        }
    }

The debugger stops at:

mouse = new USBH_Mouse(device);

with the message:

Mouse Connected
#### Exception System.Exception - 0xffffffff (3) ####
#### Message:
#### GHIElectronics.NETMF.USBHost.USBH_Mouse::MouseInit [IP: 0000] ####
#### GHIElectronics.NETMF.USBHost.USBH_Mouse::.ctor [IP: 0073] ####
#### NavSystem.Program::DeviceConnectedEvent [IP: 001b] ####
#### GHIElectronics.NETMF.USBHost.USBH_DeviceConnectionEventHandler::Invoke [IP: 0000] ####
#### GHIElectronics.NETMF.USBHost.USBHostController::nativeEventDispatcher_OnInterrupt [IP: 0037] ####
#### GHIElectronics.NETMF.System.InternalEvent::nativeEventDispatcher_OnInterrupt [IP: 0054] ####
A first chance exception of type ‘System.Exception’ occurred in GHIElectronics.NETMF.USBHost.dll
An unhandled exception of type ‘System.Exception’ occurred in GHIElectronics.NETMF.USBHost.dll

To your comment above about power; how would I externally power a mouse?


#8

I’m pretty sure Mike is saying don’t rely on the USB power alone to power the Fez…


#9

@ Brettskee please “code tag” your code so we can read it.


#10

Power your FEZ with a power supply and see if it still gives you problems.


#11

OK, so I powered the FEZ with an external pwer supply. I stll have the issue described above. Further, I have another wireless mouse, a microsoft model 6000. I have not seen the exception using this new mouse but wheel events do not trigger. Button events using the same code above work OK. I have of course connected the mouse to a windows machine and verified that the new mouse works. Any ideas??


#12

Not sure. You can mail them to us so we can investigate here.


#13

Mike,

I’m not sure this is a great outcome. The airfares for my mice around the planet would be more than they are worth. Is there some other debug information I could provide to help you diagnose the problem?


#14

If you unplug and plug the mouse on a PC several times, does it always work?
I have a feeling it is related to the mouse itself and its wireless connection. We never had problems with mice before. Maybe catch the exception and ask the user to re-attach in this case.
If this is for a commercial project, please send us an email so we can see how to obtain the mouse and try it here.


#15

Yes, I now have three wireless mice. 2 x Logitch and the 6000 MS mouse. They all work with windows with some very tough insertion and removal testing. Rock solid. Both Logitech mice exhibit the issue and while the MS mouse does not raise the exception, the wheel events do not trigger as explained above.