Extract mouse descriptors and macros to usb_keyboard_descriptors.[ch]

This commit is contained in:
László Monda
2016-02-25 07:54:27 +01:00
parent 8ae37ce6f3
commit cfb1135aac
7 changed files with 154 additions and 119 deletions

View File

@@ -8,49 +8,7 @@
#include "hid_mouse.h"
#include "hid_keyboard.h"
#include "usb_keyboard_descriptors.h"
// HID mouse endpoint
usb_device_endpoint_struct_t g_UsbDeviceHidMouseEndpoints[USB_HID_MOUSE_ENDPOINT_COUNT] = {
// HID mouse interrupt IN pipe
{
USB_HID_MOUSE_ENDPOINT_IN | (USB_IN << USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT), USB_ENDPOINT_INTERRUPT,
FS_HID_MOUSE_INTERRUPT_IN_PACKET_SIZE,
},
};
// HID mouse interface information
usb_device_interface_struct_t g_UsbDeviceHidMouseInterface[] = {{
0U, // The alternate setting of the interface
{
USB_HID_MOUSE_ENDPOINT_COUNT,
g_UsbDeviceHidMouseEndpoints,
},
NULL,
}};
usb_device_interfaces_struct_t g_UsbDeviceHidMouseInterfaces[USB_HID_MOUSE_INTERFACE_COUNT] = {
{
USB_HID_MOUSE_CLASS,
USB_HID_MOUSE_SUBCLASS,
USB_HID_MOUSE_PROTOCOL,
USB_HID_MOUSE_INTERFACE_INDEX,
g_UsbDeviceHidMouseInterface,
sizeof(g_UsbDeviceHidMouseInterface) / sizeof(usb_device_interfaces_struct_t),
},
};
usb_device_interface_list_t g_UsbDeviceHidMouseInterfaceList[USB_DEVICE_CONFIGURATION_COUNT] = {
{
USB_HID_MOUSE_INTERFACE_COUNT,
g_UsbDeviceHidMouseInterfaces,
},
};
usb_device_class_struct_t g_UsbDeviceHidMouseConfig = {
g_UsbDeviceHidMouseInterfaceList,
kUSB_DeviceClassTypeHid,
USB_DEVICE_CONFIGURATION_COUNT,
};
#include "usb_mouse_descriptors.h"
uint8_t g_UsbDeviceDescriptor[USB_DESCRIPTOR_LENGTH_DEVICE] = {
USB_DESCRIPTOR_LENGTH_DEVICE, /* Size of this descriptor in bytes */
@@ -179,42 +137,6 @@ uint8_t g_UsbDeviceConfigurationDescriptor[USB_DESCRIPTOR_LENGTH_CONFIGURATION_A
FS_HID_KEYBOARD_INTERRUPT_IN_INTERVAL, /* Interval for polling endpoint for data transfers. */
};
uint8_t g_UsbDeviceHidMouseReportDescriptor[USB_DESCRIPTOR_LENGTH_HID_MOUSE_REPORT] = {
0x05U, 0x01U, /* Usage Page (Generic Desktop)*/
0x09U, 0x02U, /* Usage (Mouse) */
0xA1U, 0x01U, /* Collection (Application) */
0x09U, 0x01U, /* Usage (Pointer) */
0xA1U, 0x00U, /* Collection (Physical) */
0x05U, 0x09U, /* Usage Page (Buttons) */
0x19U, 0x01U, /* Usage Minimum (01U) */
0x29U, 0x03U, /* Usage Maximum (03U) */
0x15U, 0x00U, /* logical Minimum (0U) */
0x25U, 0x01U, /* logical Maximum (1U) */
0x95U, 0x03U, /* Report Count (3U) */
0x75U, 0x01U, /* Report Size (1U) */
0x81U, 0x02U, /* Input(Data, Variable, Absolute) 3U button bit fields */
0x95U, 0x01U, /* Report count (1U) */
0x75U, 0x05U, /* Report Size (5U) */
0x81U, 0x01U, /* Input (Constant), 5U constant field */
0x05U, 0x01U, /* Usage Page (Generic Desktop) */
0x09U, 0x30U, /* Usage (X) */
0x09U, 0x31U, /* Usage (Y) */
0x09U, 0x38U, /* Usage (Z) */
0x15U, 0x81U, /* Logical Minimum (-127) */
0x25U, 0x7FU, /* Logical Maximum (127) */
0x75U, 0x08U, /* Report Size (8U) */
0x95U, 0x03U, /* Report Count (3U) */
0x81U, 0x06U, /* Input(Data, Variable, Relative), three position bytes (X & Y & Z)*/
0xC0U, /* end collection, Close Pointer collection*/
0xC0U /* end collection, Close Mouse collection */
};
uint8_t g_UsbDeviceString0[USB_DESCRIPTOR_LENGTH_STRING0] = {
sizeof(g_UsbDeviceString0), USB_DESCRIPTOR_TYPE_STRING, 0x09U, 0x04U,
};
@@ -273,27 +195,6 @@ uint8_t g_UsbDeviceString2[USB_DESCRIPTOR_LENGTH_STRING2] = {
'E', 0x00U,
};
uint8_t g_UsbDeviceString3[USB_DESCRIPTOR_LENGTH_STRING3] = {
sizeof(g_UsbDeviceString3),
USB_DESCRIPTOR_TYPE_STRING,
'H', 0x00U,
'I', 0x00U,
'D', 0x00U,
' ', 0x00U,
'M', 0x00U,
'O', 0x00U,
'U', 0x00U,
'S', 0x00U,
'E', 0x00U,
' ', 0x00U,
'D', 0x00U,
'E', 0x00U,
'V', 0x00U,
'I', 0x00U,
'C', 0x00U,
'E', 0x00U,
};
uint32_t g_UsbDeviceStringDescriptorLength[USB_DEVICE_STRING_COUNT] = {
sizeof(g_UsbDeviceString0), sizeof(g_UsbDeviceString1), sizeof(g_UsbDeviceString2),
sizeof(g_UsbDeviceString3), sizeof(g_UsbKeyboardString),