View Single Post
Posts: 156 | Thanked: 44 times | Joined on Dec 2007
#49
I think I've figured out the sticky mouse problem - it's simple. The tablet generates a seperate mouse moved message to the mouse down (stylus pressed) message, and the mouse down gets there before the mouse moved.

Fixing it... is less so.

Edit: Indeed, as that's not the issue.

It seems that the mouse moved isn't processed until after the mouse is down... though the events are being fired off in the right order.

Edit: Solved it

It actually was similar to what I initially thought. What happens is that when an event comes in (i.e. the stylus is moved), the mouse state is saved in a few variables - the location is updated and the button state is updated. 60 times a second, an interrupt fires, and this data is read from these variables and their current state is passed into the Mac, by patching where it reads from the hardware ADB controller. In a normal mouse, there is highly unlikely to be a mouse moved and mouse clicked event separated by less than 1/60th of a second with the mouse having moved a long way. But on a touchscreen, the two events fire at exactly the same time, given that there is no way to move the mouse without the pen being down.

So what happens is both the mouse position and button state are updated in one go - so it clicks and drags from the old location every time you put the pen in a new location.

What I made it do was to get the position of the pen down event, set it in the variables, and then clear a flag that is set by the next ADB interrupt (update). It then waits in a loop waiting for this flag to be set, meaning that the interrupt has fired, and then it registers the mouse button down, ensuring that both events happen seperately and sequentially in the right order. Hence no "sticky mouse"

The downside is that it delays things by 1/60th of a second, but it's now usable. And very much so.

New binary/sources to be posted soon (screenshot not required).

Binary: http://gm.stackunderflow.com/maemo/b...ary_0.2.tar.gz

Sources: http://gm.stackunderflow.com/maemo/b...emo_0.2.tar.gz

Last edited by t3h; 2008-02-11 at 14:06.
 

The Following 3 Users Say Thank You to t3h For This Useful Post: