The Madder controller state is a struct used for deserializing the input sent from a player’s Madder controller app to
the Unity game. The WebGL build calls UpdateMadderControllerState() on the
Madder Manager to update the Madder controller state. The inputs from the player’s controller are sent as follows:
Name: string
Joystick: {x: float, y: float}
Triangle Button: boolean
Circle Button: boolean
Plus Button: boolean
Upon receiving the input from the player’s controller, the Madder Manager will deserialize the json object, convert to
the expected datatypes, and update the Madder Controller State with the new input values.This class, along with the Madder Controller class, defines the layout of the Madder Controller for
the Unity Input system.
MadderControllerState.cs
Copy
[System.Serializable] public struct MadderControllerState : IInputStateTypeInfo { public static FourCC Format => new FourCC('M', 'A', 'D', 'R'); public string name; [InputControl(name = "joystick", layout = "Vector2")] public Vector2 joystick; [InputControl(name = "circle", layout = "Button")] public float circle; [InputControl(name = "triangle", layout = "Button")] public float triangle; [InputControl(name = "plus", layout = "Button")] public float plus; public FourCC format => Format; }
The FourCC Format is used internally by the Unity Input System to identify the format of the input state and the layout
of the controller. There shouldn’t be a need to interact with this value.
See Madder Controller for usage with the Unity Input System.
If you are not using the Unity Input System, you may receive this information directly and interact with it as you need
by listening to the OnUpdateMadderControllerState event.
Copy
private void OnUpdateMadderControllerState(MadderControllerState madderControllerState) { //TODO: Handle player input //Example: Move player based on joystick input //if (player.name == madderControllerState.name) //{ // player.Move(madderControllerState.joystick); //} }