Fixed PrinterHost demo returning invalid Device ID data when the attached device...
[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/power.h>
43 #include <stdbool.h>
44 #include <string.h>
45
46 #include "Descriptors.h"
47
48 #include <LUFA/Version.h>
49 #include <LUFA/Drivers/USB/USB.h>
50 #include <LUFA/Drivers/Board/Joystick.h>
51 #include <LUFA/Drivers/Board/LEDs.h>
52 #include <LUFA/Drivers/Board/Buttons.h>
53
54 /* Macros: */
55 /** Idle period indicating that reports should be sent only when the inputs have changed */
56 #define HID_IDLE_CHANGESONLY 0
57
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 /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
77 #define LEDMASK_USB_NOTREADY LEDS_LED1
78
79 /** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */
80 #define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3)
81
82 /** LED mask for the library LED driver, to indicate that the USB interface is ready. */
83 #define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4)
84
85 /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */
86 #define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3)
87
88 /* Type Defines: */
89 /** Type define for the mouse HID report structure, for creating and sending HID reports to the host PC.
90 * This mirrors the layout described to the host in the HID report descriptor, in Descriptors.c.
91 */
92 typedef struct
93 {
94 uint8_t Button; /**< Bit mask of the currently pressed mouse buttons */
95 int8_t X; /**< Current mouse delta X movement, as a signed 8-bit integer */
96 int8_t Y; /**< Current mouse delta Y movement, as a signed 8-bit integer */
97 } USB_MouseReport_Data_t;
98
99 /* Function Prototypes: */
100 void SetupHardware(void);
101 void Mouse_Task(void);
102
103 void EVENT_USB_Device_Connect(void);
104 void EVENT_USB_Device_Disconnect(void);
105 void EVENT_USB_Device_ConfigurationChanged(void);
106 void EVENT_USB_Device_UnhandledControlRequest(void);
107 void EVENT_USB_Device_StartOfFrame(void);
108
109 void CreateMouseReport(USB_MouseReport_Data_t* ReportData);
110
111 #endif