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

Works in editor, but not in builds #8

Open
ryanslikesocool opened this issue Jul 6, 2021 · 3 comments
Open

Works in editor, but not in builds #8

ryanslikesocool opened this issue Jul 6, 2021 · 3 comments

Comments

@ryanslikesocool
Copy link

As the title says, the plugin works in the Unity Editor (I'm using 2021.1.12f1) but not in builds. I've tested builds on macOS and Windows, wired and wireless. None of them seem to work. There aren't any preprocessors that I could see that would exclude code from builds.

@ryanslikesocool
Copy link
Author

I've found what's causing the issue. No fix yet though. The package doesn't seem to like being built with IL2CPP. Building with Mono works fine.

@ryanslikesocool
Copy link
Author

Figured out a fix, but it's not nice.

IL2CPP builds require a "Fast" (precompiled) version of the input code. Luckily, that part can be easily generated with the Input System debugger window. This also requires that the Input System package version is 1.1.0 (or later), since certain bits of code in the generated script are only exposed in that version.

As for the nasty part, I Initially thought that the DualSense code had to be registered before the DualShock 4 code, but I was wrong. I haven't quite figured out how it works, but the DualSense initialization code has to be called around the same time as the DS4 code. I've only been able to get it working by calling DualSenseGamepadHID.Initialize() in PerformDefaultPluginInitialization() inside InputSystem.cs.

@GerodruS
Copy link

I had another issue with il2cpp, when gamepad works perfect at editor, but at builds starts to messed up with what buttons was pressed. For example: stick up was always pressed.

In my case there was a bug at unity/il2cpp, that cause FieldOffset attribute did not work properly.
Adding the line to DualSenseHIDInputReport.cs file fixed the issue for me:

        [InputControl(name = "rightTrigger", format = "BYTE")] [FieldOffset(6)]
        public byte rightTrigger;

        [FieldOffset(7)] public byte _notUsedByte7; // <-- this line

        [InputControl(name = "dpad", format = "BIT", layout = "Dpad", sizeInBits = 4, defaultState = 8)]

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