diff --git a/client/README.md b/client/README.md index dd6fd4ec..64e0e0ac 100644 --- a/client/README.md +++ b/client/README.md @@ -44,6 +44,7 @@ Below are a list of current key bindings: |-|-| | ScrLk | Toggle cursor screen capture | | ScrLk+F | Full Screen toggle | +| ScrLk+V | Video stream toggle | | ScrLk+I | Spice keyboard & mouse enable toggle | | ScrLk+N | Toggle night vision mode (EGL renderer only!) | | ScrLk+Q | Quit | diff --git a/client/src/main.c b/client/src/main.c index 6c71a1f5..ddc94462 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -413,7 +413,7 @@ static int frameThread(void * unused) break; } - while(state.state == APP_STATE_RUNNING) + while(state.state == APP_STATE_RUNNING && !state.stopVideo) { LGMPMessage msg; if ((status = lgmpClientProcess(queue, &msg)) != LGMP_OK) @@ -1147,6 +1147,29 @@ static void toggle_fullscreen(SDL_Scancode key, void * opaque) params.fullscreen = !params.fullscreen; } +static void toggle_video(SDL_Scancode key, void * opaque) +{ + state.stopVideo = !state.stopVideo; + app_alert( + LG_ALERT_INFO, + state.stopVideo ? "Video Stream Disabled" : "Video Stream Enabled" + ); + + if (state.stopVideo) + state.lgr->on_restart(state.lgrData); + else + { + if (t_frame) + { + lgJoinThread(t_frame, NULL); + t_frame = NULL; + } + + if (!lgCreateThread("frameThread", frameThread, NULL, &t_frame)) + DEBUG_ERROR("frame create thread failed"); + } +} + static void toggle_input(SDL_Scancode key, void * opaque) { state.ignoreInput = !state.ignoreInput; @@ -1208,6 +1231,7 @@ static void ctrl_alt_fn(SDL_Scancode key, void * opaque) static void register_key_binds() { state.kbFS = app_register_keybind(SDL_SCANCODE_F , toggle_fullscreen, NULL); + state.kbVideo = app_register_keybind(SDL_SCANCODE_V , toggle_video , NULL); state.kbInput = app_register_keybind(SDL_SCANCODE_I , toggle_input , NULL); state.kbQuit = app_register_keybind(SDL_SCANCODE_Q , quit , NULL); state.kbMouseSensInc = app_register_keybind(SDL_SCANCODE_INSERT, mouse_sens_inc , NULL); @@ -1229,9 +1253,10 @@ static void register_key_binds() static void release_key_binds() { - app_release_keybind(&state.kbFS); + app_release_keybind(&state.kbFS ); + app_release_keybind(&state.kbVideo); app_release_keybind(&state.kbInput); - app_release_keybind(&state.kbQuit); + app_release_keybind(&state.kbQuit ); app_release_keybind(&state.kbMouseSensInc); app_release_keybind(&state.kbMouseSensDec); for(int i = 0; i < 12; ++i) diff --git a/client/src/main.h b/client/src/main.h index b5669518..851e49e2 100644 --- a/client/src/main.h +++ b/client/src/main.h @@ -53,6 +53,7 @@ enum WarpState struct AppState { enum RunState state; + bool stopVideo; bool ignoreInput; bool escapeActive; SDL_Scancode escapeAction; @@ -112,6 +113,7 @@ struct AppState bool resizeDone; KeybindHandle kbFS; + KeybindHandle kbVideo; KeybindHandle kbInput; KeybindHandle kbQuit; KeybindHandle kbMouseSensInc;