{"id":1202,"date":"2014-06-06T09:21:13","date_gmt":"2014-06-06T09:21:13","guid":{"rendered":"http:\/\/www.clonefactor.com\/wordpress\/?p=1202"},"modified":"2014-06-17T06:40:00","modified_gmt":"2014-06-17T06:40:00","slug":"unity3d-usb-%e9%80%a3%e6%8e%a5%e7%ad%86%e8%a8%98","status":"publish","type":"post","link":"https:\/\/www.clonefactor.com\/wordpress\/program\/unity3d\/1202\/","title":{"rendered":"Unity3D, USB \u9023\u63a5\u7b46\u8a18"},"content":{"rendered":"<h2>[\u6e96\u5099\u90e8\u4efd]<\/h2>\n<p>\u9019\u9663\u5b50\u9700\u8981\u7528\u5230\u65bc Unity3D \u4e2d\u9023\u63a5\u4e0a USB \u7684\u7248\u5b50\u76f8\u95dc\u7684\u6587\u4ef6\u4e0d\u592a\u6e05\u6670\u81ea\u5df1\u6478\u7d22\u8457\u7684\u5fc3\u5f97\u7b46\u8a18\u4e00\u4e0b.<\/p>\n<p>\u7531\u65bc USB Device \u9700\u8981\u7528\u5230 Vid(VendorID), Pid(ProductID) \u7b49\u7684\u53c3\u6578\u7528\u4f5c search index.<br \/>\n\u6240\u4ee5\u7b2c\u4e00\u6b65\u662f\u6e05\u695a\u81ea\u5df1\u6240\u7528\u7684 device \u4e0a\u7684\u5ee0\u5546\u5beb\u5165\u53c3\u6578<br \/>\nname, type&#8230;.etc<\/p>\n<p>\u65bc\u7db2\u4e0a\u4e0b\u8f09 USB Device viewer, \u76ee\u524d\u63a8\u85a6\u00a0<div class=\"aio-button\"><div class=\"aio-pulse\"><a target=\"_blank\" href=\"http:\/\/www.nirsoft.net\/utils\/usb_devices_view.html\" class=\"aio-orange\" title=\"USB Viewer\">USB Viewer<\/a><\/div><\/div><\/p>\n<p>\u57f7\u884c\u5f8c\u6703\u5217\u51fa\u96fb\u8166\u4e0a\u6709\u8a18\u9304\u904e\u7684 USB device \u6e05\u55ae.<\/p>\n<p><a href=\"http:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2014\/06\/ScreenShot001.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1204\" src=\"http:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2014\/06\/ScreenShot001-300x162.jpg\" alt=\"Unity3d USB\" width=\"300\" height=\"162\" srcset=\"https:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2014\/06\/ScreenShot001-300x162.jpg 300w, https:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2014\/06\/ScreenShot001.jpg 880w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u7136\u5f8c Find \u5230\u81ea\u5df1\u9700\u8981\u7684 USB Device. \u53d6\u5f97\u8a73\u7d30\u7684 Info. (\u6ce8: demo \u8edf\u4ef6\u8f38\u51fa\u70ba HTML report).<\/p>\n<p><a href=\"http:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2014\/06\/ScreenShot0011.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1205\" src=\"http:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2014\/06\/ScreenShot0011-237x300.jpg\" alt=\"Unity3d USB002\" width=\"237\" height=\"300\" srcset=\"https:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2014\/06\/ScreenShot0011-237x300.jpg 237w, https:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2014\/06\/ScreenShot0011.jpg 456w\" sizes=\"auto, (max-width: 237px) 100vw, 237px\" \/><\/a><\/p>\n<p>\u627e\u88e1\u982d\u7684 Vid, Pid \u7b49\u53c3\u6578\u6284\u9304\u4e00\u4e0b, \u7b49\u4e00\u4e0b\u7a0b\u5e8f\u4e0a\u9700\u8981\u4ee5 Vid, Pid \u4f5c\u70ba search index \u7684\u6307\u6a19.<\/p>\n<p>&nbsp;<\/p>\n<h2>[\u7a0b\u5e8f\u90e8\u4efd]<\/h2>\n<p>\u56de\u5230 Unity3D \u7684 editor \u4e0a, \u7531\u65bc\u76ee\u524d\u6c92\u6709\u624b\u6bb5\u53ef\u4ee5\u76f4\u63a5\u7531 Unity3D \u76f4\u63a5\u9023\u7dda\u5230\u5176\u4ed6 USB device, \u6211\u5011\u53ef\u4ee5\u5229\u7528\u5916\u90e8\u7a0b\u5e8f\u9054\u6210, \u65bc Window \u7684\u5e73\u53f0\u4e0a\u53ef\u4ee5\u5229\u7528\u5230\u574a\u9593\u7de8\u8b6f\u597d\u7684\u00a03Party \u7684\u5916\u90e8\u6a94.<\/p>\n<p>\u9019\u4e00\u6b21\u6211\u9078\u7528\u9019\u500b\u00a0<div class=\"aio-button\"><div class=\"aio-bounce\"><a target=\"_blank\" href=\"https:\/\/code.google.com\/p\/csharp-usb-hid-driver\/\" class=\"aio-orange\" title=\"C# usb hid driver\">C# usb hid driver<\/a><\/div><\/div> <span style=\"color: #999999;\"><del>(\u4f30\u8a08\u4f7f\u7528\u7387\u9084\u9817\u9ad8\u7684)<\/del><\/span><\/p>\n<p>\u6ce8 : \u5176\u5be6\u5ee0\u5bb6\u82e5\u6709\u63d0\u4f9b command line \u7684\u57f7\u884c\u65b9\u5f0f\u4e5f\u53ef\u4ee5\u7528 System.Diagnostics \u4e2d\u7684 Process \u4f86\u57f7\u884c\u5916\u90e8 &#8220;.exe, .bat&#8230;.etc&#8221; \u7684\u57f7\u884c\u5587.<\/p>\n<p>\u65bc Unity3D \u7684 project\\asset \u4e2d\u628a USBHIDDRIVER.dll \u653e\u9032 \/Plugins \u4e2d.<\/p>\n<pre class=\"brush:csharp\">using USBHIDDRIVER;\r\nusing USBHIDDRIVER.USB;\r\nusing USBHIDDRIVER.List;\r\n\r\npublic class TestUSB : MonoBehaviour\r\n{\r\n\tAwake()\r\n\t{\r\n\t\t\/\/ USBInterface _usbi = new USBInterface(\"0\"); \/\/ all device ?\r\n\t\tUSBInterface _usbi = new USBInterface(0201,0050); \/\/ when your device's vid = 0201, pid = 0050\r\n\t\tstring[] _list=new string[0];\r\n\t\tif( ReferenceEquals(null,_usbi) )\r\n\t\t{\r\n\t\t\tDebug.LogWarning(\"UNIS Device can not found.\");\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\t_list = _usbi.getDeviceList();\r\n\t\t\tDebug.Log(\"UNIS Device found.\\n &gt;&gt; \"+ string.Join(\",\",_list) );\r\n\t\t}\r\n\t}\r\n}<\/pre>\n<p>\u4ee5\u4e0a\u70ba Unity3d \u521d\u6b65\u7684 USB \u5efa\u7acb\u65b9\u5f0f.<\/p>\n<hr \/>\n<p>\u5728\u8a66\u4e86\u574a\u9593\u80fd\u627e\u5230\u7684 4,5 \u500b library \u4e4b\u5f8c, \u9084\u662f\u6c7a\u5b9a\u81ea\u5df1\u5beb\u597d\u4e86&#8230;..<\/p>\n<p>\u4e3b\u8981\u7e3d\u7d50\u7684\u6709\u4ee5\u4e0b\u5e7e\u9ede\u6ce8\u610f\u4e8b\u9805.<\/p>\n<ol>\n<li>usb \u9760 vid, pid \u8207\u786c\u9ad4\u901a\u8a0a<\/li>\n<li>\u7531 pc \u767c\u51fa usb \u6578\u64da\u6642(write), byte[] \u7684\u7b2c\u4e00\u500b\u662f\u5b57\u7bc0\u662f report ID, \u5373\u4f7f\u786c\u9ad4\u4e0d\u652f\u63f4,<br \/>\n\u7b2c\u4e00\u500b\u5b57\u7bc0\u4e5f\u9700\u4ed8\u52a0 \u7a7a\u7684 byte \u610f\u601d\u662f\u5982\u679c\u9700\u8981\u767c\u51fa byte[64] \u4f60\u9700\u8981\u65bc array \u958b\u7aef\u589e\u52a0\u4e00\u500b 0x00<br \/>\n\u4f7f\u4e4b\u8b8a\u6210 byte[65] \u4f7f\u5f8c\u9001\u51fa, \u5426\u5247\u65bc window \u5e73\u53f0\u7684\u60c5\u6cc1\u4e0b\u672c\u6b21\u901a\u8a0a\u4e0d\u80fd\u6210\u529f.\u4f60\u7684\u786c\u9ad4\u53ea\u6703\u6536\u5230 byte[63] \u5b57\u7bc0<br \/>\nReportID \u7684\u5b9a\u7fa9\u00a0:\u00a0<a href=\"http:\/\/www.clonefactor.com\/wordpress\/wp-content\/uploads\/2014\/06\/report1.pdf\">USB Reference ReportID<\/a><\/li>\n<li>\u7559\u610f treading \u7684 abort<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>[\u6e96\u5099\u90e8\u4efd] \u9019\u9663\u5b50\u9700\u8981\u7528\u5230\u65bc Unity3D \u4e2d\u9023\u63a5\u4e0a USB \u7684\u7248\u5b50\u76f8\u95dc\u7684\u6587\u4ef6\u4e0d\u592a\u6e05\u6670\u81ea\u5df1\u6478\u7d22\u8457 &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[43,57],"class_list":["post-1202","post","type-post","status-publish","format-standard","hentry","category-unity3d","tag-unity3d-2","tag-usb"],"_links":{"self":[{"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/posts\/1202","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/comments?post=1202"}],"version-history":[{"count":0,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/posts\/1202\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1202"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/categories?post=1202"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/tags?post=1202"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}