Trying to sort out our interop nicely.
authorStephaneLenclud
Wed, 06 May 2015 21:25:49 +0200
changeset 37d3b88ef66bfe
parent 36 3b94d0640115
child 38 10d8128ccc60
Trying to sort out our interop nicely.
Interop/MiniDisplay.cs
LibMiniDisplay.nuspec
     1.1 --- a/Interop/MiniDisplay.cs	Wed May 06 21:03:53 2015 +0200
     1.2 +++ b/Interop/MiniDisplay.cs	Wed May 06 21:25:49 2015 +0200
     1.3 @@ -3,30 +3,30 @@
     1.4  using System.Text;
     1.5  using System.Runtime.InteropServices;
     1.6  
     1.7 -namespace MiniDisplay
     1.8 +namespace MiniDisplayInterop
     1.9  {
    1.10 -    public class Interop
    1.11 +	public class MiniDisplay
    1.12      {
    1.13  
    1.14  		//[Serializable]
    1.15 -		public enum TMiniDisplayType
    1.16 +		public enum Type
    1.17  		{
    1.18 -			EMiniDisplayAutoDetect, /*Not yet implemented*/
    1.19 +			AutoDetect, /*Not yet implemented*/
    1.20  			//[EnumMember(Value = "EMiniDisplayFutabaGP1212A01")]
    1.21 -			EMiniDisplayFutabaGP1212A01,
    1.22 +			FutabaGP1212A01,
    1.23  			//[EnumMember(Value = "EMiniDisplayFutabaGP1212A01")]
    1.24 -			EMiniDisplayFutabaGP1212A02
    1.25 +			FutabaGP1212A02
    1.26  		};
    1.27  
    1.28  		/// <summary>
    1.29  		/// 
    1.30  		/// </summary>
    1.31 -		public enum TMiniDisplayRequest
    1.32 +		public enum Request
    1.33  		{
    1.34 -			EMiniDisplayRequestNone,
    1.35 -			EMiniDisplayRequestDeviceId,
    1.36 -			EMiniDisplayRequestFirmwareRevision,
    1.37 -			EMiniDisplayRequestPowerSupplyStatus
    1.38 +			None,
    1.39 +			DeviceId,
    1.40 +			FirmwareRevision,
    1.41 +			PowerSupplyStatus
    1.42  		};
    1.43  
    1.44  
    1.45 @@ -34,117 +34,117 @@
    1.46  		/// Define the various type of icons we support.
    1.47  		/// For binary compatibility new entries must be added at the end.
    1.48  		/// </summary>
    1.49 -		public enum TMiniDisplayIconType
    1.50 +		public enum IconType
    1.51  		{
    1.52 -			EMiniDisplayIconNetworkSignal = 0,
    1.53 -			EMiniDisplayIconInternet,
    1.54 -			EMiniDisplayIconEmail,
    1.55 -			EMiniDisplayIconMute,
    1.56 -			EMiniDisplayIconVolume,
    1.57 -			EMiniDisplayIconVolumeLabel,
    1.58 -			EMiniDisplayIconPlay,
    1.59 -			EMiniDisplayIconPause,
    1.60 -			EMiniDisplayIconRecording
    1.61 +			NetworkSignal = 0,
    1.62 +			Internet,
    1.63 +			Email,
    1.64 +			Mute,
    1.65 +			Volume,
    1.66 +			VolumeLabel,
    1.67 +			Play,
    1.68 +			Pause,
    1.69 +			Recording
    1.70  		};
    1.71  
    1.72 -		[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
    1.73 -		public static extern IntPtr MiniDisplayOpen(TMiniDisplayType aType);
    1.74 +		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayOpen", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
    1.75 +		public static extern IntPtr Open(Type aType);
    1.76  
    1.77 -		[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
    1.78 -		public static extern void MiniDisplayClose(IntPtr aDevice);
    1.79 +		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayClose", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
    1.80 +		public static extern void Close(IntPtr aDevice);
    1.81  
    1.82 -		[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
    1.83 -		public static extern int MiniDisplayTypeCount();
    1.84 +		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayTypeCount", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
    1.85 +		public static extern int TypeCount();
    1.86  
    1.87 -		[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
    1.88 -		public static extern IntPtr MiniDisplayTypeName(TMiniDisplayType aType);
    1.89 +		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayTypeName", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
    1.90 +		public static extern IntPtr TypeName(Type aType);
    1.91  
    1.92 -		[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
    1.93 -		public static extern void MiniDisplayClear(IntPtr aDevice);
    1.94 +		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayClear", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
    1.95 +		public static extern void Clear(IntPtr aDevice);
    1.96  
    1.97 -		[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
    1.98 -		public static extern void MiniDisplayFill(IntPtr aDevice);
    1.99 +		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayFill", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.100 +		public static extern void Fill(IntPtr aDevice);
   1.101  
   1.102 -		[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.103 -		public static extern void MiniDisplaySwapBuffers(IntPtr aDevice);
   1.104 +		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplaySwapBuffers", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.105 +		public static extern void SwapBuffers(IntPtr aDevice);
   1.106  
   1.107 -		[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.108 -		public static extern void MiniDisplaySetBrightness(IntPtr aDevice, int aBrightness);
   1.109 +		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplaySetBrightness", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.110 +		public static extern void SetBrightness(IntPtr aDevice, int aBrightness);
   1.111  
   1.112 -		[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.113 -		public static extern int MiniDisplayMinBrightness(IntPtr aDevice);
   1.114 +		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayMinBrightness", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.115 +		public static extern int MinBrightness(IntPtr aDevice);
   1.116  
   1.117 -		[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.118 -		public static extern int MiniDisplayMaxBrightness(IntPtr aDevice);
   1.119 +		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayMaxBrightness", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.120 +		public static extern int MaxBrightness(IntPtr aDevice);
   1.121  
   1.122 -		[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.123 -		public static extern int MiniDisplayWidthInPixels(IntPtr aDevice);
   1.124 +		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayWidthInPixels", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.125 +		public static extern int WidthInPixels(IntPtr aDevice);
   1.126  
   1.127 -		[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.128 -		public static extern int MiniDisplayHeightInPixels(IntPtr aDevice);
   1.129 +		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayHeightInPixels", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.130 +		public static extern int HeightInPixels(IntPtr aDevice);
   1.131  
   1.132 -		[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.133 -		public static extern int MiniDisplaySetPixel(IntPtr aDevice, int aX, int aY, uint aValue);
   1.134 +		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplaySetPixel", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.135 +		public static extern int SetPixel(IntPtr aDevice, int aX, int aY, uint aValue);
   1.136  
   1.137 -		[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.138 -		public static extern IntPtr MiniDisplayVendor(IntPtr aDevice);
   1.139 +		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayVendor", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.140 +		public static extern IntPtr Vendor(IntPtr aDevice);
   1.141  
   1.142 -		[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.143 -		public static extern IntPtr MiniDisplayProduct(IntPtr aDevice);
   1.144 +		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayProduct", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.145 +		public static extern IntPtr Product(IntPtr aDevice);
   1.146  
   1.147 -		[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.148 -		public static extern IntPtr MiniDisplaySerialNumber(IntPtr aDevice);
   1.149 +		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplaySerialNumber", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.150 +		public static extern IntPtr SerialNumber(IntPtr aDevice);
   1.151  
   1.152 -		[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.153 -		public static extern IntPtr MiniDisplayDeviceId(IntPtr aDevice);
   1.154 +		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayDeviceId", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.155 +		public static extern IntPtr DeviceId(IntPtr aDevice);
   1.156  
   1.157 -		[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.158 -		public static extern IntPtr MiniDisplayFirmwareRevision(IntPtr aDevice);
   1.159 +		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayFirmwareRevision", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.160 +		public static extern IntPtr FirmwareRevision(IntPtr aDevice);
   1.161  
   1.162 -		[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.163 +		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayPowerSupplyStatus", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.164  		[return: MarshalAs(UnmanagedType.I1)]
   1.165 -		public static extern bool MiniDisplayPowerSupplyStatus(IntPtr aDevice);
   1.166 +		public static extern bool PowerSupplyStatus(IntPtr aDevice);
   1.167  
   1.168 -		[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.169 -		public static extern void MiniDisplayRequest(IntPtr aDevice, TMiniDisplayRequest aRequest);
   1.170 +		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayRequest", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.171 +		public static extern void SendRequest(IntPtr aDevice, Request aRequest);
   1.172  
   1.173 -		[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.174 -		public static extern TMiniDisplayRequest MiniDisplayAttemptRequestCompletion(IntPtr aDevice);
   1.175 +		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayAttemptRequestCompletion", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.176 +		public static extern Request AttemptRequestCompletion(IntPtr aDevice);
   1.177  
   1.178 -		[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.179 -		public static extern TMiniDisplayRequest MiniDisplayCurrentRequest(IntPtr aDevice);
   1.180 +		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayCurrentRequest", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.181 +		public static extern Request CurrentRequest(IntPtr aDevice);
   1.182  
   1.183 -		[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.184 -		public static extern void MiniDisplayCancelRequest(IntPtr aDevice);
   1.185 +		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayCancelRequest", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.186 +		public static extern void CancelRequest(IntPtr aDevice);
   1.187  
   1.188 -		[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.189 -		public static extern void MiniDisplayPowerOn(IntPtr aDevice);
   1.190 +		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayClose", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.191 +		public static extern void PowerOn(IntPtr aDevice);
   1.192  
   1.193 -		[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.194 -		public static extern void MiniDisplayPowerOff(IntPtr aDevice);
   1.195 +		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayPowerOff", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.196 +		public static extern void PowerOff(IntPtr aDevice);
   1.197  
   1.198 -		[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.199 +		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplaySupportPowerOnOff", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.200  		[return: MarshalAs(UnmanagedType.I1)]
   1.201 -		public static extern bool MiniDisplaySupportPowerOnOff(IntPtr aDevice);
   1.202 +		public static extern bool SupportPowerOnOff(IntPtr aDevice);
   1.203  
   1.204 -		[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.205 -		public static extern void MiniDisplayShowClock(IntPtr aDevice);
   1.206 +		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayShowClock", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.207 +		public static extern void ShowClock(IntPtr aDevice);
   1.208  
   1.209 -		[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.210 -		public static extern void MiniDisplayHideClock(IntPtr aDevice);
   1.211 +		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayHideClock", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.212 +		public static extern void HideClock(IntPtr aDevice);
   1.213  
   1.214 -		[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.215 +		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplaySupportClock", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.216  		[return: MarshalAs(UnmanagedType.I1)]
   1.217 -		public static extern bool MiniDisplaySupportClock(IntPtr aDevice);
   1.218 +		public static extern bool SupportClock(IntPtr aDevice);
   1.219  
   1.220 -		[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.221 -		public static extern int MiniDisplayIconCount(IntPtr aDevice, TMiniDisplayIconType aIcon);
   1.222 +		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayIconCount", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.223 +		public static extern int IconCount(IntPtr aDevice, IconType aIcon);
   1.224  
   1.225 -		[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.226 -		public static extern int MiniDisplayIconStatusCount(IntPtr aDevice, TMiniDisplayIconType aIcon);
   1.227 +		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplayIconStatusCount", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.228 +		public static extern int IconStatusCount(IntPtr aDevice, IconType aIcon);
   1.229  
   1.230 -		[DllImport("MiniDisplay.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.231 -		public static extern void MiniDisplaySetIconStatus(IntPtr aDevice, TMiniDisplayIconType aIcon, int aIndex, int aStatus);
   1.232 +		[DllImport("MiniDisplay.dll", EntryPoint = "MiniDisplaySetIconStatus", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
   1.233 +		public static extern void SetIconStatus(IntPtr aDevice, IconType aIcon, int aIndex, int aStatus);
   1.234  
   1.235  
   1.236      }
     2.1 --- a/LibMiniDisplay.nuspec	Wed May 06 21:03:53 2015 +0200
     2.2 +++ b/LibMiniDisplay.nuspec	Wed May 06 21:25:49 2015 +0200
     2.3 @@ -2,7 +2,7 @@
     2.4  <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
     2.5      <metadata>
     2.6          <id>LibMiniDisplay</id>
     2.7 -        <version>1.1.3</version>
     2.8 +        <version>1.1.4</version>
     2.9          <title>Mini Display Library</title>
    2.10          <authors>Stéphane Lenclud</authors>
    2.11          <licenseUrl>https://www.gnu.org/copyleft/gpl.html</licenseUrl>