spnav-csharp-wrapper/SpaceNavEvent.cs

101 lines
2.0 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 11:18:13 +00:00
axisValues = new Dictionary<SpaceNavAxis, int>();
axisValues[SpaceNavAxis.X] = x;
axisValues[SpaceNavAxis.Y] = y;
axisValues[SpaceNavAxis.Z] = y;
axisValues[SpaceNavAxis.Rx] = rx;
axisValues[SpaceNavAxis.Ry] = ry;
axisValues[SpaceNavAxis.Rz] = rz;
}
2018-05-31 11:18:13 +00:00
public int X
{
get
{
return axisValues[SpaceNavAxis.X];
}
}
public int Y
{
get
{
return axisValues[SpaceNavAxis.Y];
}
}
public int Z
{
get
{
return axisValues[SpaceNavAxis.Z];
}
}
public int Rx
{
get
{
return axisValues[SpaceNavAxis.Rx];
}
}
public int Ry
{
get
{
return axisValues[SpaceNavAxis.Ry];
}
}
public int Rz
{
get
{
return 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
}