public static int hndh_init_cursor(ref HNStruct.HNRect r) { if (isX64) { return(HuionDriverDLL_X64.hndh_init_cursor(ref r)); } return(HuionDriverDLL_X86.hndh_init_cursor(ref r)); }
public static void startListen(IntPtr handle) { mHandle = handle; reading = true; HNStruct.HNRect r = new HNStruct.HNRect(); try { HuionDriverDLL.hndh_init_cursor(ref r); } catch (Exception ex) { HuionLog.saveLog("start draw line", ex.Message); HuionLog.saveLog("start draw line", ex.StackTrace); } mReadThread = new Thread(new ThreadStart(onRead)); mReadThread.Start(); }
public static extern int hndh_init_cursor(ref HNStruct.HNRect r);
public void SetLayoutTablet(IntPtr pconfig) { IntPtr coTaskMemAuto = Marshal.StringToCoTaskMemAuto(Application.StartupPath + "\\res\\layout_tablet.xml"); Marshal.AllocHGlobal(Marshal.SizeOf(typeof(HNStruct.HNLayoutTablet))); IntPtr num1 = HuionDriverDLL.hnx_read_layout_tablet(ref HNStruct.globalInfo.tabletInfo, pconfig, coTaskMemAuto); HNStruct.HNLayoutTablet hnLayoutTablet = new HNStruct.HNLayoutTablet(); HNStruct.HNLayoutTablet structure = (HNStruct.HNLayoutTablet)Marshal.PtrToStructure(num1, typeof(HNStruct.HNLayoutTablet)); HNStruct.globalInfo.layoutTablet = structure; HNStruct.globalInfo.hbtnLayouts = new HNStruct.HNLayoutEkey[(int)structure.hbtnNum]; int num2 = 0; Console.WriteLine("sizeof(HNLayoutTablet)={0}", (object)Marshal.SizeOf(typeof(HNStruct.HNLayoutTablet))); foreach (HNStruct.HNLayoutEkey hnLayoutEkey in MarshalPtrToStructArray <HNStruct.HNLayoutEkey>( structure.hbtnLayouts, (int)structure.hbtnNum)) { HNStruct.globalInfo.hbtnLayouts[num2++] = hnLayoutEkey; } HNStruct.globalInfo.sbtnLayouts = new HNStruct.HNLayoutEkey[(int)structure.sbtnNum]; int num3 = 0; foreach (HNStruct.HNLayoutEkey hnLayoutEkey in MarshalPtrToStructArray <HNStruct.HNLayoutEkey>( structure.sbtnLayouts, (int)structure.sbtnNum)) { HNStruct.globalInfo.sbtnLayouts[num3++] = hnLayoutEkey; } HNStruct.globalInfo.mekeyLayouts = new HNStruct.HNLayoutEkey[(int)structure.mekeyNum]; int num4 = 0; foreach (HNStruct.HNLayoutEkey hnLayoutEkey in MarshalPtrToStructArray <HNStruct.HNLayoutEkey>( structure.mekeyLayouts, (int)structure.mekeyNum)) { if (!HNStruct.globalInfo.tabletInfo.sDevType.Equals("HUION_M182")) { HNStruct.globalInfo.mekeyLayouts[num4++] = hnLayoutEkey; } else { break; } } HNStruct.globalInfo.mekeyNames = new HNStruct.HNMEkeyName[(int)structure.mekeyNum]; int index1 = 0; foreach (HNStruct.HNMEkeyName hnmEkeyName in MarshalPtrToStructArray <HNStruct.HNMEkeyName>( structure.mekeyNames, (int)structure.mekeyNum)) { Console.WriteLine(HNStruct.globalInfo.tabletInfo.sDevType); if (!HNStruct.globalInfo.tabletInfo.sDevType.Equals("HUION_M182")) { HNStruct.globalInfo.mekeyNames[index1] = hnmEkeyName; HNStruct.globalInfo.names = new string[(int)HNStruct.globalInfo.mekeyNames[index1].num]; IntPtr ptr = HNStruct.globalInfo.mekeyNames[index1].names; for (int index2 = 0; (long)index2 < (long)HNStruct.globalInfo.mekeyNames[0].num; ++index2) { switch (IntPtr.Size) { case 4: HNStruct.globalInfo.names[index2] = Marshal.PtrToStringAuto(new IntPtr((int)Marshal.PtrToStructure(ptr, typeof(int)))); ptr = new IntPtr(ptr.ToInt64() + 4L); break; case 8: HNStruct.globalInfo.names[index2] = Marshal.PtrToStringAuto( new IntPtr((long)Marshal.PtrToStructure(ptr, typeof(long)))); ptr = new IntPtr(ptr.ToInt64() + 8L); break; } } ++index1; } else { break; } } HNStruct.globalInfo.ekLayouts = new HNStruct.HNLayoutEkey[(int)structure.ekNum]; int num5 = 0; foreach (HNStruct.HNLayoutEkey hnLayoutEkey in MarshalPtrToStructArray <HNStruct.HNLayoutEkey>( structure.ekLayouts, (int)structure.ekNum)) { HNStruct.globalInfo.ekLayouts[num5++] = hnLayoutEkey; } HNStruct.HNRect penArea = structure.penArea; HNStruct.HNSize size = structure.size; HNStruct.HNRectRatio hnRectRatio; hnRectRatio.l = (float)penArea.left / (float)size.cx; hnRectRatio.r = (float)penArea.right / (float)size.cx; hnRectRatio.t = (float)penArea.top / (float)size.cy; hnRectRatio.b = (float)penArea.bottom / (float)size.cy; HNStruct.globalInfo.penareaRatio = hnRectRatio; Marshal.FreeHGlobal(coTaskMemAuto); HuionDriverDLL.hnx_free_PHNLayoutTablet(num1); }