Remove outdated AVRStudio project files from demos, projects, bootloaders. Fix makefi...
[pub/USBasp.git] / Demos / Device / LowLevel / Mouse / Mouse.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 Dean Camera (dean [at] fourwalledcubicle [dot] com)
11
12 Permission to use, copy, modify, and distribute this software
13 and its documentation for any purpose and without fee is hereby
14 granted, provided that the above copyright notice appear in all
15 copies and that both that the copyright notice and this
16 permission notice and warranty disclaimer appear in supporting
17 documentation, and that the name of the author not be used in
18 advertising or publicity pertaining to distribution of the
19 software without specific, written prior permission.
20
21 The author disclaim all warranties with regard to this
22 software, including all implied warranties of merchantability
23 and fitness. In no event shall the author be liable for any
24 special, indirect or consequential damages or any damages
25 whatsoever resulting from loss of use, data or profits, whether
26 in an action of contract, negligence or other tortious action,
27 arising out of or in connection with the use or performance of
28 this software.
29 */
30
31 /** \file
32 *
33 * Header file for Mouse.c.
34 */
35
36 #ifndef _MOUSE_H_
37 #define _MOUSE_H_
38
39 /* Includes: */
40 #include <avr/io.h>
41 #include <avr/wdt.h>
42 #include <avr/interrupt.h>
43 #include <avr/power.h>
44 #include <stdbool.h>
45 #include <string.h>
46
47 #include "Descriptors.h"
48
49 #include <LUFA/Version.h> // Library Version Information
50 #include <LUFA/Drivers/USB/USB.h> // USB Functionality
51 #include <LUFA/Drivers/Board/Joystick.h> // Joystick driver
52 #include <LUFA/Drivers/Board/LEDs.h> // LEDs driver
53 #include <LUFA/Drivers/Board/Buttons.h> // Board Buttons driver
54 #include <LUFA/Scheduler/Scheduler.h> // Simple scheduler for task management
55
56 /* Task Definitions: */
57 TASK(USB_Mouse_Report);
58
59 /* Macros: */
60 /** Idle period indicating that reports should be sent only when the inputs have changed */
61 #define HID_IDLE_CHANGESONLY 0
62
63 /** HID Class specific request to get the next HID report from the device. */
64 #define REQ_GetReport 0x01
65
66 /** HID Class specific request to get the idle timeout period of the device. */
67 #define REQ_GetIdle 0x02
68
69 /** HID Class specific request to send the next HID report to the device. */
70 #define REQ_SetReport 0x09
71
72 /** HID Class specific request to set the idle timeout period of the device. */
73 #define REQ_SetIdle 0x0A
74
75 /** HID Class specific request to get the current HID protocol in use, either report or boot. */
76 #define REQ_GetProtocol 0x03
77
78 /** HID Class specific request to set the current HID protocol in use, either report or boot. */
79 #define REQ_SetProtocol 0x0B
80
81 /* Type Defines: */
82 /** Type define for the mouse HID report structure, for creating and sending HID reports to the host PC.
83 * This mirrors the layout described to the host in the HID report descriptor, in Descriptors.c.
84 */
85 typedef struct
86 {
87 uint8_t Button; /**< Bit mask of the currently pressed mouse buttons */
88 int8_t X; /**< Current mouse delta X movement, as a signed 8-bit integer */
89 int8_t Y; /**< Current mouse delta Y movement, as a signed 8-bit integer */
90 } USB_MouseReport_Data_t;
91
92 /* Enums: */
93 /** Enum for the possible status codes for passing to the UpdateStatus() function. */
94 enum Mouse_StatusCodes_t
95 {
96 Status_USBNotReady = 0, /**< USB is not ready (disconnected from a USB host) */
97 Status_USBEnumerating = 1, /**< USB interface is enumerating */
98 Status_USBReady = 2, /**< USB interface is connected and ready */
99 };
100
101 /* Function Prototypes: */
102 void EVENT_USB_Connect(void);
103 void EVENT_USB_Disconnect(void);
104 void EVENT_USB_ConfigurationChanged(void);
105 void EVENT_USB_UnhandledControlPacket(void);
106
107 void CreateMouseReport(USB_MouseReport_Data_t* ReportData);
108 void UpdateStatus(uint8_t CurrentStatus);
109
110 #endif