Fixed incorrect defined in Version.h.
[pub/USBasp.git] / Demos / Device / Keyboard / Keyboard.h
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2009.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
7 */
8
9 /*
10 Copyright 2009 Denver Gingerich (denver [at] ossguy [dot] com)
11 Based on code by Dean Camera (dean [at] fourwalledcubicle [dot] com)
12
13 Permission to use, copy, modify, and distribute this software
14 and its documentation for any purpose and without fee is hereby
15 granted, provided that the above copyright notice appear in all
16 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.
21
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
29 this software.
30 */
31
32 /** \file
33 *
34 * Header file for Keyboard.c.
35 */
36
37 #ifndef _KEYBOARD_H_
38 #define _KEYBOARD_H_
39
40 /* Includes: */
41 #include <avr/io.h>
42 #include <avr/wdt.h>
43 #include <avr/interrupt.h>
44 #include <avr/power.h>
45 #include <stdbool.h>
46 #include <string.h>
47
48 #include "Descriptors.h"
49
50 #include <LUFA/Version.h> // Library Version Information
51 #include <LUFA/Scheduler/Scheduler.h> // Simple scheduler for task management
52 #include <LUFA/Common/ButtLoadTag.h> // PROGMEM tags readable by the ButtLoad project
53 #include <LUFA/Drivers/USB/USB.h> // USB Functionality
54 #include <LUFA/Drivers/Board/Joystick.h> // Joystick driver
55 #include <LUFA/Drivers/Board/LEDs.h> // LEDs driver
56
57 /* Macros: */
58 /** HID Class specific request to get the next HID report from the device. */
59 #define REQ_GetReport 0x01
60
61 /** HID Class specific request to get the idle timeout period of the device. */
62 #define REQ_GetIdle 0x02
63
64 /** HID Class specific request to send the next HID report to the device. */
65 #define REQ_SetReport 0x09
66
67 /** HID Class specific request to set the idle timeout period of the device. */
68 #define REQ_SetIdle 0x0A
69
70 /** HID Class specific request to get the current HID protocol in use, either report or boot. */
71 #define REQ_GetProtocol 0x03
72
73 /** HID Class specific request to set the current HID protocol in use, either report or boot. */
74 #define REQ_SetProtocol 0x0B
75
76 /* Task Definitions: */
77 TASK(USB_Keyboard_Report);
78
79 /* Type Defines: */
80 /** Type define for the keyboard HID report structure, for creating and sending HID reports to the host PC.
81 * This mirrors the layout described to the host in the HID report descriptor, in Descriptors.c.
82 */
83 typedef struct
84 {
85 uint8_t Modifier; /**< Modifier mask byte, containing a mask of modifier keys set (such as shift or CTRL) */
86 uint8_t Reserved; /**< Reserved, always set as 0x00 */
87 uint8_t KeyCode[6]; /**< Array of up to six simultaneous key codes of pressed keys */
88 } USB_KeyboardReport_Data_t;
89
90 /* Enums: */
91 /** Enum for the possible status codes for passing to the UpdateStatus() function. */
92 enum Keyboard_StatusCodes_t
93 {
94 Status_USBNotReady = 0, /**< USB is not ready (disconnected from a USB host) */
95 Status_USBEnumerating = 1, /**< USB interface is enumerating */
96 Status_USBReady = 2, /**< USB interface is connected and ready */
97 };
98
99 /* Event Handlers: */
100 /** Indicates that this module will catch the USB_Connect event when thrown by the library. */
101 HANDLES_EVENT(USB_Connect);
102
103 /** Indicates that this module will catch the USB_Disconnect event when thrown by the library. */
104 HANDLES_EVENT(USB_Disconnect);
105
106 /** Indicates that this module will catch the USB_Reset event when thrown by the library. */
107 HANDLES_EVENT(USB_Reset);
108
109 /** Indicates that this module will catch the USB_ConfigurationChanged event when thrown by the library. */
110 HANDLES_EVENT(USB_ConfigurationChanged);
111
112 /** Indicates that this module will catch the USB_UnhandledControlPacket event when thrown by the library. */
113 HANDLES_EVENT(USB_UnhandledControlPacket);
114
115 /* Function Prototypes: */
116 void CreateKeyboardReport(USB_KeyboardReport_Data_t* ReportData);
117 void ProcessLEDReport(uint8_t LEDReport);
118 static inline void SendNextReport(void);
119 static inline void ReceiveNextReport(void);
120 void UpdateStatus(uint8_t CurrentStatus);
121
122 #endif