mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
Subtly show PIN in BadKB
This commit is contained in:
@@ -23,6 +23,7 @@ typedef enum {
|
||||
|
||||
typedef struct {
|
||||
BadKbWorkerState state;
|
||||
uint32_t pin;
|
||||
uint16_t line_cur;
|
||||
uint16_t line_nb;
|
||||
uint32_t delay_remain;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "bad_kb_view.h"
|
||||
#include "../bad_kb_script.h"
|
||||
#include "../bad_kb_app_i.h"
|
||||
#include <toolbox/path.h>
|
||||
#include <gui/elements.h>
|
||||
#include <assets_icons.h>
|
||||
@@ -38,6 +39,9 @@ static void bad_kb_draw_callback(Canvas* canvas, void* _model) {
|
||||
furi_string_push_back(disp_str, model->layout[i]);
|
||||
furi_string_push_back(disp_str, ')');
|
||||
}
|
||||
if(model->state.pin) {
|
||||
furi_string_cat_printf(disp_str, " PIN: %ld", model->state.pin);
|
||||
}
|
||||
elements_string_fit_width(canvas, disp_str, 128 - 2);
|
||||
canvas_draw_str(
|
||||
canvas, 2, 8 + canvas_current_font_height(canvas), furi_string_get_cstr(disp_str));
|
||||
@@ -214,6 +218,11 @@ void bad_kb_set_layout(BadKb* bad_kb, const char* layout) {
|
||||
|
||||
void bad_kb_set_state(BadKb* bad_kb, BadKbState* st) {
|
||||
furi_assert(st);
|
||||
if(bad_kb->context != NULL && ((BadKbApp*)bad_kb->context)->bt != NULL) {
|
||||
st->pin = ((BadKbApp*)bad_kb->context)->bt->pin;
|
||||
} else {
|
||||
st->pin = 0;
|
||||
}
|
||||
with_view_model(
|
||||
bad_kb->view,
|
||||
BadKbModel * model,
|
||||
|
||||
@@ -76,6 +76,7 @@ static void bt_pin_code_hide(Bt* bt) {
|
||||
|
||||
static bool bt_pin_code_verify_event_handler(Bt* bt, uint32_t pin) {
|
||||
furi_assert(bt);
|
||||
bt->pin = pin;
|
||||
|
||||
if(bt_get_profile_pairing_method(bt) == GapPairingNone) return true;
|
||||
|
||||
@@ -154,6 +155,8 @@ Bt* bt_alloc() {
|
||||
// API evnent
|
||||
bt->api_event = furi_event_flag_alloc();
|
||||
|
||||
bt->pin = 0;
|
||||
|
||||
return bt;
|
||||
}
|
||||
|
||||
@@ -219,6 +222,7 @@ static bool bt_on_gap_event_callback(GapEvent event, void* context) {
|
||||
furi_assert(context);
|
||||
Bt* bt = context;
|
||||
bool ret = false;
|
||||
bt->pin = 0;
|
||||
|
||||
if(event.type == GapEventTypeConnected) {
|
||||
// Update status bar
|
||||
|
||||
@@ -76,4 +76,5 @@ struct Bt {
|
||||
FuriEventFlag* api_event;
|
||||
BtStatusChangedCallback status_changed_cb;
|
||||
void* status_changed_ctx;
|
||||
uint32_t pin;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user