Cleanup lib imports

This commit is contained in:
Mihai Dinculescu
2022-10-07 17:26:37 +01:00
parent cb00061d43
commit 9776960540
5 changed files with 309 additions and 349 deletions

Binary file not shown.

View File

@@ -2,33 +2,13 @@ use std::env;
use std::path::PathBuf;
fn main() {
println!("cargo:rerun-if-changed=wrapper.h");
println!("cargo:rerun-if-changed=SimConnect.dll");
println!("cargo:rerun-if-changed=SimConnect.lib");
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
let binary_name = "SimConnect";
let binary_name_dll = &format!("{binary_name}.dll");
let simconnect_path = PathBuf::from(env::current_dir().unwrap().to_str().unwrap());
let simconnect_dir = simconnect_path.as_path().to_str().unwrap();
println!("cargo:rustc-link-search={}", simconnect_dir);
println!("cargo:rustc-link-lib={}", binary_name);
// copy the dll
let mut source_path = PathBuf::from(simconnect_dir);
source_path.push(binary_name_dll);
let mut target_path = out_path.clone();
target_path.pop();
target_path.pop();
target_path.pop();
target_path.push(binary_name_dll);
std::fs::copy(source_path.as_path(), target_path.as_path()).unwrap();
println!("cargo:rustc-link-search=ffi/lib");
println!("cargo:rustc-link-lib=static=SimConnect");
println!("cargo:rerun-if-changed=ffi/include/SimConnect.h");
println!("cargo:rerun-if-changed=ffi/lib/SimConnect.lib");
let bindings = bindgen::Builder::default()
.header("wrapper.h")
.header("ffi/include/SimConnect.h")
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
.clang_args(&["-x", "c++"])
.allowlist_function("SimConnect_Open")
@@ -54,7 +34,8 @@ fn main() {
.generate()
.expect("Unable to generate bindings");
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
bindings
.write_to_file(out_path.join("bindings.rs"))
.expect("Couldn't write bindings!");
.expect("Failed to write the bindings!");
}

View File

@@ -4,6 +4,8 @@
//
//-----------------------------------------------------------------------------
#include "Windows.h"
#ifndef _SIMCONNECT_H_
#define _SIMCONNECT_H_
@@ -34,7 +36,6 @@ static const float SIMCONNECT_CAMERA_IGNORE_FIELD = FLT_MAX; //Used to tell t
static const DWORD SIMCONNECT_CLIENTDATA_MAX_SIZE = 8192; // maximum value for SimConnect_CreateClientData dwSize parameter
// Notification Group priority values
static const DWORD SIMCONNECT_GROUP_PRIORITY_HIGHEST = 1; // highest priority
static const DWORD SIMCONNECT_GROUP_PRIORITY_HIGHEST_MASKABLE = 10000000; // highest priority that allows events to be masked
@@ -84,7 +85,6 @@ static const DWORD SIMCONNECT_OPEN_CONFIGINDEX_LOCAL = -1; // ignore SimConn
#define SIMCONNECT_ENUM_FLAGS typedef DWORD
#define SIMCONNECT_USER_ENUM typedef DWORD
// Receive data types
SIMCONNECT_ENUM SIMCONNECT_RECV_ID{
SIMCONNECT_RECV_ID_NULL,
@@ -119,8 +119,6 @@ SIMCONNECT_ENUM SIMCONNECT_RECV_ID {
#endif // ENABLE_SIMCONNECT_EXPERIMENTAL
};
// Data data types
SIMCONNECT_ENUM SIMCONNECT_DATATYPE{
SIMCONNECT_DATATYPE_INVALID, // invalid data type
@@ -213,12 +211,10 @@ SIMCONNECT_ENUM SIMCONNECT_PERIOD {
SIMCONNECT_PERIOD_SECOND,
};
SIMCONNECT_ENUM SIMCONNECT_MISSION_END{
SIMCONNECT_MISSION_FAILED,
SIMCONNECT_MISSION_CRASHED,
SIMCONNECT_MISSION_SUCCEEDED
};
SIMCONNECT_MISSION_SUCCEEDED};
// ClientData Request Period values
SIMCONNECT_ENUM SIMCONNECT_CLIENT_DATA_PERIOD{
@@ -282,15 +278,12 @@ SIMCONNECT_ENUM SIMCONNECT_FACILITY_LIST_TYPE {
SIMCONNECT_FACILITY_LIST_TYPE_COUNT // invalid
};
SIMCONNECT_ENUM_FLAGS SIMCONNECT_VOR_FLAGS; // flags for SIMCONNECT_RECV_ID_VOR_LIST
static const DWORD SIMCONNECT_RECV_ID_VOR_LIST_HAS_NAV_SIGNAL = 0x00000001; // Has Nav signal
static const DWORD SIMCONNECT_RECV_ID_VOR_LIST_HAS_LOCALIZER = 0x00000002; // Has localizer
static const DWORD SIMCONNECT_RECV_ID_VOR_LIST_HAS_GLIDE_SLOPE = 0x00000004; // Has Nav signal
static const DWORD SIMCONNECT_RECV_ID_VOR_LIST_HAS_DME = 0x00000008; // Station has DME
// bits for the Waypoint Flags field: may be combined
SIMCONNECT_ENUM_FLAGS SIMCONNECT_WAYPOINT_FLAGS;
static const DWORD SIMCONNECT_WAYPOINT_NONE = 0x00;
@@ -325,7 +318,6 @@ SIMCONNECT_ENUM_FLAGS SIMCONNECT_CREATE_CLIENT_DATA_FLAG;
static const DWORD SIMCONNECT_CREATE_CLIENT_DATA_FLAG_DEFAULT = 0x00000000;
static const DWORD SIMCONNECT_CREATE_CLIENT_DATA_FLAG_READ_ONLY = 0x00000001; // permit only ClientData creator to write into ClientData
SIMCONNECT_ENUM_FLAGS SIMCONNECT_CLIENT_DATA_REQUEST_FLAG;
static const DWORD SIMCONNECT_CLIENT_DATA_REQUEST_FLAG_DEFAULT = 0x00000000;
static const DWORD SIMCONNECT_CLIENT_DATA_REQUEST_FLAG_CHANGED = 0x00000001; // send requested ClientData when value(s) change
@@ -335,7 +327,6 @@ SIMCONNECT_ENUM_FLAGS SIMCONNECT_CLIENT_DATA_SET_FLAG;
static const DWORD SIMCONNECT_CLIENT_DATA_SET_FLAG_DEFAULT = 0x00000000;
static const DWORD SIMCONNECT_CLIENT_DATA_SET_FLAG_TAGGED = 0x00000001; // data is in tagged format
SIMCONNECT_ENUM_FLAGS SIMCONNECT_VIEW_SYSTEM_EVENT_DATA; // dwData contains these flags for the "View" System Event
static const DWORD SIMCONNECT_VIEW_SYSTEM_EVENT_DATA_COCKPIT_2D = 0x00000001; // 2D Panels in cockpit view
static const DWORD SIMCONNECT_VIEW_SYSTEM_EVENT_DATA_COCKPIT_VIRTUAL = 0x00000002; // Virtual (3D) panels in cockpit view
@@ -344,11 +335,9 @@ SIMCONNECT_ENUM_FLAGS SIMCONNECT_VIEW_SYSTEM_EVENT_DATA; // dwDat
SIMCONNECT_ENUM_FLAGS SIMCONNECT_SOUND_SYSTEM_EVENT_DATA; // dwData contains these flags for the "Sound" System Event
static const DWORD SIMCONNECT_SOUND_SYSTEM_EVENT_DATA_MASTER = 0x00000001; // Sound Master
#ifdef ENABLE_SIMCONNECT_EXPERIMENTAL
SIMCONNECT_ENUM_FLAGS SIMCONNECT_PICK_FLAGS
{
SIMCONNECT_ENUM_FLAGS SIMCONNECT_PICK_FLAGS{
SIMCONNECT_PICK_GROUND = 0x01, // pick ground/ pick result item is ground location
SIMCONNECT_PICK_AI = 0x02, // pick AI / pick result item is AI, (dwSimObjectID is valid)
SIMCONNECT_PICK_SCENERY = 0x04, // pick scenery/ pick result item is scenery object (hSceneryObject is valid)
@@ -371,7 +360,6 @@ SIMCONNECT_USER_ENUM SIMCONNECT_CLIENT_EVENT_ID; //client-defined clie
SIMCONNECT_USER_ENUM SIMCONNECT_CLIENT_DATA_ID; // client-defined client data ID
SIMCONNECT_USER_ENUM SIMCONNECT_CLIENT_DATA_DEFINITION_ID; // client-defined client data definition ID
//----------------------------------------------------------------------------
// Struct definitions
//----------------------------------------------------------------------------
@@ -410,8 +398,7 @@ SIMCONNECT_REFSTRUCT SIMCONNECT_RECV_OPEN : public SIMCONNECT_RECV // when dwI
};
SIMCONNECT_REFSTRUCT SIMCONNECT_RECV_QUIT : public SIMCONNECT_RECV // when dwID == SIMCONNECT_RECV_ID_QUIT
{
};
{};
SIMCONNECT_REFSTRUCT SIMCONNECT_RECV_EVENT : public SIMCONNECT_RECV // when dwID == SIMCONNECT_RECV_ID_EVENT
{
@@ -492,12 +479,10 @@ SIMCONNECT_REFSTRUCT SIMCONNECT_RECV_SIMOBJECT_DATA : public SIMCONNECT_RECV
};
SIMCONNECT_REFSTRUCT SIMCONNECT_RECV_SIMOBJECT_DATA_BYTYPE : public SIMCONNECT_RECV_SIMOBJECT_DATA // when dwID == SIMCONNECT_RECV_ID_SIMOBJECT_DATA_BYTYPE
{
};
{};
SIMCONNECT_REFSTRUCT SIMCONNECT_RECV_CLIENT_DATA : public SIMCONNECT_RECV_SIMOBJECT_DATA // when dwID == SIMCONNECT_RECV_ID_CLIENT_DATA
{
};
{};
SIMCONNECT_REFSTRUCT SIMCONNECT_RECV_WEATHER_OBSERVATION : public SIMCONNECT_RECV // when dwID == SIMCONNECT_RECV_ID_WEATHER_OBSERVATION
{
@@ -542,8 +527,7 @@ SIMCONNECT_REFSTRUCT SIMCONNECT_RECV_CUSTOM_ACTION : public SIMCONNECT_RECV_EVEN
SIMCONNECT_STRINGV(szPayLoad); // Variable length string payload associated with the mission action.
};
SIMCONNECT_REFSTRUCT SIMCONNECT_RECV_EVENT_WEATHER_MODE : public SIMCONNECT_RECV_EVENT
{
SIMCONNECT_REFSTRUCT SIMCONNECT_RECV_EVENT_WEATHER_MODE : public SIMCONNECT_RECV_EVENT{
// No event specific data - the new weather mode is in the base structure dwData member.
};
@@ -571,7 +555,6 @@ SIMCONNECT_REFSTRUCT SIMCONNECT_RECV_AIRPORT_LIST : public SIMCONNECT_RECV_FACIL
SIMCONNECT_FIXEDTYPE_DATAV(SIMCONNECT_DATA_FACILITY_AIRPORT, rgData, dwArraySize, U1 /*member of UnmanagedType enum*/, SIMCONNECT_DATA_FACILITY_AIRPORT /*cli type*/);
};
// SIMCONNECT_DATA_FACILITY_WAYPOINT
SIMCONNECT_REFSTRUCT SIMCONNECT_DATA_FACILITY_WAYPOINT : public SIMCONNECT_DATA_FACILITY_AIRPORT
{
@@ -632,7 +615,6 @@ SIMCONNECT_REFSTRUCT SIMCONNECT_RECV_PICK : public SIMCONNECT_RECV // when dwID
#endif // ENABLE_SIMCONNECT_EXPERIMENTAL
// SIMCONNECT_DATATYPE_INITPOSITION
SIMCONNECT_STRUCT SIMCONNECT_DATA_INITPOSITION
{
@@ -646,7 +628,6 @@ SIMCONNECT_STRUCT SIMCONNECT_DATA_INITPOSITION
DWORD Airspeed; // knots
};
// SIMCONNECT_DATATYPE_MARKERSTATE
SIMCONNECT_STRUCT SIMCONNECT_DATA_MARKERSTATE
{

View File

@@ -1,2 +0,0 @@
#include "Windows.h"
#include "C:\MSFS SDK\SimConnect SDK\include\SimConnect.h"