Remove a transition key by setting the key matrix before enabling it

The FAFT key press simulation is originally achieved by controlling
the keyboard matrix on the internal keyboard. Selecting the row and
the column emulates a key press.

The recent devices no longer use this keyboard matrix. It uses EC to
simulate keys. However, the control logic is still compatible with
the original matrix design. Pressing a key still needs to select a
row and a column. The code monitors the row and the column to send
proper EC commands. It generates an extra transition key. For
example, it is the KEY_MATRIX.

    KEY_MATRIX = {
            'ctrl_refresh':  ['0', '0', '0', '1'],
            'ctrl_d':        ['0', '1', '0', '0'],
            'd':             ['0', '1', '1', '1'],
            'ctrl_enter':    ['1', '0', '0', '0'],
            'enter':         ['1', '0', '1', '1'],
            'ctrl':          ['1', '1', '0', '0'],
            'refresh':       ['1', '1', '0', '1'],
            'unused':        ['1', '1', '1', '0'],
            'none':          ['1', '1', '1', '1']}

When pressing a Ctrl+D, the state is changed like:
  ['1', '1', '1', '1'] -> None
  ['1', '1', '1', '0'] -> Transition key
  ['1', '1', '0', '0'] -> Ctrl
  ['0', '1', '0', '0'] -> Ctrl + D

Thought this transition key doesn't hurt, it adds overhead to EC to
send this unnecessary key. This change is to remove it by setting
the key matrix first and then enable the key simulation.

BUG=chrome-os-partner:39517
TEST=Put the modified code to servo v3, started servod, and ran firmware_DevMode:
$ test_that --fast --arg "servo_host=$SERVO" $DUT f:.*firmware_DevMode/control$

Change-Id: Ia462ab8a62de45b355a48b82ae408d3433d72d36
Reviewed-on: https://chromium-review.googlesource.com/267124
Reviewed-by: Yusuf Mohsinally <mohsinally@chromium.org>
Commit-Queue: Tom Tam <waihong@google.com>
Tested-by: Tom Tam <waihong@google.com>
1 file changed