3 Copyright (C) Dean Camera, 2010.
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
10 Copyright 2010 Denver Gingerich (denver [at] ossguy [dot] com)
11 Based on code by Dean Camera (dean [at] fourwalledcubicle [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
34 * Header file for Keyboard.c.
43 #include <avr/power.h>
47 #include "Descriptors.h"
49 #include <LUFA/Version.h>
50 #include <LUFA/Drivers/USB/USB.h>
51 #include <LUFA/Drivers/Board/Joystick.h>
52 #include <LUFA/Drivers/Board/Buttons.h>
53 #include <LUFA/Drivers/Board/LEDs.h>
56 /** Idle period indicating that reports should be sent only when the inputs have changed */
57 #define HID_IDLE_CHANGESONLY 0
59 /** HID Class specific request to get the next HID report from the device. */
60 #define REQ_GetReport 0x01
62 /** HID Class specific request to get the idle timeout period of the device. */
63 #define REQ_GetIdle 0x02
65 /** HID Class specific request to send the next HID report to the device. */
66 #define REQ_SetReport 0x09
68 /** HID Class specific request to set the idle timeout period of the device. */
69 #define REQ_SetIdle 0x0A
71 /** HID Class specific request to get the current HID protocol in use, either report or boot. */
72 #define REQ_GetProtocol 0x03
74 /** HID Class specific request to set the current HID protocol in use, either report or boot. */
75 #define REQ_SetProtocol 0x0B
77 /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
78 #define LEDMASK_USB_NOTREADY LEDS_LED1
80 /** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */
81 #define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3)
83 /** LED mask for the library LED driver, to indicate that the USB interface is ready. */
84 #define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4)
86 /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */
87 #define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3)
90 /** Type define for the keyboard HID report structure, for creating and sending HID reports to the host PC.
91 * This mirrors the layout described to the host in the HID report descriptor, in Descriptors.c.
95 uint8_t Modifier
; /**< Modifier mask byte, containing a mask of modifier keys set (such as shift or CTRL) */
96 uint8_t Reserved
; /**< Reserved, always set as 0x00 */
97 uint8_t KeyCode
[6]; /**< Array of up to six simultaneous key codes of pressed keys */
98 } USB_KeyboardReport_Data_t
;
100 /* Function Prototypes: */
101 void SetupHardware(void);
104 void EVENT_USB_Device_Connect(void);
105 void EVENT_USB_Device_Disconnect(void);
106 void EVENT_USB_Device_ConfigurationChanged(void);
107 void EVENT_USB_Device_UnhandledControlRequest(void);
108 void EVENT_USB_Device_StartOfFrame(void);
110 void CreateKeyboardReport(USB_KeyboardReport_Data_t
* ReportData
);
111 void ProcessLEDReport(uint8_t LEDReport
);
112 void SendNextReport(void);
113 void ReceiveNextReport(void);