mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-26 03:39:58 -07:00
Merge branch 'dev' of https://github.com/flipperdevices/flipperzero-firmware into mntm-dev
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#include "input_i.h"
|
||||
#include "input.h"
|
||||
|
||||
#include <furi.h>
|
||||
#include <cli/cli.h>
|
||||
@@ -20,11 +20,11 @@ static void input_cli_dump_events_callback(const void* value, void* ctx) {
|
||||
furi_message_queue_put(input_queue, value, FuriWaitForever);
|
||||
}
|
||||
|
||||
static void input_cli_dump(Cli* cli, FuriString* args, Input* input) {
|
||||
static void input_cli_dump(Cli* cli, FuriString* args, FuriPubSub* event_pubsub) {
|
||||
UNUSED(args);
|
||||
FuriMessageQueue* input_queue = furi_message_queue_alloc(8, sizeof(InputEvent));
|
||||
FuriPubSubSubscription* input_subscription =
|
||||
furi_pubsub_subscribe(input->event_pubsub, input_cli_dump_events_callback, input_queue);
|
||||
furi_pubsub_subscribe(event_pubsub, input_cli_dump_events_callback, input_queue);
|
||||
|
||||
InputEvent input_event;
|
||||
printf("Press CTRL+C to stop\r\n");
|
||||
@@ -37,28 +37,28 @@ static void input_cli_dump(Cli* cli, FuriString* args, Input* input) {
|
||||
}
|
||||
}
|
||||
|
||||
furi_pubsub_unsubscribe(input->event_pubsub, input_subscription);
|
||||
furi_pubsub_unsubscribe(event_pubsub, input_subscription);
|
||||
furi_message_queue_free(input_queue);
|
||||
}
|
||||
|
||||
static void fake_input(Input* input, InputKey key, InputType type) {
|
||||
static void fake_input(FuriPubSub* event_pubsub, 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);
|
||||
furi_pubsub_publish(event_pubsub, &event);
|
||||
}
|
||||
event.type = type;
|
||||
furi_pubsub_publish(input->event_pubsub, &event);
|
||||
furi_pubsub_publish(event_pubsub, &event);
|
||||
if(wrap) {
|
||||
event.type = InputTypeRelease;
|
||||
furi_pubsub_publish(input->event_pubsub, &event);
|
||||
furi_pubsub_publish(event_pubsub, &event);
|
||||
}
|
||||
}
|
||||
|
||||
static void input_cli_keyboard(Cli* cli, FuriString* args, Input* input) {
|
||||
static void input_cli_keyboard(Cli* cli, FuriString* args, FuriPubSub* event_pubsub) {
|
||||
UNUSED(args);
|
||||
printf("Using console keyboard feedback for flipper input\r\n");
|
||||
|
||||
@@ -70,6 +70,7 @@ static void input_cli_keyboard(Cli* cli, FuriString* args, Input* input) {
|
||||
|
||||
printf("\r\nPress CTRL+C to stop\r\n");
|
||||
bool hold = false;
|
||||
FuriPubSub* ascii_pubsub = furi_record_open(RECORD_ASCII_EVENTS);
|
||||
while(cli_is_connected(cli)) {
|
||||
char in_chr = cli_getc(cli);
|
||||
if(in_chr == CliSymbolAsciiETX) break;
|
||||
@@ -123,15 +124,16 @@ static void input_cli_keyboard(Cli* cli, FuriString* args, Input* input) {
|
||||
}
|
||||
|
||||
if(send_key != InputKeyMAX) {
|
||||
fake_input(input, send_key, hold ? InputTypeLong : InputTypeShort);
|
||||
fake_input(event_pubsub, send_key, hold ? InputTypeLong : InputTypeShort);
|
||||
hold = false;
|
||||
}
|
||||
if(send_ascii != AsciiValueNUL) {
|
||||
AsciiEvent event = {.value = send_ascii};
|
||||
furi_pubsub_publish(input->ascii_pubsub, &event);
|
||||
furi_pubsub_publish(ascii_pubsub, &event);
|
||||
hold = false;
|
||||
}
|
||||
}
|
||||
furi_record_close(RECORD_ASCII_EVENTS);
|
||||
}
|
||||
|
||||
static void input_cli_send_print_usage(void) {
|
||||
@@ -141,7 +143,7 @@ static void input_cli_send_print_usage(void) {
|
||||
printf("\t\t <type>\t - one of 'press', 'release', 'short', 'long'\r\n");
|
||||
}
|
||||
|
||||
static void input_cli_send(Cli* cli, FuriString* args, Input* input) {
|
||||
static void input_cli_send(Cli* cli, FuriString* args, FuriPubSub* event_pubsub) {
|
||||
UNUSED(cli);
|
||||
InputKey key;
|
||||
InputType type;
|
||||
@@ -185,7 +187,7 @@ static void input_cli_send(Cli* cli, FuriString* args, Input* input) {
|
||||
} while(false);
|
||||
|
||||
if(parsed) { //-V547
|
||||
fake_input(input, key, type);
|
||||
fake_input(event_pubsub, key, type);
|
||||
} else {
|
||||
input_cli_send_print_usage();
|
||||
}
|
||||
@@ -195,7 +197,7 @@ static void input_cli_send(Cli* cli, FuriString* args, Input* input) {
|
||||
void input_cli(Cli* cli, FuriString* args, void* context) {
|
||||
furi_assert(cli);
|
||||
furi_assert(context);
|
||||
Input* input = context;
|
||||
FuriPubSub* event_pubsub = context;
|
||||
FuriString* cmd;
|
||||
cmd = furi_string_alloc();
|
||||
|
||||
@@ -205,15 +207,15 @@ void input_cli(Cli* cli, FuriString* args, void* context) {
|
||||
break;
|
||||
}
|
||||
if(furi_string_cmp_str(cmd, "dump") == 0) {
|
||||
input_cli_dump(cli, args, input);
|
||||
input_cli_dump(cli, args, event_pubsub);
|
||||
break;
|
||||
}
|
||||
if(furi_string_cmp_str(cmd, "keyboard") == 0) {
|
||||
input_cli_keyboard(cli, args, input);
|
||||
input_cli_keyboard(cli, args, event_pubsub);
|
||||
break;
|
||||
}
|
||||
if(furi_string_cmp_str(cmd, "send") == 0) {
|
||||
input_cli_send(cli, args, input);
|
||||
input_cli_send(cli, args, event_pubsub);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user