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

Add sensor API implementation #1131

Merged
merged 10 commits into from Oct 10, 2021
Merged

Add sensor API implementation #1131

merged 10 commits into from Oct 10, 2021

Conversation

Yamakaky
Copy link

@Yamakaky Yamakaky commented Jul 28, 2021

Fixes #1123 .

Still draft for now. Edit: ready to merge

Documentation and examples are very minimal for this feature. Best use I could find is at https://github.com/Electronicks/JoyShockMapper/blob/master/JoyShockMapper/src/SDL2Wrapper.cpp.

Missing:

  • integration in the event loop
  • doc
  • test different controllers, for now dualshock 4 works but switch ones doesn't. Update: 2.0.16 is out with better switch support.

@Yamakaky
Copy link
Author

How can I try this crate with the master version of SDL2 ? There has been significant changes since 2.0.14.

@Cobrand
Copy link
Member

Cobrand commented Jul 28, 2021

How can I try this crate with the master version of SDL2 ? There has been significant changes since 2.0.14.

I doubt it's breaking changes, SDL2 is heavily against breaking anything, only adding new calls.

There is no way to build and link to master directly via this crate, but you could try to compile SDL2 yourself, and link it the old way with rustflags. That, or you can use "bundled" and change build.rs to point to the master source code tarball instead of the 2.0.14 one temporarily.

@Yamakaky
Copy link
Author

By "significant changes", I mean "gyro and accel work on switch controllers instead of not working" ^^

@Yamakaky
Copy link
Author

TODO: add sensor events.

@Yamakaky
Copy link
Author

Ready to merge.

@Yamakaky Yamakaky changed the title First try at sensor API implementation Add sensor API implementation Aug 21, 2021
src/sdl2/sensor.rs Outdated Show resolved Hide resolved
src/sdl2/sensor.rs Outdated Show resolved Hide resolved
src/sdl2/sensor.rs Outdated Show resolved Hide resolved
src/sdl2/event.rs Outdated Show resolved Hide resolved
@Yamakaky
Copy link
Author

The CI error is because SDL 2.0.10 is installed, which doesn't support the new features. What could be done? Conditional compilation?

@Cobrand
Copy link
Member

Cobrand commented Aug 21, 2021

The CI error is because SDL 2.0.10 is installed, which doesn't support the new features. What could be done? Conditional compilation?

Update CI to 2.0.14 somehow?

Mikaël Fourrier added 2 commits August 21, 2021 19:53
@Yamakaky
Copy link
Author

github uses Ubuntu 2020 focal which uses sdl 2.0.10. https://launchpad.net/ubuntu/+source/libsdl2. The new calls are on 2.0.14.

@Cobrand
Copy link
Member

Cobrand commented Aug 22, 2021

Skip this example for pkg-config? Those functions probably won't be linked if they aren't used by any rust code (probably)

@Yamakaky
Copy link
Author

Just disabled sensors.rs for build-linux, we'll see if it works.

@Yamakaky
Copy link
Author

Oops, missing --features

@Yamakaky
Copy link
Author

Yamakaky commented Sep 2, 2021

updated

@Yamakaky
Copy link
Author

Yamakaky commented Sep 6, 2021

I think I need to add sensors as an optional feature. We can't ship a version that doesn't compile on the latest ubuntu.

@Yamakaky
Copy link
Author

Ended up adding a default hidapi feature, should work this time. After that I'll cleanup the commits a bit.

@Cobrand Cobrand merged commit 6a31d31 into Rust-SDL2:master Oct 10, 2021
@Yamakaky Yamakaky deleted the sensor-api branch October 10, 2021 18:14
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

Successfully merging this pull request may close these issues.

Add support for the sensor API
2 participants