Add Gamepad buttons to Axis Config.
This commit is contained in:
@@ -157,6 +157,8 @@ void InputSettings::Deserialize(DeserializeStream& stream, ISerializeModifier* m
|
||||
config.Gamepad = JsonTools::GetEnum(v, "Gamepad", InputGamepadIndex::All);
|
||||
config.PositiveButton = JsonTools::GetEnum(v, "PositiveButton", KeyboardKeys::None);
|
||||
config.NegativeButton = JsonTools::GetEnum(v, "NegativeButton", KeyboardKeys::None);
|
||||
config.GamepadPositiveButton = JsonTools::GetEnum(v, "GamepadPositiveButton", GamepadButton::None);
|
||||
config.GamepadNegativeButton = JsonTools::GetEnum(v, "GamepadNegativeButton", GamepadButton::None);
|
||||
config.DeadZone = JsonTools::GetFloat(v, "DeadZone", 0.1f);
|
||||
config.Sensitivity = JsonTools::GetFloat(v, "Sensitivity", 0.4f);
|
||||
config.Gravity = JsonTools::GetFloat(v, "Gravity", 1.0f);
|
||||
@@ -873,8 +875,8 @@ void InputService::Update()
|
||||
const AxisData& data = Axes[name];
|
||||
|
||||
// Get key raw value
|
||||
const bool isPositiveKey = Input::GetKey(config.PositiveButton);
|
||||
const bool isNegativeKey = Input::GetKey(config.NegativeButton);
|
||||
const bool isPositiveKey = Input::GetKey(config.PositiveButton) || Input::GetGamepadButton(config.Gamepad, config.GamepadPositiveButton);
|
||||
const bool isNegativeKey = Input::GetKey(config.NegativeButton) || Input::GetGamepadButton(config.Gamepad, config.GamepadNegativeButton);
|
||||
float keyRawValue = 0;
|
||||
if (isPositiveKey && !isNegativeKey)
|
||||
{
|
||||
|
||||
@@ -87,6 +87,18 @@ API_STRUCT() struct AxisConfig
|
||||
API_FIELD(Attributes="EditorOrder(40)")
|
||||
KeyboardKeys NegativeButton;
|
||||
|
||||
/// <summary>
|
||||
/// The button to be pressed for movement in positive direction. Use <see cref="GamepadButton.None"/> to ignore it.
|
||||
/// </summary>
|
||||
API_FIELD(Attributes="EditorOrder(45)")
|
||||
GamepadButton GamepadPositiveButton;
|
||||
|
||||
/// <summary>
|
||||
/// The button to be pressed for movement in negative direction. Use <see cref="GamepadButton.None"/> to ignore it.
|
||||
/// </summary>
|
||||
API_FIELD(Attributes="EditorOrder(46)")
|
||||
GamepadButton GamepadNegativeButton;
|
||||
|
||||
/// <summary>
|
||||
/// Any positive or negative values that are less than this number will register as zero. Useful for gamepads to specify the deadzone.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user