aboutsummaryrefslogtreecommitdiffstats
path: root/desktop
diff options
context:
space:
mode:
Diffstat (limited to 'desktop')
-rw-r--r--desktop/island/Obs.qml42
1 files changed, 41 insertions, 1 deletions
diff --git a/desktop/island/Obs.qml b/desktop/island/Obs.qml
index 5addca4..7a1900c 100644
--- a/desktop/island/Obs.qml
+++ b/desktop/island/Obs.qml
@@ -15,6 +15,7 @@ import Quickshell
import Quickshell.Io
import QtQuick
import QtWebSockets
+import "Logic.js" as Logic
// OBS Studio over obs-websocket v5. Connected means OBS is running with
// its server enabled, so nothing checks for the process. State follows
@@ -34,6 +35,13 @@ Singleton {
// GetGroupSceneItemList if one ever is.
property int camId: -1
property bool camOn: false
+ property real camW: 0
+ property real camH: 0
+ // The global "Desktop Audio" input's name, "" when none is configured.
+ property string desktopAudio: ""
+ property bool desktopMuted: false
+ property real baseWidth: 0
+ property real baseHeight: 0
function toggleRecord() { request("ToggleRecord"); }
function togglePause() { request("ToggleRecordPause"); }
@@ -42,6 +50,17 @@ Singleton {
if (camId >= 0)
request("SetSceneItemEnabled", { sceneName: scene, sceneItemId: camId, sceneItemEnabled: !camOn });
}
+ function toggleAudio() {
+ if (desktopAudio)
+ request("SetInputMute", { inputName: desktopAudio, inputMuted: !desktopMuted });
+ }
+ // The corner math assumes the webcam item is top-left aligned (alignment 5).
+ function moveCam(corner) {
+ if (camId < 0 || baseWidth <= 0 || camW <= 0 || camH <= 0) return;
+ const p = Logic.cornerPos(corner, baseWidth, baseHeight, camW, camH, 16);
+ request("SetSceneItemTransform", { sceneName: scene, sceneItemId: camId,
+ sceneItemTransform: { positionX: p.x, positionY: p.y } });
+ }
// --- config -----------------------------------------------------------
@@ -85,6 +104,9 @@ Singleton {
connected = false; wasOpen = false;
recording = false; paused = false; duration = 0;
scenes = []; scene = ""; camId = -1; camOn = false;
+ camW = 0; camH = 0;
+ desktopAudio = ""; desktopMuted = false;
+ baseWidth = 0; baseHeight = 0;
}
// Retry while not connected; a closed or failed socket is reopened by
@@ -116,7 +138,7 @@ Singleton {
}
function identify(token) {
- const d = { rpcVersion: 1, eventSubscriptions: 4 | 64 | 128 }; // Scenes | Outputs | SceneItems
+ const d = { rpcVersion: 1, eventSubscriptions: 4 | 8 | 64 | 128 }; // Scenes | Inputs | Outputs | SceneItems
if (token) d.authentication = token;
send(1, d);
}
@@ -147,6 +169,8 @@ Singleton {
warned = false;
request("GetRecordStatus");
request("GetSceneList");
+ request("GetSpecialInputs");
+ request("GetVideoSettings");
break;
case 5:
event(m.d.eventType, m.d.eventData || {});
@@ -176,6 +200,9 @@ Singleton {
case "SceneItemEnableStateChanged":
if (d.sceneName === scene && d.sceneItemId === camId) camOn = d.sceneItemEnabled;
break;
+ case "InputMuteStateChanged":
+ if (d.inputName === desktopAudio) desktopMuted = d.inputMuted;
+ break;
}
}
@@ -201,8 +228,21 @@ Singleton {
const it = r.sceneItems.find(i => i.inputKind === "v4l2_input");
camId = it ? it.sceneItemId : -1;
camOn = !!it && it.sceneItemEnabled;
+ camW = it ? it.sceneItemTransform.width : 0;
+ camH = it ? it.sceneItemTransform.height : 0;
break;
}
+ case "GetSpecialInputs":
+ desktopAudio = r.desktop1 || "";
+ if (desktopAudio) request("GetInputMute", { inputName: desktopAudio });
+ break;
+ case "GetVideoSettings":
+ baseWidth = r.baseWidth;
+ baseHeight = r.baseHeight;
+ break;
+ case "GetInputMute":
+ desktopMuted = r.inputMuted;
+ break;
}
}