//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2_core_foundation::*;

use crate::*;

#[cfg(feature = "CGEventTypes")]
unsafe impl ConcreteType for CGEventSource {
    #[doc(alias = "CGEventSourceGetTypeID")]
    #[inline]
    fn type_id() -> CFTypeID {
        extern "C-unwind" {
            fn CGEventSourceGetTypeID() -> CFTypeID;
        }
        unsafe { CGEventSourceGetTypeID() }
    }
}

#[cfg(feature = "CGEventTypes")]
impl CGEventSource {
    #[doc(alias = "CGEventSourceCreate")]
    #[cfg(feature = "CGEventTypes")]
    #[inline]
    pub fn new(state_id: CGEventSourceStateID) -> Option<CFRetained<CGEventSource>> {
        extern "C-unwind" {
            fn CGEventSourceCreate(
                state_id: CGEventSourceStateID,
            ) -> Option<NonNull<CGEventSource>>;
        }
        let ret = unsafe { CGEventSourceCreate(state_id) };
        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
    }

    #[doc(alias = "CGEventSourceGetKeyboardType")]
    #[cfg(feature = "CGEventTypes")]
    #[inline]
    pub fn keyboard_type(source: Option<&CGEventSource>) -> CGEventSourceKeyboardType {
        extern "C-unwind" {
            fn CGEventSourceGetKeyboardType(
                source: Option<&CGEventSource>,
            ) -> CGEventSourceKeyboardType;
        }
        unsafe { CGEventSourceGetKeyboardType(source) }
    }

    #[doc(alias = "CGEventSourceSetKeyboardType")]
    #[cfg(feature = "CGEventTypes")]
    #[inline]
    pub fn set_keyboard_type(
        source: Option<&CGEventSource>,
        keyboard_type: CGEventSourceKeyboardType,
    ) {
        extern "C-unwind" {
            fn CGEventSourceSetKeyboardType(
                source: Option<&CGEventSource>,
                keyboard_type: CGEventSourceKeyboardType,
            );
        }
        unsafe { CGEventSourceSetKeyboardType(source, keyboard_type) }
    }

    #[doc(alias = "CGEventSourceGetPixelsPerLine")]
    #[cfg(feature = "CGEventTypes")]
    #[inline]
    pub fn pixels_per_line(source: Option<&CGEventSource>) -> c_double {
        extern "C-unwind" {
            fn CGEventSourceGetPixelsPerLine(source: Option<&CGEventSource>) -> c_double;
        }
        unsafe { CGEventSourceGetPixelsPerLine(source) }
    }

    #[doc(alias = "CGEventSourceSetPixelsPerLine")]
    #[cfg(feature = "CGEventTypes")]
    #[inline]
    pub fn set_pixels_per_line(source: Option<&CGEventSource>, pixels_per_line: c_double) {
        extern "C-unwind" {
            fn CGEventSourceSetPixelsPerLine(
                source: Option<&CGEventSource>,
                pixels_per_line: c_double,
            );
        }
        unsafe { CGEventSourceSetPixelsPerLine(source, pixels_per_line) }
    }

    #[doc(alias = "CGEventSourceGetSourceStateID")]
    #[cfg(feature = "CGEventTypes")]
    #[inline]
    pub fn source_state_id(source: Option<&CGEventSource>) -> CGEventSourceStateID {
        extern "C-unwind" {
            fn CGEventSourceGetSourceStateID(
                source: Option<&CGEventSource>,
            ) -> CGEventSourceStateID;
        }
        unsafe { CGEventSourceGetSourceStateID(source) }
    }

    #[doc(alias = "CGEventSourceButtonState")]
    #[cfg(feature = "CGEventTypes")]
    #[inline]
    pub fn button_state(state_id: CGEventSourceStateID, button: CGMouseButton) -> bool {
        extern "C-unwind" {
            fn CGEventSourceButtonState(
                state_id: CGEventSourceStateID,
                button: CGMouseButton,
            ) -> bool;
        }
        unsafe { CGEventSourceButtonState(state_id, button) }
    }

    #[doc(alias = "CGEventSourceKeyState")]
    #[cfg(all(feature = "CGEventTypes", feature = "CGRemoteOperation"))]
    #[inline]
    pub fn key_state(state_id: CGEventSourceStateID, key: CGKeyCode) -> bool {
        extern "C-unwind" {
            fn CGEventSourceKeyState(state_id: CGEventSourceStateID, key: CGKeyCode) -> bool;
        }
        unsafe { CGEventSourceKeyState(state_id, key) }
    }

    #[doc(alias = "CGEventSourceFlagsState")]
    #[cfg(feature = "CGEventTypes")]
    #[inline]
    pub fn flags_state(state_id: CGEventSourceStateID) -> CGEventFlags {
        extern "C-unwind" {
            fn CGEventSourceFlagsState(state_id: CGEventSourceStateID) -> CGEventFlags;
        }
        unsafe { CGEventSourceFlagsState(state_id) }
    }

    #[doc(alias = "CGEventSourceSecondsSinceLastEventType")]
    #[cfg(feature = "CGEventTypes")]
    #[inline]
    pub fn seconds_since_last_event_type(
        state_id: CGEventSourceStateID,
        event_type: CGEventType,
    ) -> CFTimeInterval {
        extern "C-unwind" {
            fn CGEventSourceSecondsSinceLastEventType(
                state_id: CGEventSourceStateID,
                event_type: CGEventType,
            ) -> CFTimeInterval;
        }
        unsafe { CGEventSourceSecondsSinceLastEventType(state_id, event_type) }
    }

    #[doc(alias = "CGEventSourceCounterForEventType")]
    #[cfg(feature = "CGEventTypes")]
    #[inline]
    pub fn counter_for_event_type(state_id: CGEventSourceStateID, event_type: CGEventType) -> u32 {
        extern "C-unwind" {
            fn CGEventSourceCounterForEventType(
                state_id: CGEventSourceStateID,
                event_type: CGEventType,
            ) -> u32;
        }
        unsafe { CGEventSourceCounterForEventType(state_id, event_type) }
    }

    #[doc(alias = "CGEventSourceSetUserData")]
    #[cfg(feature = "CGEventTypes")]
    #[inline]
    pub fn set_user_data(source: Option<&CGEventSource>, user_data: i64) {
        extern "C-unwind" {
            fn CGEventSourceSetUserData(source: Option<&CGEventSource>, user_data: i64);
        }
        unsafe { CGEventSourceSetUserData(source, user_data) }
    }

    #[doc(alias = "CGEventSourceGetUserData")]
    #[cfg(feature = "CGEventTypes")]
    #[inline]
    pub fn user_data(source: Option<&CGEventSource>) -> i64 {
        extern "C-unwind" {
            fn CGEventSourceGetUserData(source: Option<&CGEventSource>) -> i64;
        }
        unsafe { CGEventSourceGetUserData(source) }
    }

    #[doc(alias = "CGEventSourceSetLocalEventsFilterDuringSuppressionState")]
    #[cfg(all(feature = "CGEventTypes", feature = "CGRemoteOperation"))]
    #[inline]
    pub fn set_local_events_filter_during_suppression_state(
        source: Option<&CGEventSource>,
        filter: CGEventFilterMask,
        state: CGEventSuppressionState,
    ) {
        extern "C-unwind" {
            fn CGEventSourceSetLocalEventsFilterDuringSuppressionState(
                source: Option<&CGEventSource>,
                filter: CGEventFilterMask,
                state: CGEventSuppressionState,
            );
        }
        unsafe { CGEventSourceSetLocalEventsFilterDuringSuppressionState(source, filter, state) }
    }

    #[doc(alias = "CGEventSourceGetLocalEventsFilterDuringSuppressionState")]
    #[cfg(all(feature = "CGEventTypes", feature = "CGRemoteOperation"))]
    #[inline]
    pub fn local_events_filter_during_suppression_state(
        source: Option<&CGEventSource>,
        state: CGEventSuppressionState,
    ) -> CGEventFilterMask {
        extern "C-unwind" {
            fn CGEventSourceGetLocalEventsFilterDuringSuppressionState(
                source: Option<&CGEventSource>,
                state: CGEventSuppressionState,
            ) -> CGEventFilterMask;
        }
        unsafe { CGEventSourceGetLocalEventsFilterDuringSuppressionState(source, state) }
    }

    #[doc(alias = "CGEventSourceSetLocalEventsSuppressionInterval")]
    #[cfg(feature = "CGEventTypes")]
    #[inline]
    pub fn set_local_events_suppression_interval(
        source: Option<&CGEventSource>,
        seconds: CFTimeInterval,
    ) {
        extern "C-unwind" {
            fn CGEventSourceSetLocalEventsSuppressionInterval(
                source: Option<&CGEventSource>,
                seconds: CFTimeInterval,
            );
        }
        unsafe { CGEventSourceSetLocalEventsSuppressionInterval(source, seconds) }
    }

    #[doc(alias = "CGEventSourceGetLocalEventsSuppressionInterval")]
    #[cfg(feature = "CGEventTypes")]
    #[inline]
    pub fn local_events_suppression_interval(source: Option<&CGEventSource>) -> CFTimeInterval {
        extern "C-unwind" {
            fn CGEventSourceGetLocalEventsSuppressionInterval(
                source: Option<&CGEventSource>,
            ) -> CFTimeInterval;
        }
        unsafe { CGEventSourceGetLocalEventsSuppressionInterval(source) }
    }
}

#[cfg(feature = "CGEventTypes")]
#[deprecated = "renamed to `CGEventSource::new`"]
#[inline]
pub extern "C-unwind" fn CGEventSourceCreate(
    state_id: CGEventSourceStateID,
) -> Option<CFRetained<CGEventSource>> {
    extern "C-unwind" {
        fn CGEventSourceCreate(state_id: CGEventSourceStateID) -> Option<NonNull<CGEventSource>>;
    }
    let ret = unsafe { CGEventSourceCreate(state_id) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[cfg(feature = "CGEventTypes")]
#[deprecated = "renamed to `CGEventSource::keyboard_type`"]
#[inline]
pub extern "C-unwind" fn CGEventSourceGetKeyboardType(
    source: Option<&CGEventSource>,
) -> CGEventSourceKeyboardType {
    extern "C-unwind" {
        fn CGEventSourceGetKeyboardType(
            source: Option<&CGEventSource>,
        ) -> CGEventSourceKeyboardType;
    }
    unsafe { CGEventSourceGetKeyboardType(source) }
}

#[cfg(feature = "CGEventTypes")]
#[deprecated = "renamed to `CGEventSource::set_keyboard_type`"]
#[inline]
pub extern "C-unwind" fn CGEventSourceSetKeyboardType(
    source: Option<&CGEventSource>,
    keyboard_type: CGEventSourceKeyboardType,
) {
    extern "C-unwind" {
        fn CGEventSourceSetKeyboardType(
            source: Option<&CGEventSource>,
            keyboard_type: CGEventSourceKeyboardType,
        );
    }
    unsafe { CGEventSourceSetKeyboardType(source, keyboard_type) }
}

#[cfg(feature = "CGEventTypes")]
#[deprecated = "renamed to `CGEventSource::pixels_per_line`"]
#[inline]
pub extern "C-unwind" fn CGEventSourceGetPixelsPerLine(source: Option<&CGEventSource>) -> c_double {
    extern "C-unwind" {
        fn CGEventSourceGetPixelsPerLine(source: Option<&CGEventSource>) -> c_double;
    }
    unsafe { CGEventSourceGetPixelsPerLine(source) }
}

#[cfg(feature = "CGEventTypes")]
#[deprecated = "renamed to `CGEventSource::set_pixels_per_line`"]
#[inline]
pub extern "C-unwind" fn CGEventSourceSetPixelsPerLine(
    source: Option<&CGEventSource>,
    pixels_per_line: c_double,
) {
    extern "C-unwind" {
        fn CGEventSourceSetPixelsPerLine(source: Option<&CGEventSource>, pixels_per_line: c_double);
    }
    unsafe { CGEventSourceSetPixelsPerLine(source, pixels_per_line) }
}

#[cfg(feature = "CGEventTypes")]
#[deprecated = "renamed to `CGEventSource::source_state_id`"]
#[inline]
pub extern "C-unwind" fn CGEventSourceGetSourceStateID(
    source: Option<&CGEventSource>,
) -> CGEventSourceStateID {
    extern "C-unwind" {
        fn CGEventSourceGetSourceStateID(source: Option<&CGEventSource>) -> CGEventSourceStateID;
    }
    unsafe { CGEventSourceGetSourceStateID(source) }
}

#[cfg(feature = "CGEventTypes")]
#[deprecated = "renamed to `CGEventSource::button_state`"]
#[inline]
pub extern "C-unwind" fn CGEventSourceButtonState(
    state_id: CGEventSourceStateID,
    button: CGMouseButton,
) -> bool {
    extern "C-unwind" {
        fn CGEventSourceButtonState(state_id: CGEventSourceStateID, button: CGMouseButton) -> bool;
    }
    unsafe { CGEventSourceButtonState(state_id, button) }
}

#[cfg(all(feature = "CGEventTypes", feature = "CGRemoteOperation"))]
#[deprecated = "renamed to `CGEventSource::key_state`"]
#[inline]
pub extern "C-unwind" fn CGEventSourceKeyState(
    state_id: CGEventSourceStateID,
    key: CGKeyCode,
) -> bool {
    extern "C-unwind" {
        fn CGEventSourceKeyState(state_id: CGEventSourceStateID, key: CGKeyCode) -> bool;
    }
    unsafe { CGEventSourceKeyState(state_id, key) }
}

#[cfg(feature = "CGEventTypes")]
#[deprecated = "renamed to `CGEventSource::flags_state`"]
#[inline]
pub extern "C-unwind" fn CGEventSourceFlagsState(state_id: CGEventSourceStateID) -> CGEventFlags {
    extern "C-unwind" {
        fn CGEventSourceFlagsState(state_id: CGEventSourceStateID) -> CGEventFlags;
    }
    unsafe { CGEventSourceFlagsState(state_id) }
}

#[cfg(feature = "CGEventTypes")]
#[deprecated = "renamed to `CGEventSource::seconds_since_last_event_type`"]
#[inline]
pub extern "C-unwind" fn CGEventSourceSecondsSinceLastEventType(
    state_id: CGEventSourceStateID,
    event_type: CGEventType,
) -> CFTimeInterval {
    extern "C-unwind" {
        fn CGEventSourceSecondsSinceLastEventType(
            state_id: CGEventSourceStateID,
            event_type: CGEventType,
        ) -> CFTimeInterval;
    }
    unsafe { CGEventSourceSecondsSinceLastEventType(state_id, event_type) }
}

#[cfg(feature = "CGEventTypes")]
#[deprecated = "renamed to `CGEventSource::counter_for_event_type`"]
#[inline]
pub extern "C-unwind" fn CGEventSourceCounterForEventType(
    state_id: CGEventSourceStateID,
    event_type: CGEventType,
) -> u32 {
    extern "C-unwind" {
        fn CGEventSourceCounterForEventType(
            state_id: CGEventSourceStateID,
            event_type: CGEventType,
        ) -> u32;
    }
    unsafe { CGEventSourceCounterForEventType(state_id, event_type) }
}

#[cfg(feature = "CGEventTypes")]
#[deprecated = "renamed to `CGEventSource::set_user_data`"]
#[inline]
pub extern "C-unwind" fn CGEventSourceSetUserData(source: Option<&CGEventSource>, user_data: i64) {
    extern "C-unwind" {
        fn CGEventSourceSetUserData(source: Option<&CGEventSource>, user_data: i64);
    }
    unsafe { CGEventSourceSetUserData(source, user_data) }
}

#[cfg(feature = "CGEventTypes")]
#[deprecated = "renamed to `CGEventSource::user_data`"]
#[inline]
pub extern "C-unwind" fn CGEventSourceGetUserData(source: Option<&CGEventSource>) -> i64 {
    extern "C-unwind" {
        fn CGEventSourceGetUserData(source: Option<&CGEventSource>) -> i64;
    }
    unsafe { CGEventSourceGetUserData(source) }
}

#[cfg(all(feature = "CGEventTypes", feature = "CGRemoteOperation"))]
#[deprecated = "renamed to `CGEventSource::set_local_events_filter_during_suppression_state`"]
#[inline]
pub extern "C-unwind" fn CGEventSourceSetLocalEventsFilterDuringSuppressionState(
    source: Option<&CGEventSource>,
    filter: CGEventFilterMask,
    state: CGEventSuppressionState,
) {
    extern "C-unwind" {
        fn CGEventSourceSetLocalEventsFilterDuringSuppressionState(
            source: Option<&CGEventSource>,
            filter: CGEventFilterMask,
            state: CGEventSuppressionState,
        );
    }
    unsafe { CGEventSourceSetLocalEventsFilterDuringSuppressionState(source, filter, state) }
}

#[cfg(all(feature = "CGEventTypes", feature = "CGRemoteOperation"))]
#[deprecated = "renamed to `CGEventSource::local_events_filter_during_suppression_state`"]
#[inline]
pub extern "C-unwind" fn CGEventSourceGetLocalEventsFilterDuringSuppressionState(
    source: Option<&CGEventSource>,
    state: CGEventSuppressionState,
) -> CGEventFilterMask {
    extern "C-unwind" {
        fn CGEventSourceGetLocalEventsFilterDuringSuppressionState(
            source: Option<&CGEventSource>,
            state: CGEventSuppressionState,
        ) -> CGEventFilterMask;
    }
    unsafe { CGEventSourceGetLocalEventsFilterDuringSuppressionState(source, state) }
}

#[cfg(feature = "CGEventTypes")]
#[deprecated = "renamed to `CGEventSource::set_local_events_suppression_interval`"]
#[inline]
pub extern "C-unwind" fn CGEventSourceSetLocalEventsSuppressionInterval(
    source: Option<&CGEventSource>,
    seconds: CFTimeInterval,
) {
    extern "C-unwind" {
        fn CGEventSourceSetLocalEventsSuppressionInterval(
            source: Option<&CGEventSource>,
            seconds: CFTimeInterval,
        );
    }
    unsafe { CGEventSourceSetLocalEventsSuppressionInterval(source, seconds) }
}

#[cfg(feature = "CGEventTypes")]
#[deprecated = "renamed to `CGEventSource::local_events_suppression_interval`"]
#[inline]
pub extern "C-unwind" fn CGEventSourceGetLocalEventsSuppressionInterval(
    source: Option<&CGEventSource>,
) -> CFTimeInterval {
    extern "C-unwind" {
        fn CGEventSourceGetLocalEventsSuppressionInterval(
            source: Option<&CGEventSource>,
        ) -> CFTimeInterval;
    }
    unsafe { CGEventSourceGetLocalEventsSuppressionInterval(source) }
}
