From: Dean Camera Date: Sun, 7 Feb 2010 13:56:36 +0000 (+0000) Subject: Added Keyboard LED report masks (KEYBOARD_LED_*) to the HID class driver and demos. X-Git-Tag: LUFA-110528-BETA~610 X-Git-Url: http://git.linex4red.de/pub/USBasp.git/commitdiff_plain/0c5d6f5f975790f9cd19a0f65a2a0c4598b2862f?ds=sidebyside Added Keyboard LED report masks (KEYBOARD_LED_*) to the HID class driver and demos. --- diff --git a/Demos/Device/ClassDriver/Keyboard/Keyboard.c b/Demos/Device/ClassDriver/Keyboard/Keyboard.c index 7e5834868..26636bf41 100644 --- a/Demos/Device/ClassDriver/Keyboard/Keyboard.c +++ b/Demos/Device/ClassDriver/Keyboard/Keyboard.c @@ -182,13 +182,13 @@ void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDI uint8_t LEDMask = LEDS_NO_LEDS; uint8_t* LEDReport = (uint8_t*)ReportData; - if (*LEDReport & 0x01) // NUM Lock + if (*LEDReport & HID_KEYBOARD_LED_NUMLOCK) LEDMask |= LEDS_LED1; - if (*LEDReport & 0x02) // CAPS Lock + if (*LEDReport & HID_KEYBOARD_LED_CAPSLOCK) LEDMask |= LEDS_LED3; - if (*LEDReport & 0x04) // SCROLL Lock + if (*LEDReport & HID_KEYBOARD_LED_SCROLLLOCK) LEDMask |= LEDS_LED4; LEDs_SetAllLEDs(LEDMask); diff --git a/Demos/Device/ClassDriver/KeyboardMouse/KeyboardMouse.c b/Demos/Device/ClassDriver/KeyboardMouse/KeyboardMouse.c index 8e91d1229..af6e83949 100644 --- a/Demos/Device/ClassDriver/KeyboardMouse/KeyboardMouse.c +++ b/Demos/Device/ClassDriver/KeyboardMouse/KeyboardMouse.c @@ -239,13 +239,13 @@ void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDI uint8_t LEDMask = LEDS_NO_LEDS; uint8_t* LEDReport = (uint8_t*)ReportData; - if (*LEDReport & 0x01) // NUM Lock + if (*LEDReport & HID_KEYBOARD_LED_NUMLOCK) LEDMask |= LEDS_LED1; - if (*LEDReport & 0x02) // CAPS Lock + if (*LEDReport & HID_KEYBOARD_LED_CAPSLOCK) LEDMask |= LEDS_LED3; - if (*LEDReport & 0x04) // SCROLL Lock + if (*LEDReport & HID_KEYBOARD_LED_SCROLLLOCK) LEDMask |= LEDS_LED4; LEDs_SetAllLEDs(LEDMask); diff --git a/Demos/Device/ClassDriver/MassStorageKeyboard/MassStorageKeyboard.c b/Demos/Device/ClassDriver/MassStorageKeyboard/MassStorageKeyboard.c index 0f0d62469..4816b7e15 100644 --- a/Demos/Device/ClassDriver/MassStorageKeyboard/MassStorageKeyboard.c +++ b/Demos/Device/ClassDriver/MassStorageKeyboard/MassStorageKeyboard.c @@ -227,13 +227,13 @@ void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDI uint8_t LEDMask = LEDS_NO_LEDS; uint8_t* LEDReport = (uint8_t*)ReportData; - if (*LEDReport & 0x01) // NUM Lock + if (*LEDReport & HID_KEYBOARD_LED_NUMLOCK) LEDMask |= LEDS_LED1; - if (*LEDReport & 0x02) // CAPS Lock + if (*LEDReport & HID_KEYBOARD_LED_CAPSLOCK) LEDMask |= LEDS_LED3; - if (*LEDReport & 0x04) // SCROLL Lock + if (*LEDReport & HID_KEYBOARD_LED_SCROLLLOCK) LEDMask |= LEDS_LED4; LEDs_SetAllLEDs(LEDMask); diff --git a/Demos/Device/LowLevel/Keyboard/Keyboard.c b/Demos/Device/LowLevel/Keyboard/Keyboard.c index 1d8b8ff54..e09bed7ca 100644 --- a/Demos/Device/LowLevel/Keyboard/Keyboard.c +++ b/Demos/Device/LowLevel/Keyboard/Keyboard.c @@ -294,13 +294,13 @@ void ProcessLEDReport(uint8_t LEDReport) { uint8_t LEDMask = LEDS_LED2; - if (LEDReport & 0x01) // NUM Lock + if (*LEDReport & KEYBOARD_LED_NUMLOCK) LEDMask |= LEDS_LED1; - if (LEDReport & 0x02) // CAPS Lock + if (*LEDReport & KEYBOARD_LED_CAPSLOCK) LEDMask |= LEDS_LED3; - if (LEDReport & 0x04) // SCROLL Lock + if (*LEDReport & KEYBOARD_LED_SCROLLLOCK) LEDMask |= LEDS_LED4; /* Set the status LEDs to the current Keyboard LED status */ diff --git a/Demos/Device/LowLevel/Keyboard/Keyboard.h b/Demos/Device/LowLevel/Keyboard/Keyboard.h index 6b29be8c1..4cb3616c7 100644 --- a/Demos/Device/LowLevel/Keyboard/Keyboard.h +++ b/Demos/Device/LowLevel/Keyboard/Keyboard.h @@ -98,6 +98,18 @@ /** Constant for a keyboard report modifier byte, indicating that the keyboard's right GUI key is currently pressed. */ #define KEYBOARD_MODIFER_RIGHTGUI (1 << 7) + /** Constant for a keyboard output report LED byte, indicating that the host's NUM LOCK mode is currently set. */ + #define KEYBOARD_LED_NUMLOCK (1 << 0) + + /** Constant for a keyboard output report LED byte, indicating that the host's CAPS LOCK mode is currently set. */ + #define KEYBOARD_LED_CAPSLOCK (1 << 1) + + /** Constant for a keyboard output report LED byte, indicating that the host's SCROLL LOCK mode is currently set. */ + #define KEYBOARD_LED_SCROLLLOCK (1 << 2) + + /** Constant for a keyboard output report LED byte, indicating that the host's KATANA mode is currently set. */ + #define KEYBOARD_LED_KATANA (1 << 3) + /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ #define LEDMASK_USB_NOTREADY LEDS_LED1 diff --git a/Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.c b/Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.c index d6c9b4d11..d31f94db0 100644 --- a/Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.c +++ b/Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.c @@ -184,13 +184,13 @@ void EVENT_USB_Device_UnhandledControlRequest(void) uint8_t LEDStatus = Endpoint_Read_Byte(); uint8_t LEDMask = LEDS_LED2; - if (LEDStatus & 0x01) // NUM Lock + if (LEDStatus & KEYBOARD_LED_NUMLOCK) LEDMask |= LEDS_LED1; - if (LEDStatus & 0x02) // CAPS Lock + if (LEDStatus & KEYBOARD_LED_CAPSLOCK) LEDMask |= LEDS_LED3; - if (LEDStatus & 0x04) // SCROLL Lock + if (LEDStatus & KEYBOARD_LED_SCROLLLOCK) LEDMask |= LEDS_LED4; /* Set the status LEDs to the current HID LED status */ @@ -264,13 +264,13 @@ void Keyboard_HID_Task(void) uint8_t LEDStatus = Endpoint_Read_Byte(); uint8_t LEDMask = LEDS_LED2; - if (LEDStatus & 0x01) // NUM Lock + if (LEDStatus & KEYBOARD_LED_NUMLOCK) LEDMask |= LEDS_LED1; - if (LEDStatus & 0x02) // CAPS Lock + if (LEDStatus & KEYBOARD_LED_CAPSLOCK) LEDMask |= LEDS_LED3; - if (LEDStatus & 0x04) // SCROLL Lock + if (LEDStatus & KEYBOARD_LED_SCROLLLOCK) LEDMask |= LEDS_LED4; /* Set the status LEDs to the current Keyboard LED status */ diff --git a/Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.h b/Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.h index ff2831408..e5337f2ef 100644 --- a/Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.h +++ b/Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.h @@ -84,6 +84,18 @@ /** Constant for a keyboard report modifier byte, indicating that the keyboard's right GUI key is currently pressed. */ #define KEYBOARD_MODIFER_RIGHTGUI (1 << 7) + /** Constant for a keyboard output report LED byte, indicating that the host's NUM LOCK mode is currently set. */ + #define KEYBOARD_LED_NUMLOCK (1 << 0) + + /** Constant for a keyboard output report LED byte, indicating that the host's CAPS LOCK mode is currently set. */ + #define KEYBOARD_LED_CAPSLOCK (1 << 1) + + /** Constant for a keyboard output report LED byte, indicating that the host's SCROLL LOCK mode is currently set. */ + #define KEYBOARD_LED_SCROLLLOCK (1 << 2) + + /** Constant for a keyboard output report LED byte, indicating that the host's KATANA mode is currently set. */ + #define KEYBOARD_LED_KATANA (1 << 3) + /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ #define LEDMASK_USB_NOTREADY LEDS_LED1 diff --git a/LUFA/Drivers/USB/Class/Common/HID.h b/LUFA/Drivers/USB/Class/Common/HID.h index 6f2d7c222..5afaf48c9 100644 --- a/LUFA/Drivers/USB/Class/Common/HID.h +++ b/LUFA/Drivers/USB/Class/Common/HID.h @@ -109,6 +109,18 @@ /** Constant for a keyboard report modifier byte, indicating that the keyboard's right GUI key is currently pressed. */ #define HID_KEYBOARD_MODIFER_RIGHTGUI (1 << 7) + + /** Constant for a keyboard output report LED byte, indicating that the host's NUM LOCK mode is currently set. */ + #define HID_KEYBOARD_LED_NUMLOCK (1 << 0) + + /** Constant for a keyboard output report LED byte, indicating that the host's CAPS LOCK mode is currently set. */ + #define HID_KEYBOARD_LED_CAPSLOCK (1 << 1) + + /** Constant for a keyboard output report LED byte, indicating that the host's SCROLL LOCK mode is currently set. */ + #define HID_KEYBOARD_LED_SCROLLLOCK (1 << 2) + + /** Constant for a keyboard output report LED byte, indicating that the host's KATANA mode is currently set. */ + #define HID_KEYBOARD_LED_KATANA (1 << 3) /* Type Defines: */ /** Enum for the different types of HID reports. */ diff --git a/LUFA/ManPages/ChangeLog.txt b/LUFA/ManPages/ChangeLog.txt index e9469ff09..9f9157de5 100644 --- a/LUFA/ManPages/ChangeLog.txt +++ b/LUFA/ManPages/ChangeLog.txt @@ -23,7 +23,8 @@ * - New Webserver project, a RNDIS host USB webserver using the open source uIP TCP/IP network stack and FatFS library * - New BOARD value option BOARD_NONE (equivelent to not specifying BOARD) which will remove all board hardware drivers which * do not adversely affect the code operation (currently only the LEDs driver) - * - Added keyboard modifier masks (HID_KEYBOARD_MODIFER_*) to the HID class driver and Keyboard demos + * - Added keyboard modifier masks (HID_KEYBOARD_MODIFER_*) and LED report masks (KEYBOARD_LED_*) to the HID class driver and + * Keyboard demos * * Changed: * - Slowed down software USART carried PDI programming in the AVRISP project to prevent transmission errors