aboutsummaryrefslogtreecommitdiffstats
path: root/Demos/Device/LowLevel/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/LowLevel/KeyboardMouse
parentcd3aae87daa243413413ab9fc4e32c225c3bea03 (diff)
downloadlufa-9ef29ea2293dde7225360fe258224d22d3a68756.tar.gz
lufa-9ef29ea2293dde7225360fe258224d22d3a68756.tar.bz2
lufa-9ef29ea2293dde7225360fe258224d22d3a68756.zip
Extract interface numbers into enums.
Diffstat (limited to 'Demos/Device/LowLevel/KeyboardMouse')
-rw-r--r--Demos/Device/LowLevel/KeyboardMouse/Descriptors.c38
-rw-r--r--Demos/Device/LowLevel/KeyboardMouse/Descriptors.h16
2 files changed, 33 insertions, 21 deletions
diff --git a/Demos/Device/LowLevel/KeyboardMouse/Descriptors.c b/Demos/Device/LowLevel/KeyboardMouse/Descriptors.c
index d45cd593f..4a339f415 100644
--- a/Demos/Device/LowLevel/KeyboardMouse/Descriptors.c
+++ b/Demos/Device/LowLevel/KeyboardMouse/Descriptors.c
@@ -168,7 +168,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 = 2,
@@ -215,7 +215,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,
@@ -327,27 +327,29 @@ 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/LowLevel/KeyboardMouse/Descriptors.h b/Demos/Device/LowLevel/KeyboardMouse/Descriptors.h
index 6d2543ac2..99f423e1b 100644
--- a/Demos/Device/LowLevel/KeyboardMouse/Descriptors.h
+++ b/Demos/Device/LowLevel/KeyboardMouse/Descriptors.h
@@ -63,15 +63,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: */