From cb94b3ae2ee7a66845895e2c704cdf62ee74ba13 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Tue, 21 Jul 2020 02:33:53 -0400 Subject: keyboard add ability to specify temporary custom layouts rb core allows you to load custom keyboard layouts this patch adds the ability to load a keyboard layout in a buffer the custom layout is temporary and does not overwrite the current layout use like so: unsigned short kbd[64]; unsigned short *kbd_p = kbd; if (!kbd_create_layout("ABCD1234\n", kbd, sizeof(kbd))) kbd_p = NULL; rb->kbd_input(buf,sizeof(buf), kbd_p); Change-Id: I7be2bd4a1b4797a147fa70228a9749dc56ac052a --- apps/plugins/otp.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'apps/plugins/otp.c') diff --git a/apps/plugins/otp.c b/apps/plugins/otp.c index 6dece4ad38..2da1ef83f5 100644 --- a/apps/plugins/otp.c +++ b/apps/plugins/otp.c @@ -411,10 +411,11 @@ static void add_acct_manual(void) memset(accounts + next_slot, 0, sizeof(struct account_t)); rb->splash(HZ * 1, "Enter account name."); - if(rb->kbd_input(accounts[next_slot].name, sizeof(accounts[next_slot].name)) < 0) + char* buf = accounts[next_slot].name; + if(rb->kbd_input(buf, sizeof(accounts[next_slot].name), NULL) < 0) return; - if(acct_exists(accounts[next_slot].name)) + if(acct_exists(buf)) { rb->splash(HZ * 2, "Duplicate account name!"); return; @@ -425,7 +426,7 @@ static void add_acct_manual(void) char temp_buf[SECRET_MAX * 2]; memset(temp_buf, 0, sizeof(temp_buf)); - if(rb->kbd_input(temp_buf, sizeof(temp_buf)) < 0) + if(rb->kbd_input(temp_buf, sizeof(temp_buf), NULL) < 0) return; if((accounts[next_slot].sec_len = base32_decode(accounts[next_slot].secret, SECRET_MAX, temp_buf)) <= 0) @@ -457,7 +458,7 @@ static void add_acct_manual(void) temp_buf[1] = '0'; } - if(rb->kbd_input(temp_buf, sizeof(temp_buf)) < 0) + if(rb->kbd_input(temp_buf, sizeof(temp_buf), NULL) < 0) return; if(!accounts[next_slot].is_totp) @@ -470,7 +471,7 @@ static void add_acct_manual(void) memset(temp_buf, 0, sizeof(temp_buf)); temp_buf[0] = '6'; - if(rb->kbd_input(temp_buf, sizeof(temp_buf)) < 0) + if(rb->kbd_input(temp_buf, sizeof(temp_buf), NULL) < 0) return; accounts[next_slot].digits = rb->atoi(temp_buf); @@ -667,7 +668,7 @@ static void edit_menu(int acct) case 0: // rename rb->splash(HZ, "Enter new name."); rb->strlcpy(data_buf, accounts[acct].name, sizeof(data_buf)); - if(rb->kbd_input(data_buf, sizeof(data_buf)) < 0) + if(rb->kbd_input(data_buf, sizeof(data_buf), NULL) < 0) break; if(acct_exists(data_buf)) { @@ -695,7 +696,7 @@ static void edit_menu(int acct) else rb->snprintf(data_buf, sizeof(data_buf), "%d", accounts[acct].totp_period); - if(rb->kbd_input(data_buf, sizeof(data_buf)) < 0) + if(rb->kbd_input(data_buf, sizeof(data_buf), NULL) < 0) break; if(accounts[acct].is_totp) @@ -709,7 +710,7 @@ static void edit_menu(int acct) break; case 3: // digits rb->snprintf(data_buf, sizeof(data_buf), "%d", accounts[acct].digits); - if(rb->kbd_input(data_buf, sizeof(data_buf)) < 0) + if(rb->kbd_input(data_buf, sizeof(data_buf), NULL) < 0) break; accounts[acct].digits = rb->atoi(data_buf); @@ -722,7 +723,7 @@ static void edit_menu(int acct) memcpy(temp_sec, accounts[acct].secret, accounts[acct].sec_len); base32_encode(accounts[acct].secret, accounts[acct].sec_len, data_buf, sizeof(data_buf)); - if(rb->kbd_input(data_buf, sizeof(data_buf)) < 0) + if(rb->kbd_input(data_buf, sizeof(data_buf), NULL) < 0) break; int ret = base32_decode(accounts[acct].secret, sizeof(accounts[acct].secret), data_buf); -- cgit v1.2.3