Posts: 16
Joined: Fri Feb 01, 2019 4:27 am

Need to Zero array in PyUSB

Fri Feb 01, 2019 4:35 am

Hi guys,

I've written a pyUSB script in IDLE2 that records mouse movement and clicks etc and outputs it to the Rpi GPIO via PWM.
Im having a problem where I need the mouse data to be zero when its not moving as at the moment it just holds its previous value until it detects movement again.

I could constantly scan the array and check for values changing, but I'm having trouble figuring out how to do this. I have kind of implemented this but I'm having trouble getting it to constantly scan the data array as it only updates when movement is detected.

Or could I just request a HID Report Descriptor and compare the input strings?

Anyone have any ideas?


User avatar
Posts: 711
Joined: Tue Aug 01, 2017 10:06 am

Re: Need to Zero array in PyUSB

Sat Feb 02, 2019 7:37 am

I assume that your using a call back when a mouse event occurs. If so what I would do is have a global variable that holds a time stamp that is updated every-time the call back occurs then in your main loop compare the time stamp to current time and if the needed time has passed then zero the array :)

Posts: 16
Joined: Fri Feb 01, 2019 4:27 am

Re: Need to Zero array in PyUSB

Mon Feb 04, 2019 9:50 pm

Thanks OutoftheBOTS
Seems like the go, just trying to figure out how to implement it now will be the hard part

Return to “Python”