Update events with GetAxis

This commit is contained in:
Thibaud Gasser 2018-05-31 11:56:21 +02:00
parent 6b16cee62b
commit 7bf9f39301

View File

@ -1,26 +1,44 @@
using System; using System;
using System.Collections.Generic;
namespace SpaceNavWrapper namespace SpaceNavWrapper
{ {
public enum SpaceNavAxis {
X, Y, Z, Rx, Ry, Rz
}
public class MotionEventArgs : EventArgs public class MotionEventArgs : EventArgs
{ {
public readonly int X, Y, Z; public readonly Dictionary<SpaceNavAxis, int> axisValues;
public readonly int Rx, Ry, Rz;
public MotionEventArgs(int x, int y, int z, int rx, int ry, int rz) public MotionEventArgs(int x, int y, int z, int rx, int ry, int rz)
{ {
X = x; axisValues = new Dictionary<SpaceNavAxis, int>
Y = y; {
Z = z; [SpaceNavAxis.X] = x,
Rx = rx; [SpaceNavAxis.Y] = y,
Ry = ry; [SpaceNavAxis.Z] = y,
Rz = rz; [SpaceNavAxis.Rx] = rx,
[SpaceNavAxis.Ry] = ry,
[SpaceNavAxis.Rz] = rz
};
} }
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];
public override string ToString() public override string ToString()
{ {
return "x=" + X + " y=" + Y + " z=" + Z + return string.Format("x={0} y={1} z={2} rx={3} ry={4} rz={5}", X, Y, Z, Rx, Ry, Rz);
" rx=" + Rz + " ry=" + Ry + " rz=" + Rz; }
public int GetAxis(SpaceNavAxis axis)
{
return axisValues[axis];
} }
} }
@ -34,9 +52,10 @@ namespace SpaceNavWrapper
Pressed = pressed; Pressed = pressed;
Button = button; Button = button;
} }
public override string ToString() public override string ToString()
{ {
return string.Format("[ButtonEventArgs: button={0}, pressed={1}]", Button, Pressed); return string.Format("button={0}, pressed={1}", Button, Pressed);
} }
} }
} }