mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-12 16:58:36 -07:00
Merge branch 'dev' of https://github.com/DarkFlippers/unleashed-firmware into mntm-dev --nobuild
This commit is contained in:
@@ -17,14 +17,21 @@ void ibutton_scene_delete_confirm_on_enter(void* context) {
|
||||
|
||||
ibutton_protocols_render_uid(ibutton->protocols, key, uid);
|
||||
|
||||
furi_string_cat_printf(
|
||||
uid,
|
||||
"\n%s %s",
|
||||
ibutton_protocols_get_manufacturer(ibutton->protocols, ibutton_key_get_protocol_id(key)),
|
||||
ibutton_protocols_get_name(ibutton->protocols, ibutton_key_get_protocol_id(key)));
|
||||
|
||||
furi_string_cat(tmp, uid);
|
||||
|
||||
furi_string_push_back(tmp, '\n');
|
||||
|
||||
const char* protocol =
|
||||
ibutton_protocols_get_name(ibutton->protocols, ibutton_key_get_protocol_id(key));
|
||||
const char* manufacturer =
|
||||
ibutton_protocols_get_manufacturer(ibutton->protocols, ibutton_key_get_protocol_id(key));
|
||||
|
||||
if(strcasecmp(protocol, manufacturer) != 0 && strcasecmp(manufacturer, "N/A") != 0) {
|
||||
furi_string_cat_printf(tmp, "%s ", manufacturer);
|
||||
}
|
||||
|
||||
furi_string_cat(tmp, protocol);
|
||||
|
||||
widget_add_text_box_element(
|
||||
widget, 0, 0, 128, 64, AlignCenter, AlignTop, furi_string_get_cstr(tmp), false);
|
||||
|
||||
|
||||
@@ -21,17 +21,14 @@ void ibutton_scene_emulate_on_enter(void* context) {
|
||||
|
||||
widget_add_icon_element(widget, 3, 10, &I_iButtonKey_49x44);
|
||||
|
||||
if(furi_string_empty(ibutton->file_path)) {
|
||||
furi_string_printf(
|
||||
tmp,
|
||||
"Unsaved\n%s",
|
||||
ibutton_protocols_get_name(ibutton->protocols, ibutton_key_get_protocol_id(key)));
|
||||
} else {
|
||||
furi_string_printf(tmp, "%s", ibutton->key_name);
|
||||
}
|
||||
furi_string_printf(
|
||||
tmp,
|
||||
"[%s]\n%s",
|
||||
ibutton_protocols_get_name(ibutton->protocols, ibutton_key_get_protocol_id(key)),
|
||||
furi_string_empty(ibutton->file_path) ? "Unsaved Key" : ibutton->key_name);
|
||||
|
||||
widget_add_text_box_element(
|
||||
widget, 52, 23, 75, 26, AlignCenter, AlignTop, furi_string_get_cstr(tmp), false);
|
||||
widget, 52, 24, 75, 40, AlignCenter, AlignTop, furi_string_get_cstr(tmp), true);
|
||||
|
||||
widget_add_string_multiline_element(
|
||||
widget, 88, 10, AlignCenter, AlignTop, FontPrimary, "Emulating");
|
||||
|
||||
@@ -10,12 +10,23 @@ void ibutton_scene_info_on_enter(void* context) {
|
||||
FuriString* tmp = furi_string_alloc();
|
||||
FuriString* brief_data = furi_string_alloc();
|
||||
|
||||
furi_string_printf(
|
||||
tmp,
|
||||
"Name:%s\n\e#%s %s\e#\n",
|
||||
ibutton->key_name,
|
||||
ibutton_protocols_get_manufacturer(ibutton->protocols, protocol_id),
|
||||
ibutton_protocols_get_name(ibutton->protocols, protocol_id));
|
||||
if((strcmp(
|
||||
ibutton_protocols_get_manufacturer(ibutton->protocols, protocol_id),
|
||||
ibutton_protocols_get_name(ibutton->protocols, protocol_id)) != 0) &&
|
||||
(strcmp(ibutton_protocols_get_manufacturer(ibutton->protocols, protocol_id), "N/A") != 0)) {
|
||||
furi_string_printf(
|
||||
tmp,
|
||||
"Name:%s\n\e#%s %s\e#\n",
|
||||
ibutton->key_name,
|
||||
ibutton_protocols_get_manufacturer(ibutton->protocols, protocol_id),
|
||||
ibutton_protocols_get_name(ibutton->protocols, protocol_id));
|
||||
} else {
|
||||
furi_string_printf(
|
||||
tmp,
|
||||
"Name:%s\n\e#%s\e#\n",
|
||||
ibutton->key_name,
|
||||
ibutton_protocols_get_name(ibutton->protocols, protocol_id));
|
||||
}
|
||||
|
||||
ibutton_protocols_render_brief_data(ibutton->protocols, key, brief_data);
|
||||
|
||||
|
||||
@@ -40,15 +40,14 @@ void ibutton_scene_write_on_enter(void* context) {
|
||||
|
||||
widget_add_icon_element(widget, 3, 10, &I_iButtonKey_49x44);
|
||||
|
||||
if(furi_string_empty(ibutton->file_path)) {
|
||||
furi_string_printf(
|
||||
tmp, "Unsaved\n%s", ibutton_protocols_get_name(ibutton->protocols, protocol_id));
|
||||
} else {
|
||||
furi_string_printf(tmp, "%s", ibutton->key_name);
|
||||
}
|
||||
furi_string_printf(
|
||||
tmp,
|
||||
"[%s]\n%s",
|
||||
ibutton_protocols_get_name(ibutton->protocols, protocol_id),
|
||||
furi_string_empty(ibutton->file_path) ? "Unsaved Key" : ibutton->key_name);
|
||||
|
||||
widget_add_text_box_element(
|
||||
widget, 52, 23, 75, 26, AlignCenter, AlignTop, furi_string_get_cstr(tmp), false);
|
||||
widget, 52, 24, 75, 40, AlignCenter, AlignTop, furi_string_get_cstr(tmp), true);
|
||||
|
||||
ibutton_worker_write_set_callback(worker, ibutton_scene_write_callback, ibutton);
|
||||
|
||||
|
||||
@@ -15,16 +15,15 @@ void lfrfid_scene_emulate_on_enter(void* context) {
|
||||
|
||||
FuriString* display_text = furi_string_alloc_set("\e#Emulating\e#\n");
|
||||
|
||||
if(furi_string_empty(app->file_name)) {
|
||||
furi_string_cat(display_text, "Unsaved\n");
|
||||
furi_string_cat(display_text, protocol_dict_get_name(app->dict, app->protocol_id));
|
||||
} else {
|
||||
furi_string_cat(display_text, app->file_name);
|
||||
}
|
||||
furi_string_cat_printf(
|
||||
display_text,
|
||||
"[%s]\n%s",
|
||||
protocol_dict_get_name(app->dict, app->protocol_id),
|
||||
furi_string_empty(app->file_name) ? "Unsaved Tag" : furi_string_get_cstr(app->file_name));
|
||||
|
||||
widget_add_icon_element(widget, 0, 0, &I_NFC_dolphin_emulation_51x64);
|
||||
widget_add_text_box_element(
|
||||
widget, 55, 16, 67, 48, AlignCenter, AlignTop, furi_string_get_cstr(display_text), true);
|
||||
widget, 51, 6, 79, 50, AlignCenter, AlignTop, furi_string_get_cstr(display_text), false);
|
||||
|
||||
furi_string_free(display_text);
|
||||
|
||||
|
||||
@@ -25,12 +25,18 @@ void lfrfid_scene_write_on_enter(void* context) {
|
||||
popup_set_header(popup, "Writing", 94, 16, AlignCenter, AlignTop);
|
||||
|
||||
if(!furi_string_empty(app->file_name)) {
|
||||
popup_set_text(popup, furi_string_get_cstr(app->file_name), 94, 29, AlignCenter, AlignTop);
|
||||
snprintf(
|
||||
app->text_store,
|
||||
LFRFID_TEXT_STORE_SIZE,
|
||||
"[%s]\n%s",
|
||||
protocol_dict_get_name(app->dict, app->protocol_id),
|
||||
furi_string_get_cstr(app->file_name));
|
||||
popup_set_text(popup, app->text_store, 94, 29, AlignCenter, AlignTop);
|
||||
} else {
|
||||
snprintf(
|
||||
app->text_store,
|
||||
LFRFID_TEXT_STORE_SIZE,
|
||||
"Unsaved\n%s",
|
||||
"[%s]\nUnsaved Tag",
|
||||
protocol_dict_get_name(app->dict, app->protocol_id));
|
||||
popup_set_text(popup, app->text_store, 94, 29, AlignCenter, AlignTop);
|
||||
}
|
||||
|
||||
@@ -22,8 +22,14 @@ void lfrfid_scene_write_and_set_pass_on_enter(void* context) {
|
||||
LfRfid* app = context;
|
||||
Popup* popup = app->popup;
|
||||
|
||||
popup_set_header(popup, "Writing\nwith password", 89, 30, AlignCenter, AlignTop);
|
||||
popup_set_icon(popup, 0, 3, &I_RFIDDolphinSend_97x61);
|
||||
popup_set_header(popup, "Writing\nwith\npassword", 94, 8, AlignCenter, AlignTop);
|
||||
popup_set_icon(popup, 0, 8, &I_NFC_manual_60x50);
|
||||
snprintf(
|
||||
app->text_store,
|
||||
LFRFID_TEXT_STORE_SIZE,
|
||||
"[%s]",
|
||||
protocol_dict_get_name(app->dict, app->protocol_id));
|
||||
popup_set_text(popup, app->text_store, 94, 45, AlignCenter, AlignTop);
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, LfRfidViewPopup);
|
||||
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
#include "mf_plus.h"
|
||||
#include "mf_plus_render.h"
|
||||
|
||||
#include <nfc/protocols/mf_plus/mf_plus_poller.h>
|
||||
|
||||
#include "nfc/nfc_app_i.h"
|
||||
|
||||
#include "../nfc_protocol_support_common.h"
|
||||
#include "../nfc_protocol_support_gui_common.h"
|
||||
#include "../iso14443_4a/iso14443_4a_i.h"
|
||||
|
||||
static void nfc_scene_info_on_enter_mf_plus(NfcApp* instance) {
|
||||
const NfcDevice* device = instance->nfc_device;
|
||||
const MfPlusData* data = nfc_device_get_data(device, NfcProtocolMfPlus);
|
||||
|
||||
FuriString* temp_str = furi_string_alloc();
|
||||
nfc_append_filename_string_when_present(instance, temp_str);
|
||||
furi_string_cat_printf(
|
||||
temp_str, "\e#%s\n", nfc_device_get_name(device, NfcDeviceNameTypeFull));
|
||||
furi_string_replace(temp_str, "Mifare", "MIFARE");
|
||||
nfc_render_mf_plus_info(data, NfcProtocolFormatTypeFull, temp_str);
|
||||
|
||||
widget_add_text_scroll_element(
|
||||
instance->widget, 0, 0, 128, 52, furi_string_get_cstr(temp_str));
|
||||
|
||||
furi_string_free(temp_str);
|
||||
}
|
||||
static NfcCommand nfc_scene_read_poller_callback_mf_plus(NfcGenericEvent event, void* context) {
|
||||
furi_assert(event.protocol == NfcProtocolMfPlus);
|
||||
|
||||
NfcApp* instance = context;
|
||||
const MfPlusPollerEvent* mf_plus_event = event.event_data;
|
||||
|
||||
if(mf_plus_event->type == MfPlusPollerEventTypeReadSuccess) {
|
||||
nfc_device_set_data(
|
||||
instance->nfc_device, NfcProtocolMfPlus, nfc_poller_get_data(instance->poller));
|
||||
FURI_LOG_D(
|
||||
"MFP",
|
||||
"Read success: %s",
|
||||
nfc_device_get_name(instance->nfc_device, NfcDeviceNameTypeFull));
|
||||
view_dispatcher_send_custom_event(instance->view_dispatcher, NfcCustomEventPollerSuccess);
|
||||
return NfcCommandStop;
|
||||
}
|
||||
|
||||
return NfcCommandContinue;
|
||||
}
|
||||
|
||||
static void nfc_scene_read_on_enter_mf_plus(NfcApp* instance) {
|
||||
nfc_poller_start(instance->poller, nfc_scene_read_poller_callback_mf_plus, instance);
|
||||
}
|
||||
|
||||
static void nfc_scene_read_success_on_enter_mf_plus(NfcApp* instance) {
|
||||
const NfcDevice* device = instance->nfc_device;
|
||||
const MfPlusData* data = nfc_device_get_data(device, NfcProtocolMfPlus);
|
||||
|
||||
FuriString* temp_str = furi_string_alloc();
|
||||
furi_string_cat_printf(
|
||||
temp_str, "\e#%s\n", nfc_device_get_name(device, NfcDeviceNameTypeFull));
|
||||
furi_string_replace(temp_str, "Mifare", "MIFARE");
|
||||
nfc_render_mf_plus_info(data, NfcProtocolFormatTypeShort, temp_str);
|
||||
|
||||
widget_add_text_scroll_element(
|
||||
instance->widget, 0, 0, 128, 52, furi_string_get_cstr(temp_str));
|
||||
|
||||
furi_string_free(temp_str);
|
||||
}
|
||||
|
||||
static void nfc_scene_emulate_on_enter_mf_plus(NfcApp* instance) {
|
||||
const Iso14443_4aData* iso14443_4a_data =
|
||||
nfc_device_get_data(instance->nfc_device, NfcProtocolIso14443_4a);
|
||||
|
||||
instance->listener =
|
||||
nfc_listener_alloc(instance->nfc, NfcProtocolIso14443_4a, iso14443_4a_data);
|
||||
nfc_listener_start(
|
||||
instance->listener, nfc_scene_emulate_listener_callback_iso14443_4a, instance);
|
||||
}
|
||||
|
||||
const NfcProtocolSupportBase nfc_protocol_support_mf_plus = {
|
||||
.features = NfcProtocolFeatureMoreInfo,
|
||||
|
||||
.scene_info =
|
||||
{
|
||||
.on_enter = nfc_scene_info_on_enter_mf_plus,
|
||||
.on_event = nfc_protocol_support_common_on_event_empty,
|
||||
},
|
||||
.scene_more_info =
|
||||
{
|
||||
.on_enter = nfc_protocol_support_common_on_enter_empty,
|
||||
.on_event = nfc_protocol_support_common_on_event_empty,
|
||||
},
|
||||
.scene_read =
|
||||
{
|
||||
.on_enter = nfc_scene_read_on_enter_mf_plus,
|
||||
.on_event = nfc_protocol_support_common_on_event_empty,
|
||||
},
|
||||
.scene_read_menu =
|
||||
{
|
||||
.on_enter = nfc_protocol_support_common_on_enter_empty,
|
||||
.on_event = nfc_protocol_support_common_on_event_empty,
|
||||
},
|
||||
.scene_read_success =
|
||||
{
|
||||
.on_enter = nfc_scene_read_success_on_enter_mf_plus,
|
||||
.on_event = nfc_protocol_support_common_on_event_empty,
|
||||
},
|
||||
.scene_saved_menu =
|
||||
{
|
||||
.on_enter = nfc_protocol_support_common_on_enter_empty,
|
||||
.on_event = nfc_protocol_support_common_on_event_empty,
|
||||
},
|
||||
.scene_save_name =
|
||||
{
|
||||
.on_enter = nfc_protocol_support_common_on_enter_empty,
|
||||
.on_event = nfc_protocol_support_common_on_event_empty,
|
||||
},
|
||||
.scene_emulate =
|
||||
{
|
||||
.on_enter = nfc_scene_emulate_on_enter_mf_plus,
|
||||
.on_event = nfc_protocol_support_common_on_event_empty,
|
||||
},
|
||||
};
|
||||
@@ -1,5 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "../nfc_protocol_support_base.h"
|
||||
|
||||
extern const NfcProtocolSupportBase nfc_protocol_support_mf_plus;
|
||||
@@ -1,67 +0,0 @@
|
||||
#include "mf_plus_render.h"
|
||||
|
||||
#include "../iso14443_4a/iso14443_4a_render.h"
|
||||
|
||||
void nfc_render_mf_plus_info(
|
||||
const MfPlusData* data,
|
||||
NfcProtocolFormatType format_type,
|
||||
FuriString* str) {
|
||||
nfc_render_iso14443_4a_brief(mf_plus_get_base_data(data), str);
|
||||
|
||||
if(format_type != NfcProtocolFormatTypeFull) return;
|
||||
|
||||
furi_string_cat(str, "\n\e#ISO14443-4 data");
|
||||
nfc_render_iso14443_4a_extra(mf_plus_get_base_data(data), str);
|
||||
}
|
||||
|
||||
void nfc_render_mf_plus_data(const MfPlusData* data, FuriString* str) {
|
||||
nfc_render_mf_plus_version(&data->version, str);
|
||||
}
|
||||
|
||||
void nfc_render_mf_plus_version(const MfPlusVersion* data, FuriString* str) {
|
||||
furi_string_cat_printf(
|
||||
str,
|
||||
"%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
data->uid[0],
|
||||
data->uid[1],
|
||||
data->uid[2],
|
||||
data->uid[3],
|
||||
data->uid[4],
|
||||
data->uid[5],
|
||||
data->uid[6]);
|
||||
furi_string_cat_printf(
|
||||
str,
|
||||
"hw %02x type %02x sub %02x\n"
|
||||
" maj %02x min %02x\n"
|
||||
" size %02x proto %02x\n",
|
||||
data->hw_vendor,
|
||||
data->hw_type,
|
||||
data->hw_subtype,
|
||||
data->hw_major,
|
||||
data->hw_minor,
|
||||
data->hw_storage,
|
||||
data->hw_proto);
|
||||
furi_string_cat_printf(
|
||||
str,
|
||||
"sw %02x type %02x sub %02x\n"
|
||||
" maj %02x min %02x\n"
|
||||
" size %02x proto %02x\n",
|
||||
data->sw_vendor,
|
||||
data->sw_type,
|
||||
data->sw_subtype,
|
||||
data->sw_major,
|
||||
data->sw_minor,
|
||||
data->sw_storage,
|
||||
data->sw_proto);
|
||||
furi_string_cat_printf(
|
||||
str,
|
||||
"batch %02x:%02x:%02x:%02x:%02x\n"
|
||||
"week %d year %d\n",
|
||||
data->batch[0],
|
||||
data->batch[1],
|
||||
data->batch[2],
|
||||
data->batch[3],
|
||||
data->batch[4],
|
||||
data->prod_week,
|
||||
data->prod_year);
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <nfc/protocols/mf_plus/mf_plus.h>
|
||||
|
||||
#include "../nfc_protocol_support_render_common.h"
|
||||
|
||||
void nfc_render_mf_plus_info(
|
||||
const MfPlusData* data,
|
||||
NfcProtocolFormatType format_type,
|
||||
FuriString* str);
|
||||
|
||||
void nfc_render_mf_plus_data(const MfPlusData* data, FuriString* str);
|
||||
|
||||
void nfc_render_mf_plus_version(const MfPlusVersion* data, FuriString* str);
|
||||
@@ -17,7 +17,6 @@
|
||||
#include "felica/felica.h"
|
||||
#include "mf_ultralight/mf_ultralight.h"
|
||||
#include "mf_classic/mf_classic.h"
|
||||
#include "mf_plus/mf_plus.h"
|
||||
#include "mf_desfire/mf_desfire.h"
|
||||
#include "emv/emv.h"
|
||||
#include "slix/slix.h"
|
||||
@@ -40,7 +39,6 @@ const NfcProtocolSupportBase* nfc_protocol_support[NfcProtocolNum] = {
|
||||
[NfcProtocolFelica] = &nfc_protocol_support_felica,
|
||||
[NfcProtocolMfUltralight] = &nfc_protocol_support_mf_ultralight,
|
||||
[NfcProtocolMfClassic] = &nfc_protocol_support_mf_classic,
|
||||
[NfcProtocolMfPlus] = &nfc_protocol_support_mf_plus,
|
||||
[NfcProtocolMfDesfire] = &nfc_protocol_support_mf_desfire,
|
||||
[NfcProtocolSlix] = &nfc_protocol_support_slix,
|
||||
[NfcProtocolSt25tb] = &nfc_protocol_support_st25tb,
|
||||
|
||||
@@ -15,12 +15,10 @@ struct HidMouseJiggler {
|
||||
typedef struct {
|
||||
bool connected;
|
||||
bool running;
|
||||
int interval_idx;
|
||||
uint8_t counter;
|
||||
int min_interval; // Minimum interval for random range
|
||||
int max_interval; // Maximum interval for random range
|
||||
} HidMouseJigglerModel;
|
||||
|
||||
const int intervals[6] = {500, 2000, 5000, 10000, 30000, 60000};
|
||||
|
||||
static void hid_mouse_jiggler_draw_callback(Canvas* canvas, void* context) {
|
||||
furi_assert(context);
|
||||
HidMouseJigglerModel* model = context;
|
||||
@@ -34,22 +32,26 @@ static void hid_mouse_jiggler_draw_callback(Canvas* canvas, void* context) {
|
||||
}
|
||||
#endif
|
||||
|
||||
// Title "Mouse Jiggler"
|
||||
canvas_set_font(canvas, FontPrimary);
|
||||
elements_multiline_text_aligned(canvas, 17, 2, AlignLeft, AlignTop, "Mouse Jiggler");
|
||||
|
||||
// Timeout
|
||||
elements_multiline_text(canvas, AlignLeft, 26, "Interval (ms):");
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
if(model->interval_idx != 0) canvas_draw_icon(canvas, 74, 19, &I_ButtonLeft_4x7);
|
||||
if(model->interval_idx != (int)COUNT_OF(intervals) - 1)
|
||||
canvas_draw_icon(canvas, 80, 19, &I_ButtonRight_4x7);
|
||||
FuriString* interval_str = furi_string_alloc_printf("%d", intervals[model->interval_idx]);
|
||||
elements_multiline_text(canvas, 91, 26, furi_string_get_cstr(interval_str));
|
||||
furi_string_free(interval_str);
|
||||
// Display the current min interval in minutes
|
||||
canvas_set_font(canvas, FontSecondary); // Assuming there's a smaller font available
|
||||
FuriString* min_interval_str = furi_string_alloc_printf("Min: %d min", model->min_interval);
|
||||
elements_multiline_text_aligned(
|
||||
canvas, 0, 16, AlignLeft, AlignTop, furi_string_get_cstr(min_interval_str));
|
||||
furi_string_free(min_interval_str);
|
||||
|
||||
// Display the current max interval in minutes
|
||||
FuriString* max_interval_str = furi_string_alloc_printf("Max: %d min", model->max_interval);
|
||||
elements_multiline_text_aligned(
|
||||
canvas, 0, 28, AlignLeft, AlignTop, furi_string_get_cstr(max_interval_str));
|
||||
furi_string_free(max_interval_str);
|
||||
|
||||
// "Press Start to jiggle"
|
||||
canvas_set_font(canvas, FontPrimary);
|
||||
elements_multiline_text(canvas, AlignLeft, 40, "Press Start\nto jiggle");
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
elements_multiline_text(canvas, AlignLeft, 50, "Press Start\nto jiggle");
|
||||
|
||||
// Ok
|
||||
canvas_draw_icon(canvas, 63, 30, &I_Space_65x18);
|
||||
@@ -78,11 +80,20 @@ static void hid_mouse_jiggler_timer_callback(void* context) {
|
||||
HidMouseJigglerModel * model,
|
||||
{
|
||||
if(model->running) {
|
||||
model->counter++;
|
||||
hid_hal_mouse_move(
|
||||
hid_mouse_jiggler->hid,
|
||||
(model->counter % 2 == 0) ? MOUSE_MOVE_SHORT : -MOUSE_MOVE_SHORT,
|
||||
0);
|
||||
// Generate a random interval in minutes and convert to milliseconds
|
||||
int randomIntervalMinutes =
|
||||
model->min_interval + rand() % (model->max_interval - model->min_interval + 1);
|
||||
|
||||
// Randomize the mouse movement distance and direction
|
||||
int move_x = (rand() % 2001) - 1000; // Randomly between -1000 and 1000
|
||||
int move_y = (rand() % 2001) - 1000; // Randomly between -1000 and 1000
|
||||
|
||||
// Perform the mouse move with the randomized values
|
||||
hid_hal_mouse_move(hid_mouse_jiggler->hid, move_x, move_y);
|
||||
|
||||
// Restart timer with the new random interval
|
||||
furi_timer_stop(hid_mouse_jiggler->timer);
|
||||
furi_timer_start(hid_mouse_jiggler->timer, randomIntervalMinutes * 60000);
|
||||
}
|
||||
},
|
||||
false);
|
||||
@@ -104,23 +115,51 @@ static bool hid_mouse_jiggler_input_callback(InputEvent* event, void* context) {
|
||||
hid_mouse_jiggler->view,
|
||||
HidMouseJigglerModel * model,
|
||||
{
|
||||
if(event->type == InputTypePress && event->key == InputKeyOk) {
|
||||
model->running = !model->running;
|
||||
if(model->running) {
|
||||
furi_timer_stop(hid_mouse_jiggler->timer);
|
||||
furi_timer_start(hid_mouse_jiggler->timer, intervals[model->interval_idx]);
|
||||
};
|
||||
consumed = true;
|
||||
}
|
||||
if(event->type == InputTypePress && event->key == InputKeyRight && !model->running &&
|
||||
model->interval_idx < (int)COUNT_OF(intervals) - 1) {
|
||||
model->interval_idx++;
|
||||
consumed = true;
|
||||
}
|
||||
if(event->type == InputTypePress && event->key == InputKeyLeft && !model->running &&
|
||||
model->interval_idx > 0) {
|
||||
model->interval_idx--;
|
||||
consumed = true;
|
||||
if(event->type == InputTypePress) {
|
||||
switch(event->key) {
|
||||
case InputKeyOk:
|
||||
model->running = !model->running;
|
||||
if(model->running) {
|
||||
furi_timer_stop(hid_mouse_jiggler->timer);
|
||||
int randomIntervalMinutes =
|
||||
model->min_interval +
|
||||
rand() % (model->max_interval - model->min_interval + 1);
|
||||
furi_timer_start(hid_mouse_jiggler->timer, randomIntervalMinutes * 60000);
|
||||
}
|
||||
consumed = true;
|
||||
break;
|
||||
|
||||
case InputKeyUp:
|
||||
if(!model->running && model->min_interval < model->max_interval) {
|
||||
model->min_interval++; // Increment min interval by 1 minute
|
||||
}
|
||||
consumed = true;
|
||||
break;
|
||||
|
||||
case InputKeyDown:
|
||||
if(!model->running && model->min_interval > 1) { // Minimum 1 minute
|
||||
model->min_interval--; // Decrement min interval by 1 minute
|
||||
}
|
||||
consumed = true;
|
||||
break;
|
||||
|
||||
case InputKeyRight:
|
||||
if(!model->running && model->max_interval < 30) { // Maximum 30 minutes
|
||||
model->max_interval++; // Increment max interval by 1 minute
|
||||
}
|
||||
consumed = true;
|
||||
break;
|
||||
|
||||
case InputKeyLeft:
|
||||
if(!model->running && model->max_interval > model->min_interval + 1) {
|
||||
model->max_interval--; // Decrement max interval by 1 minute
|
||||
}
|
||||
consumed = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
true);
|
||||
@@ -145,7 +184,14 @@ HidMouseJiggler* hid_mouse_jiggler_alloc(Hid* hid) {
|
||||
hid_mouse_jiggler_timer_callback, FuriTimerTypePeriodic, hid_mouse_jiggler);
|
||||
|
||||
with_view_model(
|
||||
hid_mouse_jiggler->view, HidMouseJigglerModel * model, { model->interval_idx = 2; }, true);
|
||||
hid_mouse_jiggler->view,
|
||||
HidMouseJigglerModel * model,
|
||||
{
|
||||
// Initialize the min and max interval values
|
||||
model->min_interval = 2; // 2 minutes
|
||||
model->max_interval = 15; // 15 minutes
|
||||
},
|
||||
true);
|
||||
|
||||
return hid_mouse_jiggler;
|
||||
}
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
|
||||
#include <gui/view.h>
|
||||
|
||||
#define MOUSE_MOVE_SHORT 5
|
||||
#define MOUSE_MOVE_LONG 20
|
||||
|
||||
typedef struct Hid Hid;
|
||||
typedef struct HidMouseJiggler HidMouseJiggler;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user