fpit - fixes and passive-pen support

"David M. Clay" <[email protected]>
Newsgroups gmane.comp.xfree86.devel
Message-ID <[email protected]>
Hello all.

I am new at this, so please gently guide me through this wonderful 
process of open-source coding.

I just recently purchased a Stylistic 3400 and found the current fpit 
driver did not support the passive pen of the 3400. So I modified the 
current driver to support the passive pen.

I am looking to have my changes added to the latest source tree. What is 
the best was to have others test my changes on other systems with 
different hardware, especially the active-pen models? I am pretty sure 
that I have fixed several bugs that had to have affected the active-pen 
systems as well, and I hope that I haven't broken anything. I don't have 
access to any other Stylistic tablets so I am unable to test it myself. 
The driver does work beautifully on my Stylistic 3400 though. Are there 
any testers out there? Whats the best way for me to post the changes? Is 
there a preferred style for diff patches? Is there a FAQ for this?

I would also like to describe the changes and fixes I have made in hopes 
someone will have comments. Keep in mind that this is my first attempt 
at X driver programing (though I've been a Windows application 
programmer for over 10 years), so there will be instances where I have 
no idea what I am talking about.

The POXIMITY_BIT was defined as 0x40 which is bit 6 "Switch status 
change." So I changed it to 0x20 or bit 5 "Proximity" (according to the 
protocol chart in the code). I don't know if on an active-pen system 
0x40 is really the proximity bit, I just made the constant consistent 
with my 3400 and with the bit-assignment chart in the code.

Also, to figure out which buttons have changed state, the current code 
subtracts the old value from the new. This gives an arithmetic 
difference but not a bit-wise difference. I believe what is needed here 
is XOR to show which bits (and therefore switches) have changed: delta = 
buttons ^ priv->fpitOldButtons

Also, the current code searches backward through the read buffer to get 
the last valid pen event. In effect it processes only the last available 
event in the buffer, and discards any events that may be before it. 
Although the pen uses absolute coordinates, those discarded events 
contain useful information. They can be intermediate points when using 
the pen to draw curves, or they can be switch events (especially if the 
switches are quickly cycled or if the buffer contains many events) which 
we want to pass on. On a related issue, some events weren't getting read 
(the pen up event in particular) until more events got put in the buffer 
(like a pen down). xf86FpitReadInput() wasn't getting called even though 
there was data available. So I added a loop on xf86WaitForInput() to 
make sure we got all the data, and the problem cleared up.

Also, the current code didn't seem to support the right mouse button 
(button 3), so I modified the button switch map to {0, 1, 2, 3}. Ive 
read of users getting strange button numbers on switch number 3. This is 
most likely due to the 4th value (3rd button) of the map array not being 
defined, but instead pointing to random data on the stack.

After all these modifications, my 3400 passive pen worked beautifully. 
Then I realized that this same driver should easily be able to work with 
an active-pen system. The only difference I could see would be how the 
buttons behave. So I added a Option parameter called "Passive" to allow 
the driver to be used for either system:

Thanks and I look forward to your comments and directions.

Sincerely,
David Clay
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.