Add opt-in automatic recording
This commit is contained in:
1 parent
14bb5009c6
commit
9ac5a30a17
2 files changed
+65
-10
No files matched your search
+40
-10
@@ -57,6 +57,7 @@ struct DesktopStatus {
|
|||||||
detected_game: Option<String>,
|
detected_game: Option<String>,
|
||||||
replay_buffer_seconds: u64,
|
replay_buffer_seconds: u64,
|
||||||
mic_enabled: bool,
|
mic_enabled: bool,
|
||||||
|
auto_record_enabled: bool,
|
||||||
upload_enabled: bool,
|
upload_enabled: bool,
|
||||||
session_recording: bool,
|
session_recording: bool,
|
||||||
capture_active: bool,
|
capture_active: bool,
|
||||||
@@ -99,23 +100,37 @@ fn get_status(runtime: State<'_, AppRuntime>) -> Result<DesktopStatus, String> {
|
|||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
fn refresh_detected_game(runtime: State<'_, AppRuntime>) -> Result<DesktopStatus, String> {
|
fn refresh_detected_game(runtime: State<'_, AppRuntime>) -> Result<DesktopStatus, String> {
|
||||||
let mut recorder = runtime.recorder.lock().map_err(|error| error.to_string())?;
|
|
||||||
let capture = runtime.capture.lock().map_err(|error| error.to_string())?;
|
|
||||||
let detected = detect_game(&running_processes(), &default_profiles());
|
let detected = detect_game(&running_processes(), &default_profiles());
|
||||||
|
let mut should_auto_start = false;
|
||||||
|
|
||||||
match detected {
|
{
|
||||||
Some(game) => {
|
let mut recorder = runtime.recorder.lock().map_err(|error| error.to_string())?;
|
||||||
if recorder.state.detected_game_id.as_deref() != Some(&game.game_id) {
|
let capture = runtime.capture.lock().map_err(|error| error.to_string())?;
|
||||||
recorder.start_for_game(game.game_id, SystemTime::now());
|
|
||||||
|
match detected {
|
||||||
|
Some(game) => {
|
||||||
|
should_auto_start = game.process.process_name.len() > 0
|
||||||
|
&& default_profiles()
|
||||||
|
.iter()
|
||||||
|
.any(|profile| profile.game_id == game.game_id && profile.auto_record)
|
||||||
|
&& capture.is_none()
|
||||||
|
&& !recorder.settings.privacy.desktop_capture_requires_confirmation;
|
||||||
|
if recorder.state.detected_game_id.as_deref() != Some(&game.game_id) {
|
||||||
|
recorder.start_for_game(game.game_id, SystemTime::now());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
None if capture.is_none() => {
|
||||||
|
let _ = recorder.stop();
|
||||||
|
}
|
||||||
|
None => {}
|
||||||
}
|
}
|
||||||
None if capture.is_none() => {
|
|
||||||
let _ = recorder.stop();
|
if !should_auto_start {
|
||||||
|
return Ok(status_from_recorder(&recorder, capture.as_ref()));
|
||||||
}
|
}
|
||||||
None => {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(status_from_recorder(&recorder, capture.as_ref()))
|
start_capture_inner(runtime.inner())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
@@ -145,6 +160,19 @@ fn set_mic_enabled(enabled: bool, runtime: State<'_, AppRuntime>) -> Result<Desk
|
|||||||
Ok(status_from_recorder(&recorder, capture.as_ref()))
|
Ok(status_from_recorder(&recorder, capture.as_ref()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
fn set_auto_record_enabled(
|
||||||
|
enabled: bool,
|
||||||
|
runtime: State<'_, AppRuntime>,
|
||||||
|
) -> Result<DesktopStatus, String> {
|
||||||
|
let mut recorder = runtime.recorder.lock().map_err(|error| error.to_string())?;
|
||||||
|
let capture = runtime.capture.lock().map_err(|error| error.to_string())?;
|
||||||
|
recorder.settings.privacy.desktop_capture_requires_confirmation = !enabled;
|
||||||
|
save_settings(&runtime.library_root, &recorder.settings)
|
||||||
|
.map_err(|error| format!("Could not save settings: {error}"))?;
|
||||||
|
Ok(status_from_recorder(&recorder, capture.as_ref()))
|
||||||
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
fn write_gsi_configs(runtime: State<'_, AppRuntime>) -> Result<Vec<GsiConfigDto>, String> {
|
fn write_gsi_configs(runtime: State<'_, AppRuntime>) -> Result<Vec<GsiConfigDto>, String> {
|
||||||
write_gsi_config_templates(&runtime.library_root)
|
write_gsi_config_templates(&runtime.library_root)
|
||||||
@@ -686,6 +714,7 @@ fn main() {
|
|||||||
list_clips,
|
list_clips,
|
||||||
set_replay_buffer,
|
set_replay_buffer,
|
||||||
set_mic_enabled,
|
set_mic_enabled,
|
||||||
|
set_auto_record_enabled,
|
||||||
write_gsi_configs,
|
write_gsi_configs,
|
||||||
poll_auto_clip_events,
|
poll_auto_clip_events,
|
||||||
save_manual_clip,
|
save_manual_clip,
|
||||||
@@ -805,6 +834,7 @@ fn status_from_recorder(recorder: &RecorderService, capture: Option<&ActiveCaptu
|
|||||||
detected_game: recorder.state.detected_game_id.clone(),
|
detected_game: recorder.state.detected_game_id.clone(),
|
||||||
replay_buffer_seconds: recorder.settings.replay_buffer.as_secs(),
|
replay_buffer_seconds: recorder.settings.replay_buffer.as_secs(),
|
||||||
mic_enabled: recorder.settings.privacy.mic_enabled,
|
mic_enabled: recorder.settings.privacy.mic_enabled,
|
||||||
|
auto_record_enabled: !recorder.settings.privacy.desktop_capture_requires_confirmation,
|
||||||
upload_enabled: false,
|
upload_enabled: false,
|
||||||
session_recording: matches!(recorder.state.status, RecordingStatus::RecordingSession),
|
session_recording: matches!(recorder.state.status, RecordingStatus::RecordingSession),
|
||||||
capture_active: capture.is_some(),
|
capture_active: capture.is_some(),
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ type DesktopStatus = {
|
|||||||
detected_game: string | null;
|
detected_game: string | null;
|
||||||
replay_buffer_seconds: number;
|
replay_buffer_seconds: number;
|
||||||
mic_enabled: boolean;
|
mic_enabled: boolean;
|
||||||
|
auto_record_enabled: boolean;
|
||||||
upload_enabled: boolean;
|
upload_enabled: boolean;
|
||||||
session_recording: boolean;
|
session_recording: boolean;
|
||||||
capture_active: boolean;
|
capture_active: boolean;
|
||||||
@@ -83,6 +84,7 @@ type AppState = {
|
|||||||
ffmpegPath: string | null;
|
ffmpegPath: string | null;
|
||||||
systemAudioAvailable: boolean;
|
systemAudioAvailable: boolean;
|
||||||
micEnabled: boolean;
|
micEnabled: boolean;
|
||||||
|
autoRecordEnabled: boolean;
|
||||||
autoUpload: boolean;
|
autoUpload: boolean;
|
||||||
uploadProvider: "catbox" | "litterbox" | "custom_http" | "lustful";
|
uploadProvider: "catbox" | "litterbox" | "custom_http" | "lustful";
|
||||||
customUploadEndpoint: string;
|
customUploadEndpoint: string;
|
||||||
@@ -120,6 +122,7 @@ const state: AppState = {
|
|||||||
ffmpegPath: null,
|
ffmpegPath: null,
|
||||||
systemAudioAvailable: false,
|
systemAudioAvailable: false,
|
||||||
micEnabled: false,
|
micEnabled: false,
|
||||||
|
autoRecordEnabled: false,
|
||||||
autoUpload: false,
|
autoUpload: false,
|
||||||
uploadProvider: "catbox",
|
uploadProvider: "catbox",
|
||||||
customUploadEndpoint: "",
|
customUploadEndpoint: "",
|
||||||
@@ -453,6 +456,7 @@ function renderSettingsView() {
|
|||||||
<article class="settings-panel">
|
<article class="settings-panel">
|
||||||
<p class="eyebrow">Privacy</p>
|
<p class="eyebrow">Privacy</p>
|
||||||
<h2>Local-first</h2>
|
<h2>Local-first</h2>
|
||||||
|
<label class="toggle"><input type="checkbox" ${state.autoRecordEnabled ? "checked" : ""} data-action="toggle-auto-record" /> Start recording when a supported game is detected</label>
|
||||||
<label class="toggle"><input type="checkbox" ${state.autoUpload ? "checked" : ""} data-action="toggle-auto-upload" /> Auto-upload after clipping</label>
|
<label class="toggle"><input type="checkbox" ${state.autoUpload ? "checked" : ""} data-action="toggle-auto-upload" /> Auto-upload after clipping</label>
|
||||||
</article>
|
</article>
|
||||||
<article class="settings-panel">
|
<article class="settings-panel">
|
||||||
@@ -531,6 +535,12 @@ function bindEvents() {
|
|||||||
render();
|
render();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
appRoot.querySelector<HTMLInputElement>("[data-action='toggle-auto-record']")?.addEventListener("change", (event) => {
|
||||||
|
state.autoRecordEnabled = (event.target as HTMLInputElement).checked;
|
||||||
|
render();
|
||||||
|
void saveAutoRecordSetting(state.autoRecordEnabled);
|
||||||
|
});
|
||||||
|
|
||||||
appRoot.querySelectorAll<HTMLButtonElement>("[data-upload-provider]").forEach((button) => {
|
appRoot.querySelectorAll<HTMLButtonElement>("[data-upload-provider]").forEach((button) => {
|
||||||
button.addEventListener("click", () => {
|
button.addEventListener("click", () => {
|
||||||
state.uploadProvider = button.dataset.uploadProvider as AppState["uploadProvider"];
|
state.uploadProvider = button.dataset.uploadProvider as AppState["uploadProvider"];
|
||||||
@@ -620,6 +630,7 @@ function applyDesktopStatus(status: DesktopStatus) {
|
|||||||
state.detectedGame = status.detected_game ?? "Waiting for game";
|
state.detectedGame = status.detected_game ?? "Waiting for game";
|
||||||
state.replayBufferSeconds = status.replay_buffer_seconds;
|
state.replayBufferSeconds = status.replay_buffer_seconds;
|
||||||
state.micEnabled = status.mic_enabled;
|
state.micEnabled = status.mic_enabled;
|
||||||
|
state.autoRecordEnabled = status.auto_record_enabled;
|
||||||
state.autoUpload = status.upload_enabled;
|
state.autoUpload = status.upload_enabled;
|
||||||
state.sessionRecording = status.session_recording;
|
state.sessionRecording = status.session_recording;
|
||||||
state.captureActive = status.capture_active;
|
state.captureActive = status.capture_active;
|
||||||
@@ -762,6 +773,20 @@ async function saveMicSetting(enabled: boolean) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function saveAutoRecordSetting(enabled: boolean) {
|
||||||
|
if (!tauriInvoke) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const status = await tauriInvoke<DesktopStatus>("set_auto_record_enabled", { enabled });
|
||||||
|
applyDesktopStatus(status);
|
||||||
|
render();
|
||||||
|
} catch (error) {
|
||||||
|
console.warn("Could not save auto-record setting", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function refreshStatus() {
|
async function refreshStatus() {
|
||||||
if (!tauriInvoke) {
|
if (!tauriInvoke) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in new issue
Block a user