mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
replay buffer: start without "Save" hotkey set
This commit is contained in:
31
Utils.cpp
31
Utils.cpp
@ -459,7 +459,36 @@ bool Utils::ReplayBufferEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Utils::RPHotkeySet() {
|
||||
void Utils::StartReplayBuffer() {
|
||||
if (obs_frontend_replay_buffer_active())
|
||||
return;
|
||||
|
||||
if (!IsRPHotkeySet()) {
|
||||
obs_output_t* rpOutput = obs_frontend_get_replay_buffer_output();
|
||||
OBSData outputHotkeys = obs_hotkeys_save_output(rpOutput);
|
||||
|
||||
OBSData dummyBinding = obs_data_create();
|
||||
obs_data_set_bool(dummyBinding, "control", true);
|
||||
obs_data_set_bool(dummyBinding, "alt", true);
|
||||
obs_data_set_bool(dummyBinding, "shift", true);
|
||||
obs_data_set_bool(dummyBinding, "command", true);
|
||||
obs_data_set_string(dummyBinding, "key", "OBS_KEY_0");
|
||||
|
||||
OBSDataArray rpSaveHotkey = obs_data_get_array(
|
||||
outputHotkeys, "ReplayBuffer.Save");
|
||||
obs_data_array_push_back(rpSaveHotkey, dummyBinding);
|
||||
|
||||
obs_hotkeys_load_output(rpOutput, outputHotkeys);
|
||||
obs_frontend_replay_buffer_start();
|
||||
|
||||
obs_output_release(rpOutput);
|
||||
}
|
||||
else {
|
||||
obs_frontend_replay_buffer_start();
|
||||
}
|
||||
}
|
||||
|
||||
bool Utils::IsRPHotkeySet() {
|
||||
obs_output_t* rp_output = obs_frontend_get_replay_buffer_output();
|
||||
|
||||
obs_data_t *hotkeys = obs_hotkeys_save_output(rp_output);
|
||||
|
3
Utils.h
3
Utils.h
@ -73,7 +73,8 @@ class Utils {
|
||||
static QString* ParseDataToQueryString(obs_data_t * data);
|
||||
static obs_hotkey_t* FindHotkeyByName(const char* name);
|
||||
static bool ReplayBufferEnabled();
|
||||
static bool RPHotkeySet();
|
||||
static void StartReplayBuffer();
|
||||
static bool IsRPHotkeySet();
|
||||
};
|
||||
|
||||
#endif // UTILS_H
|
||||
|
@ -705,11 +705,7 @@ void WSRequestHandler::HandleStartStopReplayBuffer(WSRequestHandler* req) {
|
||||
if (obs_frontend_replay_buffer_active()) {
|
||||
obs_frontend_replay_buffer_stop();
|
||||
} else {
|
||||
if (!Utils::RPHotkeySet()) {
|
||||
req->SendErrorResponse("replay buffer hotkey not set");
|
||||
return;
|
||||
}
|
||||
obs_frontend_replay_buffer_start();
|
||||
Utils::StartReplayBuffer();
|
||||
}
|
||||
req->SendOKResponse();
|
||||
}
|
||||
@ -737,12 +733,7 @@ void WSRequestHandler::HandleStartReplayBuffer(WSRequestHandler* req) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Utils::RPHotkeySet()) {
|
||||
req->SendErrorResponse("replay buffer hotkey not set");
|
||||
return;
|
||||
}
|
||||
|
||||
obs_frontend_replay_buffer_start();
|
||||
Utils::StartReplayBuffer();
|
||||
req->SendOKResponse();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user