stm32 hid游戏手柄程序
用USB键盘程序修改成了 USB游戏手柄,是3轴 12按钮的
用手头的STM32F103C8T6最小系统板 测试过 可以用了
USB每次传输5字节
1:x轴
2:y轴
3:滑块
4 :按钮 1234
5 :按钮5678 9 10 11 12
需要修改的地方很多 我就不详细说了
提供一个程序工程下载的链接
https://pan.baidu.com/s/1hLlRVM9_cqiK7TQGxUGQVQ
const u8 CustomHID_DeviceDescriptor[CUSTOMHID_SIZ_DEVICE_DESC] =
{
0x12, /*bLength */
USB_DEVICE_DESCRIPTOR_TYPE, /*bDescriptorType*/
0x01, /*bcdUSB */
0x10,
0x00, /*bDeviceClass*/
0x00, /*bDeviceSubClass*/
0x00, /*bDeviceProtocol*/
0x40, /*bMaxPacketSize40*/
0xF3, /*idVendor (0x0483)*/
0x04,
0x04, /*idProduct = 0x5750*/
0x01,
0x00, /*bcdDevice rel. 2.00*/
0x02,
1, /*Index of string descriptor describing
manufacturer */
2, /*Index of string descriptor describing
product*/
3, /*Index of string descriptor describing the
device serial number */
0x01 /*bNumConfigurations*/
}
; /* CustomHID_DeviceDescriptor */
/* USB Configuration Descriptor */
/* All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */
const u8 CustomHID_ConfigDescriptor[CUSTOMHID_SIZ_CONFIG_DESC] =
{
0x09, /* bLength: Configuation Descriptor size */
USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType: Configuration */
CUSTOMHID_SIZ_CONFIG_DESC,
/* wTotalLength: Bytes returned */
0x00,
0x01, /* bNumInterfaces: 1 interface */
0x01, /* bConfigurationValue: Configuration value */
0x00, /* iConfiguration: Index of string descriptor describing
the configuration*/
0xC0, /* bmAttributes: Bus powered */
/*Bus powered: 7th bit, Self Powered: 6th bit, Remote wakeup: 5th bit, reserved: 4..0 bits */
0x32, /* MaxPower 100 mA: this current is used for detecting Vbus */
// 0x96, /* MaxPower 300 mA: this current is used for detecting Vbus */
/************** Descriptor of Custom HID interface ****************/
/* 09 */
0x09, /* bLength: Interface Descriptor size */
USB_INTERFACE_DESCRIPTOR_TYPE,/* bDescriptorType: Interface descriptor type */
0x00, /* bInterfaceNumber: Number of Interface */
0x00, /* bAlternateSetting: Alternate setting */
0x01, /* bNumEndpoints */
0x03, /* bInterfaceClass: HID */
0x01, /* bInterfaceSubClass : 1=BOOT, 0=no boot */
0x00, /* nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse */
0, /* iInterface: Index of string descriptor */
/******************** Descriptor of Custom HID HID ********************/
/* 18 */
0x09, /* bLength: HID Descriptor size */
HID_DESCRIPTOR_TYPE, /* bDescriptorType: HID */
0x00, /* bcdHID: HID Class Spec release number */
0x01,
0x00, /* bCountryCode: Hardware target country */
0x01, /* bNumDescriptors: Number of HID class descriptors to follow */
0x22, /* bDescriptorType */
CUSTOMHID_SIZ_REPORT_DESC,/* wItemLength: Total length of Report descriptor */
0x00,
/******************** Descriptor of Custom HID endpoints ******************/
/* 27 */
0x07, /* bLength: Endpoint Descriptor size */
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: */
0x81, /* bEndpointAddress: Endpoint Address (IN) */
// bit 3...0 : the endpoint number
// bit 6...4 : reserved
// bit 7 : 0(OUT), 1(IN)
0x03, /* bmAttributes: Interrupt endpoint */
0x05,//0x02, /* wMaxPacketSize: 20 Bytes max */
0x00,
0x20, /* bInterval: Polling Interval (21 ms) */
/* 34 */
}
; /* CustomHID_ConfigDescriptor */
const u8 CustomHID_ReportDescriptor[CUSTOMHID_SIZ_REPORT_DESC] =
{
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x05, // USAGE (Game Pad)
0xa1, 0x01, // COLLECTION (Application)
0x09, 0x01, // USAGE (Pointer)
0xa1, 0x00, // COLLECTION (Physical)
0x09, 0x30, // USAGE (X)
0x09, 0x31, // USAGE (Y)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255)
0x35, 0x00, // PHYSICAL_MINIMUM (0)
0x46, 0xff, 0x7f, // PHYSICAL_MAXIMUM (32767)
0x75, 0x08, // REPORT_SIZE (8)
0x95, 0x02, // REPORT_COUNT (2)
0x81, 0x02, // INPUT (Data,Var,Abs)
0xc0, // END_COLLECTION
0x09, 0x36, // USAGE (Slider)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255)
0x35, 0x00, // PHYSICAL_MINIMUM (0)
0x46, 0xff, 0x7f, // PHYSICAL_MAXIMUM (32767)
0x75, 0x08, // REPORT_SIZE (8)
0x95, 0x01, // REPORT_COUNT (1)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x09, 0x39, // USAGE (Hat switch)
0x15, 0x01, // LOGICAL_MINIMUM (1)
0x25, 0x08, // LOGICAL_MAXIMUM (8)
0x75, 0x04, // REPORT_SIZE (4)
0x95, 0x01, // REPORT_COUNT (1)
0x81, 0x42, // INPUT (Data,Var,Abs,Null)
0x05, 0x09, // USAGE_PAGE (Button)
0x19, 0x01, // USAGE_MINIMUM (Button 1)
0x29, 0x0c, // USAGE_MAXIMUM (Button 12)
0x75, 0x01, // REPORT_SIZE (1)
0x95, 0x0c, // REPORT_COUNT (12)
0x81, 0x02, // INPUT (Data,Var,Abs)
0xc0 // END_COLLECTION
}; /* CustomHID_ReportDescriptor */
醉经升级了WIN10系统,发现识别不了USB手柄了
修改下面的描述符就可以了
const u8 CustomHID_DeviceDescriptor[CUSTOMHID_SIZ_DEVICE_DESC] =
{
0x12, /*bLength */
USB_DEVICE_DESCRIPTOR_TYPE, /*bDescriptorType*/
0x00, /*bcdUSB */ 改成0x00
0x02, 改成0x02
0x00, /*bDeviceClass*/
0x00, /*bDeviceSubClass*/
0x00, /*bDeviceProtocol*/
0x40, /*bMaxPacketSize40*/
0xF3, /*idVendor (0x0483)*/
0x04,
0x04, /*idProduct = 0x5750*/
0x01,
0x00, /*bcdDevice rel. 2.00*/
承接项目 13810175694 微信 注明 做项目
stm32 hid游戏手柄程序相关推荐
- Arduino框架下STM32F1/F4系列HID模式程序烧录教程
Arduino框架下STM32F1/F4系列HID模式程序烧录教程 相关篇<Arduino框架下STM32全系列开发固件安装指南> HID BootLoader烧录模式 "Upl ...
- ubuntu linux下建立stm32开发环境: 程序烧录 openocd+openjtag
原文出处: http://blog.csdn.net/embbnux/article/details/17619621 之前建立stm32开发环境,程序也已经编译好生成main.bin,接下来就是要把 ...
- 嵌入式IAP开发笔记之一:面向STM32的BootLoader程序
对于很多人来说,BootLoader并不是一个陌生的词,甚至会经常用到它.因为在很多情况下我们都需要BootLoader程序,比如我们需要对系统在线升级时就需要它,还有当我们需要在外部存储器中运行程序 ...
- ## STM32——闪烁灯程序
STM32--闪烁灯程序 单片机的闪烁灯是继点灯后的一个简单的程序,这也是每一个初学者的必经路程,也并没有我们想象的那么难,我们要相信自己.人生难得几回搏,此时不搏待何时. --至每一个为自己的理想而 ...
- STM32在线烧录程序的开发
STM32在线烧录程序的开发 2013年03月10日 17:07:38 vishtvro 阅读数 2515 STM32在线烧录程序的开发<梅川酷子原创> STM32在芯片生产的阶段固化了一 ...
- 一个stm32的简单程序的编译
一个stm32的简单程序的编译 stm32程序-LED 总结 stm32程序-LED 一.建立一个工程 1.打开Keil uVision5,找到project,然后点击New uVision Proj ...
- 小白从零开始:小程序阿里云平台控制stm32(小程序篇)
小白从零开始:小程序阿里云平台控制stm32(小程序篇) 文章目录 前言 一.准备:小程序注册+开发者工具 二.小程序开发者工具配置 三.小程序 js代码更改位置 四.小程序 wxml代码更改位置 五 ...
- STM32串口中断程序-迪文屏,
STM32串口中断程序-迪文屏,串口接收准确数值 这几天一直在做原子开发板与迪文屏的通信,开发板向迪文屏写数据已经完成,但是从迪文屏读的数据总是无法返回开发板.原始及调试程序见下图: 在串口接收到从d ...
- STM32+ESP8266+小程序的智能家居(项目简介)
"学习或者了解人工智能小伙伴福利来了,前些天发现了一个巨牛的人工智能学习网站,通俗易懂,风趣幽默,忍不住分享一下给大家." 想了解或者学习人工智能可以看一下,我觉得学习起来挺有趣的 ...
最新文章
- 那些轻轻拍了拍Attention的后浪们
- java对xml文件的读写_java 自己做的对XML文件的读写操作
- power bi可视化表_如何使用Power BI可视化数据?
- LSGO软件技术团队2015~2016学年第二周(0907~0912)总结
- java @Column 引发的一点思考
- 映射文件中增删改查标签中的parameterType和resultType
- alexa api php,php 读取 alexa信息
- HDU2000 ASCII码排序【字符排序】
- Oracle分配内存的基本单位:Granule(粒度)
- 文本分割器TXTSpliter
- Android程序崩溃处理
- STM32L151缓慢上断电-电源控制模块的使用(PVD、BOR、POR/PDR)
- qt 禁止alt+f4_禁止上下关闭按钮和Alt + F4
- 【信管1.17】信息化发展
- 163网页邮箱的实现
- 一度智信|拼多多店铺取名大全
- chatbot学习汇总
- 50部经典影片,你看过哪些
- 如何寻找出色的产品经理
- Linux-查看服务器配置
热门文章
- 辣椒的python之旅
- 云计算与大数据---21大数据张舒
- 转一篇经典音响文章《“摩机”宝典之如何“摩功放”》
- 怎样使用iPhone对Apple TV进行色彩平衡调整?
- 在学习thymeleaf中,给function 方法传Controller传递过来的参数,报错:Uncaught SyntaxError: missing ) after argument list
- # 公有云?私有云?混合云?多云?行业云?傻傻分不清楚(上篇)
- 第一次使用Arduino MKR WIFI 1010
- 4-3. 统计素数并求和
- 2021年森林督查暨森林资源管理“一张图”更新工作方案
- python 换页符_Python用什么方法可以将换行符分割成多行?