зеркало из https://github.com/stride3d/opentk.git
[OpenTK] Protect against invalid axis/button ids
This commit is contained in:
Родитель
e6a9adf494
Коммит
44e2576c86
|
@ -130,22 +130,28 @@ namespace OpenTK.Input
|
|||
|
||||
internal void SetAxis(JoystickAxis axis, float @value)
|
||||
{
|
||||
move_args.Axis = axis;
|
||||
move_args.Delta = move_args.Value - @value;
|
||||
axis_collection[axis] = move_args.Value = @value;
|
||||
Move(this, move_args);
|
||||
if ((int)axis < axis_collection.Count)
|
||||
{
|
||||
move_args.Axis = axis;
|
||||
move_args.Delta = move_args.Value - @value;
|
||||
axis_collection[axis] = move_args.Value = @value;
|
||||
Move(this, move_args);
|
||||
}
|
||||
}
|
||||
|
||||
internal void SetButton(JoystickButton button, bool @value)
|
||||
{
|
||||
if (button_collection[button] != @value)
|
||||
if ((int)button < button_collection.Count)
|
||||
{
|
||||
button_args.Button = button;
|
||||
button_collection[button] = button_args.Pressed = @value;
|
||||
if (@value)
|
||||
ButtonDown(this, button_args);
|
||||
else
|
||||
ButtonUp(this, button_args);
|
||||
if (button_collection[button] != @value)
|
||||
{
|
||||
button_args.Button = button;
|
||||
button_collection[button] = button_args.Pressed = @value;
|
||||
if (@value)
|
||||
ButtonDown(this, button_args);
|
||||
else
|
||||
ButtonUp(this, button_args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче