aboutsummaryrefslogtreecommitdiffstats
path: root/Demos/Device/ClassDriver/KeyboardMouse
diff options
context:
space:
mode:
authorLászló Monda <laci@monda.hu>2013-10-06 22:16:20 +0200
committerLászló Monda <laci@monda.hu>2013-10-06 22:16:20 +0200
commit9ef29ea2293dde7225360fe258224d22d3a68756 (patch)
tree8b97bebc31be97f73384a605ccc2f41b2a04d492 /Demos/Device/ClassDriver/KeyboardMouse
parentcd3aae87daa243413413ab9fc4e32c225c3bea03 (diff)
downloadlufa-9ef29ea2293dde7225360fe258224d22d3a68756.tar.gz
lufa-9ef29ea2293dde7225360fe258224d22d3a68756.tar.bz2
lufa-9ef29ea2293dde7225360fe258224d22d3a68756.zip
Extract interface numbers into enums.
Diffstat (limited to 'Demos/Device/ClassDriver/KeyboardMouse')
-rw-r--r--Demos/Device/ClassDriver/KeyboardMouse/Descriptors.c38
-rw-r--r--Demos/Device/ClassDriver/KeyboardMouse/Descriptors.h16
-rw-r--r--Demos/Device/ClassDriver/KeyboardMouse/KeyboardMouse.c4
3 files changed, 35 insertions, 23 deletions
diff --git a/Demos/Device/ClassDriver/KeyboardMouse/Descriptors.c b/Demos/Device/ClassDriver/KeyboardMouse/Descriptors.c
index c3b2e2c7b..0d350c764 100644
--- a/Demos/Device/ClassDriver/KeyboardMouse/Descriptors.c
+++ b/Demos/Device/ClassDriver/KeyboardMouse/Descriptors.c
@@ -120,7 +120,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
{
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
- .InterfaceNumber = 0x00,
+ .InterfaceNumber = INTERFACE_ID_Keyboard,
.AlternateSetting = 0x00,
.TotalEndpoints = 1,
@@ -157,7 +157,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
{
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
- .InterfaceNumber = 0x01,
+ .InterfaceNumber = INTERFACE_ID_Mouse,
.AlternateSetting = 0x00,
.TotalEndpoints = 1,
@@ -269,28 +269,30 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
break;
case HID_DTYPE_HID:
- if (!(wIndex))
+ switch (wIndex)
{
- Address = &ConfigurationDescriptor.HID1_KeyboardHID;
- Size = sizeof(USB_HID_Descriptor_HID_t);
- }
- else
- {
- Address = &ConfigurationDescriptor.HID2_MouseHID;
- Size = sizeof(USB_HID_Descriptor_HID_t);
+ case INTERFACE_ID_Keyboard:
+ Address = &ConfigurationDescriptor.HID1_KeyboardHID;
+ Size = sizeof(USB_HID_Descriptor_HID_t);
+ break;
+ case INTERFACE_ID_Mouse:
+ Address = &ConfigurationDescriptor.HID2_MouseHID;
+ Size = sizeof(USB_HID_Descriptor_HID_t);
+ break;
}
break;
case HID_DTYPE_Report:
- if (!(wIndex))
+ switch (wIndex)
{
- Address = &KeyboardReport;
- Size = sizeof(KeyboardReport);
- }
- else
- {
- Address = &MouseReport;
- Size = sizeof(MouseReport);
+ case INTERFACE_ID_Keyboard:
+ Address = &KeyboardReport;
+ Size = sizeof(KeyboardReport);
+ break;
+ case INTERFACE_ID_Mouse:
+ Address = &MouseReport;
+ Size = sizeof(MouseReport);
+ break;
}
break;
diff --git a/Demos/Device/ClassDriver/KeyboardMouse/Descriptors.h b/Demos/Device/ClassDriver/KeyboardMouse/Descriptors.h
index 27120eb34..1a45f74bd 100644
--- a/Demos/Device/ClassDriver/KeyboardMouse/Descriptors.h
+++ b/Demos/Device/ClassDriver/KeyboardMouse/Descriptors.h
@@ -61,15 +61,25 @@
USB_Descriptor_Endpoint_t HID2_ReportINEndpoint;
} USB_Descriptor_Configuration_t;
+ /** Enum for the device interface descriptor IDs within the device. Each interface descriptor
+ * should have a unique ID index associated with it, which can be used to refer to the
+ * interface from other descriptors.
+ */
+ enum InterfaceDescriptors_t
+ {
+ INTERFACE_ID_Keyboard = 0, /**< Keyboard interface descriptor ID */
+ INTERFACE_ID_Mouse = 1, /**< Mouse interface descriptor ID */
+ };
+
/** Enum for the device string descriptor IDs within the device. Each string descriptor should
* have a unique ID index associated with it, which can be used to refer to the string from
* other descriptors.
*/
enum StringDescriptors_t
{
- STRING_ID_Language = 0, /**< Supported Languages string descriptor ID (must be zero) */
- STRING_ID_Manufacturer = 1, /**< Manufacturer string ID */
- STRING_ID_Product = 2, /**< Product string ID */
+ STRING_ID_Language = 0, /**< Supported Languages string descriptor ID (must be zero) */
+ STRING_ID_Manufacturer = 1, /**< Manufacturer string ID */
+ STRING_ID_Product = 2, /**< Product string ID */
};
/* Macros: */
diff --git a/Demos/Device/ClassDriver/KeyboardMouse/KeyboardMouse.c b/Demos/Device/ClassDriver/KeyboardMouse/KeyboardMouse.c
index f663f1683..789fc215d 100644
--- a/Demos/Device/ClassDriver/KeyboardMouse/KeyboardMouse.c
+++ b/Demos/Device/ClassDriver/KeyboardMouse/KeyboardMouse.c
@@ -51,7 +51,7 @@ USB_ClassInfo_HID_Device_t Keyboard_HID_Interface =
{
.Config =
{
- .InterfaceNumber = 0,
+ .InterfaceNumber = INTERFACE_ID_Keyboard,
.ReportINEndpoint =
{
.Address = KEYBOARD_IN_EPADDR,
@@ -72,7 +72,7 @@ USB_ClassInfo_HID_Device_t Mouse_HID_Interface =
{
.Config =
{
- .InterfaceNumber = 1,
+ .InterfaceNumber = INTERFACE_ID_Mouse,
.ReportINEndpoint =
{
.Address = MOUSE_IN_EPADDR,