Device mode class driver callbacks are now fired before the control request status...
[pub/USBasp.git] / Demos / Device / ClassDriver / Keyboard / Keyboard.c
index fd135b7..0da5295 100644 (file)
@@ -1,14 +1,13 @@
 /*\r
              LUFA Library\r
-     Copyright (C) Dean Camera, 2009.\r
+     Copyright (C) Dean Camera, 2010.\r
               \r
   dean [at] fourwalledcubicle [dot] com\r
       www.fourwalledcubicle.com\r
 */\r
 \r
 /*\r
-  Copyright 2009  Denver Gingerich (denver [at] ossguy [dot] com)\r
-      Based on code by Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+  Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
 \r
   Permission to use, copy, modify, distribute, and sell this \r
   software and its documentation for any purpose is hereby granted\r
@@ -67,6 +66,7 @@ int main(void)
        SetupHardware();\r
 \r
        LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);\r
+       sei();\r
        \r
        for (;;)\r
        {\r
@@ -146,7 +146,7 @@ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDIn
        uint8_t ButtonStatus_LCL = Buttons_GetStatus();\r
 \r
        uint8_t UsedKeyCodes = 0;\r
-       \r
+               \r
        if (JoyStatus_LCL & JOY_UP)\r
          KeyboardReport->KeyCode[UsedKeyCodes++] = 0x04; // A\r
        else if (JoyStatus_LCL & JOY_DOWN)\r
@@ -163,6 +163,9 @@ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDIn
        if (ButtonStatus_LCL & BUTTONS_BUTTON1)\r
          KeyboardReport->KeyCode[UsedKeyCodes++] = 0x09; // F\r
 \r
+       if (UsedKeyCodes)\r
+         KeyboardReport->Modifier = HID_KEYBOARD_MODIFER_LEFTSHIFT;\r
+\r
        *ReportSize = sizeof(USB_KeyboardReport_Data_t);\r
        return false;\r
 }\r
@@ -180,13 +183,13 @@ void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDI
        uint8_t  LEDMask   = LEDS_NO_LEDS;\r
        uint8_t* LEDReport = (uint8_t*)ReportData;\r
 \r
-       if (*LEDReport & 0x01) // NUM Lock\r
+       if (*LEDReport & HID_KEYBOARD_LED_NUMLOCK)\r
          LEDMask |= LEDS_LED1;\r
        \r
-       if (*LEDReport & 0x02) // CAPS Lock\r
+       if (*LEDReport & HID_KEYBOARD_LED_CAPSLOCK)\r
          LEDMask |= LEDS_LED3;\r
 \r
-       if (*LEDReport & 0x04) // SCROLL Lock\r
+       if (*LEDReport & HID_KEYBOARD_LED_SCROLLLOCK)\r
          LEDMask |= LEDS_LED4;\r
          \r
        LEDs_SetAllLEDs(LEDMask);\r