Break device mode class driver interfaces into seperate config and state structs...
[pub/USBasp.git] / Demos / Device / ClassDriver / KeyboardMouse / KeyboardMouse.c
index 30e90f4..9372219 100644 (file)
  *  within a device can be differentiated from one another. This is for the keyboard HID\r
  *  interface within the device.\r
  */\r
-USB_ClassInfo_HID_t Keyboard_HID_Interface =\r
+USB_ClassInfo_HID_Device_t Keyboard_HID_Interface =\r
        {\r
-               .InterfaceNumber         = 0,\r
-\r
-               .ReportINEndpointNumber  = KEYBOARD_IN_EPNUM,\r
-               .ReportINEndpointSize    = HID_EPSIZE,\r
-               \r
-               .ReportINBufferSize      = sizeof(USB_KeyboardReport_Data_t),\r
-\r
-               .IdleCount               = 500,\r
+               .Config =\r
+                       {\r
+                               .InterfaceNumber         = 0,\r
+\r
+                               .ReportINEndpointNumber  = KEYBOARD_IN_EPNUM,\r
+                               .ReportINEndpointSize    = HID_EPSIZE,\r
+                               \r
+                               .ReportINBufferSize      = sizeof(USB_KeyboardReport_Data_t),\r
+                       },\r
+\r
+               .State =\r
+                       {\r
+                               .IdleCount               = 500,\r
+                       }\r
        };\r
        \r
 /** LUFA HID Class driver interface configuration and state information. This structure is\r
@@ -59,14 +65,22 @@ USB_ClassInfo_HID_t Keyboard_HID_Interface =
  *  within a device can be differentiated from one another. This is for the mouse HID\r
  *  interface within the device.\r
  */\r
-USB_ClassInfo_HID_t Mouse_HID_Interface =\r
+USB_ClassInfo_HID_Device_t Mouse_HID_Interface =\r
        {\r
-               .InterfaceNumber         = 0,\r
-\r
-               .ReportINEndpointNumber  = MOUSE_IN_EPNUM,\r
-               .ReportINEndpointSize    = HID_EPSIZE,\r
-\r
-               .ReportINBufferSize      = sizeof(USB_MouseReport_Data_t),\r
+               .Config =\r
+                       {\r
+                               .InterfaceNumber         = 0,\r
+\r
+                               .ReportINEndpointNumber  = MOUSE_IN_EPNUM,\r
+                               .ReportINEndpointSize    = HID_EPSIZE,\r
+\r
+                               .ReportINBufferSize      = sizeof(USB_MouseReport_Data_t),\r
+                       },\r
+                       \r
+               .State =\r
+                       {\r
+                               // Leave all state values to their defaults\r
+                       }                       \r
        };\r
 \r
 /** Main program entry point. This routine contains the overall program flow, including initial\r
@@ -142,11 +156,11 @@ void EVENT_USB_UnhandledControlPacket(void)
 /** ISR to keep track of each millisecond interrupt, for determining the HID class idle period remaining when set. */\r
 ISR(TIMER0_COMPA_vect, ISR_BLOCK)\r
 {\r
-       if (Keyboard_HID_Interface.IdleMSRemaining)\r
-         Keyboard_HID_Interface.IdleMSRemaining--;\r
+       if (Keyboard_HID_Interface.State.IdleMSRemaining)\r
+         Keyboard_HID_Interface.State.IdleMSRemaining--;\r
 \r
-       if (Mouse_HID_Interface.IdleMSRemaining)\r
-         Mouse_HID_Interface.IdleMSRemaining--;\r
+       if (Mouse_HID_Interface.State.IdleMSRemaining)\r
+         Mouse_HID_Interface.State.IdleMSRemaining--;\r
 }\r
 \r
 /** HID class driver callback function for the creation of HID reports to the host.\r
@@ -157,7 +171,7 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK)
  *\r
  *  \return Number of bytes written in the report (or zero if no report is to be sent\r
  */\r
-uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData)\r
+uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData)\r
 {\r
        uint8_t JoyStatus_LCL    = Joystick_GetStatus();\r
        uint8_t ButtonStatus_LCL = Buttons_GetStatus();\r
@@ -217,7 +231,7 @@ uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_t* HIDInterfaceIn
  *  \param ReportData  Pointer to a buffer where the created report has been stored\r
  *  \param ReportSize  Size in bytes of the received HID report\r
  */\r
-void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID,\r
+void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* HIDInterfaceInfo, uint8_t ReportID,\r
                                           void* ReportData, uint16_t ReportSize)\r
 {\r
        if (HIDInterfaceInfo == &Keyboard_HID_Interface)\r