Add unsubscribe to facilities

This commit is contained in:
Mihai Dinculescu
2022-10-17 20:17:04 +01:00
parent 6be70c8566
commit a2002e02cd
9 changed files with 279 additions and 197 deletions

View File

@@ -0,0 +1,40 @@
use crate::{bindings, success, Event, NotificationGroup, SimConnect, SimConnectError};
impl SimConnect {
/// Associates a client defined event with a Microsoft Flight Simulator event name.
///
/// WIP
#[tracing::instrument(name = "SimConnect::register_event")]
pub fn register_event(
&self,
event: Event,
notification_group: NotificationGroup,
) -> Result<(), SimConnectError> {
success!(unsafe {
bindings::SimConnect_MapClientEventToSimEvent(
self.handle.as_ptr(),
event as u32,
event.into_c_char(),
)
});
success!(unsafe {
bindings::SimConnect_AddClientEventToNotificationGroup(
self.handle.as_ptr(),
notification_group as u32,
event as u32,
0,
)
});
success!(unsafe {
bindings::SimConnect_SetNotificationGroupPriority(
self.handle.as_ptr(),
notification_group as u32,
1,
)
});
Ok(())
}
}