diff options
Diffstat (limited to 'common/keyboard_scan.c')
-rw-r--r-- | common/keyboard_scan.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/common/keyboard_scan.c b/common/keyboard_scan.c index 4bc2391722..df9e9064ff 100644 --- a/common/keyboard_scan.c +++ b/common/keyboard_scan.c @@ -270,11 +270,26 @@ static int check_runtime_keys(const uint8_t *state) int num_press = 0; int c; +#ifdef BOARD_SAMUS + int16_t chg_override; + + /* + * TODO(crosbug.com/p/34850): remove these hot-keys for samus, should + * be done at higher level than this. + */ + /* + * All runtime key combos are (right or left ) alt + volume up|down + + * (some key NOT on the same col as alt or volume up|down ) + */ + if (state[KEYBOARD_COL_VOL_UP] != KEYBOARD_MASK_VOL_UP && + state[KEYBOARD_COL_VOL_DOWN] != KEYBOARD_MASK_VOL_DOWN) +#else /* * All runtime key combos are (right or left ) alt + volume up + (some * key NOT on the same col as alt or volume up ) */ if (state[KEYBOARD_COL_VOL_UP] != KEYBOARD_MASK_VOL_UP) +#endif return 0; if (state[KEYBOARD_COL_RIGHT_ALT] != KEYBOARD_MASK_RIGHT_ALT && @@ -307,6 +322,36 @@ static int check_runtime_keys(const uint8_t *state) system_hibernate(0, 0); return 1; } +#ifdef BOARD_SAMUS + /* + * TODO(crosbug.com/p/34850): remove these hot-keys for samus, should + * be done at higher level than this. + */ + /* + * On samus, alt + volume down + 0|1|2 sets the active charge port + * by sending the charge override host command. Should only be sent + * when chipset is in S0. + */ + else if (state[KEYBOARD_COL_VOL_DOWN] == KEYBOARD_MASK_VOL_DOWN && + chipset_in_state(CHIPSET_STATE_ON)) { + if (state[KEYBOARD_COL_KEY_0] == KEYBOARD_MASK_KEY_0) { + /* Charge from neither port */ + chg_override = -2; + pd_host_command(EC_CMD_PD_CHARGE_PORT_OVERRIDE, 0, + &chg_override, 2, NULL, 0); + } else if (state[KEYBOARD_COL_KEY_1] == KEYBOARD_MASK_KEY_1) { + /* Charge from port 0 (left side) */ + chg_override = 0; + pd_host_command(EC_CMD_PD_CHARGE_PORT_OVERRIDE, 0, + &chg_override, 2, NULL, 0); + } else if (state[KEYBOARD_COL_KEY_2] == KEYBOARD_MASK_KEY_2) { + /* Charge from port 1 (right side) */ + chg_override = 1; + pd_host_command(EC_CMD_PD_CHARGE_PORT_OVERRIDE, 0, + &chg_override, 2, NULL, 0); + } + } +#endif return 0; } |