mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-10 05:59:08 -07:00
BLE Spam refactor random/set/custom mode handling
This commit is contained in:
@@ -4,27 +4,33 @@
|
||||
// Hacked together by @Willy-JL and @Spooks4576
|
||||
// Documentation at https://learn.microsoft.com/en-us/windows-hardware/design/component-guidelines/bluetooth-swift-pair
|
||||
|
||||
const char* names[] = {
|
||||
"Assquach💦",
|
||||
"Flipper 🐬",
|
||||
"iOS 17 🍎",
|
||||
"Kink💦",
|
||||
"👉👌",
|
||||
"🔵🦷",
|
||||
};
|
||||
const uint8_t names_count = COUNT_OF(names);
|
||||
|
||||
static const char* get_name(const ProtocolCfg* _cfg) {
|
||||
UNUSED(_cfg);
|
||||
return "SwiftPair";
|
||||
}
|
||||
|
||||
static void make_packet(uint8_t* _size, uint8_t** _packet, const ProtocolCfg* _cfg) {
|
||||
const SwiftpairCfg* cfg = _cfg ? &_cfg->swiftpair : NULL;
|
||||
static void make_packet(uint8_t* _size, uint8_t** _packet, ProtocolCfg* _cfg) {
|
||||
SwiftpairCfg* cfg = _cfg ? &_cfg->specific.swiftpair : NULL;
|
||||
|
||||
const char* name;
|
||||
if(cfg && cfg->name[0] != '\0') {
|
||||
switch(cfg ? _cfg->mode : ProtocolModeRandom) {
|
||||
case ProtocolModeRandom:
|
||||
default:
|
||||
name = names[rand() % names_count];
|
||||
break;
|
||||
case ProtocolModeValue:
|
||||
name = cfg->name;
|
||||
} else {
|
||||
const char* names[] = {
|
||||
"Assquach💦",
|
||||
"Flipper 🐬",
|
||||
"iOS 17 🍎",
|
||||
"Kink💦",
|
||||
"👉👌",
|
||||
"🔵🦷",
|
||||
};
|
||||
name = names[rand() % COUNT_OF(names)];
|
||||
break;
|
||||
}
|
||||
uint8_t name_len = strlen(name);
|
||||
|
||||
@@ -67,12 +73,14 @@ static void config_callback(void* _ctx, uint32_t index) {
|
||||
}
|
||||
}
|
||||
static void extra_config(Ctx* ctx) {
|
||||
SwiftpairCfg* cfg = &ctx->attack->payload.cfg.swiftpair;
|
||||
ProtocolCfg* _cfg = &ctx->attack->payload.cfg;
|
||||
SwiftpairCfg* cfg = &_cfg->specific.swiftpair;
|
||||
VariableItemList* list = ctx->variable_item_list;
|
||||
VariableItem* item;
|
||||
|
||||
item = variable_item_list_add(list, "Display Name", 0, NULL, NULL);
|
||||
variable_item_set_current_value_text(item, cfg->name[0] != '\0' ? cfg->name : "Random");
|
||||
variable_item_set_current_value_text(
|
||||
item, _cfg->mode == ProtocolModeRandom ? "Random" : cfg->name);
|
||||
|
||||
variable_item_list_add(list, "Requires enabling SwiftPair", 0, NULL, NULL);
|
||||
|
||||
@@ -94,15 +102,18 @@ const Protocol protocol_swiftpair = {
|
||||
|
||||
static void name_callback(void* _ctx) {
|
||||
Ctx* ctx = _ctx;
|
||||
ProtocolCfg* _cfg = &ctx->attack->payload.cfg;
|
||||
_cfg->mode = ProtocolModeValue;
|
||||
scene_manager_previous_scene(ctx->scene_manager);
|
||||
}
|
||||
void scene_swiftpair_name_on_enter(void* _ctx) {
|
||||
Ctx* ctx = _ctx;
|
||||
SwiftpairCfg* cfg = &ctx->attack->payload.cfg.swiftpair;
|
||||
ProtocolCfg* _cfg = &ctx->attack->payload.cfg;
|
||||
SwiftpairCfg* cfg = &_cfg->specific.swiftpair;
|
||||
TextInput* text_input = ctx->text_input;
|
||||
text_input_reset(text_input);
|
||||
|
||||
text_input_set_header_text(text_input, "Leave empty for random");
|
||||
text_input_set_header_text(text_input, "Press back for random");
|
||||
|
||||
text_input_set_result_callback(
|
||||
text_input, name_callback, ctx, cfg->name, sizeof(cfg->name), true);
|
||||
@@ -112,8 +123,11 @@ void scene_swiftpair_name_on_enter(void* _ctx) {
|
||||
view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewTextInput);
|
||||
}
|
||||
bool scene_swiftpair_name_on_event(void* _ctx, SceneManagerEvent event) {
|
||||
UNUSED(_ctx);
|
||||
UNUSED(event);
|
||||
Ctx* ctx = _ctx;
|
||||
ProtocolCfg* _cfg = &ctx->attack->payload.cfg;
|
||||
if(event.type == SceneManagerEventTypeBack) {
|
||||
_cfg->mode = ProtocolModeRandom;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
void scene_swiftpair_name_on_exit(void* _ctx) {
|
||||
|
||||
Reference in New Issue
Block a user