diff --git a/mediaportal/MiniDisplayLibrary/MiniDisplayPlugin/VFD_Control/DeviceManagement.cs b/mediaportal/MiniDisplayLibrary/MiniDisplayPlugin/VFD_Control/DeviceManagement.cs
index 21efd6db41b..5732403a243 100644
--- a/mediaportal/MiniDisplayLibrary/MiniDisplayPlugin/VFD_Control/DeviceManagement.cs
+++ b/mediaportal/MiniDisplayLibrary/MiniDisplayPlugin/VFD_Control/DeviceManagement.cs
@@ -151,9 +151,8 @@ internal static bool FindDeviceFromGuid(Guid myGuid, ref string[] devicePathName
// no more devices are available.
// The cbSize element of the MyDeviceInterfaceData structure must be set to
- // the structure's size in bytes. The size is 28 bytes.
- MyDeviceInterfaceData.cbSize = 28;
- //Marshal.SizeOf(MyDeviceInterfaceData);
+ // the structure's size in bytes.
+ MyDeviceInterfaceData.cbSize = Marshal.SizeOf(MyDeviceInterfaceData);
// ***
// API function:
@@ -184,7 +183,11 @@ internal static bool FindDeviceFromGuid(Guid myGuid, ref string[] devicePathName
if (Result == 0)
{
- LastDevice = true;
+ int iLastError = Marshal.GetLastWin32Error();
+ if (iLastError == DeviceManagementApiDeclarations.ERROR_NO_MORE_ITEMS)
+ LastDevice = true;
+ else
+ throw new System.ComponentModel.Win32Exception(iLastError);
}
else
{
@@ -234,7 +237,7 @@ internal static bool FindDeviceFromGuid(Guid myGuid, ref string[] devicePathName
IntPtr DetailDataBuffer = Marshal.AllocHGlobal(BufferSize);
// Store cbSize in the first 4 bytes of the array
- Marshal.WriteInt32(DetailDataBuffer, 4 + Marshal.SystemDefaultCharSize);
+ Marshal.WriteInt32(DetailDataBuffer, IntPtr.Size == 4 ? 4 + Marshal.SystemDefaultCharSize : 8);
Debug.WriteLine("cbsize = " + MyDeviceInterfaceDetailData.cbSize);
// Call SetupDiGetDeviceInterfaceDetail again.
diff --git a/mediaportal/MiniDisplayLibrary/MiniDisplayPlugin/VFD_Control/DeviceManagementDeclarations.cs b/mediaportal/MiniDisplayLibrary/MiniDisplayPlugin/VFD_Control/DeviceManagementDeclarations.cs
index c2499d133f9..f7eaf82d998 100644
--- a/mediaportal/MiniDisplayLibrary/MiniDisplayPlugin/VFD_Control/DeviceManagementDeclarations.cs
+++ b/mediaportal/MiniDisplayLibrary/MiniDisplayPlugin/VFD_Control/DeviceManagementDeclarations.cs
@@ -46,6 +46,8 @@ internal sealed class DeviceManagementApiDeclarations
public const short DIGCF_PRESENT = 0x00000002;
public const short DIGCF_DEVICEINTERFACE = 0x00000010;
+ public const int ERROR_NO_MORE_ITEMS = 259;
+
// ******************************************************************************
// Structures and classes for API calls, listed alphabetically
// ******************************************************************************
@@ -59,31 +61,31 @@ internal sealed class DeviceManagementApiDeclarations
// API functions, listed alphabetically
// ******************************************************************************
- [DllImport("user32.dll", CharSet = CharSet.Auto)]
+ [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern IntPtr RegisterDeviceNotification(IntPtr hRecipient, IntPtr NotificationFilter, int Flags);
- [DllImport("setupapi.dll")]
+ [DllImport("setupapi.dll", SetLastError = true)]
public static extern int SetupDiCreateDeviceInfoList(ref Guid ClassGuid, int hwndParent);
- [DllImport("setupapi.dll")]
+ [DllImport("setupapi.dll", SetLastError = true)]
public static extern int SetupDiDestroyDeviceInfoList(IntPtr DeviceInfoSet);
- [DllImport("setupapi.dll")]
+ [DllImport("setupapi.dll", SetLastError = true)]
public static extern int SetupDiEnumDeviceInterfaces(IntPtr DeviceInfoSet, int DeviceInfoData,
ref Guid InterfaceClassGuid, int MemberIndex,
ref SP_DEVICE_INTERFACE_DATA DeviceInterfaceData);
- [DllImport("setupapi.dll", CharSet = CharSet.Auto)]
+ [DllImport("setupapi.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern IntPtr SetupDiGetClassDevs(ref Guid ClassGuid, string Enumerator, int hwndParent, int Flags);
- [DllImport("setupapi.dll", CharSet = CharSet.Auto)]
+ [DllImport("setupapi.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern bool SetupDiGetDeviceInterfaceDetail(IntPtr DeviceInfoSet,
ref SP_DEVICE_INTERFACE_DATA DeviceInterfaceData,
IntPtr DeviceInterfaceDetailData,
int DeviceInterfaceDetailDataSize, ref int RequiredSize,
IntPtr DeviceInfoData);
- [DllImport("user32.dll")]
+ [DllImport("user32.dll", SetLastError = true)]
public static extern bool UnregisterDeviceNotification(IntPtr Handle);
[StructLayout(LayoutKind.Sequential)]
@@ -110,10 +112,11 @@ public class DEV_BROADCAST_DEVICEINTERFACE_1
public int dbcc_devicetype;
public int dbcc_reserved;
- [MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.U1, SizeConst = 16)] public byte[]
- dbcc_classguid;
+ [MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.U1, SizeConst = 16)]
+ public byte[] dbcc_classguid;
- [MarshalAs(UnmanagedType.ByValArray, SizeConst = 255)] public char[] dbcc_name;
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 255)]
+ public char[] dbcc_name;
#endregion
}
@@ -126,9 +129,12 @@ public class DEV_BROADCAST_HANDLE
public int dbch_size;
public int dbch_devicetype;
public int dbch_reserved;
- public int dbch_handle;
- public int dbch_hdevnotify;
-
+ public IntPtr dbch_handle;
+ public IntPtr dbch_hdevnotify;
+ public Guid dbch_eventguid;
+ public int dbch_nameoffset;
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1, ArraySubType = UnmanagedType.I1)]
+ public byte[] dbch_data;
#endregion
}
@@ -152,7 +158,7 @@ public struct SP_DEVICE_INTERFACE_DATA
public int cbSize;
public Guid InterfaceClassGuid;
public int Flags;
- public int Reserved;
+ public IntPtr Reserved;
#endregion
}
@@ -176,7 +182,7 @@ public struct SP_DEVINFO_DATA
public int cbSize;
public Guid ClassGuid;
public int DevInst;
- public int Reserved;
+ public IntPtr Reserved;
#endregion
}
diff --git a/mediaportal/MiniDisplayLibrary/MiniDisplayPlugin/VFD_Control/FileIODeclarations.cs b/mediaportal/MiniDisplayLibrary/MiniDisplayPlugin/VFD_Control/FileIODeclarations.cs
index d162ee4c861..6a3c37cfbee 100644
--- a/mediaportal/MiniDisplayLibrary/MiniDisplayPlugin/VFD_Control/FileIODeclarations.cs
+++ b/mediaportal/MiniDisplayLibrary/MiniDisplayPlugin/VFD_Control/FileIODeclarations.cs
@@ -18,6 +18,7 @@
#endregion
+using System;
using System.Runtime.InteropServices;
namespace MediaPortal.ProcessPlugins.MiniDisplayPlugin.VFD_Control
@@ -35,7 +36,7 @@ internal class FileIOApiDeclarations
public const uint FILE_SHARE_READ = 0x00000001;
public const uint FILE_SHARE_WRITE = 0x00000002;
public const uint FILE_FLAG_OVERLAPPED = 0x40000000;
- public const int INVALID_HANDLE_VALUE = -1;
+ public static readonly IntPtr INVALID_HANDLE_VALUE = new IntPtr(-1);
public const short OPEN_EXISTING = 3;
public const int WAIT_TIMEOUT = 0x102;
public const short WAIT_OBJECT_0 = 0;
@@ -48,56 +49,60 @@ internal class FileIOApiDeclarations
// API functions, listed alphabetically
// ******************************************************************************
- [DllImport("kernel32.dll")]
- public static extern int CancelIo(int hFile);
+ [DllImport("kernel32.dll", SetLastError = true)]
+ public static extern int CancelIo(IntPtr hFile);
- [DllImport("kernel32.dll")]
- public static extern int CloseHandle(int hObject);
+ [DllImport("kernel32.dll", SetLastError = true)]
+ public static extern int CloseHandle(IntPtr hObject);
- [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
- public static extern int CreateEvent(ref SECURITY_ATTRIBUTES SecurityAttributes, int bManualReset, int bInitialState,
+ [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
+ public static extern IntPtr CreateEvent(ref SECURITY_ATTRIBUTES SecurityAttributes, int bManualReset, int bInitialState,
string lpName);
- [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
- public static extern int
+ [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
+ public static extern IntPtr
CreateFile(string lpFileName, uint dwDesiredAccess, uint dwShareMode, ref SECURITY_ATTRIBUTES lpSecurityAttributes,
- int dwCreationDisposition, uint dwFlagsAndAttributes, int hTemplateFile);
+ int dwCreationDisposition, uint dwFlagsAndAttributes, IntPtr hTemplateFile);
- [DllImport("kernel32.dll")]
- public static extern int ReadFile(int hFile, ref byte lpBuffer, int nNumberOfBytesToRead,
+ [DllImport("kernel32.dll", SetLastError = true)]
+ public static extern int ReadFile(IntPtr hFile, ref byte lpBuffer, int nNumberOfBytesToRead,
ref int lpNumberOfBytesRead, ref OVERLAPPED lpOverlapped);
- [DllImport("kernel32.dll")]
- public static extern int WaitForSingleObject(int hHandle, int dwMilliseconds);
+ [DllImport("kernel32.dll", SetLastError = true)]
+ public static extern int WaitForSingleObject(IntPtr hHandle, int dwMilliseconds);
- [DllImport("kernel32.dll")]
- public static extern int WriteFile(int hFile, ref byte lpBuffer, int nNumberOfBytesToWrite,
+ [DllImport("kernel32.dll", SetLastError = true)]
+ public static extern int WriteFile(IntPtr hFile, ref byte lpBuffer, int nNumberOfBytesToWrite,
ref int lpNumberOfBytesWritten, int lpOverlapped);
- [StructLayout(LayoutKind.Sequential)]
+ [StructLayout(LayoutKind.Explicit, Size = 20)]
public struct OVERLAPPED
{
- #region Fields
+ [FieldOffset(0)]
+ public uint Internal;
+
+ [FieldOffset(4)]
+ public uint InternalHigh;
+
+ [FieldOffset(8)]
+ public uint Offset;
- public int Internal;
- public int InternalHigh;
- public int Offset;
- public int OffsetHigh;
- public int hEvent;
+ [FieldOffset(12)]
+ public uint OffsetHigh;
- #endregion
+ [FieldOffset(8)]
+ public IntPtr Pointer;
+
+ [FieldOffset(16)]
+ public IntPtr hEvent;
}
[StructLayout(LayoutKind.Sequential)]
public struct SECURITY_ATTRIBUTES
{
- #region Fields
-
public int nLength;
- public int lpSecurityDescriptor;
+ public IntPtr lpSecurityDescriptor;
public int bInheritHandle;
-
- #endregion
}
}
}
\ No newline at end of file
diff --git a/mediaportal/MiniDisplayLibrary/MiniDisplayPlugin/VFD_Control/Hid.cs b/mediaportal/MiniDisplayLibrary/MiniDisplayPlugin/VFD_Control/Hid.cs
index e663c7dfe83..880f8a8fd64 100644
--- a/mediaportal/MiniDisplayLibrary/MiniDisplayPlugin/VFD_Control/Hid.cs
+++ b/mediaportal/MiniDisplayLibrary/MiniDisplayPlugin/VFD_Control/Hid.cs
@@ -46,7 +46,7 @@ internal class Hid
///
/// a handle to a device.
/// True on success, False on failure.
- internal static bool FlushQueue(int hidHandle)
+ internal static bool FlushQueue(IntPtr hidHandle)
{
bool Result = false;
@@ -79,7 +79,7 @@ internal static bool FlushQueue(int hidHandle)
///
/// a handle to a device.
/// An HIDP_CAPS structure.
- internal HidApiDeclarations.HIDP_CAPS GetDeviceCapabilities(int hidHandle)
+ internal HidApiDeclarations.HIDP_CAPS GetDeviceCapabilities(IntPtr hidHandle)
{
byte[] PreparsedDataBytes = new byte[30];
IntPtr PreparsedDataPointer = new IntPtr();
@@ -172,7 +172,7 @@ internal HidApiDeclarations.HIDP_CAPS GetDeviceCapabilities(int hidHandle)
// Accepts: A pointer to the PreparsedData structure returned by HidD_GetPreparsedData.
// Returns: True on success, False on failure.
// ***
- HidApiDeclarations.HidD_FreePreparsedData(ref PreparsedDataPointer);
+ HidApiDeclarations.HidD_FreePreparsedData(PreparsedDataPointer);
if (Settings.Instance.ExtensiveLogging)
{
@@ -218,7 +218,7 @@ internal abstract class DeviceReport
// asynchronous reads use a callback method that can access parameters passed by ByRef
// but not Function return values.
- protected abstract void ProtectedRead(int readHandle, int hidHandle, ref bool myDeviceDetected,
+ protected abstract void ProtectedRead(IntPtr readHandle, IntPtr hidHandle, ref bool myDeviceDetected,
ref byte[] readBuffer, ref bool success);
///
@@ -234,7 +234,7 @@ protected abstract void ProtectedRead(int readHandle, int hidHandle, ref bool my
/// tells whether the device is currently attached and communicating.
/// a byte array to hold the report ID and report data.
/// read success
- internal void Read(int readHandle, int hidHandle, ref bool myDeviceDetected, ref byte[] readBuffer,
+ internal void Read(IntPtr readHandle, IntPtr hidHandle, ref bool myDeviceDetected, ref byte[] readBuffer,
ref bool success)
{
try
@@ -263,7 +263,7 @@ internal class InFeatureReport : DeviceReport
/// tells whether the device is currently attached.
/// contains the requested report.
/// read success
- protected override void ProtectedRead(int readHandle, int hidHandle, ref bool myDeviceDetected,
+ protected override void ProtectedRead(IntPtr readHandle, IntPtr hidHandle, ref bool myDeviceDetected,
ref byte[] inFeatureReportBuffer, ref bool success)
{
try
@@ -308,7 +308,7 @@ internal class InputReport : DeviceReport
///
/// the handle for reading from the device.
/// the handle for other device communications.
- internal void CancelTransfer(int readHandle, int hidHandle)
+ internal void CancelTransfer(IntPtr readHandle, IntPtr hidHandle)
{
try
{
@@ -329,7 +329,7 @@ internal void CancelTransfer(int readHandle, int hidHandle)
// so close any open handles and
// set myDeviceDetected=False to cause the application to
// look for the device on the next attempt.
- if (hidHandle != 0)
+ if (hidHandle != IntPtr.Zero)
{
FileIOApiDeclarations.CloseHandle(hidHandle);
if (Settings.Instance.ExtensiveLogging)
@@ -339,7 +339,7 @@ internal void CancelTransfer(int readHandle, int hidHandle)
}
}
- if (hidHandle != 0)
+ if (hidHandle != IntPtr.Zero)
{
FileIOApiDeclarations.CloseHandle(readHandle);
if (Settings.Instance.ExtensiveLogging)
@@ -361,14 +361,14 @@ internal void CancelTransfer(int readHandle, int hidHandle)
///
///
///
- internal void PrepareForOverlappedTransfer(ref FileIOApiDeclarations.OVERLAPPED hidOverlapped, ref int eventObject)
+ internal void PrepareForOverlappedTransfer(ref FileIOApiDeclarations.OVERLAPPED hidOverlapped, ref IntPtr eventObject)
{
FileIOApiDeclarations.SECURITY_ATTRIBUTES Security = new FileIOApiDeclarations.SECURITY_ATTRIBUTES();
try
{
// Values for the SECURITY_ATTRIBUTES structure:
- Security.lpSecurityDescriptor = 0;
+ Security.lpSecurityDescriptor = IntPtr.Zero;
Security.bInheritHandle = Convert.ToInt32(true);
Security.nLength = Marshal.SizeOf(Security);
@@ -411,10 +411,10 @@ internal void PrepareForOverlappedTransfer(ref FileIOApiDeclarations.OVERLAPPED
/// tells whether the device is currently attached.
/// contains the requested report.
/// read success
- protected override void ProtectedRead(int readHandle, int hidHandle, ref bool myDeviceDetected,
+ protected override void ProtectedRead(IntPtr readHandle, IntPtr hidHandle, ref bool myDeviceDetected,
ref byte[] inputReportBuffer, ref bool success)
{
- int EventObject = 0;
+ IntPtr EventObject = IntPtr.Zero;
FileIOApiDeclarations.OVERLAPPED HIDOverlapped = new FileIOApiDeclarations.OVERLAPPED();
int NumberOfBytesRead = 0;
@@ -525,7 +525,7 @@ internal class InputReportViaControlTransfer : DeviceReport
/// tells whether the device is currently attached.
/// contains the requested report.
/// read success
- protected override void ProtectedRead(int readHandle, int hidHandle, ref bool myDeviceDetected,
+ protected override void ProtectedRead(IntPtr readHandle, IntPtr hidHandle, ref bool myDeviceDetected,
ref byte[] inputReportBuffer, ref bool success)
{
try
@@ -562,7 +562,7 @@ protected override void ProtectedRead(int readHandle, int hidHandle, ref bool my
///
internal abstract class HostReport
{
- protected abstract bool ProtectedWrite(int deviceHandle, byte[] reportBuffer);
+ protected abstract bool ProtectedWrite(IntPtr deviceHandle, byte[] reportBuffer);
///
/// Calls the overridden ProtectedWrite routine.
@@ -575,7 +575,7 @@ internal abstract class HostReport
/// contains the report ID and report data.
/// handle to the device.
/// True on success. False on failure.
- internal bool Write(byte[] reportBuffer, int deviceHandle)
+ internal bool Write(byte[] reportBuffer, IntPtr deviceHandle)
{
bool Success = false;
@@ -603,7 +603,7 @@ internal class OutFeatureReport : HostReport
/// a handle to the device.
/// contains the report ID and report to send.
/// True on success. False on failure.
- protected override bool ProtectedWrite(int hidHandle, byte[] outFeatureReportBuffer)
+ protected override bool ProtectedWrite(IntPtr hidHandle, byte[] outFeatureReportBuffer)
{
bool Success = false;
@@ -653,7 +653,7 @@ internal class OutputReport : HostReport
/// a handle to the device.
/// contains the report ID and report to send.
/// True on success. False on failure.
- protected override bool ProtectedWrite(int hidHandle, byte[] outputReportBuffer)
+ protected override bool ProtectedWrite(IntPtr hidHandle, byte[] outputReportBuffer)
{
int NumberOfBytesWritten = 0;
bool Success = false;
@@ -711,7 +711,7 @@ internal class OutputReportViaControlTransfer : HostReport
/// a handle to the device.
/// contains the report ID and report to send.
/// True on success. False on failure.
- protected override bool ProtectedWrite(int hidHandle, byte[] outputReportBuffer)
+ protected override bool ProtectedWrite(IntPtr hidHandle, byte[] outputReportBuffer)
{
bool Success = false;
diff --git a/mediaportal/MiniDisplayLibrary/MiniDisplayPlugin/VFD_Control/HidDeclarations.cs b/mediaportal/MiniDisplayLibrary/MiniDisplayPlugin/VFD_Control/HidDeclarations.cs
index f6b9e46c9f6..ca4afafa009 100644
--- a/mediaportal/MiniDisplayLibrary/MiniDisplayPlugin/VFD_Control/HidDeclarations.cs
+++ b/mediaportal/MiniDisplayLibrary/MiniDisplayPlugin/VFD_Control/HidDeclarations.cs
@@ -46,37 +46,37 @@ internal sealed class HidApiDeclarations
// ******************************************************************************
[DllImport("hid.dll", SetLastError = true)]
- public static extern bool HidD_FlushQueue(int HidDeviceObject);
+ public static extern bool HidD_FlushQueue(IntPtr HidDeviceObject);
[DllImport("hid.dll", SetLastError = true)]
- public static extern bool HidD_FreePreparsedData(ref IntPtr PreparsedData);
+ public static extern bool HidD_FreePreparsedData(IntPtr PreparsedData);
[DllImport("hid.dll", SetLastError = true)]
- public static extern int HidD_GetAttributes(int HidDeviceObject, ref HIDD_ATTRIBUTES Attributes);
+ public static extern int HidD_GetAttributes(IntPtr HidDeviceObject, ref HIDD_ATTRIBUTES Attributes);
[DllImport("hid.dll", SetLastError = true)]
- public static extern bool HidD_GetFeature(int HidDeviceObject, ref byte lpReportBuffer, int ReportBufferLength);
+ public static extern bool HidD_GetFeature(IntPtr HidDeviceObject, ref byte lpReportBuffer, int ReportBufferLength);
[DllImport("hid.dll", SetLastError = true)]
- public static extern bool HidD_GetInputReport(int HidDeviceObject, ref byte lpReportBuffer, int ReportBufferLength);
+ public static extern bool HidD_GetInputReport(IntPtr HidDeviceObject, ref byte lpReportBuffer, int ReportBufferLength);
[DllImport("hid.dll", SetLastError = true)]
public static extern void HidD_GetHidGuid(out Guid HidGuid);
[DllImport("hid.dll", SetLastError = true)]
- public static extern bool HidD_GetNumInputBuffers(int HidDeviceObject, ref int NumberBuffers);
+ public static extern bool HidD_GetNumInputBuffers(IntPtr HidDeviceObject, ref int NumberBuffers);
[DllImport("hid.dll", SetLastError = true)]
- public static extern bool HidD_GetPreparsedData(int HidDeviceObject, ref IntPtr PreparsedData);
+ public static extern bool HidD_GetPreparsedData(IntPtr HidDeviceObject, ref IntPtr PreparsedData);
[DllImport("hid.dll", SetLastError = true)]
- public static extern bool HidD_SetFeature(int HidDeviceObject, ref byte lpReportBuffer, int ReportBufferLength);
+ public static extern bool HidD_SetFeature(IntPtr HidDeviceObject, ref byte lpReportBuffer, int ReportBufferLength);
[DllImport("hid.dll", SetLastError = true)]
- public static extern bool HidD_SetNumInputBuffers(int HidDeviceObject, int NumberBuffers);
+ public static extern bool HidD_SetNumInputBuffers(IntPtr HidDeviceObject, int NumberBuffers);
[DllImport("hid.dll", SetLastError = true)]
- public static extern bool HidD_SetOutputReport(int HidDeviceObject, ref byte lpReportBuffer, int ReportBufferLength);
+ public static extern bool HidD_SetOutputReport(IntPtr HidDeviceObject, ref byte lpReportBuffer, int ReportBufferLength);
[DllImport("hid.dll", SetLastError = true)]
public static extern int HidP_GetCaps(IntPtr PreparsedData, ref HIDP_CAPS Capabilities);
@@ -125,47 +125,92 @@ public struct HIDP_CAPS
[StructLayout(LayoutKind.Sequential)]
- public struct HidP_Value_Caps
+ public struct HidP_Range
{
- #region Fields
+ public short UsageMin;
+ public short UsageMax;
+ public short StringMin;
+ public short StringMax;
+ public short DesignatorMin;
+ public short DesignatorMax;
+ public short DataIndexMin;
+ public short DataIndexMax;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ public struct HidP_NotRange
+ {
+ public short Usage;
+ public short Reserved1;
+ public short StringIndex;
+ public short Reserved2;
+ public short DesignatorIndex;
+ public short Reserved3;
+ public short DataIndex;
+ public short Reserved4;
+ }
+ [StructLayout(LayoutKind.Explicit)]
+ public struct HidP_Value_Caps
+ {
+ [FieldOffset(0)]
public ushort UsagePage;
+ [FieldOffset(2)]
public byte ReportID;
- public int IsAlias;
+ [FieldOffset(3), MarshalAs(UnmanagedType.U1)]
+ public bool IsAlias;
+ [FieldOffset(4)]
public ushort BitField;
+ [FieldOffset(6)]
public ushort LinkCollection;
+ [FieldOffset(8)]
public ushort LinkUsage;
+ [FieldOffset(10)]
public ushort LinkUsagePage;
- public int IsRange; // If IsRange is false, UsageMin is the Usage and UsageMax is unused.
- public int IsStringRange; // If IsStringRange is false, StringMin is the string index and StringMax is unused.
-
- public int IsDesignatorRange;
- // If IsDesignatorRange is false, DesignatorMin is the designator index and DesignatorMax is unused.
-
- public int IsAbsolute;
- public int HasNull;
+ [FieldOffset(12), MarshalAs(UnmanagedType.U1)]
+ public bool IsRange; // If IsRange is false, UsageMin is the Usage and UsageMax is unused.
+ [FieldOffset(13), MarshalAs(UnmanagedType.U1)]
+ public bool IsStringRange; // If IsStringRange is false, StringMin is the string index and StringMax is unused.
+ [FieldOffset(14), MarshalAs(UnmanagedType.U1)]
+ public bool IsDesignatorRange; // If IsDesignatorRange is false, DesignatorMin is the designator index and DesignatorMax is unused.
+ [FieldOffset(15), MarshalAs(UnmanagedType.U1)]
+ public bool IsAbsolute;
+ [FieldOffset(16), MarshalAs(UnmanagedType.U1)]
+ public bool HasNull;
+ [FieldOffset(17)]
public byte Reserved;
- public ushort BitSize;
- public ushort ReportCount;
- public ushort Reserved2;
- public ushort Reserved3;
- public ushort Reserved4;
- public ushort Reserved5;
- public ushort Reserved6;
+ [FieldOffset(18)]
+ public short BitSize;
+ [FieldOffset(20)]
+ public short ReportCount;
+ [FieldOffset(22)]
+ public ushort Reserved2a;
+ [FieldOffset(24)]
+ public ushort Reserved2b;
+ [FieldOffset(26)]
+ public ushort Reserved2c;
+ [FieldOffset(28)]
+ public ushort Reserved2d;
+ [FieldOffset(30)]
+ public ushort Reserved2e;
+ [FieldOffset(32)]
+ public int UnitsExp;
+ [FieldOffset(36)]
+ public int Units;
+ [FieldOffset(40)]
public int LogicalMin;
+ [FieldOffset(44)]
public int LogicalMax;
+ [FieldOffset(48)]
public int PhysicalMin;
+ [FieldOffset(52)]
public int PhysicalMax;
- public ushort UsageMin;
- public ushort UsageMax;
- public ushort StringMin;
- public ushort StringMax;
- public ushort DesignatorMin;
- public ushort DesignatorMax;
- public ushort DataIndexMin;
- public ushort DataIndexMax;
- #endregion
+ [FieldOffset(56)]
+ public HidP_Range Range;
+ [FieldOffset(56)]
+ public HidP_NotRange NotRange;
+
}
}
}
\ No newline at end of file
diff --git a/mediaportal/MiniDisplayLibrary/MiniDisplayPlugin/VFD_Control/VFD_Control.cs b/mediaportal/MiniDisplayLibrary/MiniDisplayPlugin/VFD_Control/VFD_Control.cs
index bc63110ca76..23bfbdf8cdb 100644
--- a/mediaportal/MiniDisplayLibrary/MiniDisplayPlugin/VFD_Control/VFD_Control.cs
+++ b/mediaportal/MiniDisplayLibrary/MiniDisplayPlugin/VFD_Control/VFD_Control.cs
@@ -51,7 +51,7 @@ public class control
#region Fields
- private int _HIDHandle;
+ private IntPtr _HIDHandle;
private bool _MyDeviceDetected;
private int _Volume = -1;
private readonly bool[] FICIconStatus = new bool[50];
@@ -87,7 +87,7 @@ private bool FindTheHid()
_MyDeviceDetected = false;
// Values for the SECURITY_ATTRIBUTES structure:
- Security.lpSecurityDescriptor = 0;
+ Security.lpSecurityDescriptor = IntPtr.Zero;
Security.bInheritHandle = Convert.ToInt32(true);
Security.nLength = Marshal.SizeOf(Security);
@@ -144,7 +144,7 @@ private bool FindTheHid()
FileIOApiDeclarations.GENERIC_READ | FileIOApiDeclarations.GENERIC_WRITE,
FileIOApiDeclarations.FILE_SHARE_READ | FileIOApiDeclarations.FILE_SHARE_WRITE,
ref Security,
- FileIOApiDeclarations.OPEN_EXISTING, 0, 0);
+ FileIOApiDeclarations.OPEN_EXISTING, 0, IntPtr.Zero);
if (Settings.Instance.ExtensiveLogging)
{
@@ -616,7 +616,7 @@ public void Shutdown()
try
{
// Close open handles to the device.
- if (_HIDHandle != 0)
+ if (_HIDHandle != IntPtr.Zero)
{
FileIOApiDeclarations.CloseHandle(_HIDHandle);
if (Settings.Instance.ExtensiveLogging)