JaydenMaalouf / JoystickPlugin

Native Input Joystick Plugin for Unreal Engine 4/5
MIT License
30 stars 6 forks source link

Gyro/Accelerometer support #43

Closed Caffiendish closed 7 months ago

Caffiendish commented 1 year ago

I'm not sure if it's something you're interested in supporting, but I've implemented some very basic gyro/accelerometer functionality.

If you're interested in pulling that into the main plugin, you can find it here: https://github.com/Caffiendish/JoystickPlugin/tree/Gamepad-MotionSensor

It needs a newer version of the SDL library than the one in releases, though.

JaydenMaalouf commented 1 year ago

That's pretty sweet. I will have some time to review the changes in the coming weeks. Thanks for mentioning this! I assume this works with Unreal 5.2 only?

Caffiendish commented 1 year ago

I've only tried it with 5.2, but it might work on other versions, not sure. It's all very basic, and doesn't implement any events or anything, I'm only working with Joycons at the moment (no magnetometer 😞), so it's very imprecise and hacky.

Thanks for checking it out!

Caffiendish commented 1 year ago

Oh, just to clarify, when I said a newer SDL DLL, I meant I had to get the actual current SDL release, the 5.1 SDL in releases here didn't recognise my joycons as joycons, IIRC.

JaydenMaalouf commented 1 year ago

I've just released a new major version for the plugin now that UE4 is technically not required to be compiled for anymore (even though the source code is backwards compatible)

This has some major changes to the plugin but it should allow me to more easily extend the functionality of the plugin

I've taken a look at the SDL functions for sensors and it should be fairly easy to implement in the existing input loop

May be something I look into for 3.1.0!

Would you see these sensors being safe to put into Axis Mappings? Or would this be better suited for an event driven structure? I'm not sure how people would consume these sensors data haha

Caffiendish commented 1 year ago

I'm not sure either, it's just been something that I've been trying to implement some basic functionality for, to make some basic exercise gamification type games, to keep things like using the treadmill from being too boring.

I think it's probably worth asking people like JibbSmart, who makes https://github.com/JibbSmart/GamepadMotionHelpers, https://github.com/JibbSmart/JoyShockLibrary, Electronicks who maintains the https://github.com/Electronicks/JoyShockMapper now, and the gyro community they have at: https://discord.gg/b4nAm6F

JaydenMaalouf commented 1 year ago

Thanks for those resources, they're really useful!

I'm making some good headway getting the motion sensor data into the Unreal Input loop. Got some issues with the units at the moment but will continue tomorrow to see if I can sort it out

Will get you to test it out once it's ready if that's all good?

Can check the changes here if you're curious: https://github.com/JaydenMaalouf/JoystickPlugin/pull/46

Caffiendish commented 1 year ago

Sure! I don't really have much a project yet, I came to the conclusion that I'd probably need to use both Joycons on a single arm for accuracy, and then realised I could probably use my Index controllers without the HMD, as a starting point.

Turns out I was sort of mistaken :|

JaydenMaalouf commented 7 months ago

I have finally released 3.3.0 which contains support for Gyro and Accelerometer - unfortunately the math to convert these to Tilt and Gravity was beyond the scope of this plugin but feel free to add this in your own project (or even as a PR to this plugin)

Appreciate the feature request - apologies for it taking so long to become a stable build!

Caffiendish commented 6 months ago

That's great! I'll check it out soon, maybe I'll send a PR for Tilt and Gravity if I can get that cleanly supported! 👍