Sync with kernel about slot info when started

When mtplot is started, the slot info is initialized to be 0,
including x, y, pressure, and the current slot number. Sometimes,
this may result in a problem. For example, if the last tap
occurs at

  (x, y) = (1020, 500)

And then a new tap occurs at

  (x, y) = (1000, 500)

The kernel will only report x value but not y value. Since y is
initialized to be 0, the tap position is mistakenly interpreted by
mtplot as

  (x, y) = (1000, 0)

This patch fixes this problem by sync-ing with kernel about the last
slot info.

BUG=chromium:307817
TEST=Perform the following tests on a link chromebook.
It is easier to verify it using a host opening two terminals and do
ssh-ing to the chromebook.

On terminal 1:
--------------
Step 1:
Download the test raw data file, one_finger_tap.link.dat,from
Issue 307817 Comment #5 to /tmp of the chromebook.

Step 2:
Then login to the chromebook:
$ ssh root@${MACHINE_IP}

Step 3:
Launch mtplot on the chromebook.
$ DISPLAY=:0 DISPLAY=:0 /usr/bin/mtplot
Choose the appropriate device number on the prompt. Press Enter.

On terminal 2:
--------------
Login to the chromebook too as root by following the instruction at step 2.

Step 4:
Replay the raw data file.
(Assume that the device you choose at Step 3 is /dev/input/event8)
$ evemu-play --insert-slot0 /dev/input/event8 < /tmp/one_finger_tap.link.dat

You could observe two dots around the center of the screen.

Step 5:
Press ctrl-c to quit mtplot on terminal 1.

Step 6:
Perform Step 3 on terminal 1, and Step 4 on terminal 2 again.
You could still observe two dots around the center of the screen.

Further Optional tests:
Perform all the steps above with an old-version mtplot. You could
observe that the two dots shown on the top edge of the screen. This
is the problem this patch attempts to fix.

Change-Id: I59caaf129489b8cfaf8576a221d748ff1b9386fc
Reviewed-on: https://chromium-review.googlesource.com/174878
Reviewed-by: Andrew de los Reyes <adlr@chromium.org>
Tested-by: Shyh-In Hwang <josephsih@chromium.org>
Commit-Queue: Shyh-In Hwang <josephsih@chromium.org>
1 file changed