mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
Cleanup input helper function --nobuild
This commit is contained in:
@@ -54,23 +54,6 @@ const char* input_get_type_name(InputType type) {
|
||||
}
|
||||
}
|
||||
|
||||
void input_fake_event(Input* input, InputKey key, InputType type) {
|
||||
bool wrap = type == InputTypeShort || type == InputTypeLong;
|
||||
InputEvent event;
|
||||
event.key = key;
|
||||
|
||||
if(wrap) {
|
||||
event.type = InputTypePress;
|
||||
furi_pubsub_publish(input->event_pubsub, &event);
|
||||
}
|
||||
event.type = type;
|
||||
furi_pubsub_publish(input->event_pubsub, &event);
|
||||
if(wrap) {
|
||||
event.type = InputTypeRelease;
|
||||
furi_pubsub_publish(input->event_pubsub, &event);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t input_srv(void* p) {
|
||||
UNUSED(p);
|
||||
input = malloc(sizeof(Input));
|
||||
|
||||
@@ -41,6 +41,23 @@ static void input_cli_dump(Cli* cli, FuriString* args, Input* input) {
|
||||
furi_message_queue_free(input_queue);
|
||||
}
|
||||
|
||||
static void fake_input(Input* input, InputKey key, InputType type) {
|
||||
bool wrap = type == InputTypeShort || type == InputTypeLong;
|
||||
InputEvent event;
|
||||
event.key = key;
|
||||
|
||||
if(wrap) {
|
||||
event.type = InputTypePress;
|
||||
furi_pubsub_publish(input->event_pubsub, &event);
|
||||
}
|
||||
event.type = type;
|
||||
furi_pubsub_publish(input->event_pubsub, &event);
|
||||
if(wrap) {
|
||||
event.type = InputTypeRelease;
|
||||
furi_pubsub_publish(input->event_pubsub, &event);
|
||||
}
|
||||
}
|
||||
|
||||
static void input_cli_keyboard(Cli* cli, FuriString* args, Input* input) {
|
||||
UNUSED(args);
|
||||
FuriPubSub* ascii_events = furi_record_open(RECORD_ASCII_EVENTS);
|
||||
@@ -108,7 +125,7 @@ static void input_cli_keyboard(Cli* cli, FuriString* args, Input* input) {
|
||||
}
|
||||
|
||||
if(send_key != InputKeyMAX) {
|
||||
input_fake_event(input, send_key, hold ? InputTypeLong : InputTypeShort);
|
||||
fake_input(input, send_key, hold ? InputTypeLong : InputTypeShort);
|
||||
hold = false;
|
||||
}
|
||||
if(send_ascii != AsciiValueNUL) {
|
||||
@@ -172,7 +189,7 @@ static void input_cli_send(Cli* cli, FuriString* args, Input* input) {
|
||||
} while(false);
|
||||
|
||||
if(parsed) { //-V547
|
||||
input_fake_event(input, key, type);
|
||||
fake_input(input, key, type);
|
||||
} else {
|
||||
input_cli_send_print_usage();
|
||||
}
|
||||
|
||||
@@ -48,5 +48,3 @@ void input_isr(void* _ctx);
|
||||
|
||||
/** Input CLI command handler */
|
||||
void input_cli(Cli* cli, FuriString* args, void* context);
|
||||
|
||||
void input_fake_event(Input* input, InputKey key, InputType type);
|
||||
|
||||
Reference in New Issue
Block a user