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

kbscan: Do not read matrix if lid is closed #426

Merged
merged 2 commits into from
Jan 4, 2024
Merged
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
17 changes: 8 additions & 9 deletions src/board/system76/common/kbscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,6 @@ void kbscan_init(void) {

// Read the state of the row for the selected column.
static inline uint8_t kbscan_get_row(void) {
// Report all keys as released when lid is closed
if (!lid_state) {
return 0;
}

// Invert KSI for positive logic of pressed keys.
return ~KSI;
}
Expand Down Expand Up @@ -163,7 +158,7 @@ static void hardware_hotkey(uint16_t key) {

bool kbscan_press(uint16_t key, bool pressed, uint8_t *layer) {
// Wake from sleep on keypress
if (pressed && lid_state && (power_state == POWER_STATE_S3)) {
if (pressed && (power_state == POWER_STATE_S3)) {
pmc_swi();
}

Expand Down Expand Up @@ -287,7 +282,6 @@ void kbscan_event(void) {
static uint8_t kbscan_layer = 0;
uint8_t layer = kbscan_layer;
static uint8_t kbscan_last_layer[KM_OUT][KM_IN] = { { 0 } };
static bool kbscan_ghost[KM_OUT] = { false };
uint8_t matrix_curr[KM_OUT];

static bool debounce = false;
Expand All @@ -311,8 +305,13 @@ void kbscan_event(void) {

// Read the current state of the hardware matrix
for (uint8_t i = 0; i < KM_OUT; i++) {
kbscan_set_column(i);
matrix_curr[i] = kbscan_get_row();
if (!lid_state) {
// Report all keys as released when lid is closed
matrix_curr[i] = 0;
} else {
kbscan_set_column(i);
matrix_curr[i] = kbscan_get_row();
}
}
// Disable reading any keys
kbscan_set_column(KBSCAN_MATRIX_NONE);
Expand Down