I was able to get this working after coming across this c code:
github.com/signal11/hidapi/blob/master/linux/hid.c
The changes I made were:
NativeMethods.cs
public static int HIDIOCSFEATURE(int len)
{
return IOC(IOC_WRITE | IOC_READ, (byte)'H', 6, len);
}
public static int HIDIOCGFEATURE(int len)
{
return IOC(IOC_WRITE | IOC_READ, (byte)'H', 7, len);
}
[DllImport(libc, SetLastError = true)]
public static extern int ioctl(int filedes, int command, IntPtr data);
LinuxHidStream.cs
public override void GetFeature (byte[] buffer, int offset, int count)
{
byte[] data = new byte[count];
Array.Copy (buffer, offset, data, 0, count);
GetFeatureNative(data);
Array.Copy (data, 0, buffer, offset, count);
}
unsafe void GetFeatureNative(byte[] data)
{
fixed (byte* ptr = data)
{
NativeMethods.ioctl (_handle, NativeMethods.HIDIOCGFEATURE (data.Length), (IntPtr)ptr);
}
}
public override void SetFeature(byte[] buffer, int offset, int count)
{
byte[] data = new byte[count];
Array.Copy (buffer, offset, data, 0, count);
SetFeatureNative(data);
}
unsafe void SetFeatureNative(byte[] data)
{
fixed (byte* ptr = data)
{
NativeMethods.ioctl (_handle, NativeMethods.HIDIOCSFEATURE (data.Length), (IntPtr)ptr);
}
}
Hopefully it will be of use to somebody else