Events? #11

Open
geuis opened this Issue Apr 8, 2012 · 3 comments

Comments

Projects
None yet
2 participants
@geuis

geuis commented Apr 8, 2012

Now that I've got node-usb running, I've plugged in an xbox controller and am exploring what it offers.

One thing that I'm not really sure about is how to listen for events from a given device. Is it necessary to poll a usb device continuously, such as a game controller, to get its modified input values? Or rather, is there an event interface on node-usb that I can subscribe to?

@geuis

This comment has been minimized.

Show comment Hide comment
@geuis

geuis Apr 8, 2012

On further research, I see that one must poll interruptTransfer based on the bInterval value provided by the device.

There's no examples of using interruptTransfer in the examples, though there is a controlInterrupt. However the interfaces seem different.

geuis commented Apr 8, 2012

On further research, I see that one must poll interruptTransfer based on the bInterval value provided by the device.

There's no examples of using interruptTransfer in the examples, though there is a controlInterrupt. However the interfaces seem different.

@schakko

This comment has been minimized.

Show comment Hide comment
@schakko

schakko Apr 10, 2012

Owner

Exactly, you must poll the endpoint.
Interrupt transfer has the same arguments as Endpoint.bulkTransfer.

Owner

schakko commented Apr 10, 2012

Exactly, you must poll the endpoint.
Interrupt transfer has the same arguments as Endpoint.bulkTransfer.

@geuis

This comment has been minimized.

Show comment Hide comment
@geuis

geuis Apr 10, 2012

I was able to get this all working after digging through source code.

One thing I want to get your opinion on is the argument order. The interrupt is looks like (I forget what 'first' is at the moment):

interrupt(first, callbackFunction, timeout);

As I wrote code for this:

interrupt(first, function(){
//do stuff
}, 0);

It feels funny to have something other than the callback function as the last argument. Shouldn't it be in the order of first, timeout, callback?

geuis commented Apr 10, 2012

I was able to get this all working after digging through source code.

One thing I want to get your opinion on is the argument order. The interrupt is looks like (I forget what 'first' is at the moment):

interrupt(first, callbackFunction, timeout);

As I wrote code for this:

interrupt(first, function(){
//do stuff
}, 0);

It feels funny to have something other than the callback function as the last argument. Shouldn't it be in the order of first, timeout, callback?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment