Compare commits

...

3 Commits

Author SHA1 Message Date
cb0e8dd072 Update git submodule url 2019-05-11 11:42:03 +02:00
bf5855afa3 Go back to C# stoneage to please Unity 2018-05-31 13:19:00 +02:00
7bf9f39301 Update events with GetAxis 2018-05-31 12:01:10 +02:00
4 changed files with 94 additions and 24 deletions

2
.gitmodules vendored
View File

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

View File

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

View File

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

View File

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