3      Copyright (C) Dean Camera, 2010. 
   5   dean [at] fourwalledcubicle [dot] com 
   6       www.fourwalledcubicle.com 
  10   Copyright 2010  Dean Camera (dean [at] fourwalledcubicle [dot] com) 
  11   Copyright 2010  Denver Gingerich (denver [at] ossguy [dot] com) 
  13   Permission to use, copy, modify, distribute, and sell this  
  14   software and its documentation for any purpose is hereby granted 
  15   without fee, provided that the above copyright notice appear in  
  16   all copies and that both that the copyright notice and this 
  17   permission notice and warranty disclaimer appear in supporting  
  18   documentation, and that the name of the author not be used in  
  19   advertising or publicity pertaining to distribution of the  
  20   software without specific, written prior permission. 
  22   The author disclaim all warranties with regard to this 
  23   software, including all implied warranties of merchantability 
  24   and fitness.  In no event shall the author be liable for any 
  25   special, indirect or consequential damages or any damages 
  26   whatsoever resulting from loss of use, data or profits, whether 
  27   in an action of contract, negligence or other tortious action, 
  28   arising out of or in connection with the use or performance of 
  32 #ifndef _KEYBOARD_MOUSE_H_ 
  33 #define _KEYBOARD_MOUSE_H_ 
  38                 #include <avr/power.h> 
  39                 #include <avr/interrupt.h> 
  43                 #include "Descriptors.h" 
  45                 #include <LUFA/Version.h> 
  46                 #include <LUFA/Drivers/USB/USB.h> 
  47                 #include <LUFA/Drivers/Board/Joystick.h> 
  48                 #include <LUFA/Drivers/Board/LEDs.h> 
  49                 #include <LUFA/Drivers/Board/Buttons.h> 
  52                 /** HID Class specific request to get the next HID report from the device. */ 
  53                 #define REQ_GetReport               0x01 
  55                 /** HID Class specific request to send the next HID report to the device. */ 
  56                 #define REQ_SetReport               0x09 
  58                 /** HID Class specific request to get the current HID protocol in use, either report or boot. */ 
  59                 #define REQ_GetProtocol             0x03 
  61                 /** HID Class specific request to set the current HID protocol in use, either report or boot. */ 
  62                 #define REQ_SetProtocol             0x0B 
  64                 /** Constant for a keyboard report modifier byte, indicating that the keyboard's left control key is currently pressed. */ 
  65                 #define KEYBOARD_MODIFER_LEFTCTRL   (1 << 0) 
  67                 /** Constant for a keyboard report modifier byte, indicating that the keyboard's left shift key is currently pressed. */ 
  68                 #define KEYBOARD_MODIFER_LEFTSHIFT  (1 << 1) 
  70                 /** Constant for a keyboard report modifier byte, indicating that the keyboard's left alt key is currently pressed. */ 
  71                 #define KEYBOARD_MODIFER_LEFTALT    (1 << 2) 
  73                 /** Constant for a keyboard report modifier byte, indicating that the keyboard's left GUI key is currently pressed. */ 
  74                 #define KEYBOARD_MODIFER_LEFTGUI    (1 << 3) 
  76                 /** Constant for a keyboard report modifier byte, indicating that the keyboard's right control key is currently pressed. */ 
  77                 #define KEYBOARD_MODIFER_RIGHTCTRL  (1 << 4) 
  79                 /** Constant for a keyboard report modifier byte, indicating that the keyboard's right shift key is currently pressed. */ 
  80                 #define KEYBOARD_MODIFER_RIGHTSHIFT (1 << 5) 
  82                 /** Constant for a keyboard report modifier byte, indicating that the keyboard's right alt key is currently pressed. */ 
  83                 #define KEYBOARD_MODIFER_RIGHTALT   (1 << 6) 
  85                 /** Constant for a keyboard report modifier byte, indicating that the keyboard's right GUI key is currently pressed. */ 
  86                 #define KEYBOARD_MODIFER_RIGHTGUI   (1 << 7) 
  88                 /** Constant for a keyboard output report LED byte, indicating that the host's NUM LOCK mode is currently set. */ 
  89                 #define KEYBOARD_LED_NUMLOCK        (1 << 0) 
  91                 /** Constant for a keyboard output report LED byte, indicating that the host's CAPS LOCK mode is currently set. */ 
  92                 #define KEYBOARD_LED_CAPSLOCK       (1 << 1) 
  94                 /** Constant for a keyboard output report LED byte, indicating that the host's SCROLL LOCK mode is currently set. */ 
  95                 #define KEYBOARD_LED_SCROLLLOCK     (1 << 2) 
  97                 /** Constant for a keyboard output report LED byte, indicating that the host's KATANA mode is currently set. */ 
  98                 #define KEYBOARD_LED_KATANA         (1 << 3) 
 100                 /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ 
 101                 #define LEDMASK_USB_NOTREADY        LEDS_LED1 
 103                 /** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */ 
 104                 #define LEDMASK_USB_ENUMERATING     (LEDS_LED2 | LEDS_LED3) 
 106                 /** LED mask for the library LED driver, to indicate that the USB interface is ready. */ 
 107                 #define LEDMASK_USB_READY           (LEDS_LED2 | LEDS_LED4) 
 109                 /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ 
 110                 #define LEDMASK_USB_ERROR           (LEDS_LED1 | LEDS_LED3) 
 113                 /** Type define for the keyboard HID report structure, for creating and sending HID reports to the host PC. 
 114                  *  This mirrors the layout described to the host in the HID report descriptor, in Descriptors.c. 
 118                         uint8_t Modifier
; /**< Modifier mask byte, containing a mask of modifier keys set (such as shift or CTRL) */ 
 119                         uint8_t Reserved
; /**< Reserved, always set as 0x00 */ 
 120                         uint8_t KeyCode
[6]; /**< Array of up to six simultaneous key codes of pressed keys */ 
 121                 } USB_KeyboardReport_Data_t
; 
 123                 /** Type define for the mouse HID report structure, for creating and sending HID reports to the host PC. 
 124                  *  This mirrors the layout described to the host in the HID report descriptor, in Descriptors.c. 
 128                         uint8_t Button
; /**< Bit mask of the currently pressed mouse buttons */ 
 129                         int8_t  X
; /**< Current mouse delta X movement, as a signed 8-bit integer */ 
 130                         int8_t  Y
; /**< Current mouse delta Y movement, as a signed 8-bit integer */ 
 131                 } USB_MouseReport_Data_t
; 
 133         /* Function Prototypes: */ 
 134                 void SetupHardware(void); 
 135                 void Keyboard_ProcessLEDReport(const uint8_t LEDStatus
); 
 136                 void Keyboard_HID_Task(void); 
 137                 void Mouse_HID_Task(void); 
 139                 void EVENT_USB_Device_Connect(void); 
 140                 void EVENT_USB_Device_Disconnect(void); 
 141                 void EVENT_USB_Device_ConfigurationChanged(void); 
 142                 void EVENT_USB_Device_UnhandledControlRequest(void); 
 143                 void EVENT_USB_Device_StartOfFrame(void);