simondlevy / MulticopterSim

Multi-language multirotor flight simulator using UnrealEngine
MIT License
124 stars 53 forks source link

Suggestion to use windows raw input api over joystickapi #150

Open bhowiebkr opened 2 years ago

bhowiebkr commented 2 years ago

Hey I got Windows joystickapi.h pulling a single axis from my taranis x5d in ue5. Not doing anything, just reading the values and writing it to unreal’s viewport. I noticed that it has a dead-zone around the center stick. I thought it was originally coming from the taranis but nope it’s happening in software somewhere. I’m not sure if that can be turned off in joystickapi or if it’s baked in. I suspect it’s baked in because I couldn’t find any way to disable it. For my project I’m trying to control a mini quad in Acro mode and the dead-zones are no good for that. I’ve been looking at using the windows raw input api and so far I’ve got it running in a standalone app and it seems to run well for my purposes. No abstract windows layers to get in the way and possibly slow it down.

I’m not sure your intent for this project but it might be worth it to make a switch to that api. A side benefit is you won’t have to hardcode vendor/device ids to get specific joysticks to work. You might have to remap axis as I would assume not every joystick, RC controller would have different orders of axis. BTW I’ve never seen an unreal project rely on so many languages at one time!

simondlevy commented 2 years ago

Interesting suggestion -- I'd appreciate any code you can share!

simondlevy commented 2 years ago

As for multiple programming languages: you can actually get away with using just C++ (plus whatever C# required by UE5 for you to configure the build). However because we teach several different languages in my CS department (Python, Java, Haskell), and I've worked with engineers who use only Matlab, I wanted to support as many languages as possible. It's been a great exercise having to think about how to implement the same algorithms (PID control) in so many different programming paradigms!

JaydenMaalouf commented 2 years ago

Just adding my two cents. I've found the Microsoft Joystick API to be finicky at best.

I was looking into the best (hopefully multi-platform) library to achieve joystick input within Unreal Engine. I came across a decently old plugin wrapping SDL2 - which works will all sorts of devices. However, it wasn't built for Unreal input systems.

After a while of rewriting the plugin, I now have it fully working (with force feedback support) in all versions of Unreal (4.25+).

Perhaps the plugin will work for you?

See here: https://github.com/JaydenMaalouf/JoystickPlugin