00001 /* ---------------------------------------------------------------------------- 00002 * SAM Software Package License 00003 * ---------------------------------------------------------------------------- 00004 * Copyright (c) 2014, Atmel Corporation 00005 * 00006 * All rights reserved. 00007 * 00008 * Redistribution and use in source and binary forms, with or without 00009 * modification, are permitted provided that the following conditions are met: 00010 * 00011 * - Redistributions of source code must retain the above copyright notice, 00012 * this list of conditions and the disclaimer below. 00013 * 00014 * Atmel's name may not be used to endorse or promote products derived from 00015 * this software without specific prior written permission. 00016 * 00017 * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR 00018 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00019 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 00020 * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, 00021 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00022 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 00023 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00024 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00025 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 00026 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00027 * ---------------------------------------------------------------------------- 00028 */ 00029 00030 /**\file 00031 * 00032 * \section Purpose 00033 * 00034 * Definition of methods for using a HID mouse device driver. 00035 * 00036 * \section Usage 00037 * 00038 * -# Re-implement the USBDCallbacks_RequestReceived callback to forward 00039 * requests to HIDDMouseDriver_RequestHandler. This is done 00040 * automatically unless the NOAUTOCALLBACK symbol is defined during 00041 * compilation. 00042 * -# Initialize the driver using HIDDMouseDriver_Initialize. The 00043 * USB driver is automatically initialized by this method. 00044 * -# Call the HIDDMouseDriver_ChangePoints method when one or more 00045 * keys are pressed/released. 00046 */ 00047 00048 #ifndef HIDDKEYBOARDDRIVER_H 00049 #define HIDDKEYBOARDDRIVER_H 00050 00051 /** \addtogroup usbd_hid_mouse 00052 *@{ 00053 */ 00054 00055 /*------------------------------------------------------------------------------ 00056 * Headers 00057 *------------------------------------------------------------------------------*/ 00058 00059 #include <USBRequests.h> 00060 00061 #include <HIDDescriptors.h> 00062 #include <HIDRequests.h> 00063 00064 #include <USBDDriver.h> 00065 00066 /*------------------------------------------------------------------------------ 00067 * Definitions 00068 *------------------------------------------------------------------------------*/ 00069 00070 /** \addtogroup usbd_hid_mouse_button_bitmaps HID Mouse Button bitmaps 00071 * @{ 00072 * \section Bits 00073 * - HIDDMouse_LEFT_BUTTON 00074 * - HIDDMouse_RIGHT_BUTTON 00075 * - HIDDMouse_MIDDLE_BUTTON 00076 */ 00077 00078 /** Left mouse button */ 00079 #define HIDDMouse_LEFT_BUTTON (1 << 0) 00080 /** Right mouse button */ 00081 #define HIDDMouse_RIGHT_BUTTON (1 << 1) 00082 /** Middle mouse button */ 00083 #define HIDDMouse_MIDDLE_BUTTON (1 << 2) 00084 /** @}*/ 00085 00086 /** Size of the report descriptor in bytes. */ 00087 #define HIDDMouseDriver_REPORTDESCRIPTORSIZE 50 00088 00089 /*------------------------------------------------------------------------------ 00090 * Types 00091 *------------------------------------------------------------------------------*/ 00092 #pragma pack(1) 00093 #if defined ( __CC_ARM ) /* Keil ¦̀Vision 4 */ 00094 #elif defined ( __ICCARM__ ) /* IAR Ewarm */ 00095 #define __attribute__(...) 00096 #define __packed__ packed 00097 #elif defined ( __GNUC__ ) /* GCC CS3 */ 00098 #define __packed__ aligned(1) 00099 #endif 00100 00101 /** 00102 * \typedef HIDDMouseDriverConfigurationDescriptors 00103 * \brief List of descriptors that make up the configuration descriptors of a 00104 * device using the HID Mouse driver. 00105 */ 00106 typedef struct _HIDDMouseDriverConfigurationDescriptors { 00107 00108 /** Configuration descriptor. */ 00109 USBConfigurationDescriptor configuration; 00110 /** Interface descriptor. */ 00111 USBInterfaceDescriptor interface; 00112 /** HID descriptor. */ 00113 HIDDescriptor1 hid; 00114 /** Interrupt IN endpoint descriptor. */ 00115 USBEndpointDescriptor interruptIn; 00116 00117 } __attribute__ ((__packed__)) HIDDMouseDriverConfigurationDescriptors; 00118 00119 /** 00120 * \typedef HIDDMouseInputReport 00121 * \brief HID input report data struct used by the Mouse driver to notify the 00122 * host of pressed keys. 00123 */ 00124 typedef struct _HIDDMouseInputReport { 00125 00126 uint8_t bmButtons; /**< Bitmap state of three mouse buttons. */ 00127 int8_t bX; /**< Pointer displacement along the X axis. */ 00128 int8_t bY; /**< Pointer displacement along the Y axis. */ 00129 } __attribute__ ((__packed__)) HIDDMouseInputReport; /* GCC */ 00130 00131 #pragma pack() 00132 00133 /*------------------------------------------------------------------------------ 00134 * Exported functions 00135 *------------------------------------------------------------------------------*/ 00136 00137 extern void HIDDMouseDriver_Initialize(const USBDDriverDescriptors *pDescriptors); 00138 00139 extern void HIDDMouseDriver_ConfigurationChangedHandler(uint8_t cfgnum); 00140 00141 extern void HIDDMouseDriver_RequestHandler(const USBGenericRequest *request); 00142 00143 extern uint8_t HIDDMouseDriver_ChangePoints(uint8_t bmButtons, 00144 int8_t deltaX, 00145 int8_t deltaY); 00146 00147 extern void HIDDMouseDriver_RemoteWakeUp(void); 00148 00149 /**@}*/ 00150 00151 #endif /*#ifndef HIDDKEYBOARDDRIVER_H */ 00152