Skip to content

ddunwoody/hello-plugin-rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simplest possible X-Plane plugin in Rust

This is a trivial plugin which just prints to stdout when enabled or disabled.

This build has only been tested on Intel MacOS 12.6 and Ubuntu 22.04.

Installing into X-Plane

The built dylib should be copied into the appropriate plugin structure within X-Plane, for example:

cp target/debug/libhello_plugin_rust.dylib \ 
  <aircraft>/hello-plugin-rust/mac_x64/hello-plugin-rust.xpl

Adding more bindings

You can use xplm-sys (or bindgen directly), to generate the bindings, or you can create them manually, for example:

type XPLMCommandRef = *mut c_void;

extern "C" {
    pub fn XPLMFindCommand(inName: *const c_char) -> XPLMCommandRef;
}

extern "C" {
    pub fn XPLMCommandBegin(inCommand: XPLMCommandRef);
}

extern "C" {
    pub fn XPLMCommandEnd(inCommand: XPLMCommandRef);
}

Once added, these can be invoked once types are converted, for example:

    const DREF_NAME: &str = "sim/flight_controls/pitch_trim_up";

    let name = CString::new(DREF_NAME).expect("");
    let data_ref = XPLMFindCommand(name.as_ptr());
    XPLMCommandBegin(data_ref);
    // ...
    XPLMCommandEnd(data_ref);

About

Simplest possible X-Plane plugin written in Rust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages