Rework events and add proper support for client events

Added

- Client events are now implemented through `SimConnect::subscribe_to_client_event`, `SimConnect::unsubscribe_from_client_event` and `SimConnect::unsubscribe_from_all_client_events`.
- `subscribe_to_client_events.rs` example has been added.
- `SimConnectError::EventAlreadySubscribedTo` and `SimConnectError::EventNotSubscribedTo` error variants have been added.

Changed

- A second call to `SimConnect::subscribe_to_system_event` for the same event will now return an error of type `SimConnectError::EventAlreadySubscribedTo` instead of `SimConnectError::SimConnectException`.
- The call to `SimConnect::unsubscribe_from_system_event` is now a NOOP when the system event is not subscribed to.
- `SimConnectError::UnimplementedMessageType` has been renamed to `SimConnectError::UnimplementedNotification`.

Removed

- `SimConnect::register_event` has been replaced by the new client event functions.
- `NotificationGroup` has been removed in favor of an internally managed notification group.
This commit is contained in:
Mihai Dinculescu
2023-05-01 19:04:55 +01:00
parent 85e5341599
commit d89fa524c2
16 changed files with 510 additions and 141 deletions

View File

@@ -25,10 +25,12 @@ fn main() {
.allowlist_function("SimConnect_AddToDataDefinition")
.allowlist_function("SimConnect_CallDispatch")
.allowlist_function("SimConnect_ClearDataDefinition")
.allowlist_function("SimConnect_ClearNotificationGroup")
.allowlist_function("SimConnect_Close")
.allowlist_function("SimConnect_GetNextDispatch")
.allowlist_function("SimConnect_MapClientEventToSimEvent")
.allowlist_function("SimConnect_Open")
.allowlist_function("SimConnect_RemoveClientEvent")
.allowlist_function("SimConnect_RequestDataOnSimObject")
.allowlist_function("SimConnect_RequestFacilitiesList")
.allowlist_function("SimConnect_SetNotificationGroupPriority")
@@ -52,6 +54,11 @@ fn main() {
.allowlist_type("SIMCONNECT_RECV_WAYPOINT_LIST")
.allowlist_type("SIMCONNECT_RECV")
.allowlist_var("SIMCONNECT_DATA_REQUEST_FLAG_CHANGED")
.allowlist_var("SIMCONNECT_GROUP_PRIORITY_DEFAULT")
.allowlist_var("SIMCONNECT_GROUP_PRIORITY_HIGHEST_MASKABLE")
.allowlist_var("SIMCONNECT_GROUP_PRIORITY_HIGHEST")
.allowlist_var("SIMCONNECT_GROUP_PRIORITY_LOWEST")
.allowlist_var("SIMCONNECT_GROUP_PRIORITY_STANDARD")
.allowlist_var("SIMCONNECT_OBJECT_ID_USER")
.allowlist_var("SIMCONNECT_RECV_ID_VOR_LIST_HAS_DME")
.allowlist_var("SIMCONNECT_RECV_ID_VOR_LIST_HAS_GLIDE_SLOPE")