spnav-csharp-wrapper/SpaceNavEvent.cs

62 lines
1.5 KiB
C#
Raw Normal View History

using System;
2018-05-31 09:56:21 +00:00
using System.Collections.Generic;
2018-05-30 17:15:37 +00:00
namespace SpaceNavWrapper
{
2018-05-31 09:56:21 +00:00
public enum SpaceNavAxis {
X, Y, Z, Rx, Ry, Rz
}
public class MotionEventArgs : EventArgs
2018-05-30 17:15:37 +00:00
{
2018-05-31 09:56:21 +00:00
public readonly Dictionary<SpaceNavAxis, int> axisValues;
public MotionEventArgs(int x, int y, int z, int rx, int ry, int rz)
{
2018-05-31 09:56:21 +00:00
axisValues = new Dictionary<SpaceNavAxis, int>
{
[SpaceNavAxis.X] = x,
[SpaceNavAxis.Y] = y,
[SpaceNavAxis.Z] = y,
[SpaceNavAxis.Rx] = rx,
[SpaceNavAxis.Ry] = ry,
[SpaceNavAxis.Rz] = rz
};
}
2018-05-31 09:56:21 +00:00
public int X => axisValues[SpaceNavAxis.X];
public int Y => axisValues[SpaceNavAxis.Y];
public int Z => axisValues[SpaceNavAxis.Z];
public int Rx => axisValues[SpaceNavAxis.Rx];
public int Ry => axisValues[SpaceNavAxis.Ry];
public int Rz => axisValues[SpaceNavAxis.Rz];
2018-05-30 17:15:37 +00:00
public override string ToString()
2018-05-31 09:56:21 +00:00
{
return string.Format("x={0} y={1} z={2} rx={3} ry={4} rz={5}", X, Y, Z, Rx, Ry, Rz);
}
public int GetAxis(SpaceNavAxis axis)
2018-05-30 17:15:37 +00:00
{
2018-05-31 09:56:21 +00:00
return axisValues[axis];
2018-05-30 17:15:37 +00:00
}
}
public class ButtonEventArgs : EventArgs
{
public readonly bool Pressed;
public readonly int Button;
public ButtonEventArgs(bool pressed, int button)
{
Pressed = pressed;
Button = button;
}
2018-05-31 09:56:21 +00:00
public override string ToString()
{
2018-05-31 09:56:21 +00:00
return string.Format("button={0}, pressed={1}", Button, Pressed);
}
}
2018-05-30 17:15:37 +00:00
}