mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
Requests: Add ProcessHotkeyByName
Adds a new request called `ProcessHotkeyByName` which calls the routine associated with a given hotkey. The hotkey is identified by the unique name set while registering it. Works with both OBS default hotkeys and hotkeys added by plugins/scripts.
This commit is contained in:
parent
f61f45fa23
commit
bac5b1551b
@ -43,6 +43,8 @@ const QHash<QString, RpcMethodHandler> WSRequestHandler::messageMap {
|
|||||||
|
|
||||||
{ "BroadcastCustomMessage", &WSRequestHandler::BroadcastCustomMessage },
|
{ "BroadcastCustomMessage", &WSRequestHandler::BroadcastCustomMessage },
|
||||||
|
|
||||||
|
{ "ProcessHotkeyByName", &WSRequestHandler::ProcessHotkeyByName },
|
||||||
|
|
||||||
{ "SetCurrentScene", &WSRequestHandler::SetCurrentScene },
|
{ "SetCurrentScene", &WSRequestHandler::SetCurrentScene },
|
||||||
{ "GetCurrentScene", &WSRequestHandler::GetCurrentScene },
|
{ "GetCurrentScene", &WSRequestHandler::GetCurrentScene },
|
||||||
{ "GetSceneList", &WSRequestHandler::GetSceneList },
|
{ "GetSceneList", &WSRequestHandler::GetSceneList },
|
||||||
|
@ -61,6 +61,8 @@ class WSRequestHandler {
|
|||||||
|
|
||||||
RpcResponse BroadcastCustomMessage(const RpcRequest&);
|
RpcResponse BroadcastCustomMessage(const RpcRequest&);
|
||||||
|
|
||||||
|
RpcResponse ProcessHotkeyByName(const RpcRequest&);
|
||||||
|
|
||||||
RpcResponse SetCurrentScene(const RpcRequest&);
|
RpcResponse SetCurrentScene(const RpcRequest&);
|
||||||
RpcResponse GetCurrentScene(const RpcRequest&);
|
RpcResponse GetCurrentScene(const RpcRequest&);
|
||||||
RpcResponse GetSceneList(const RpcRequest&);
|
RpcResponse GetSceneList(const RpcRequest&);
|
||||||
|
@ -345,3 +345,24 @@ RpcResponse WSRequestHandler::OpenProjector(const RpcRequest& request) {
|
|||||||
obs_frontend_open_projector(type, monitor, geometry, name);
|
obs_frontend_open_projector(type, monitor, geometry, name);
|
||||||
return request.success();
|
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();
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user