mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-22 12:33:11 +00:00
RPC: Fix input lockup on disconnect (#3732)
* RPC: Fix input lockup on disconnect * Rpc: minor GUI module cleanup Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
parent
653423145b
commit
ecf38cd30a
1 changed files with 17 additions and 4 deletions
|
@ -55,6 +55,7 @@ typedef struct {
|
|||
RpcSession* session;
|
||||
Gui* gui;
|
||||
const Icon* icon;
|
||||
FuriPubSub* input_events;
|
||||
|
||||
// Receive part
|
||||
ViewPort* virtual_display_view_port;
|
||||
|
@ -234,10 +235,7 @@ static void
|
|||
}
|
||||
|
||||
// Submit event
|
||||
FuriPubSub* input_events = furi_record_open(RECORD_INPUT_EVENTS);
|
||||
furi_check(input_events);
|
||||
furi_pubsub_publish(input_events, &event);
|
||||
furi_record_close(RECORD_INPUT_EVENTS);
|
||||
furi_pubsub_publish(rpc_gui->input_events, &event);
|
||||
rpc_send_and_release_empty(session, request->command_id, PB_CommandStatus_OK);
|
||||
}
|
||||
|
||||
|
@ -401,6 +399,7 @@ void* rpc_system_gui_alloc(RpcSession* session) {
|
|||
|
||||
RpcGuiSystem* rpc_gui = malloc(sizeof(RpcGuiSystem));
|
||||
rpc_gui->gui = furi_record_open(RECORD_GUI);
|
||||
rpc_gui->input_events = furi_record_open(RECORD_INPUT_EVENTS);
|
||||
rpc_gui->session = session;
|
||||
|
||||
// Active session icon
|
||||
|
@ -447,6 +446,19 @@ void rpc_system_gui_free(void* context) {
|
|||
RpcGuiSystem* rpc_gui = context;
|
||||
furi_assert(rpc_gui->gui);
|
||||
|
||||
// Release ongoing inputs to avoid lockup
|
||||
for(InputKey key = 0; key < InputKeyMAX; key++) {
|
||||
if(rpc_gui->input_key_counter[key] != RPC_GUI_INPUT_RESET) {
|
||||
InputEvent event = {
|
||||
.key = key,
|
||||
.type = InputTypeRelease,
|
||||
.sequence_source = INPUT_SEQUENCE_SOURCE_SOFTWARE,
|
||||
.sequence_counter = rpc_gui->input_key_counter[key],
|
||||
};
|
||||
furi_pubsub_publish(rpc_gui->input_events, &event);
|
||||
}
|
||||
}
|
||||
|
||||
if(rpc_gui->virtual_display_view_port) {
|
||||
gui_remove_view_port(rpc_gui->gui, rpc_gui->virtual_display_view_port);
|
||||
view_port_free(rpc_gui->virtual_display_view_port);
|
||||
|
@ -474,6 +486,7 @@ void rpc_system_gui_free(void* context) {
|
|||
free(rpc_gui->transmit_frame);
|
||||
rpc_gui->transmit_frame = NULL;
|
||||
}
|
||||
furi_record_close(RECORD_INPUT_EVENTS);
|
||||
furi_record_close(RECORD_GUI);
|
||||
free(rpc_gui);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue