[FL-1491] Gui: input injection in screen stream (#573)

* Gui: input injection in screen stream
* Cli: expose ASCII table in public header
This commit is contained in:
あく 2021-07-09 05:16:54 +03:00 committed by GitHub
parent fe3bedbd3c
commit c3fda0c8c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 15 deletions

View File

@ -6,6 +6,20 @@ extern "C" {
#include <m-string.h> #include <m-string.h>
typedef enum {
CliSymbolAsciiSOH = 0x01,
CliSymbolAsciiETX = 0x03,
CliSymbolAsciiEOT = 0x04,
CliSymbolAsciiBell = 0x07,
CliSymbolAsciiBackspace = 0x08,
CliSymbolAsciiTab = 0x09,
CliSymbolAsciiCR = 0x0D,
CliSymbolAsciiEsc = 0x1B,
CliSymbolAsciiUS = 0x1F,
CliSymbolAsciiSpace = 0x20,
CliSymbolAsciiDel = 0x7F,
} CliSymbols;
/* Cli type /* Cli type
* Anonymous structure. Use cli_i.h if you need to go deeper. * Anonymous structure. Use cli_i.h if you need to go deeper.
*/ */

View File

@ -24,20 +24,6 @@ BPTREE_DEF2(
CliCommand, CliCommand,
M_POD_OPLIST) M_POD_OPLIST)
typedef enum {
CliSymbolAsciiSOH = 0x01,
CliSymbolAsciiETX = 0x03,
CliSymbolAsciiEOT = 0x04,
CliSymbolAsciiBell = 0x07,
CliSymbolAsciiBackspace = 0x08,
CliSymbolAsciiTab = 0x09,
CliSymbolAsciiCR = 0x0D,
CliSymbolAsciiEsc = 0x1B,
CliSymbolAsciiUS = 0x1F,
CliSymbolAsciiSpace = 0x20,
CliSymbolAsciiDel = 0x7F,
} CliSymbols;
struct Cli { struct Cli {
CliCommandTree_t commands; CliCommandTree_t commands;
osMutexId_t mutex; osMutexId_t mutex;

View File

@ -262,7 +262,24 @@ void gui_cli_screen_stream(Cli* cli, string_t args, void* context) {
gui_set_framebuffer_callback_context(gui, gui); gui_set_framebuffer_callback_context(gui, gui);
gui_set_framebuffer_callback(gui, gui_cli_screen_stream_callback); gui_set_framebuffer_callback(gui, gui_cli_screen_stream_callback);
gui_redraw(gui); gui_redraw(gui);
cli_getc(gui->cli);
// Wait for control events
while(true) {
char c = cli_getc(gui->cli);
if(c == CliSymbolAsciiEsc) {
c = cli_getc(gui->cli);
if(c == 'i') {
InputEvent input_event;
input_event.key = cli_getc(gui->cli);
input_event.type = cli_getc(gui->cli);
osMessageQueuePut(gui->input_queue, &input_event, 0, osWaitForever);
osThreadFlagsSet(gui->thread, GUI_THREAD_FLAG_INPUT);
}
} else {
break;
}
}
gui_set_framebuffer_callback(gui, NULL); gui_set_framebuffer_callback(gui, NULL);
gui_set_framebuffer_callback_context(gui, NULL); gui_set_framebuffer_callback_context(gui, NULL);
} }