Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crate breaks with different build targets #21

Open
spacey-sooty opened this issue Jul 31, 2023 · 7 comments
Open

Crate breaks with different build targets #21

spacey-sooty opened this issue Jul 31, 2023 · 7 comments

Comments

@spacey-sooty
Copy link

I am attempting to write some code to control a robot in Rust using the EV3 brick and with ev3dev-lang-rust. I want to use and Xbox Controller to control it and have used this crate for Xbox control before. To use the ev3dev crate for rust you are required to use a linux musleabi toolchain which I have found a compatible dll for but the crate breaks with that build target. I attempt to call rusty_xinput::XInputHandle for my handler but the compiler tells me that it cannot find XInputHandle in rusty_xinput.
image
Would there be any way to make this crate work with different build targets or would I need to create me own interface with the dll or find a different crate? Thank you for the amazing crate and thanks for any help in advance!

@Lokathor
Copy link
Owner

https://github.com/Lokathor/rusty-xinput/blob/master/src/lib.rs#L28

This line here is what makes the whole module be effectively blank when not on windows.

Normally, I'd say we can just add a cargo feature to allow the crate to build more places if another crate provides a compatible interface, but I think that the winapi crate (which this crate depends on for many of its definitions) is itself configured to be windows only.

The docs at https://docs.rs/ev3dev-lang-rust don't seem to show the base windows definitions, how are you getting them on linux?

@spacey-sooty
Copy link
Author

First of all thank you for your help I greatly appreciate it. The ev3dev-lang-rust crate relies on you using your brick with the ev3dev Linux distro installed. This means you cannot use the crate without configuring your build target to the Linux musleabi toolchain. Essentially to my understanding it just doesn't have Windows bindings. I have attempted to use the crate without a configured build target but it just produces similar issues the the one found here. I will look into the winapi crate and see if there is any way to make this work on Linux. If not then I will have a look at some other XInput handlers as I know of at least one in a different language to Rust which is built for Linux. Thanks again for your help

@spacey-sooty
Copy link
Author

I have looked into winapi and it doesn't appear to be at all compatible with Linux not altogether shockingly. I am using this https://github.com/kozec/dumbxinputemu for an XInput dll on Linux and am now trying to port over some of the functionality used for windows onto Linux.

@Lokathor
Copy link
Owner

Lokathor commented Aug 1, 2023

If you just provide all the defines that rusty-xinput imports the rest should "just work" in terms of those definitions, though since they could theoretically vary by target and your "use xinput on linux" situation sounds rather unusual there could be some unexpected problem.

If you figure it out and get it working I'd be happy to try and integrate it back into this crate. Without your special linux device I'm bot sure how much help i can provide from my end though.

@spacey-sooty
Copy link
Author

spacey-sooty commented Aug 1, 2023

When you say provide all the defines do you mean just define them eg for XInputHandle just something like

#[cfg(not(windows))]
#[derive(clone)]
pub struct XInputHandle {}

And thank you so much for your help.

@Lokathor
Copy link
Owner

Lokathor commented Aug 1, 2023

I was thinking more like a use that imports the definition from whichever other crate, but if we have to then we could define the types directly in this crate I guess.

@spacey-sooty
Copy link
Author

Ahh ok I didn't think of that I will try have a look at both, thank you again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants