rise and shine mr freeman...

This commit is contained in:
MX 2022-10-09 00:37:22 +03:00
parent b0c9af9c06
commit 45840a1146
No known key found for this signature in database
GPG key ID: 6C4C311DFD4B4AB5
10 changed files with 135 additions and 120 deletions

View file

@ -372,24 +372,28 @@ static bool archive_view_input(InputEvent* event, void* context) {
}
if(event->key == InputKeyUp || event->key == InputKeyDown) {
with_view_model(
browser->view, (ArchiveBrowserViewModel * model) {
browser->view,
ArchiveBrowserViewModel * model,
{
size_t size_menu = menu_array_size(model->context_menu);
if(event->key == InputKeyUp) {
model->menu_idx = ((model->menu_idx - 1) + size_menu) % size_menu;
} else if(event->key == InputKeyDown) {
model->menu_idx = (model->menu_idx + 1) % size_menu;
}
return true;
});
},
true);
} else if(event->key == InputKeyOk) {
uint32_t idx;
with_view_model(
browser->view, (ArchiveBrowserViewModel * model) {
browser->view,
ArchiveBrowserViewModel * model,
{
ArchiveContextMenuItem_t* current =
menu_array_get(model->context_menu, model->menu_idx);
idx = current->event;
return false;
});
},
false);
browser->callback(idx, browser->context);
} else if(event->key == InputKeyBack) {
browser->callback(ArchiveBrowserEventFileMenuClose, browser->context);
@ -503,11 +507,13 @@ void browser_free(ArchiveBrowserView* browser) {
}
with_view_model(
browser->view, (ArchiveBrowserViewModel * model) {
browser->view,
ArchiveBrowserViewModel * model,
{
files_array_clear(model->files);
menu_array_clear(model->context_menu);
return false;
});
},
false);
furi_string_free(browser->path);

View file

@ -305,7 +305,7 @@ static int32_t ducky_parse_line(BadUsbScript* bad_usb, FuriString* line) {
} else if(strncmp(line_tmp, ducky_cmd_sysrq, strlen(ducky_cmd_sysrq)) == 0) {
// SYSRQ
line_tmp = &line_tmp[ducky_get_command_len(line_tmp) + 1];
uint16_t key = ducky_get_keycode(line_tmp, true);
uint16_t key = ducky_get_keycode(bad_usb, line_tmp, true);
furi_hal_hid_kb_press(KEY_MOD_LEFT_ALT | HID_KEYBOARD_PRINT_SCREEN);
furi_hal_hid_kb_press(key);
furi_hal_hid_kb_release_all();

View file

@ -188,10 +188,10 @@ void bad_usb_set_file_name(BadUsb* bad_usb, const char* name) {
void bad_usb_set_layout(BadUsb* bad_usb, const char* layout) {
furi_assert(layout);
with_view_model(
bad_usb->view, (BadUsbModel * model) {
strlcpy(model->layout, layout, MAX_NAME_LEN);
return true;
});
bad_usb->view,
BadUsbModel * model,
{ strlcpy(model->layout, layout, MAX_NAME_LEN); },
true);
}
void bad_usb_set_state(BadUsb* bad_usb, BadUsbState* st) {
furi_assert(st);

View file

@ -68,10 +68,7 @@ void subghz_view_receiver_set_mode(
SubGhzViewReceiver* subghz_receiver,
SubGhzViewReceiverMode mode) {
with_view_model(
subghz_receiver->view, (SubGhzViewReceiverModel * model) {
model->mode = mode;
return true;
});
subghz_receiver->view, SubGhzViewReceiverModel * model, { model->mode = mode; }, true);
}
void subghz_view_receiver_set_lock(SubGhzViewReceiver* subghz_receiver, SubGhzLock lock) {
@ -172,10 +169,10 @@ void subghz_view_receiver_add_data_progress(
const char* progress_str) {
furi_assert(subghz_receiver);
with_view_model(
subghz_receiver->view, (SubGhzViewReceiverModel * model) {
furi_string_set(model->progress_str, progress_str);
return true;
});
subghz_receiver->view,
SubGhzViewReceiverModel * model,
{ furi_string_set(model->progress_str, progress_str); },
true);
}
static void subghz_view_receiver_draw_frame(Canvas* canvas, uint16_t idx, bool scrollbar) {

View file

@ -277,7 +277,9 @@ bool subghz_frequency_analyzer_input(InputEvent* event, void* context) {
if(event->key == InputKeyOk) {
bool updated = false;
with_view_model(
instance->view, (SubGhzFrequencyAnalyzerModel * model) {
instance->view,
SubGhzFrequencyAnalyzerModel * model,
{
uint32_t prev_freq_to_save = model->frequency_to_save;
uint32_t frequency_candidate = 0;
if(model->frequency != 0) {
@ -305,8 +307,8 @@ bool subghz_frequency_analyzer_input(InputEvent* event, void* context) {
notification_message(instance->notifications, &sequence_hw_blink);
updated = true;
}
return true;
});
},
true);
#ifdef FURI_DEBUG
FURI_LOG_I(
@ -340,14 +342,16 @@ bool subghz_frequency_analyzer_input(InputEvent* event, void* context) {
if(need_redraw) {
SubGhzFrequencyAnalyzer* instance = context;
with_view_model(
instance->view, (SubGhzFrequencyAnalyzerModel * model) {
instance->view,
SubGhzFrequencyAnalyzerModel * model,
{
model->rssi_last = instance->rssi_last;
model->frequency_last = instance->frequency_last;
model->trigger =
subghz_frequency_analyzer_worker_get_trigger_level(instance->worker);
model->feedback_level = instance->feedback_level;
return true;
});
},
true);
}
return true;
@ -415,8 +419,8 @@ void subghz_frequency_analyzer_pair_callback(void* context, uint32_t frequency,
model->frequency_last = instance->frequency_last_vis;
model->trigger = subghz_frequency_analyzer_worker_get_trigger_level(instance->worker);
model->feedback_level = instance->feedback_level;
return true;
});
},
true);
}
void subghz_frequency_analyzer_enter(void* context) {
@ -452,8 +456,8 @@ void subghz_frequency_analyzer_enter(void* context) {
model->frequency_last = 0;
model->frequency_to_save = 0;
model->trigger = RSSI_MIN;
return true;
});
},
true);
}
void subghz_frequency_analyzer_exit(void* context) {
@ -507,10 +511,10 @@ uint32_t subghz_frequency_analyzer_get_frequency_to_save(SubGhzFrequencyAnalyzer
furi_assert(instance);
uint32_t frequency;
with_view_model(
instance->view, (SubGhzFrequencyAnalyzerModel * model) {
frequency = model->frequency_to_save;
return false;
});
instance->view,
SubGhzFrequencyAnalyzerModel * model,
{ frequency = model->frequency_to_save; },
false);
return frequency;
}

View file

@ -378,7 +378,9 @@ bool subghz_read_raw_input(InputEvent* event, void* context) {
true);
} else if(event->key == InputKeyLeft && event->type == InputTypeShort) {
with_view_model(
instance->view, (SubGhzReadRAWModel * model) {
instance->view,
SubGhzReadRAWModel * model,
{
if(!model->raw_send_only) {
if(model->status == SubGhzReadRAWStatusStart) {
//Config
@ -399,7 +401,9 @@ bool subghz_read_raw_input(InputEvent* event, void* context) {
true);
} else if(event->key == InputKeyRight && event->type == InputTypeShort) {
with_view_model(
instance->view, (SubGhzReadRAWModel * model) {
instance->view,
SubGhzReadRAWModel * model,
{
if(!model->raw_send_only) {
if(model->status == SubGhzReadRAWStatusIDLE) {
//Save

View file

@ -46,21 +46,23 @@ bool subbrute_attack_view_input(InputEvent* event, void* context) {
if(event->key == InputKeyBack && event->type == InputTypeShort) {
instance->callback(SubBruteCustomEventTypeBackPressed, instance->context);
with_view_model(
instance->view, (SubBruteAttackViewModel * model) {
instance->view,
SubBruteAttackViewModel * model,
{
model->is_attacking = false;
model->is_continuous_worker = false;
return true;
});
},
true);
return true;
}
bool is_attacking = false;
with_view_model(
instance->view, (SubBruteAttackViewModel * model) {
is_attacking = model->is_attacking;
return false;
});
instance->view,
SubBruteAttackViewModel * model,
{ is_attacking = model->is_attacking; },
false);
// if(!is_attacking) {
// instance->callback(SubBruteCustomEventTypeTransmitNotStarted, instance->context);
@ -74,13 +76,15 @@ bool subbrute_attack_view_input(InputEvent* event, void* context) {
FURI_LOG_D(TAG, "InputKey: %d OK", event->key);
#endif
with_view_model(
instance->view, (SubBruteAttackViewModel * model) {
instance->view,
SubBruteAttackViewModel * model,
{
model->is_attacking = true;
model->is_continuous_worker = false;
icon_animation_stop(model->icon);
icon_animation_start(model->icon);
return true;
});
},
true);
instance->callback(SubBruteCustomEventTypeTransmitStarted, instance->context);
/*if(event->type == InputTypeRepeat && event->key == InputKeyOk) {
#ifdef FURI_DEBUG
@ -151,13 +155,15 @@ bool subbrute_attack_view_input(InputEvent* event, void* context) {
if((event->type == InputTypeShort || event->type == InputTypeRepeat) &&
(event->key == InputKeyOk || event->key == InputKeyBack)) {
with_view_model(
instance->view, (SubBruteAttackViewModel * model) {
instance->view,
SubBruteAttackViewModel * model,
{
model->is_attacking = false;
model->is_continuous_worker = false;
icon_animation_stop(model->icon);
icon_animation_start(model->icon);
return true;
});
},
true);
instance->callback(SubBruteCustomEventTypeTransmitNotStarted, instance->context);
}
}
@ -173,11 +179,13 @@ SubBruteAttackView* subbrute_attack_view_alloc() {
view_set_context(instance->view, instance);
with_view_model(
instance->view, (SubBruteAttackViewModel * model) {
instance->view,
SubBruteAttackViewModel * model,
{
model->icon = icon_animation_alloc(&A_Sub1ghz_14);
view_tie_icon_animation(instance->view, model->icon);
return false;
});
},
false);
view_set_draw_callback(instance->view, (ViewDrawCallback)subbrute_attack_view_draw);
view_set_input_callback(instance->view, subbrute_attack_view_input);
@ -203,10 +211,10 @@ void subbrute_attack_view_free(SubBruteAttackView* instance) {
#endif
with_view_model(
instance->view, (SubBruteAttackViewModel * model) {
icon_animation_free(model->icon);
return false;
});
instance->view,
SubBruteAttackViewModel * model,
{ icon_animation_free(model->icon); },
false);
view_free(instance->view);
free(instance);
@ -223,19 +231,19 @@ void subbrute_attack_view_set_current_step(SubBruteAttackView* instance, uint64_
//FURI_LOG_D(TAG, "Set step: %d", current_step);
#endif
with_view_model(
instance->view, (SubBruteAttackViewModel * model) {
model->current_step = current_step;
return true;
});
instance->view,
SubBruteAttackViewModel * model,
{ model->current_step = current_step; },
true);
}
void subbrute_attack_view_set_worker_type(SubBruteAttackView* instance, bool is_continuous_worker) {
furi_assert(instance);
with_view_model(
instance->view, (SubBruteAttackViewModel * model) {
model->is_continuous_worker = is_continuous_worker;
return true;
});
instance->view,
SubBruteAttackViewModel * model,
{ model->is_continuous_worker = is_continuous_worker; },
true);
}
// We need to call init every time, because not every time we calls enter
@ -255,7 +263,9 @@ void subbrute_attack_view_init_values(
current_step);
#endif
with_view_model(
instance->view, (SubBruteAttackViewModel * model) {
instance->view,
SubBruteAttackViewModel * model,
{
model->max_value = max_value;
model->index = index;
model->current_step = current_step;
@ -265,8 +275,8 @@ void subbrute_attack_view_init_values(
} else {
icon_animation_stop(model->icon);
}
return true;
});
},
true);
}
void subbrute_attack_view_exit(void* context) {
@ -276,10 +286,10 @@ void subbrute_attack_view_exit(void* context) {
FURI_LOG_D(TAG, "subbrute_attack_view_exit");
#endif
with_view_model(
instance->view, (SubBruteAttackViewModel * model) {
icon_animation_stop(model->icon);
return false;
});
instance->view,
SubBruteAttackViewModel * model,
{ icon_animation_stop(model->icon); },
false);
}
void elements_button_top_left(Canvas* canvas, const char* str) {

View file

@ -173,17 +173,19 @@ bool subbrute_main_view_input(InputEvent* event, void* context) {
uint8_t index = 0;
bool is_select_byte = false;
with_view_model(
instance->view, (SubBruteMainViewModel * model) {
is_select_byte = model->is_select_byte;
return false;
});
instance->view,
SubBruteMainViewModel * model,
{ is_select_byte = model->is_select_byte; },
false);
bool consumed = false;
if(!is_select_byte) {
if((event->type == InputTypeShort) || (event->type == InputTypeRepeat)) {
bool ret = false;
with_view_model(
instance->view, (SubBruteMainViewModel * model) {
bool ret = false;
instance->view,
SubBruteMainViewModel * model,
{
uint8_t items_on_screen = 3;
if(event->key == InputKeyUp) {
if(model->index == min_value) {
@ -219,8 +221,8 @@ bool subbrute_main_view_input(InputEvent* event, void* context) {
}
}
index = model->index;
return ret;
});
},
ret);
}
#ifdef FURI_DEBUG
@ -243,7 +245,9 @@ bool subbrute_main_view_input(InputEvent* event, void* context) {
} else {
if((event->type == InputTypeShort) || (event->type == InputTypeRepeat)) {
with_view_model(
instance->view, (SubBruteMainViewModel * model) {
instance->view,
SubBruteMainViewModel * model,
{
if(event->key == InputKeyLeft) {
if(model->index > 0) {
model->index--;
@ -255,8 +259,8 @@ bool subbrute_main_view_input(InputEvent* event, void* context) {
}
index = model->index;
return true;
});
},
true);
}
#ifdef FURI_DEBUG
@ -304,13 +308,15 @@ SubBruteMainView* subbrute_main_view_alloc() {
view_set_exit_callback(instance->view, subbrute_main_view_exit);
with_view_model(
instance->view, (SubBruteMainViewModel * model) {
instance->view,
SubBruteMainViewModel * model,
{
model->index = 0;
model->window_position = 0;
model->key_field = NULL;
model->is_select_byte = false;
return true;
});
},
true);
return instance;
}
@ -338,7 +344,9 @@ void subbrute_main_view_set_index(
FURI_LOG_I(TAG, "Set index: %d", idx);
#endif
with_view_model(
instance->view, (SubBruteMainViewModel * model) {
instance->view,
SubBruteMainViewModel * model,
{
model->is_select_byte = is_select_byte;
model->key_field = key_field;
model->index = idx;
@ -359,8 +367,8 @@ void subbrute_main_view_set_index(
}
}
}
return true;
});
},
true);
}
SubBruteAttacks subbrute_main_view_get_index(SubBruteMainView* instance) {
@ -368,10 +376,7 @@ SubBruteAttacks subbrute_main_view_get_index(SubBruteMainView* instance) {
uint8_t idx = 0;
with_view_model(
instance->view, (SubBruteMainViewModel * model) {
idx = model->index;
return false;
});
instance->view, SubBruteMainViewModel * model, { idx = model->index; }, false);
#ifdef FURI_DEBUG
FURI_LOG_D(TAG, "Get index: %d", idx);

View file

@ -146,52 +146,39 @@ View* wav_player_view_get_view(WavPlayerView* wav_view) {
void wav_player_view_set_volume(WavPlayerView* wav_view, float volume) {
furi_assert(wav_view);
with_view_model(
wav_view->view, (WavPlayerViewModel * model) {
model->volume = volume;
return true;
});
wav_view->view, WavPlayerViewModel * model, { model->volume = volume; }, true);
}
void wav_player_view_set_start(WavPlayerView* wav_view, size_t start) {
furi_assert(wav_view);
with_view_model(
wav_view->view, (WavPlayerViewModel * model) {
model->start = start;
return true;
});
wav_view->view, WavPlayerViewModel * model, { model->start = start; }, true);
}
void wav_player_view_set_end(WavPlayerView* wav_view, size_t end) {
furi_assert(wav_view);
with_view_model(
wav_view->view, (WavPlayerViewModel * model) {
model->end = end;
return true;
});
wav_view->view, WavPlayerViewModel * model, { model->end = end; }, true);
}
void wav_player_view_set_current(WavPlayerView* wav_view, size_t current) {
furi_assert(wav_view);
with_view_model(
wav_view->view, (WavPlayerViewModel * model) {
model->current = current;
return true;
});
wav_view->view, WavPlayerViewModel * model, { model->current = current; }, true);
}
void wav_player_view_set_play(WavPlayerView* wav_view, bool play) {
furi_assert(wav_view);
with_view_model(
wav_view->view, (WavPlayerViewModel * model) {
model->play = play;
return true;
});
wav_view->view, WavPlayerViewModel * model, { model->play = play; }, true);
}
void wav_player_view_set_data(WavPlayerView* wav_view, uint16_t* data, size_t data_count) {
furi_assert(wav_view);
with_view_model(
wav_view->view, (WavPlayerViewModel * model) {
wav_view->view,
WavPlayerViewModel * model,
{
size_t inc = (data_count / DATA_COUNT) - 1;
for(size_t i = 0; i < DATA_COUNT; i++) {
@ -199,8 +186,8 @@ void wav_player_view_set_data(WavPlayerView* wav_view, uint16_t* data, size_t da
if(model->data[i] > 42) model->data[i] = 42;
data += inc;
}
return true;
});
},
true);
}
void wav_player_view_set_ctrl_callback(WavPlayerView* wav_view, WavPlayerCtrlCallback callback) {

View file

@ -87,11 +87,13 @@ ButtonPanel* button_panel_alloc() {
void button_panel_reset_selection(ButtonPanel* button_panel) {
with_view_model(
button_panel->view, (ButtonPanelModel * model) {
button_panel->view,
ButtonPanelModel * model,
{
model->selected_item_x = 0;
model->selected_item_y = 0;
return true;
});
},
true);
}
void button_panel_reserve(ButtonPanel* button_panel, size_t reserve_x, size_t reserve_y) {