If I am trying to abstract out my input is it wise to use event messaging for the left and right sticks on a controller? I am just wondering if there is a better way to handle this. The event messaging is great for things like buttons, just not sure if I should use it for the sticks. Since I am capturing input through fixedupdate, it seems like this might be a few too many messages.
private void FixedUpdate()
{
_inputDevice = InControl.InputManager.ActiveDevice;
_leftStickX = _inputDevice.LeftStickX;
_leftStickY = _inputDevice.LeftStickY;
_rightStickX = _inputDevice.RightStickX;
_rightStickY = _inputDevice.RightStickY;
LeftStickUpdate();
RightStickUpdate();
LeftShoulderButtonUpdate();
RightShoulderButtonUpdate();
Action1ButtonUpdate();
Action2ButtonUpdate();
Action3ButtonUpdate();
Action4ButtonUpdate();
}
#region ANALOG STICKS
private void LeftStickUpdate()
{
if (_leftStickX != 0.0f || _leftStickY != 0.0f)
{
object[] paramsArray = new object[2] {_leftStickX, _leftStickY};
MessageDispatcher.SendMessage(this, InputEventNameConst.OnLeftStickUpdate, paramsArray, 0);
}
}
private void RightStickUpdate()
{
if (_rightStickX == 0 && _rightStickY == 0)
{
object[] paramsArray = new object[2] {_leftStickX, _leftStickY};
MessageDispatcher.SendMessage(this, InputEventNameConst.OnRightStickUpdate, paramsArray, 0);
}
else
{
object[] paramsArray = new object[2] {_rightStickX, _rightStickY};
MessageDispatcher.SendMessage(this, InputEventNameConst.OnRightStickUpdate, paramsArray, 0);
}
}