mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-06-19 20:34:19 -07:00
BadKB edit name and mac in temp buffers + cleanup
This commit is contained in:
@@ -143,6 +143,8 @@ struct BadKbApp {
|
||||
VariableItemList* var_item_list;
|
||||
TextInput* text_input;
|
||||
ByteInput* byte_input;
|
||||
char bt_name_buf[BAD_KB_NAME_LEN];
|
||||
uint8_t bt_mac_buf[BAD_KB_MAC_LEN];
|
||||
|
||||
BadKbAppError error;
|
||||
FuriString* file_path;
|
||||
|
||||
@@ -10,17 +10,20 @@ void bad_kb_scene_config_mac_byte_input_callback(void* context) {
|
||||
|
||||
void bad_kb_scene_config_mac_on_enter(void* context) {
|
||||
BadKbApp* bad_kb = context;
|
||||
|
||||
// Setup view
|
||||
ByteInput* byte_input = bad_kb->byte_input;
|
||||
|
||||
memmove(bad_kb->bt_mac_buf, bad_kb->config.bt_mac, GAP_MAC_ADDR_SIZE);
|
||||
|
||||
byte_input_set_header_text(byte_input, "Set BT MAC address");
|
||||
|
||||
byte_input_set_result_callback(
|
||||
byte_input,
|
||||
bad_kb_scene_config_mac_byte_input_callback,
|
||||
NULL,
|
||||
bad_kb,
|
||||
bad_kb->config.bt_mac,
|
||||
bad_kb->bt_mac_buf,
|
||||
GAP_MAC_ADDR_SIZE);
|
||||
|
||||
view_dispatcher_switch_to_view(bad_kb->view_dispatcher, BadKbAppViewByteInput);
|
||||
}
|
||||
|
||||
@@ -29,19 +32,20 @@ bool bad_kb_scene_config_mac_on_event(void* context, SceneManagerEvent event) {
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
consumed = true;
|
||||
if(event.event == BadKbAppCustomEventByteInputDone) {
|
||||
memmove(bad_kb->config.bt_mac, bad_kb->bt_mac_buf, GAP_MAC_ADDR_SIZE);
|
||||
bt_set_profile_mac_address(bad_kb->bt, bad_kb->config.bt_mac);
|
||||
scene_manager_previous_scene(bad_kb->scene_manager);
|
||||
consumed = true;
|
||||
}
|
||||
scene_manager_previous_scene(bad_kb->scene_manager);
|
||||
}
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void bad_kb_scene_config_mac_on_exit(void* context) {
|
||||
BadKbApp* bad_kb = context;
|
||||
ByteInput* byte_input = bad_kb->byte_input;
|
||||
|
||||
// Clear view
|
||||
byte_input_set_result_callback(bad_kb->byte_input, NULL, NULL, NULL, NULL, 0);
|
||||
byte_input_set_header_text(bad_kb->byte_input, "");
|
||||
byte_input_set_result_callback(byte_input, NULL, NULL, NULL, NULL, 0);
|
||||
byte_input_set_header_text(byte_input, "");
|
||||
}
|
||||
|
||||
@@ -10,13 +10,15 @@ void bad_kb_scene_config_name_on_enter(void* context) {
|
||||
BadKbApp* bad_kb = context;
|
||||
TextInput* text_input = bad_kb->text_input;
|
||||
|
||||
strlcpy(bad_kb->bt_name_buf, bad_kb->config.bt_name, BAD_KB_ADV_NAME_MAX_LEN);
|
||||
|
||||
text_input_set_header_text(text_input, "Set BT device name");
|
||||
|
||||
text_input_set_result_callback(
|
||||
text_input,
|
||||
bad_kb_scene_config_name_text_input_callback,
|
||||
bad_kb,
|
||||
bad_kb->config.bt_name,
|
||||
bad_kb->bt_name_buf,
|
||||
BAD_KB_ADV_NAME_MAX_LEN,
|
||||
true);
|
||||
|
||||
@@ -30,6 +32,7 @@ bool bad_kb_scene_config_name_on_event(void* context, SceneManagerEvent event) {
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
consumed = true;
|
||||
if(event.event == BadKbAppCustomEventTextInputDone) {
|
||||
strlcpy(bad_kb->config.bt_name, bad_kb->bt_name_buf, BAD_KB_ADV_NAME_MAX_LEN);
|
||||
bt_set_profile_adv_name(bad_kb->bt, bad_kb->config.bt_name);
|
||||
}
|
||||
scene_manager_previous_scene(bad_kb->scene_manager);
|
||||
|
||||
Reference in New Issue
Block a user