{"id":4978,"date":"2022-01-14T19:41:41","date_gmt":"2022-01-14T10:41:41","guid":{"rendered":"https:\/\/now0930.pe.kr\/wordpress\/?p=4978"},"modified":"2022-01-18T02:35:40","modified_gmt":"2022-01-17T17:35:40","slug":"linux-usb-driver-xbox3604","status":"publish","type":"post","link":"https:\/\/now0930.pe.kr\/wordpress\/linux-usb-driver-xbox3604\/","title":{"rendered":"linux usb driver xbox360(4)"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">input \ud14c\uc2a4\ud2b8<\/h3>\n\n\n\n<p> usb\ub85c \ub4e4\uc5b4\uc624\ub294 \ubc84\ud2bc \uc785\ub825\uc744 \ud14c\uc2a4\ud2b8 \ud588\ub2e4. LED\ub97c \ucf1c\ub294 \ucd9c\ub825\uacfc \ube44\uc2b7\ud558\uac8c \uc9c4\ud589\ub41c\ub2e4. \uc5ed\uc2dc \ucd9c\ub825\uc744 \ubcf4\ub294 \uc791\uc5c5\uc774 \uc81c\uc77c \uc5b4\ub824\uc6e0\ub2e4.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\uc785\ub825 \ub514\ubc14\uc774\uc2a4 \ud560\ub2f9: input_allocate_device();<\/li><li>urb \ud560\ub2f9<ul><li>usb_alloc_coherent<\/li><li>usb_alloc_urb<\/li><\/ul><\/li><li>\uc778\ud130\ub7fd\ud2b8\ub85c urb \uc124\uc815: usb_rcvintpipe, usb_fill_int_urb<\/li><li>input device \uc8fc\uc18c \ubcc0\uacbd?: input_set_drvdata<\/li><li>open, close \ud568\uc218 \uc624\ubc84\ub85c\ub4dc<ul><li>input_dev-&gt;open = xpad_open<\/li><li>input_dev-&gt;close = xpad_close<\/li><\/ul><\/li><li>usb_submit_urb call back \ud568\uc218 \uc124\uc815<\/li><\/ul>\n\n\n\n<p>input_dev->close\uc5d0 usb_kill_urb\ub85c urb\ub97c \ud574\uc81c\ud558\uc9c0 \uc54a\uc73c\uba74 \ub2e4\uc2dc \uc785\ub825 \ub514\uc774\uc2a4\ub97c \uc5f4\uc5c8\uc744 \ub54c \uc0ac\uc6a9\ud560 \uc218 \uc5c6\ub2e4.<\/p>\n\n\n\n<p>xpad.c \ub4dc\ub77c\uc774\ubc84\ub294 \uc778\ud130\ub7fd\ud2b8 \uc2e4\ud589\ub420 \ub54c \uc644\ub8cc \ud568\uc218\ub97c \ub4f1\ub85d\ud588\ub2e4. \uadf8 \ud568\uc218 \uc548\uc5d0\uc788\ub294 work queue\uac00 input_report_key, input_sync\ub85c \uc785\ub825 \ud0a4\ub97c \uc774\ubca4\ud2b8\ub85c OS\uc5d0 \uc804\ub2ec\ud55c\ub2e4.<\/p>\n\n\n\n<p>\ubc84\ud2bc\uc774 \ub20c\ub838\uc744 \uacbd\uc6b0 \uc774\ubca4\ud2b8\uac00 0, 1 \uac12\uc73c\ub85c \uc804\ub2ec\ub418\uc5b4\uc57c \ud55c\ub2e4. urb\ub85c \ub4e4\uc5b4\uc624\ub294 data \ud328\ud0b7 \uc911 2\ubc88, 3\ubc88 \uc8fc\uc18c\uc5d0 mask\ub97c \uc50c\uc6cc EV_KEY \uac12 \uc0c1\ud0dc\ub97c \ud655\uc778\ud55c\ub2e4.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\uc778\ud130\ub7fd\ud2b8 \ubc1c\uc0dd \ud655\uc778.<\/li><li>urb data \uac12 \uc218\uc2e0.<\/li><li>\ud574\ub2f9\ud558\ub294 \uc8fc\uc18c\uc5d0 mask\ub97c \uc50c\uc6cc \ud2b9\uc815 \uc774\ubca4\ud2b8\ub97c OS\uc5d0 \uc804\ub2ec.<\/li><\/ul>\n\n\n\n<p>\ub9ac\ub205\uc2a4 \uc2dc\uc2a4\ud15c \ub0b4\uc5d0\uc11c \uc0ac\uc6a9\ud560 \uc218 \uc788\ub294 \uc774\ubca4\ud2b8\uac00 \uc774\ubbf8 \uc815\ud574\uc838 \uc788\uc5b4 \uc0ac\uc6a9\uc790 \ub9d8\ub300\ub85c \uc124\uc815\ud560 \uc218 \uc5c6\ub2e4. \uadf8 \ub9d0\uc740 \uc870\uc774\uc2a4\ud2f1 \uc774\ub3d9\uc744 \ub9c8\uc6b0\uc2a4 \uc774\ub3d9 \ud0a4\ub85c \ud560\ub2f9\ud558\uba74 \ub9c8\uc6b0\uc2a4 \ub300\uc2e0 \uc870\uc774\uc2a4\ud2f1\uc744 \uc0ac\uc6a9\ud560 \uc218 \uc788\ub2e8 \ub9d0\uc774\ub2e4. \uc870\uc774\uc2a4\ud2f1\uc744 \ub20c\ub800\uc744 \ub54c \uc5b4\ub290 \ub370\uc774\ud130\uac00 \ucf1c\uc9c0\ub294\uc9c0\ub294 \uae30\uae30\ub9c8\ub2e4 \ub2e4\ub974\uae30 \ub54c\ubb38\uc5d0 \uba87 \ubc88 \ud14c\uc2a4\ud2b8\ub97c \ud574\uc57c \ud55c\ub2e4.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"2000\" height=\"459\" src=\"https:\/\/now0930.pe.kr\/wordpress\/wp-content\/uploads\/2022\/01\/X360_ButtonPackets.jpg\" alt=\"\" class=\"wp-image-4984\" srcset=\"https:\/\/now0930.pe.kr\/wordpress\/wp-content\/uploads\/2022\/01\/X360_ButtonPackets.jpg 2000w, https:\/\/now0930.pe.kr\/wordpress\/wp-content\/uploads\/2022\/01\/X360_ButtonPackets-768x176.jpg 768w, https:\/\/now0930.pe.kr\/wordpress\/wp-content\/uploads\/2022\/01\/X360_ButtonPackets-1536x353.jpg 1536w, https:\/\/now0930.pe.kr\/wordpress\/wp-content\/uploads\/2022\/01\/X360_ButtonPackets-1568x360.jpg 1568w\" sizes=\"auto, (max-width: 2000px) 100vw, 2000px\" \/><figcaption><a href=\"https:\/\/www.partsnotincluded.com\/understanding-the-xbox-360-wired-controllers-usb-data\/\">data \ud328\ud0b7 \uc911 \ubc84\ud2bc \uac12 \uc704\uce58<\/a><\/figcaption><\/figure>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">static void xpad360_process_packet(struct usb_xpad *xpad, struct input_dev *dev,\n                                   u16 cmd, unsigned char *data)\n{\n        if (data[0] != 0x00)\n                return;\n        \/* buttons A,B,X,Y,TL,TR and MODE *\/\n        input_report_key(dev, BTN_A,            data[3] &amp; 0x10);\n        input_report_key(dev, BTN_B,            data[3] &amp; 0x20);\n        input_sync(dev);\n}<\/pre>\n\n\n\n<p>\uc544\ub0a0\ub85c\uadf8 \ubc84\ud2bc\uc774\ub77c\uba74 \uc5bc\ub9c8\ub098 \ub20c\ub838\ub294\uc9c0 \uac12\uc744 \uc804\ub2ec\ud560 \uc218 \uc788\ub2e4. \ucf58\uc194\uc5d0\uc11c \uc2e4\ud589 \uac00\ub2a5\ud55c evtest\ub85c \uc785\ub825\uac12\uc744 \ud655\uc778\ud560 \uc218 \uc788\ub2e4.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Xbox \uc785\ub825 \ud14c\uc2a4\ud2b8\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/go9QnIBFHbk?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>xpad.c\ub97c \uc9c1\uc811 \ud574 \ubcf4\uba74\uc11c \ub2e4\uc74c\uc744 \ud559\uc2b5\ud588\ub2e4. <a href=\"https:\/\/www.kernel.org\/doc\/html\/latest\/input\/input-programming.html\">The Linux Kernel<\/a> \uc5d0\ub294 \ub108\ubb34 \uac04\ub2e8\ud55c \uc608\uac00 \uc788\ub2e4. \ub0b4\uac00 \ubb34\uc5c7\uc744 \uc54c\uace0 \uc788\uace0, \ubaa8\ub974\ub294 \uc9c0\ub97c \uc815\ud655\ud558\uac8c \ud655\uc778\ub418\uc9c0 \uc54a\uace0\ub294 \uc704 \ubb38\uc11c\ub97c \uc81c\ub300\ub85c \uc774\ud574\ud560 \uc218 \uc5c6\ub2e4. \uc801\uc808\ud55c \uc0bd\uc9c8\ub85c \uc815\ud655\ud558\uac8c \uc774\ud574\ud560 \uc218 \uc788\ub2e4.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>usb \ub4f1\ub85d, \ud574\uc81c<\/li><li>urb packet \uc0ac\uc6a9 \ubc29\ubc95<\/li><li>input device \ub4f1\ub85d, \ud574\uc81c<\/li><li>input device \uc0ac\uc6a9<\/li><\/ul>\n\n\n\n<p>\ucc38\uc870 \uc0ac\uc774\ud2b8<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/docs.huihoo.com\/linux\/kernel\/2.6.26\/kernel-api\/re1158.html\">struct input_dev<\/a><\/li><li><a href=\"https:\/\/www.kernel.org\/doc\/html\/latest\/input\/input-programming.html\">Creating an input device driver<\/a><\/li><li><a href=\"https:\/\/www.partsnotincluded.com\/understanding-the-xbox-360-wired-controllers-usb-data\/\">Understanding the Xbox 360 Wired Controller\u2019s USB Data<\/a><\/li><li><a href=\"https:\/\/github.com\/torvalds\/linux\/blob\/master\/include\/uapi\/linux\/input-event-codes.h\">linux key codes<\/a><\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>input \ud14c\uc2a4\ud2b8 usb\ub85c \ub4e4\uc5b4\uc624\ub294 \ubc84\ud2bc \uc785\ub825\uc744 \ud14c\uc2a4\ud2b8 \ud588\ub2e4. LED\ub97c \ucf1c\ub294 \ucd9c\ub825\uacfc \ube44\uc2b7\ud558\uac8c \uc9c4\ud589\ub41c\ub2e4. \uc5ed\uc2dc \ucd9c\ub825\uc744 \ubcf4\ub294 \uc791\uc5c5\uc774 \uc81c\uc77c \uc5b4\ub824\uc6e0\ub2e4. \uc785\ub825 \ub514\ubc14\uc774\uc2a4 \ud560\ub2f9: input_allocate_device(); urb \ud560\ub2f9 usb_alloc_coherent usb_alloc_urb \uc778\ud130\ub7fd\ud2b8\ub85c urb \uc124\uc815: usb_rcvintpipe, usb_fill_int_urb input device \uc8fc\uc18c \ubcc0\uacbd?: input_set_drvdata open, close \ud568\uc218 \uc624\ubc84\ub85c\ub4dc input_dev-&gt;open = xpad_open input_dev-&gt;close = xpad_close usb_submit_urb call back \ud568\uc218 \uc124\uc815 input_dev->close\uc5d0 usb_kill_urb\ub85c urb\ub97c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":4985,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[12],"tags":[775,949,1023,53,1022,950],"class_list":["post-4978","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-12","tag-c","tag-driver","tag-led","tag-linux","tag-skeleton","tag-usb"],"jetpack_featured_media_url":"https:\/\/now0930.pe.kr\/wordpress\/wp-content\/uploads\/2022\/01\/xbox360_evtest.png","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/posts\/4978","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/comments?post=4978"}],"version-history":[{"count":7,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/posts\/4978\/revisions"}],"predecessor-version":[{"id":4987,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/posts\/4978\/revisions\/4987"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/media\/4985"}],"wp:attachment":[{"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/media?parent=4978"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/categories?post=4978"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/now0930.pe.kr\/wordpress\/wp-json\/wp\/v2\/tags?post=4978"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}