mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-07-30 02:18:11 -07:00
Merge branch 'UNLEASHED' into 420darkupds
This commit is contained in:
@@ -277,7 +277,9 @@ static void bt_hid_keyboard_get_select_key(BtHidKeyboardModel* model, BtHidKeybo
|
||||
|
||||
static void bt_hid_keyboard_process(BtHidKeyboard* bt_hid_keyboard, InputEvent* event) {
|
||||
with_view_model(
|
||||
bt_hid_keyboard->view, (BtHidKeyboardModel * model) {
|
||||
bt_hid_keyboard->view,
|
||||
BtHidKeyboardModel * model,
|
||||
{
|
||||
if(event->key == InputKeyOk) {
|
||||
if(event->type == InputTypePress) {
|
||||
model->ok_pressed = true;
|
||||
@@ -338,8 +340,8 @@ static void bt_hid_keyboard_process(BtHidKeyboard* bt_hid_keyboard, InputEvent*
|
||||
bt_hid_keyboard_get_select_key(model, (BtHidKeyboardPoint){.x = 1, .y = 0});
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
},
|
||||
true);
|
||||
}
|
||||
|
||||
static bool bt_hid_keyboard_input_callback(InputEvent* event, void* context) {
|
||||
@@ -382,8 +384,5 @@ View* bt_hid_keyboard_get_view(BtHidKeyboard* bt_hid_keyboard) {
|
||||
void bt_hid_keyboard_set_connected_status(BtHidKeyboard* bt_hid_keyboard, bool connected) {
|
||||
furi_assert(bt_hid_keyboard);
|
||||
with_view_model(
|
||||
bt_hid_keyboard->view, (BtHidKeyboardModel * model) {
|
||||
model->connected = connected;
|
||||
return true;
|
||||
});
|
||||
bt_hid_keyboard->view, BtHidKeyboardModel * model, { model->connected = connected; }, true);
|
||||
}
|
||||
|
||||
@@ -128,7 +128,9 @@ static void bt_hid_keynote_draw_callback(Canvas* canvas, void* context) {
|
||||
|
||||
static void bt_hid_keynote_process(BtHidKeynote* bt_hid_keynote, InputEvent* event) {
|
||||
with_view_model(
|
||||
bt_hid_keynote->view, (BtHidKeynoteModel * model) {
|
||||
bt_hid_keynote->view,
|
||||
BtHidKeynoteModel * model,
|
||||
{
|
||||
if(event->type == InputTypePress) {
|
||||
if(event->key == InputKeyUp) {
|
||||
model->up_pressed = true;
|
||||
@@ -182,8 +184,8 @@ static void bt_hid_keynote_process(BtHidKeynote* bt_hid_keynote, InputEvent* eve
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
},
|
||||
true);
|
||||
}
|
||||
|
||||
static bool bt_hid_keynote_input_callback(InputEvent* event, void* context) {
|
||||
@@ -232,8 +234,5 @@ View* bt_hid_keynote_get_view(BtHidKeynote* bt_hid_keynote) {
|
||||
void bt_hid_keynote_set_connected_status(BtHidKeynote* bt_hid_keynote, bool connected) {
|
||||
furi_assert(bt_hid_keynote);
|
||||
with_view_model(
|
||||
bt_hid_keynote->view, (BtHidKeynoteModel * model) {
|
||||
model->connected = connected;
|
||||
return true;
|
||||
});
|
||||
bt_hid_keynote->view, BtHidKeynoteModel * model, { model->connected = connected; }, true);
|
||||
}
|
||||
|
||||
@@ -107,7 +107,9 @@ static void bt_hid_media_draw_callback(Canvas* canvas, void* context) {
|
||||
|
||||
static void bt_hid_media_process_press(BtHidMedia* bt_hid_media, InputEvent* event) {
|
||||
with_view_model(
|
||||
bt_hid_media->view, (BtHidMediaModel * model) {
|
||||
bt_hid_media->view,
|
||||
BtHidMediaModel * model,
|
||||
{
|
||||
if(event->key == InputKeyUp) {
|
||||
model->up_pressed = true;
|
||||
furi_hal_bt_hid_consumer_key_press(HID_CONSUMER_VOLUME_INCREMENT);
|
||||
@@ -124,13 +126,15 @@ static void bt_hid_media_process_press(BtHidMedia* bt_hid_media, InputEvent* eve
|
||||
model->ok_pressed = true;
|
||||
furi_hal_bt_hid_consumer_key_press(HID_CONSUMER_PLAY_PAUSE);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
},
|
||||
true);
|
||||
}
|
||||
|
||||
static void bt_hid_media_process_release(BtHidMedia* bt_hid_media, InputEvent* event) {
|
||||
with_view_model(
|
||||
bt_hid_media->view, (BtHidMediaModel * model) {
|
||||
bt_hid_media->view,
|
||||
BtHidMediaModel * model,
|
||||
{
|
||||
if(event->key == InputKeyUp) {
|
||||
model->up_pressed = false;
|
||||
furi_hal_bt_hid_consumer_key_release(HID_CONSUMER_VOLUME_INCREMENT);
|
||||
@@ -147,8 +151,8 @@ static void bt_hid_media_process_release(BtHidMedia* bt_hid_media, InputEvent* e
|
||||
model->ok_pressed = false;
|
||||
furi_hal_bt_hid_consumer_key_release(HID_CONSUMER_PLAY_PAUSE);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
},
|
||||
true);
|
||||
}
|
||||
|
||||
static bool bt_hid_media_input_callback(InputEvent* event, void* context) {
|
||||
@@ -196,8 +200,5 @@ View* bt_hid_media_get_view(BtHidMedia* bt_hid_media) {
|
||||
void bt_hid_media_set_connected_status(BtHidMedia* bt_hid_media, bool connected) {
|
||||
furi_assert(bt_hid_media);
|
||||
with_view_model(
|
||||
bt_hid_media->view, (BtHidMediaModel * model) {
|
||||
model->connected = connected;
|
||||
return true;
|
||||
});
|
||||
bt_hid_media->view, BtHidMediaModel * model, { model->connected = connected; }, true);
|
||||
}
|
||||
|
||||
@@ -103,7 +103,9 @@ static void bt_hid_mouse_draw_callback(Canvas* canvas, void* context) {
|
||||
|
||||
static void bt_hid_mouse_process(BtHidMouse* bt_hid_mouse, InputEvent* event) {
|
||||
with_view_model(
|
||||
bt_hid_mouse->view, (BtHidMouseModel * model) {
|
||||
bt_hid_mouse->view,
|
||||
BtHidMouseModel * model,
|
||||
{
|
||||
if(event->key == InputKeyBack) {
|
||||
if(event->type == InputTypeShort) {
|
||||
furi_hal_bt_hid_mouse_press(HID_MOUSE_BTN_RIGHT);
|
||||
@@ -167,8 +169,8 @@ static void bt_hid_mouse_process(BtHidMouse* bt_hid_mouse, InputEvent* event) {
|
||||
model->up_pressed = false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
},
|
||||
true);
|
||||
}
|
||||
|
||||
static bool bt_hid_mouse_input_callback(InputEvent* event, void* context) {
|
||||
@@ -211,8 +213,5 @@ View* bt_hid_mouse_get_view(BtHidMouse* bt_hid_mouse) {
|
||||
void bt_hid_mouse_set_connected_status(BtHidMouse* bt_hid_mouse, bool connected) {
|
||||
furi_assert(bt_hid_mouse);
|
||||
with_view_model(
|
||||
bt_hid_mouse->view, (BtHidMouseModel * model) {
|
||||
model->connected = connected;
|
||||
return true;
|
||||
});
|
||||
bt_hid_mouse->view, BtHidMouseModel * model, { model->connected = connected; }, true);
|
||||
}
|
||||
|
||||
@@ -248,12 +248,16 @@ static void music_player_worker_callback(
|
||||
view_port_update(music_player->view_port);
|
||||
}
|
||||
|
||||
void music_player_clear(MusicPlayer* instance) {
|
||||
memset(instance->model->duration_history, 0xff, MUSIC_PLAYER_SEMITONE_HISTORY_SIZE);
|
||||
memset(instance->model->semitone_history, 0xff, MUSIC_PLAYER_SEMITONE_HISTORY_SIZE);
|
||||
music_player_worker_clear(instance->worker);
|
||||
}
|
||||
|
||||
MusicPlayer* music_player_alloc() {
|
||||
MusicPlayer* instance = malloc(sizeof(MusicPlayer));
|
||||
|
||||
instance->model = malloc(sizeof(MusicPlayerModel));
|
||||
memset(instance->model->duration_history, 0xff, MUSIC_PLAYER_SEMITONE_HISTORY_SIZE);
|
||||
memset(instance->model->semitone_history, 0xff, MUSIC_PLAYER_SEMITONE_HISTORY_SIZE);
|
||||
instance->model->volume = 4;
|
||||
|
||||
instance->model_mutex = furi_mutex_alloc(FuriMutexTypeNormal);
|
||||
@@ -265,6 +269,8 @@ MusicPlayer* music_player_alloc() {
|
||||
instance->worker, MUSIC_PLAYER_VOLUMES[instance->model->volume]);
|
||||
music_player_worker_set_callback(instance->worker, music_player_worker_callback, instance);
|
||||
|
||||
music_player_clear(instance);
|
||||
|
||||
instance->view_port = view_port_alloc();
|
||||
view_port_draw_callback_set(instance->view_port, render_callback, instance);
|
||||
view_port_input_callback_set(instance->view_port, input_callback, instance);
|
||||
@@ -299,7 +305,7 @@ int32_t music_player_app(void* p) {
|
||||
|
||||
do {
|
||||
if(p && strlen(p)) {
|
||||
furi_string_cat(file_path, (const char*)p);
|
||||
furi_string_set(file_path, (const char*)p);
|
||||
} else {
|
||||
furi_string_set(file_path, MUSIC_PLAYER_APP_PATH_FOLDER);
|
||||
|
||||
@@ -350,7 +356,9 @@ int32_t music_player_app(void* p) {
|
||||
}
|
||||
|
||||
music_player_worker_stop(music_player->worker);
|
||||
} while(0);
|
||||
if(p && strlen(p)) break; // Exit instead of going to browser if launched with arg
|
||||
music_player_clear(music_player);
|
||||
} while(1);
|
||||
|
||||
furi_string_free(file_path);
|
||||
music_player_free(music_player);
|
||||
|
||||
@@ -108,6 +108,10 @@ MusicPlayerWorker* music_player_worker_alloc() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
void music_player_worker_clear(MusicPlayerWorker* instance) {
|
||||
NoteBlockArray_reset(instance->notes);
|
||||
}
|
||||
|
||||
void music_player_worker_free(MusicPlayerWorker* instance) {
|
||||
furi_assert(instance);
|
||||
furi_thread_free(instance->thread);
|
||||
@@ -129,6 +133,7 @@ static bool is_space(const char c) {
|
||||
|
||||
static size_t extract_number(const char* string, uint32_t* number) {
|
||||
size_t ret = 0;
|
||||
*number = 0;
|
||||
while(is_digit(*string)) {
|
||||
*number *= 10;
|
||||
*number += (*string - '0');
|
||||
@@ -140,6 +145,7 @@ static size_t extract_number(const char* string, uint32_t* number) {
|
||||
|
||||
static size_t extract_dots(const char* string, uint32_t* number) {
|
||||
size_t ret = 0;
|
||||
*number = 0;
|
||||
while(*string == '.') {
|
||||
*number += 1;
|
||||
string++;
|
||||
|
||||
@@ -18,6 +18,8 @@ typedef struct MusicPlayerWorker MusicPlayerWorker;
|
||||
|
||||
MusicPlayerWorker* music_player_worker_alloc();
|
||||
|
||||
void music_player_worker_clear(MusicPlayerWorker* instance);
|
||||
|
||||
void music_player_worker_free(MusicPlayerWorker* instance);
|
||||
|
||||
bool music_player_worker_load(MusicPlayerWorker* instance, const char* file_path);
|
||||
|
||||
@@ -44,12 +44,14 @@ static void pwm_set_config(SignalGenPwm* pwm) {
|
||||
uint8_t duty;
|
||||
|
||||
with_view_model(
|
||||
pwm->view, (SignalGenPwmViewModel * model) {
|
||||
pwm->view,
|
||||
SignalGenPwmViewModel * model,
|
||||
{
|
||||
channel = model->channel_id;
|
||||
freq = model->freq;
|
||||
duty = model->duty;
|
||||
return false;
|
||||
});
|
||||
},
|
||||
false);
|
||||
|
||||
furi_assert(pwm->callback);
|
||||
pwm->callback(channel, freq, duty, pwm->context);
|
||||
@@ -188,7 +190,9 @@ static bool signal_gen_pwm_input_callback(InputEvent* event, void* context) {
|
||||
bool need_update = false;
|
||||
|
||||
with_view_model(
|
||||
pwm->view, (SignalGenPwmViewModel * model) {
|
||||
pwm->view,
|
||||
SignalGenPwmViewModel * model,
|
||||
{
|
||||
if(model->edit_mode == false) {
|
||||
if((event->type == InputTypeShort) || (event->type == InputTypeRepeat)) {
|
||||
if(event->key == InputKeyUp) {
|
||||
@@ -238,8 +242,8 @@ static bool signal_gen_pwm_input_callback(InputEvent* event, void* context) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
},
|
||||
true);
|
||||
|
||||
if(need_update) {
|
||||
pwm_set_config(pwm);
|
||||
@@ -279,22 +283,26 @@ void signal_gen_pwm_set_callback(
|
||||
furi_assert(callback);
|
||||
|
||||
with_view_model(
|
||||
pwm->view, (SignalGenPwmViewModel * model) {
|
||||
pwm->view,
|
||||
SignalGenPwmViewModel * model,
|
||||
{
|
||||
UNUSED(model);
|
||||
pwm->callback = callback;
|
||||
pwm->context = context;
|
||||
return false;
|
||||
});
|
||||
},
|
||||
false);
|
||||
}
|
||||
|
||||
void signal_gen_pwm_set_params(SignalGenPwm* pwm, uint8_t channel_id, uint32_t freq, uint8_t duty) {
|
||||
with_view_model(
|
||||
pwm->view, (SignalGenPwmViewModel * model) {
|
||||
pwm->view,
|
||||
SignalGenPwmViewModel * model,
|
||||
{
|
||||
model->channel_id = channel_id;
|
||||
model->freq = freq;
|
||||
model->duty = duty;
|
||||
return true;
|
||||
});
|
||||
},
|
||||
true);
|
||||
|
||||
furi_assert(pwm->callback);
|
||||
pwm->callback(channel_id, freq, duty, pwm->context);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
App(
|
||||
appid="USB_Keyboard",
|
||||
name="USB Keyboard",
|
||||
name="USB Keyboard & Mouse",
|
||||
apptype=FlipperAppType.EXTERNAL,
|
||||
entry_point="usb_hid_app",
|
||||
stack_size=1 * 1024,
|
||||
@@ -10,5 +10,5 @@ App(
|
||||
],
|
||||
order=60,
|
||||
fap_icon="usb_keyboard_10px.png",
|
||||
fap_category="Tools",
|
||||
fap_category="Misc",
|
||||
)
|
||||
|
||||
@@ -99,7 +99,9 @@ static void usb_hid_dirpad_draw_callback(Canvas* canvas, void* context) {
|
||||
|
||||
static void usb_hid_dirpad_process(UsbHidDirpad* usb_hid_dirpad, InputEvent* event) {
|
||||
with_view_model(
|
||||
usb_hid_dirpad->view, (UsbHidDirpadModel * model) {
|
||||
usb_hid_dirpad->view,
|
||||
UsbHidDirpadModel * model,
|
||||
{
|
||||
if(event->type == InputTypePress) {
|
||||
if(event->key == InputKeyUp) {
|
||||
model->up_pressed = true;
|
||||
@@ -146,8 +148,8 @@ static void usb_hid_dirpad_process(UsbHidDirpad* usb_hid_dirpad, InputEvent* eve
|
||||
furi_hal_hid_consumer_key_release(HID_CONSUMER_AC_BACK);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
},
|
||||
true);
|
||||
}
|
||||
|
||||
static bool usb_hid_dirpad_input_callback(InputEvent* event, void* context) {
|
||||
@@ -190,8 +192,5 @@ View* usb_hid_dirpad_get_view(UsbHidDirpad* usb_hid_dirpad) {
|
||||
void usb_hid_dirpad_set_connected_status(UsbHidDirpad* usb_hid_dirpad, bool connected) {
|
||||
furi_assert(usb_hid_dirpad);
|
||||
with_view_model(
|
||||
usb_hid_dirpad->view, (UsbHidDirpadModel * model) {
|
||||
model->connected = connected;
|
||||
return true;
|
||||
});
|
||||
usb_hid_dirpad->view, UsbHidDirpadModel * model, { model->connected = connected; }, true);
|
||||
}
|
||||
|
||||
@@ -241,7 +241,9 @@ static uint8_t usb_hid_keyboard_get_selected_key(UsbHidKeyboardModel* model) {
|
||||
return key.value;
|
||||
}
|
||||
|
||||
static void usb_hid_keyboard_get_select_key(UsbHidKeyboardModel* model, UsbHidKeyboardPoint delta) {
|
||||
|
||||
static void
|
||||
usb_hid_keyboard_get_select_key(UsbHidKeyboardModel* model, UsbHidKeyboardPoint delta) {
|
||||
// Keep going until a valid spot is found, this allows for nulls and zero width keys in the map
|
||||
do {
|
||||
if(((int8_t)model->y) + delta.y < 0)
|
||||
@@ -261,7 +263,9 @@ static void usb_hid_keyboard_get_select_key(UsbHidKeyboardModel* model, UsbHidKe
|
||||
|
||||
static void usb_hid_keyboard_process(UsbHidKeyboard* usb_hid_keyboard, InputEvent* event) {
|
||||
with_view_model(
|
||||
usb_hid_keyboard->view, (UsbHidKeyboardModel * model) {
|
||||
usb_hid_keyboard->view,
|
||||
UsbHidKeyboardModel * model,
|
||||
{
|
||||
if(event->key == InputKeyOk) {
|
||||
if(event->type == InputTypePress) {
|
||||
model->ok_pressed = true;
|
||||
@@ -322,8 +326,8 @@ static void usb_hid_keyboard_process(UsbHidKeyboard* usb_hid_keyboard, InputEven
|
||||
usb_hid_keyboard_get_select_key(model, (UsbHidKeyboardPoint){.x = 1, .y = 0});
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
},
|
||||
true);
|
||||
}
|
||||
|
||||
static bool usb_hid_keyboard_input_callback(InputEvent* event, void* context) {
|
||||
@@ -343,18 +347,13 @@ static bool usb_hid_keyboard_input_callback(InputEvent* event, void* context) {
|
||||
|
||||
UsbHidKeyboard* usb_hid_keyboard_alloc() {
|
||||
UsbHidKeyboard* usb_hid_keyboard = malloc(sizeof(UsbHidKeyboard));
|
||||
|
||||
usb_hid_keyboard->view = view_alloc();
|
||||
view_set_context(usb_hid_keyboard->view, usb_hid_keyboard);
|
||||
view_allocate_model(usb_hid_keyboard->view, ViewModelTypeLocking, sizeof(UsbHidKeyboardModel));
|
||||
view_set_draw_callback(usb_hid_keyboard->view, usb_hid_keyboard_draw_callback);
|
||||
view_set_input_callback(usb_hid_keyboard->view, usb_hid_keyboard_input_callback);
|
||||
|
||||
with_view_model(
|
||||
usb_hid_keyboard->view, (UsbHidKeyboardModel * model) {
|
||||
model->connected = true;
|
||||
return true;
|
||||
});
|
||||
with_view_model(
|
||||
usb_hid_keyboard->view, UsbHidKeyboardModel * model, { model->connected = true; }, true);
|
||||
|
||||
return usb_hid_keyboard;
|
||||
}
|
||||
|
||||
@@ -100,7 +100,9 @@ static void usb_hid_media_draw_callback(Canvas* canvas, void* context) {
|
||||
|
||||
static void usb_hid_media_process_press(UsbHidMedia* usb_hid_media, InputEvent* event) {
|
||||
with_view_model(
|
||||
usb_hid_media->view, (UsbHidMediaModel * model) {
|
||||
usb_hid_media->view,
|
||||
UsbHidMediaModel * model,
|
||||
{
|
||||
if(event->key == InputKeyUp) {
|
||||
model->up_pressed = true;
|
||||
furi_hal_hid_consumer_key_press(HID_CONSUMER_VOLUME_INCREMENT);
|
||||
@@ -117,13 +119,15 @@ static void usb_hid_media_process_press(UsbHidMedia* usb_hid_media, InputEvent*
|
||||
model->ok_pressed = true;
|
||||
furi_hal_hid_consumer_key_press(HID_CONSUMER_PLAY_PAUSE);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
},
|
||||
true);
|
||||
}
|
||||
|
||||
static void hid_media_process_release(UsbHidMedia* usb_hid_media, InputEvent* event) {
|
||||
with_view_model(
|
||||
usb_hid_media->view, (UsbHidMediaModel * model) {
|
||||
usb_hid_media->view,
|
||||
UsbHidMediaModel * model,
|
||||
{
|
||||
if(event->key == InputKeyUp) {
|
||||
model->up_pressed = false;
|
||||
furi_hal_hid_consumer_key_release(HID_CONSUMER_VOLUME_INCREMENT);
|
||||
@@ -140,8 +144,8 @@ static void hid_media_process_release(UsbHidMedia* usb_hid_media, InputEvent* ev
|
||||
model->ok_pressed = false;
|
||||
furi_hal_hid_consumer_key_release(HID_CONSUMER_PLAY_PAUSE);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
},
|
||||
true);
|
||||
}
|
||||
|
||||
static bool usb_hid_media_input_callback(InputEvent* event, void* context) {
|
||||
@@ -172,11 +176,8 @@ UsbHidMedia* usb_hid_media_alloc() {
|
||||
view_set_draw_callback(usb_hid_media->view, usb_hid_media_draw_callback);
|
||||
view_set_input_callback(usb_hid_media->view, usb_hid_media_input_callback);
|
||||
|
||||
with_view_model(
|
||||
usb_hid_media->view, (UsbHidMediaModel* model) {
|
||||
model->connected = true;
|
||||
return true;
|
||||
});
|
||||
with_view_model(
|
||||
usb_hid_media->view, UsbHidMediaModel * model, { model->connected = true; }, true);
|
||||
|
||||
return usb_hid_media;
|
||||
}
|
||||
@@ -195,8 +196,5 @@ View* usb_hid_media_get_view(UsbHidMedia* usb_hid_media) {
|
||||
void usb_hid_media_set_connected_status(UsbHidMedia* usb_hid_media, bool connected) {
|
||||
furi_assert(usb_hid_media);
|
||||
with_view_model(
|
||||
usb_hid_media->view, (UsbHidMediaModel * model) {
|
||||
model->connected = connected;
|
||||
return true;
|
||||
});
|
||||
usb_hid_media->view, UsbHidMediaModel * model, { model->connected = connected; }, true);
|
||||
}
|
||||
|
||||
@@ -25,11 +25,11 @@ static void usb_hid_mouse_draw_callback(Canvas* canvas, void* context) {
|
||||
UsbHidMouseModel* model = context;
|
||||
|
||||
// Header
|
||||
if(model->connected) {
|
||||
/*if(model->connected) {
|
||||
canvas_draw_icon(canvas, 0, 0, &I_Ble_connected_15x15);
|
||||
} else {
|
||||
canvas_draw_icon(canvas, 0, 0, &I_Ble_disconnected_15x15);
|
||||
}
|
||||
}*/
|
||||
canvas_set_font(canvas, FontPrimary);
|
||||
elements_multiline_text_aligned(canvas, 17, 3, AlignLeft, AlignTop, "Mouse");
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
@@ -102,7 +102,9 @@ static void usb_hid_mouse_draw_callback(Canvas* canvas, void* context) {
|
||||
|
||||
static void usb_hid_mouse_process(UsbHidMouse* usb_hid_mouse, InputEvent* event) {
|
||||
with_view_model(
|
||||
usb_hid_mouse->view, (UsbHidMouseModel * model) {
|
||||
usb_hid_mouse->view,
|
||||
UsbHidMouseModel * model,
|
||||
{
|
||||
if(event->key == InputKeyBack) {
|
||||
if(event->type == InputTypeShort) {
|
||||
furi_hal_hid_mouse_press(HID_MOUSE_BTN_RIGHT);
|
||||
@@ -166,8 +168,8 @@ static void usb_hid_mouse_process(UsbHidMouse* usb_hid_mouse, InputEvent* event)
|
||||
model->up_pressed = false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
},
|
||||
true);
|
||||
}
|
||||
|
||||
static bool usb_hid_mouse_input_callback(InputEvent* event, void* context) {
|
||||
@@ -176,8 +178,8 @@ static bool usb_hid_mouse_input_callback(InputEvent* event, void* context) {
|
||||
bool consumed = false;
|
||||
|
||||
if(event->type == InputTypeLong && event->key == InputKeyBack) {
|
||||
furi_hal_hid_mouse_release(HID_MOUSE_BTN_LEFT);
|
||||
furi_hal_hid_mouse_release(HID_MOUSE_BTN_RIGHT);
|
||||
furi_hal_hid_mouse_release(HID_MOUSE_BTN_LEFT);
|
||||
furi_hal_hid_mouse_release(HID_MOUSE_BTN_RIGHT);
|
||||
} else {
|
||||
usb_hid_mouse_process(usb_hid_mouse, event);
|
||||
consumed = true;
|
||||
@@ -193,12 +195,9 @@ UsbHidMouse* usb_hid_mouse_alloc() {
|
||||
view_allocate_model(usb_hid_mouse->view, ViewModelTypeLocking, sizeof(UsbHidMouseModel));
|
||||
view_set_draw_callback(usb_hid_mouse->view, usb_hid_mouse_draw_callback);
|
||||
view_set_input_callback(usb_hid_mouse->view, usb_hid_mouse_input_callback);
|
||||
|
||||
with_view_model(
|
||||
usb_hid_mouse->view, (UsbHidMouseModel* model) {
|
||||
model->connected = true;
|
||||
return true;
|
||||
});
|
||||
|
||||
with_view_model(
|
||||
usb_hid_mouse->view, UsbHidMouseModel * model, { model->connected = true; }, true);
|
||||
|
||||
return usb_hid_mouse;
|
||||
}
|
||||
@@ -212,5 +211,4 @@ void usb_hid_mouse_free(UsbHidMouse* usb_hid_mouse) {
|
||||
View* usb_hid_mouse_get_view(UsbHidMouse* usb_hid_mouse) {
|
||||
furi_assert(usb_hid_mouse);
|
||||
return usb_hid_mouse->view;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user