06-29-2012 03:20 PM
In Short: I would like to query a usb mouse for it's X and Y velocity on a regular interval. How do?
What I've Got: My current attempt involves setting up the mouse as a VISA RAW device and grabbing the data via a VISA USB interrupt event on loop (attached). This works splendidly; my issue with this approach is that this returns buffers on uneven intervals, i.e. whenever an event is triggered or the timeout occurs.
My ideas: Though I certainly wouldn't want to stifle anyone's other solutions to the original problem, I have some leads of my own that you may be able to help with, too, if you think one is indeed the correct approach to the original problem. Ideas:
I figure once I am able to set up "on-demand sampling", so to say, of the X and Y data, it will be a simple enough matter to tie this into the master clock of the larger system that the mouse recording will be a part of. I'm looking forward to hearing what input and ideas y'all have. Fire away!
Best,
zob
Solved! Go to Solution.
07-04-2012 12:57 PM
Bumping in hope someone new will see it...
07-04-2012 02:09 PM
Well I wrote the USB nuggets, so we'll just assume for the sake of the argument that I'm a learned gentleman (although I don't think anyone's ever called me that before).
HID works intermittantly. If there's nothing to send, there's nothing sent.
You have two choices (at least) to get what you want. One is putting in an inbetween layer catching the intermittent events but storing the last state and outputting into, say, a notifier at regular intervals.
The other choice is the USB command for Getting HID data. This is meant only for initialisation purposes, but would also work as a way of polling the mouse. Look up the HID documents for the data values needed for the communications packet.
Shane.
07-04-2012 02:23 PM - edited 07-04-2012 02:23 PM
The man himself! Thanks for taking the time to respond. I'll do some reading up on HID communication. I'll likely have more questions, as I am wholly newb-ish at this. In the meanwhile, can I keep the device as a VISA RAW device or should I reinstall as a regular HID mouse?
07-05-2012 01:11 AM
I couldn't answer yesterday because the internet somewhere had a problem. Some sites were OK but most were like in a time-warp....
Either way, here's the parameters for the control command to poll the HID.
Shane.
07-06-2012 12:34 PM - edited 07-06-2012 12:34 PM
Perhaps I am doing it wrong, but I keep getting I/O errors whenever I use my simple little program to try and communicate with the mouse (as setup as a VISA RAW device). I would try reinstalling it as an HID device but for two reasons: (1) I do not want this mouse chip controller the cursor on screen and (2) I do not know how to initialize the HID device as a VISA resource (so I can use the VISA USB Control In vi). Perhaps it would be too much to ask, but would you be able to provide an example (or a link to one), please?
07-06-2012 01:02 PM - edited 07-06-2012 01:03 PM
HID is just a device class. It has a group of standard commands which the device will answer to. The commands will work no matter which driver you use to interface with. It's the DEVICE which is HID, the driver doesn't suddenly make the device HID or non-HID. As such you can use the HID commands also over VISA RAW.
If you have trouble getting the packets set up right, look closer at my nuggets.... 😉
Shane
Ps You can still use VISA RAW, just use the data provided earlier to send the required packet to the device and you'll get the data you want.
07-06-2012 03:56 PM
Alright, now I understand the difference between a device class and its driver. I have read your nuggets many times and somehow I am still doing something wrong. I have tested with a GET_DESCRIPTOR command and it works. It's just this GET_REPORT that is wrong. Here are the values I'm inputting:
NameValue (input / final*)Format (on radix)Reasoning
Request Type:10100001 / 10100001 binarygiven in 7.2.1 of HID spec
Request:0x01 / 1hexfrom top of pg 51 of HID spec
Value:010 / 10binary7.2.1 of HID spec; report type is input (01) + report ID (0) <---don't think report ID is used?
Index0 / 0decimalfor default
length18 / 0decimalfirst length to test
*by final I mean what it appears as when you input it into LV
But no dice with these values. I've also attached the sheet for the chip I'm working with for reference.
07-07-2012 01:19 PM - edited 07-07-2012 01:21 PM
Report ID is only used if the device returns more than one report which is normally not the case with a mouse. In this case DO NOT add a value for report ID.
What error are you getting when sending the request, and can you show a screenshot of your call? Or attach a VI?
Shane.
PS According to 5.2.2 of your PDF your report is only 4 bytes long... Why ask for 18?
07-07-2012 01:22 PM
I didn't read the whole thread, but after a quick glance I didn't see any reference to the following options, which should be simpler: