to into account button swap

This commit is contained in:
King Kévin 2024-04-14 03:49:13 +02:00
parent 931672c665
commit 144ac21a4f
1 changed files with 22 additions and 18 deletions

View File

@ -435,6 +435,26 @@ void hid_task(void)
}
}
static void past_credentials(bool user)
{
if (!credentials || 0 == strlen(username) || 0 == strlen(password)) {
printf("no credentials to paste\r\n");
return;
}
user_paste = 0;
pass_paste = 0;
pasted_when = board_millis();
if (user) {
send_hid_report(username[user_paste++]);
printf("pasting username and password\r\n");
} else {
send_hid_report(password[pass_paste++]);
printf("pasting password\r\n");
}
}
void button_task(void)
{
static uint32_t button1_ms = 0; // when the button has been pressed (in ms)
@ -485,25 +505,9 @@ void button_task(void)
printf("clearing credentials\r\n");
}
} else if (!button1_pressed && button1_ok && !button2_ok) { // button 1 released
if (!credentials) {
printf("no credentials saved\r\n");
} else {
user_paste = 0;
pass_paste = 0;
pasted_when = board_millis();
send_hid_report(username[user_paste++]);
printf("pasting username and password\r\n");
}
past_credentials(!config.button_swap);
} else if (!button2_pressed && !button1_ok && button2_ok) { // button 2 released
if (!credentials) {
printf("no credentials saved\r\n");
} else {
user_paste = 0;
pass_paste = 0;
pasted_when = board_millis();
send_hid_report(password[pass_paste++]);
printf("pasting password\r\n");
}
past_credentials(config.button_swap);
}
// clear button state