diff --git a/src/WSRequestHandler.cpp b/src/WSRequestHandler.cpp index 56c4cdaa..2c92305a 100644 --- a/src/WSRequestHandler.cpp +++ b/src/WSRequestHandler.cpp @@ -43,6 +43,8 @@ const QHash WSRequestHandler::messageMap { { "BroadcastCustomMessage", &WSRequestHandler::BroadcastCustomMessage }, + { "ProcessHotkeyByName", &WSRequestHandler::ProcessHotkeyByName }, + { "SetCurrentScene", &WSRequestHandler::SetCurrentScene }, { "GetCurrentScene", &WSRequestHandler::GetCurrentScene }, { "GetSceneList", &WSRequestHandler::GetSceneList }, diff --git a/src/WSRequestHandler.h b/src/WSRequestHandler.h index e409db50..7a4e64ff 100644 --- a/src/WSRequestHandler.h +++ b/src/WSRequestHandler.h @@ -61,6 +61,8 @@ class WSRequestHandler { RpcResponse BroadcastCustomMessage(const RpcRequest&); + RpcResponse ProcessHotkeyByName(const RpcRequest&); + RpcResponse SetCurrentScene(const RpcRequest&); RpcResponse GetCurrentScene(const RpcRequest&); RpcResponse GetSceneList(const RpcRequest&); diff --git a/src/WSRequestHandler_General.cpp b/src/WSRequestHandler_General.cpp index ea1c6a63..54675a84 100644 --- a/src/WSRequestHandler_General.cpp +++ b/src/WSRequestHandler_General.cpp @@ -345,3 +345,24 @@ RpcResponse WSRequestHandler::OpenProjector(const RpcRequest& request) { obs_frontend_open_projector(type, monitor, geometry, name); return request.success(); } + +/** +* Executes hotkey routine, identified by hotkey unique name +* +* @param {String} `name` Unique name of the hotkey, as defined when registering the hotkey (e.g. "ReplayBuffer.Save") +* +* @api requests +* @name ProcessHotkeyByName +* @category general +* @since unreleased +*/ +RpcResponse WSRequestHandler::ProcessHotkeyByName(const RpcRequest& request) { + const char* name = obs_data_get_string(request.parameters(), "name"); + + obs_hotkey_t* hk = Utils::FindHotkeyByName(name); + if (!hk) { + return request.failed("Hotkey not found"); + } + obs_hotkey_trigger_routed_callback(obs_hotkey_get_id(hk), true); + return request.success(); +}