Cleanup input helper function --nobuild

This commit is contained in:
Willy-JL
2024-01-17 22:49:50 +00:00
parent 7845cc0eeb
commit 40ab1ead72
3 changed files with 19 additions and 21 deletions

View File

@@ -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));

View File

@@ -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();
}

View File

@@ -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);