mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
Format
This commit is contained in:
@@ -151,7 +151,8 @@ BadKbApp* bad_kb_app_alloc(char* arg) {
|
||||
app->error = BadKbAppErrorCloseRpc;
|
||||
scene_manager_next_scene(app->scene_manager, BadKbSceneError);
|
||||
} else {
|
||||
app->conn_init_thread = furi_thread_alloc_ex("BadKbConnInit", 512, (FuriThreadCallback)bad_kb_connection_init, app);
|
||||
app->conn_init_thread = furi_thread_alloc_ex(
|
||||
"BadKbConnInit", 512, (FuriThreadCallback)bad_kb_connection_init, app);
|
||||
furi_thread_start(app->conn_init_thread);
|
||||
if(!furi_string_empty(app->file_path)) {
|
||||
app->bad_kb_script = bad_kb_script_open(app->file_path, app->is_bt ? app->bt : NULL);
|
||||
|
||||
@@ -19,15 +19,15 @@
|
||||
#define BAD_KB_APP_BASE_FOLDER ANY_PATH("badkb")
|
||||
#define BAD_KB_APP_PATH_LAYOUT_FOLDER BAD_KB_APP_BASE_FOLDER "/assets/layouts"
|
||||
#define BAD_KB_APP_PATH_BOUND_KEYS_FOLDER EXT_PATH("badkb/.bt_keys")
|
||||
#define BAD_KB_APP_PATH_BOUND_KEYS_FILE BAD_KB_APP_PATH_BOUND_KEYS_FOLDER "/.devices.keys"
|
||||
#define BAD_KB_APP_PATH_BOUND_KEYS_FILE BAD_KB_APP_PATH_BOUND_KEYS_FOLDER "/.devices.keys"
|
||||
#define BAD_KB_APP_SCRIPT_EXTENSION ".txt"
|
||||
#define BAD_KB_APP_LAYOUT_EXTENSION ".kl"
|
||||
|
||||
#define BAD_KB_MAC_ADDRESS_LEN 6 // need replace with MAC size maccro
|
||||
#define BAD_KB_ADV_NAME_MAX_LEN 18
|
||||
#define BAD_KB_MAC_ADDRESS_LEN 6 // need replace with MAC size maccro
|
||||
#define BAD_KB_ADV_NAME_MAX_LEN 18
|
||||
|
||||
// this is the MAC address used when we do not forget paired device (BOUND STATE)
|
||||
#define BAD_KB_BOUND_MAC_ADDRESS { 0x41, 0x4a, 0xef, 0xb6, 0xa9, 0xd4 };
|
||||
#define BAD_KB_BOUND_MAC_ADDRESS {0x41, 0x4a, 0xef, 0xb6, 0xa9, 0xd4};
|
||||
|
||||
typedef enum {
|
||||
BadKbAppErrorNoFiles,
|
||||
@@ -61,7 +61,7 @@ struct BadKbApp {
|
||||
ByteInput* byte_input;
|
||||
uint8_t mac[BAD_KB_MAC_ADDRESS_LEN];
|
||||
char name[BAD_KB_ADV_NAME_MAX_LEN + 1];
|
||||
bool bt_remember; // weither we remember paired devices or not
|
||||
bool bt_remember; // weither we remember paired devices or not
|
||||
BadKbBtConfig bt_old_config;
|
||||
|
||||
BadKbAppError error;
|
||||
|
||||
@@ -650,12 +650,13 @@ void bad_kb_config_switch_mode(BadKbApp* app) {
|
||||
}
|
||||
}
|
||||
|
||||
void bad_kb_config_switch_remember_mode(BadKbApp *app) {
|
||||
if (app->bt_remember) {
|
||||
void bad_kb_config_switch_remember_mode(BadKbApp* app) {
|
||||
if(app->bt_remember) {
|
||||
// set bouding mac
|
||||
uint8_t mac[6] = BAD_KB_BOUND_MAC_ADDRESS;
|
||||
furi_hal_bt_set_profile_pairing_method(FuriHalBtProfileHidKeyboard, GapPairingPinCodeVerifyYesNo);
|
||||
bt_set_profile_mac_address(app->bt, mac); // this also restart bt
|
||||
furi_hal_bt_set_profile_pairing_method(
|
||||
FuriHalBtProfileHidKeyboard, GapPairingPinCodeVerifyYesNo);
|
||||
bt_set_profile_mac_address(app->bt, mac); // this also restart bt
|
||||
// enable keys storage
|
||||
bt_enable_peer_key_update(app->bt);
|
||||
} else {
|
||||
@@ -676,11 +677,12 @@ int32_t bad_kb_connection_init(BadKbApp* app) {
|
||||
// furi_delay_ms(200);
|
||||
bt_keys_storage_set_storage_path(app->bt, BAD_KB_APP_PATH_BOUND_KEYS_FILE);
|
||||
app->bt_prev_mode = furi_hal_bt_get_profile_pairing_method(FuriHalBtProfileHidKeyboard);
|
||||
if (app->bt_remember) {
|
||||
if(app->bt_remember) {
|
||||
uint8_t mac[6] = BAD_KB_BOUND_MAC_ADDRESS;
|
||||
furi_hal_bt_set_profile_mac_addr(FuriHalBtProfileHidKeyboard, mac);
|
||||
// using GapPairingNone breaks bounding between devices
|
||||
furi_hal_bt_set_profile_pairing_method(FuriHalBtProfileHidKeyboard, GapPairingPinCodeVerifyYesNo);
|
||||
furi_hal_bt_set_profile_pairing_method(
|
||||
FuriHalBtProfileHidKeyboard, GapPairingPinCodeVerifyYesNo);
|
||||
} else {
|
||||
furi_hal_bt_set_profile_pairing_method(FuriHalBtProfileHidKeyboard, GapPairingNone);
|
||||
}
|
||||
@@ -688,7 +690,7 @@ int32_t bad_kb_connection_init(BadKbApp* app) {
|
||||
bt_set_profile(app->bt, BtProfileHidKeyboard);
|
||||
if(app->is_bt) {
|
||||
furi_hal_bt_start_advertising();
|
||||
if (app->bt_remember) {
|
||||
if(app->bt_remember) {
|
||||
bt_enable_peer_key_update(app->bt);
|
||||
} else {
|
||||
bt_disable_peer_key_update(app->bt); // disable peer key adding to bt SRAM storage
|
||||
@@ -711,7 +713,7 @@ void bad_kb_connection_deinit(BadKbApp* app) {
|
||||
bt_disconnect(app->bt); // stop ble
|
||||
// furi_delay_ms(200); // Wait 2nd core to update nvm storage
|
||||
bt_keys_storage_set_default_path(app->bt);
|
||||
if (app->bt_remember) {
|
||||
if(app->bt_remember) {
|
||||
// hal primitives doesn't restarts ble, that's what we want cuz we are shutting down
|
||||
furi_hal_bt_set_profile_mac_addr(FuriHalBtProfileHidKeyboard, app->mac);
|
||||
}
|
||||
@@ -911,7 +913,8 @@ static int32_t bad_kb_worker(void* context) {
|
||||
} else if(
|
||||
(worker_state == BadKbStateFileError) ||
|
||||
(worker_state == BadKbStateScriptError)) { // State: error
|
||||
uint32_t flags = bad_kb_flags_get(WorkerEvtEnd, FuriWaitForever); // Waiting for exit command
|
||||
uint32_t flags =
|
||||
bad_kb_flags_get(WorkerEvtEnd, FuriWaitForever); // Waiting for exit command
|
||||
if(flags & WorkerEvtEnd) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ typedef struct {
|
||||
|
||||
void bad_kb_config_switch_mode(BadKbApp* app);
|
||||
|
||||
void bad_kb_config_switch_remember_mode(BadKbApp *app);
|
||||
void bad_kb_config_switch_remember_mode(BadKbApp* app);
|
||||
|
||||
int32_t bad_kb_connection_init(BadKbApp* app);
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ void bad_kb_scene_config_bt_on_enter(void* context) {
|
||||
item = variable_item_list_add(var_item_list, "BT device name", 0, NULL, bad_kb);
|
||||
|
||||
// this doesn't update instantly when toggling between Bounding modes
|
||||
if (!bad_kb->bt_remember) {
|
||||
if(!bad_kb->bt_remember) {
|
||||
item = variable_item_list_add(var_item_list, "BT MAC address", 0, NULL, bad_kb);
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ bool bad_kb_scene_config_bt_on_event(void* context, SceneManagerEvent event) {
|
||||
scene_manager_next_scene(bad_kb->scene_manager, BadKbSceneConfigLayout);
|
||||
} else if(event.event == VarItemListIndexConnection) {
|
||||
bad_kb_config_switch_mode(bad_kb);
|
||||
} else if (event.event == VarItemListIndexRemember) {
|
||||
} else if(event.event == VarItemListIndexRemember) {
|
||||
bad_kb_config_switch_remember_mode(bad_kb);
|
||||
scene_manager_previous_scene(bad_kb->scene_manager);
|
||||
scene_manager_next_scene(bad_kb->scene_manager, BadKbSceneConfigBt);
|
||||
|
||||
@@ -239,8 +239,7 @@ bool bad_kb_is_idle_state(BadKb* bad_kb) {
|
||||
bad_kb->view,
|
||||
BadKbModel * model,
|
||||
{
|
||||
if((model->state.state == BadKbStateIdle) ||
|
||||
(model->state.state == BadKbStateDone) ||
|
||||
if((model->state.state == BadKbStateIdle) || (model->state.state == BadKbStateDone) ||
|
||||
(model->state.state == BadKbStateNotConnected)) {
|
||||
is_idle = true;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,11 @@ void xtreme_app_scene_protocols_on_enter(void* context) {
|
||||
variable_item_set_current_value_text(item, xtreme_settings->bad_bt ? "BT" : "USB");
|
||||
|
||||
item = variable_item_list_add(
|
||||
var_item_list, "Bad BT Remember", 2, xtreme_app_scene_protocols_bad_bt_remember_changed, app);
|
||||
var_item_list,
|
||||
"Bad BT Remember",
|
||||
2,
|
||||
xtreme_app_scene_protocols_bad_bt_remember_changed,
|
||||
app);
|
||||
variable_item_set_current_value_index(item, xtreme_settings->bad_bt_remember);
|
||||
variable_item_set_current_value_text(item, xtreme_settings->bad_bt_remember ? "ON" : "OFF");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user