Compare commits

..

No commits in common. "master" and "rewrite-events" have entirely different histories.

4 changed files with 23 additions and 93 deletions

2
.gitmodules vendored
View File

@ -1,3 +1,3 @@
[submodule "spacenav-driver"] [submodule "spacenav-driver"]
path = spacenav-driver path = spacenav-driver
url = https://github.com/thib8956/spacenav-driver.git url = https://git.digiserv.ovh/thibaud/spacenav-driver.git

View File

@ -1,3 +1,3 @@
# spnav-csharp-wrapper # spnav-csharp-wrapper
Simple C# wrapper for the [HID spacenavigator driver](https://github.com/thib8956/spacenav-driver.git) Simple C# wrapper for the HID spacenavigator [driver](https://git.digiserv.ovh/thibaud/spacenav-driver)

View File

@ -110,11 +110,7 @@ namespace SpaceNavWrapper
#region Properties #region Properties
public double Sensitivity public double Sensitivity
{ {
get get => _sensitivity;
{
return _sensitivity;
}
set set
{ {
_sensitivity = value; _sensitivity = value;
@ -124,34 +120,26 @@ namespace SpaceNavWrapper
public int Threshold public int Threshold
{ {
get get => _threshold;
{
return _threshold;
}
set set
{ {
_threshold = value; _threshold = value;
spnav_deadzone(value); spnav_deadzone(value);
} }
} }
public bool Nonblocking public bool Nonblocking
{ {
get get => _nonblocking;
{
return _nonblocking;
}
set set
{ {
_nonblocking = value; _nonblocking = value;
spnav_set_nonblocking(value); spnav_set_nonblocking(value);
} }
} }
#endregion #endregion
public void Dispose() public void Dispose()
{ {
if (!isDisposed) if (!isDisposed)
{ {

View File

@ -1,83 +1,26 @@
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 Dictionary<SpaceNavAxis, int> axisValues; public readonly int X, Y, Z;
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)
{ {
axisValues = new Dictionary<SpaceNavAxis, int>(); X = x;
axisValues[SpaceNavAxis.X] = x; Y = y;
axisValues[SpaceNavAxis.Y] = y; Z = z;
axisValues[SpaceNavAxis.Z] = y; Rx = rx;
axisValues[SpaceNavAxis.Rx] = rx; Ry = ry;
axisValues[SpaceNavAxis.Ry] = ry; Rz = rz;
axisValues[SpaceNavAxis.Rz] = rz;
} }
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];
}
}
public override string ToString() public override string ToString()
{
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)
{ {
return axisValues[axis]; return "x=" + X + " y=" + Y + " z=" + Z +
" rx=" + Rz + " ry=" + Ry + " rz=" + Rz;
} }
} }
@ -91,10 +34,9 @@ namespace SpaceNavWrapper
Pressed = pressed; Pressed = pressed;
Button = button; Button = button;
} }
public override string ToString() public override string ToString()
{ {
return string.Format("button={0}, pressed={1}", Button, Pressed); return string.Format("[ButtonEventArgs: button={0}, pressed={1}]", Button, Pressed);
} }
} }
} }