[gpm]Data Sync

Cserveny Tamas smil@fiktiv.szgtikol.kando.hu
Thu, 3 Oct 2002 23:40:25 +0200 (CEST)


  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.
  Send mail to mime@docserver.cac.washington.edu for more info.

---507444509-1361164347-1033681225=:18255
Content-Type: TEXT/PLAIN; charset=US-ASCII

On Wed, 2 Oct 2002, Alessandro Rubini wrote:
Hi! 

>first byte and some other protocol don't.  If your protocol does but
>it's not used than this is a bug in the definition of the type.

OK. I've found, and fix that. 

>Please fix mice.c, not the main loop, and please send a patch even it
>it's one line. Patches are generated and applied by tools, descriptions
>must be written and applied by hand [this is "type-once use many"]

The problem was more complex then i though.

After each screen change gpm calls the I_* rutine again. If there was some
leftover data, then imps2 initialization failed. It turs out, that this
was failed because reading an ACK and not the answer. ImPS/2 is falling
back then to plain PS/2. 
But, if there was a real imps2, then it would send 4 byte packes, since we
requested that, but PS/2 driver cannot handle them.

Things that changed:

I_imps2 now flushes the data input at startup. 

Intelli Explorer mouse with 5 button is the same protocol, with small changes.
I_imps2 now detect exps2 also. 

If imps/2 was not found, then now a reset is issued, to be clear, that no
imps/2 like wonder sends 4 byte packets again to ps2 driver. 

data[0] & c0 == 0 now data[0] & 8 == 8, according to the ps2 protocol.

There is now support for the 4th and 5th button of exps2. 
(Defining GPM_B_FIFTH)

-----> 

I have a bug also, bug i had no time to fix it:
If an I_* returned with null, then the /var/run/gpm.pid is not removed!

Regards,

-- 
Cserveny Tamas

"Mosokonyha! Vigyazat ne ingereljuk a bestiat!" Vanek B. Eduard

---507444509-1361164347-1033681225=:18255
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="im.patch"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.LNX.4.21.0210032340250.18255@fiktiv.szgtikol.kando.hu>
Content-Description: 
Content-Disposition: attachment; filename="im.patch"

ZGlmZiAtcnUgZ3BtLWN2cy9zcmMvaGVhZGVycy9ncG0uaCBncG0tY3ZzLnBh
d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GlzIGxhbWUsIGJ1
dCB3b3JrcyENCisgICovDQorc3RhdGljIHZvaWQgZmx1c2hfaW5wdXQoaW50
IGZkKSB7DQorICAgY2hhciBjOw0KKyAgIGludCBtb2RlID0gZmNudGwoZmQs
Rl9HRVRGTCk7DQorDQorICAgZmNudGwoZmQsIEZfU0VURkwsIE9fTk9OQkxP
Q0spOw0KKyAgIA0KKyAgIC8qIEZsdXNoIGxlZnRvdmVyIGRhdGEgKi8NCisg
ICB3aGlsZSAocmVhZChmZCwgJmMsIDEpID4gMCk7DQorDQorICAgZmNudGwo
ZmQsIEZfU0VURkwsIG1vZGUpOw0KK30NCisNCiANCiAvKiBpbnRlbGxpbW91
c2UsIHBzMiB2ZXJzaW9uOiBCZW4gUGZhZmYgYW5kIENvbGluIFBsdW1iICov
DQogLyogQXV0b2RldGVjdDogU3RldmUgQmVubmV0dCAqLw0KKy8qIEludGVs
bGltb3VzZSBleHBsb3JlciBzdXBwb3J0LCBsZWZ0b3ZlciBkYXRhIGNvcnJ1
cHRpb24gZml4OiBDc2VydmVueSBUYW1hcyAqLw0KKw0KIHN0YXRpYyBHcG1f
VHlwZSAqSV9pbXBzMihpbnQgZmQsIHVuc2lnbmVkIHNob3J0IGZsYWdzLCBz
dHJ1Y3QgR3BtX1R5cGUgKnR5cGUsDQotICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGludCBhcmdjLCBj
aGFyICoqYXJndikNCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICBpbnQgYXJnYywgY2hhciAqKmFyZ3Yp
DQogew0KICAgIGludCBpZDsNCiAgICBzdGF0aWMgdW5zaWduZWQgY2hhciBi
YXNpY19pbml0W10gPSB7IEdQTV9BVVhfRU5BQkxFX0RFViwgR1BNX0FVWF9T
RVRfU0FNUExFLCAxMDAgfTsNCi0gICBzdGF0aWMgdW5zaWduZWQgY2hhciBp
bXBzMl9pbml0W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dG9jb2wsIGJ1dCBvbmx5IDMgYnl0ZXMgcGVyIHBhY2tl
dC4iLA0KICAgICAgICAgICAgIiIsIE1fc3VuLCBJX3NlcmlhbCwgQ1M4IHwg
Q1NUT1BCIHwgU1REX0ZMRywNCiAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgIHsweGY4LCAweDgwLCAweDAwLCAweDAwfSwgMywgMSwgMCwgMCwg
MH0sDQo=
---507444509-1361164347-1033681225=:18255--