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"] [submodule "spacenav-driver"]
path = 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 # 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 #region Properties
public double Sensitivity public double Sensitivity
{ {
get => _sensitivity; get
{
return _sensitivity;
}
set set
{ {
_sensitivity = value; _sensitivity = value;
@ -120,26 +124,34 @@ namespace SpaceNavWrapper
public int Threshold public int Threshold
{ {
get => _threshold; get
{
return _threshold;
}
set set
{ {
_threshold = value; _threshold = value;
spnav_deadzone(value); spnav_deadzone(value);
} }
} }
public bool Nonblocking public bool Nonblocking
{ {
get => _nonblocking; get
{
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,26 +1,83 @@
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; axisValues[SpaceNavAxis.X] = x;
Z = z; axisValues[SpaceNavAxis.Y] = y;
Rx = rx; axisValues[SpaceNavAxis.Z] = y;
Ry = ry; axisValues[SpaceNavAxis.Rx] = rx;
Rz = rz; axisValues[SpaceNavAxis.Ry] = ry;
axisValues[SpaceNavAxis.Rz] = rz;
} }
public override string ToString() public int X
{ {
return "x=" + X + " y=" + Y + " z=" + Z + get
" rx=" + Rz + " ry=" + Ry + " rz=" + Rz; {
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; 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);
} }
} }
} }