Hello.
I am making a Playstation VR game using the new Input System.
I would like to bind the control of the MoveController to the action I have.
But I can’t find the move controller device in the control picker.
I couldn’t find mapping information about the move controller anywhere.
So I want to create a custom device using the UnityEngine.PS4.PS4Input library and map it to my actions.
I researched several places and wrote the move controller custom device script.
But I’m asking because some of the codes are not clear.
[RuntimeInitializeOnLoadMethod]
private static void Initialize()
{
// It is not known if this code is correct.
// Because I couldn't find an example anywhere.
InputSystem.RegisterLayout<MoveControllerCustomDevice>(
matches: new InputDeviceMatcher()
.WithInterface("MoveController"));
InputSystem.RegisterLayoutOverride(@"
{
""name"" : ""MoveControllerWithUsageTags"",
""extend"" : ""MoveControllerCustomDevice"",
""commonUsages"" : [
""Right"", ""Left""
]
}
");
}
It’s the first confusing part.
I’d like to use commonUsages like MoveController (Right) and MoveController (Left) to separate each MoveController.
Is this code valid?
If there is any mistake, please let me know.
// This function is called when the move controller is connected.
// The isRight variable is true when creating the first connected move controller.
private static void CreateDevice(bool _IsRight)
{
if(_IsRight)
{
InputSystem.AddDeviceUsage(new MoveControllerCustomDevice(_IsRight), "Right");
}
else
{
InputSystem.AddDeviceUsage(new MoveControllerCustomDevice(_IsRight), "Left");
}
}
The second part is the CreateDevice function.
This function is invoked when the movecontroller is connected and creates an instance of MoveControllerCustomDevice and adds it to the Input System.
You want to set m_IsRight to true when the first moveController to connect is created.
I would like to know if I can create a device in this way and add it to the Input System.
Lastly, I attached the script that I wrote. I’d appreciate it if you could help me with any mistakes.
And if you know any other ways to map a MovieController, please let me know.