/* LUFA Library Copyright (C) Dean Camera, 2018. dean [at] fourwalledcubicle [dot] com www.lufa-lib.org */ /* Copyright 2018 Dean Camera (dean [at] fourwalledcubicle [dot] com) Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this permission notice and warranty disclaimer appear in supporting documentation, and that the name of the author not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaims all warranties with regard to this software, including all implied warranties of merchantability and fitness. In no event shall the author be liable for any special, indirect or consequential damages or any damages whatsoever resulting from loss of use, data or profits, whether in an action of contract, negligence or other tortious action, arising out of or in connection with the use or performance of this software. */ #include #include #include #include #define output_low(port,pin) port &= ~(1<Button |= 1; } if (wheelmode==0) { wheelmode=1; } else if (wheelmode==3 && (PIND&2)) { wheelmode=0; } } else if (!(PIND&2)) { if (wheelmode==0) { MouseReport->Button |= 2; } else if (wheelmode==3) { MouseReport->Button |= 4; } } else { if (wheelmode<2) wheelmode=0; if (wheelmode==2) wheelmode=3; } //if ((nx!=0 || ny!=0) && (wheelmode>0 && wheelmode<3)) wheelmode=0; MouseReport->Wheel = 0; if (wheelmode<2) { MouseReport->X = nx; MouseReport->Y = ny; } else if (wheelmode>=3) { MouseReport->Wheel = -ny/3; } *ReportSize = sizeof(USB_WheelMouseReport_Data_t); return true; } /** HID class driver callback function for the processing of HID reports from the host. * * \param[in] HIDInterfaceInfo Pointer to the HID class interface configuration structure being referenced * \param[in] ReportID Report ID of the received report from the host * \param[in] ReportType The type of report that the host has sent, either HID_REPORT_ITEM_Out or HID_REPORT_ITEM_Feature * \param[in] ReportData Pointer to a buffer where the received report has been stored * \param[in] ReportSize Size in bytes of the received HID report */ void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, const uint8_t ReportID, const uint8_t ReportType, const void* ReportData, const uint16_t ReportSize) { // Unused (but mandatory for the HID class driver) in this demo, since there are no Host->Device reports } int main(void) { SetupHardware(); GlobalInterruptEnable(); for (;;) { HID_Device_USBTask(&Mouse_HID_Interface); USB_USBTask(); } }