-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathmod.rs
More file actions
80 lines (69 loc) · 2.04 KB
/
mod.rs
File metadata and controls
80 lines (69 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
use serde::{Deserialize, Serialize};
use specta::Type;
#[cfg(target_os = "windows")]
pub mod win;
#[cfg(target_os = "macos")]
pub mod macos;
#[cfg(target_os = "macos")]
pub use macos::*;
#[cfg(target_os = "linux")]
pub mod linux;
use tracing::instrument;
#[derive(Debug, Serialize, Deserialize, Type, Default)]
#[serde(rename_all = "camelCase")]
#[repr(isize)]
pub enum HapticPattern {
Alignment = 0,
LevelChange = 1,
#[default]
Generic = 2,
}
#[derive(Debug, Serialize, Deserialize, Type, Default)]
#[serde(rename_all = "camelCase")]
#[repr(usize)]
pub enum HapticPerformanceTime {
Default = 0,
#[default]
Now = 1,
DrawCompleted = 2,
}
#[tauri::command]
#[specta::specta]
#[instrument]
pub fn perform_haptic_feedback(
_pattern: Option<HapticPattern>,
_time: Option<HapticPerformanceTime>,
) -> Result<(), String> {
#[cfg(target_os = "macos")]
unsafe {
use objc2_app_kit::{
NSHapticFeedbackManager, NSHapticFeedbackPattern, NSHapticFeedbackPerformanceTime,
NSHapticFeedbackPerformer,
};
NSHapticFeedbackManager::defaultPerformer().performFeedbackPattern_performanceTime(
NSHapticFeedbackPattern(_pattern.unwrap_or_default() as isize),
NSHapticFeedbackPerformanceTime(_time.unwrap_or_default() as usize),
);
Ok(())
}
#[cfg(not(target_os = "macos"))]
Err("Haptics are only supported on macOS.".into())
}
/// Check if system audio capture is supported on the current platform and OS version.
/// On macOS, system audio capture requires macOS 13.0 or later.
/// On Windows/Linux, this may have different requirements.
#[tauri::command]
#[specta::specta]
#[instrument]
pub fn is_system_audio_capture_supported() -> bool {
#[cfg(target_os = "macos")]
{
scap_screencapturekit::is_system_audio_supported()
}
#[cfg(not(target_os = "macos"))]
{
// On Windows/Linux, we assume system audio capture is available
// This can be refined later based on platform-specific requirements
true
}
}