InControl Support
-
- Posts: 1
- Joined: Sat Feb 16, 2019 4:31 pm
InControl Support
I've been looking through the documentation for the dialogue system to determine if I want to use it in my game, but I've noticed that there is only support for Rewired and none for InControl (a similar system, but the one my team prefers). Will there be any third party support for InControl in the near future or will it be possible to use InControl with the dialogue system regardless?
Re: InControl Support
Hi,
Thanks for checking out the Dialogue System!
You can use it with InControl. The Dialogue System abstracts itself away from the input system, so it's easy to swap in a different input system. Here's the entirety of the Dialogue System's Rewired integration. As you can see, it doesn't take much. You can pretty much just copy it and replace the Rewired calls with InControl calls. If you need a hand with that, just let me know.
Thanks for checking out the Dialogue System!
You can use it with InControl. The Dialogue System abstracts itself away from the input system, so it's easy to swap in a different input system. Here's the entirety of the Dialogue System's Rewired integration. As you can see, it doesn't take much. You can pretty much just copy it and replace the Rewired calls with InControl calls. If you need a hand with that, just let me know.
InputDeviceManagerRewired.cs
Code: Select all
using UnityEngine;
using Rewired;
namespace PixelCrushers.RewiredSupport
{
/// <summary>
/// This script tells the Input Device Manager to use Rewired for
/// GetButtonDown and GetAxis checks.
/// </summary>
[AddComponentMenu("Pixel Crushers/Third Party/Rewired Support/Input Device Manager Rewired")]
public class InputDeviceManagerRewired : MonoBehaviour
{
/// <summary>
/// Rewired player ID.
/// </summary>
[Tooltip("Rewired player ID.")]
public int playerId = 0;
private Player m_player;
private void Start()
{
if (InputDeviceManager.instance == null) Debug.LogWarning("The scene is missing an Input Device Manager. Can't set up InputDeviceManagerRewired.", this);
// Tell Dialogue System to use Rewired to check button down and axis input:
InputDeviceManager.instance.GetButtonDown = RewiredGetButtonDown;
InputDeviceManager.instance.GetInputAxis = RewiredGetAxis;
m_player = ReInput.players.GetPlayer(playerId);
if (m_player == null) Debug.LogWarning("Didn't find a Rewired player #" + playerId, this);
}
public bool RewiredGetButtonDown(string buttonName)
{
return (m_player != null) ? m_player.GetButtonDown(buttonName) : Input.GetButtonDown(buttonName);
}
public float RewiredGetAxis(string axisName)
{
return (m_player != null) ? m_player.GetAxis(axisName) : Input.GetAxis(axisName);
}
}
}
Re: InControl Support
Hi Tony,
Sorry to re-open an old thread but I'm currently implementing InControl to handle my controller switching and I am at the point the OP was at when posting this thread. I am attempting to replace the calls and having some trouble figuring out how to get the player's device inputs from inControl. The game is only single player so using the 'InputManager.ActiveDevice' route to gain access to inputs should be fine. But I don't see how to connect Dialogue Manager to the ActiveDevice. I saw in another thread that it was being assigned to the Dialogue Manager Input device, but I just get a cannot convert type error, Has the method for switching the rewired support to inControl changed at all in the past year? Or am I just missing something?
Cheers,
Rob
Sorry to re-open an old thread but I'm currently implementing InControl to handle my controller switching and I am at the point the OP was at when posting this thread. I am attempting to replace the calls and having some trouble figuring out how to get the player's device inputs from inControl. The game is only single player so using the 'InputManager.ActiveDevice' route to gain access to inputs should be fine. But I don't see how to connect Dialogue Manager to the ActiveDevice. I saw in another thread that it was being assigned to the Dialogue Manager Input device, but I just get a cannot convert type error, Has the method for switching the rewired support to inControl changed at all in the past year? Or am I just missing something?
Cheers,
Rob
Re: InControl Support
Hi Rob,
It follows a similar format. It's been a while since I've used InControl. I don't remember if it has an editor to set bindings, so I just set them in a script. Here's an example scene:
DS_InControlExample_2020-04-20.unitypackage
And here's the script from the example scene package:
InputDeviceManagerInControl.cs
It follows a similar format. It's been a while since I've used InControl. I don't remember if it has an editor to set bindings, so I just set them in a script. Here's an example scene:
DS_InControlExample_2020-04-20.unitypackage
And here's the script from the example scene package:
InputDeviceManagerInControl.cs
Code: Select all
using UnityEngine;
using InControl;
namespace PixelCrushers.InControlSupport
{
/// <summary>
/// This script tells the Input Device Manager to use InControl for GetButtonDown and GetAxis checks.
/// </summary>
public class InputDeviceManagerInControl : MonoBehaviour
{
public MyActions actions;
private void Start()
{
if (InputDeviceManager.instance == null) Debug.LogWarning("The scene is missing an Input Device Manager. Can't set up InputDeviceManagerInControl.", this);
// Tell Dialogue System to use InControl to check button and axis input:
InputDeviceManager.instance.GetButtonDown = InControlGetButtonDown;
InputDeviceManager.instance.GetButtonUp = InControlGetButtonUp;
InputDeviceManager.instance.GetInputAxis = InControlGetAxis;
actions = new MyActions();
}
public bool InControlGetButtonDown(string buttonName)
{
return actions.GetPlayerActionByName(buttonName).WasPressed;
}
public bool InControlGetButtonUp(string buttonName)
{
return actions.GetPlayerActionByName(buttonName).WasReleased;
}
public float InControlGetAxis(string axisName)
{
switch (axisName)
{
case "Mouse X": return actions.MouseX.Value;
case "Mouse Y": return actions.MouseY.Value;
case "Horizontal": return actions.Horizontal.Value;
case "Vertical": return actions.Vertical.Value;
}
return actions.GetPlayerActionByName(axisName).Value;
}
}
public class MyActions : PlayerActionSet
{
public PlayerOneAxisAction MouseX;
public PlayerOneAxisAction MouseY;
public PlayerOneAxisAction Horizontal;
public PlayerOneAxisAction Vertical;
public MyActions()
{
var Fire1 = CreatePlayerAction("Fire1");
Fire1.AddDefaultBinding(Key.Space);
var Use = CreatePlayerAction("Use");
Use.AddDefaultBinding(Key.E);
var Cancel = CreatePlayerAction("Cancel");
Cancel.AddDefaultBinding(Key.Backspace);
var MouseLeft = CreatePlayerAction("Mouse Left");
var MouseRight = CreatePlayerAction("Mouse Right");
var MouseUp = CreatePlayerAction("Mouse Up");
var MouseDown = CreatePlayerAction("Mouse Down");
MouseLeft.AddDefaultBinding(Mouse.NegativeX);
MouseRight.AddDefaultBinding(Mouse.PositiveX);
MouseUp.AddDefaultBinding(Mouse.PositiveY);
MouseDown.AddDefaultBinding(Mouse.NegativeY);
MouseX = CreateOneAxisPlayerAction(MouseLeft, MouseRight);
MouseY = CreateOneAxisPlayerAction(MouseDown, MouseUp);
var Left = CreatePlayerAction("Left");
var Right = CreatePlayerAction("Right");
var Up = CreatePlayerAction("Up");
var Down = CreatePlayerAction("Down");
Left.AddDefaultBinding(Key.LeftArrow);
Right.AddDefaultBinding(Key.RightArrow);
Up.AddDefaultBinding(Key.UpArrow);
Down.AddDefaultBinding(Key.DownArrow);
Horizontal = CreateOneAxisPlayerAction(Left, Right);
Vertical = CreateOneAxisPlayerAction(Down, Up);
}
}
}
Re: InControl Support
Thanks for the info Tony. Seeing the formatting helped a tonne. The entire project is now running through the inControl actions system .
Cheers again,
Rob
Cheers again,
Rob
Re: InControl Support
Great! Glad to help.