Skip to content

Commit

Permalink
TOTP: Update for new CLI key enum
Browse files Browse the repository at this point in the history
  • Loading branch information
Willy-JL committed Oct 14, 2024
1 parent 36671ed commit 6e157c2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
8 changes: 4 additions & 4 deletions totp/cli/cli_shared_methods.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ void totp_cli_force_close_app(void* ctx) {
bool totp_cli_read_line(Cli* cli, FuriString* out_str, bool mask_user_input) {
uint8_t c;
while(cli_read(cli, &c, 1) == 1) {
if(c == CliSymbolAsciiEsc) {
if(c == CliKeyEsc) {
// Some keys generating escape-sequences
// We need to ignore them as we care about alpha-numerics only
uint8_t c2;
cli_read_timeout(cli, &c2, 1, 0);
cli_read_timeout(cli, &c2, 1, 0);
} else if(c == CliSymbolAsciiETX) {
} else if(c == CliKeyETX) {
cli_nl(cli);
return false;
} else if(
Expand All @@ -54,13 +54,13 @@ bool totp_cli_read_line(Cli* cli, FuriString* out_str, bool mask_user_input) {
}
fflush(stdout);
furi_string_push_back(out_str, c);
} else if(c == CliSymbolAsciiBackspace || c == CliSymbolAsciiDel) {
} else if(c == CliKeyBackspace || c == CliKeyDEL) {
size_t out_str_size = furi_string_size(out_str);
if(out_str_size > 0) {
TOTP_CLI_DELETE_LAST_CHAR();
furi_string_left(out_str, out_str_size - 1);
}
} else if(c == CliSymbolAsciiCR) {
} else if(c == CliKeyCR) {
cli_nl(cli);
break;
}
Expand Down
1 change: 1 addition & 0 deletions totp/cli/cli_shared_methods.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <cli/cli.h>
#include <cli/cli_ansi.h>
#include "../types/plugin_state.h"

#ifdef __cplusplus
Expand Down
6 changes: 3 additions & 3 deletions totp/cli/plugins/delete/delete.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ static void handle(PluginState* plugin_state, FuriString* args, Cli* cli) {
char user_pick;
do {
user_pick = tolower(cli_getc(cli));
} while(user_pick != 'y' && user_pick != 'n' && user_pick != CliSymbolAsciiCR &&
user_pick != CliSymbolAsciiETX && user_pick != CliSymbolAsciiEsc);
} while(user_pick != 'y' && user_pick != 'n' && user_pick != CliKeyCR &&
user_pick != CliKeyETX && user_pick != CliKeyEsc);

confirmed = user_pick == 'y' || user_pick == CliSymbolAsciiCR;
confirmed = user_pick == 'y' || user_pick == CliKeyCR;
}

if(confirmed) {
Expand Down
8 changes: 4 additions & 4 deletions totp/cli/plugins/pin/pin.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static bool totp_cli_read_pin(Cli* cli, uint8_t* pin, uint8_t* pin_length) {
uint8_t c;
*pin_length = 0;
while(cli_read(cli, &c, 1) == 1) {
if(c == CliSymbolAsciiEsc) {
if(c == CliKeyEsc) {
uint8_t c2;
uint8_t c3;
if(cli_read_timeout(cli, &c2, 1, 0) == 1 && cli_read_timeout(cli, &c3, 1, 0) == 1 &&
Expand All @@ -55,17 +55,17 @@ static bool totp_cli_read_pin(Cli* cli, uint8_t* pin, uint8_t* pin_length) {
fflush(stdout);
}
}
} else if(c == CliSymbolAsciiETX) {
} else if(c == CliKeyETX) {
TOTP_CLI_DELETE_CURRENT_LINE();
TOTP_CLI_PRINTF_INFO("Cancelled by user\r\n");
return false;
} else if(c == CliSymbolAsciiBackspace || c == CliSymbolAsciiDel) {
} else if(c == CliKeyBackspace || c == CliKeyDEL) {
if(*pin_length > 0) {
*pin_length = *pin_length - 1;
pin[*pin_length] = 0;
TOTP_CLI_DELETE_LAST_CHAR();
}
} else if(c == CliSymbolAsciiCR) {
} else if(c == CliKeyCR) {
cli_nl(cli);
break;
}
Expand Down

0 comments on commit 6e157c2

Please sign in to comment.