clap_sys/ext/draft/
triggers.rs1use crate::{cstr, events::*, host::*, id::*, plugin::*, string_sizes::*};
2
3use std::ffi::{c_char, c_void, CStr};
4
5pub const CLAP_EXT_TRIGGERS: &CStr = cstr!("clap.triggers/1");
6
7pub const CLAP_TRIGGER_IS_AUTOMATABLE_PER_NOTE_ID: clap_trigger_info_flags = 1 << 0;
8pub const CLAP_TRIGGER_IS_AUTOMATABLE_PER_KEY: clap_trigger_info_flags = 1 << 1;
9pub const CLAP_TRIGGER_IS_AUTOMATABLE_PER_CHANNEL: clap_trigger_info_flags = 1 << 2;
10pub const CLAP_TRIGGER_IS_AUTOMATABLE_PER_PORT: clap_trigger_info_flags = 1 << 3;
11
12pub type clap_trigger_info_flags = u32;
13
14pub const CLAP_EVENT_TRIGGER: clap_event_type = 0;
15
16#[repr(C)]
17#[derive(Debug, Copy, Clone)]
18pub struct clap_event_trigger {
19 pub header: clap_event_header,
20 pub trigger_id: clap_id,
21 pub cookie: *mut c_void,
22 pub note_id: i32,
23 pub port_index: i16,
24 pub channel: i16,
25 pub key: i16,
26}
27
28unsafe impl Send for clap_event_trigger {}
29unsafe impl Sync for clap_event_trigger {}
30
31#[repr(C)]
32#[derive(Debug, Copy, Clone)]
33pub struct clap_trigger_info {
34 pub id: clap_id,
35 pub flags: clap_trigger_info_flags,
36 pub cookie: *mut c_void,
37 pub name: [c_char; CLAP_NAME_SIZE],
38 pub module: [c_char; CLAP_PATH_SIZE],
39}
40
41unsafe impl Send for clap_trigger_info {}
42unsafe impl Sync for clap_trigger_info {}
43
44#[repr(C)]
45#[derive(Debug, Copy, Clone)]
46pub struct clap_plugin_triggers {
47 pub count: Option<unsafe extern "C" fn(plugin: *const clap_plugin) -> u32>,
48 pub get_info: Option<
49 unsafe extern "C" fn(
50 plugin: *const clap_plugin,
51 trigger_index: u32,
52 trigger_info: *mut clap_trigger_info,
53 ) -> bool,
54 >,
55}
56
57pub const CLAP_TRIGGER_RESCAN_INFO: clap_trigger_rescan_flags = 1 << 0;
58pub const CLAP_TRIGGER_RESCAN_ALL: clap_trigger_rescan_flags = 1 << 1;
59
60pub type clap_trigger_rescan_flags = u32;
61
62pub const CLAP_TRIGGER_CLEAR_ALL: clap_trigger_clear_flags = 1 << 0;
63pub const CLAP_TRIGGER_CLEAR_AUTOMATIONS: clap_trigger_clear_flags = 1 << 1;
64
65pub type clap_trigger_clear_flags = u32;
66
67#[repr(C)]
68#[derive(Debug, Copy, Clone)]
69pub struct clap_host_triggers {
70 pub rescan:
71 Option<unsafe extern "C" fn(host: *const clap_host, flags: clap_trigger_rescan_flags)>,
72 pub clear: Option<
73 unsafe extern "C" fn(
74 host: *const clap_host,
75 trigger_id: clap_id,
76 flags: clap_trigger_clear_flags,
77 ),
78 >,
79}