Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for dual-use function key #79

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/board/system76/common/kbscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,20 @@ static bool kbscan_has_ghost_in_row(int row, uint8_t rowdata) {
}

bool kbscan_press(uint16_t key, bool pressed, uint8_t * layer) {
static bool dual_use_send = false;

if (pressed &&
(power_state == POWER_STATE_S3 || power_state == POWER_STATE_DS3)) {
gpio_set(&SWI_N, false);
delay_ticks(10); //TODO: find correct delay
gpio_set(&SWI_N, true);
}

// Do not send dual use key
if (pressed) {
dual_use_send = false;
}

switch (key & KT_MASK) {
case (KT_NORMAL):
if (kbscan_enabled) {
Expand All @@ -142,6 +149,19 @@ bool kbscan_press(uint16_t key, bool pressed, uint8_t * layer) {
if (layer != NULL) {
if (pressed) *layer = 1;
else *layer = 0;

if (kbscan_enabled) {
// Dual use key can be modifier or standard
uint16_t dual_use_key = key & (~KT_MASK);
if (dual_use_key) {
if (pressed) {
dual_use_send = true;
} else if (dual_use_send) {
kbc_scancode(&KBC, dual_use_key, true);
kbc_scancode(&KBC, dual_use_key, false);
}
}
}
} else {
// In the case no layer can be set, reset bit
return false;
Expand Down