/* 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 "i2cmaster/i2cmaster.h" #define output_low(port,pin) port &= ~(1<Button |= 1; } if (!(PIND&(1<<3))) { MouseReport->Button |= 2; } if (!(PIND&(1<<1))) { MouseReport->Button |= 4; } if (!(PIND&(1<<2))) { MouseReport->Button |= 1; } MouseReport->Wheel = 0; if (!(PIND&1) || !(PIND&(1<<2))) { // wheel MouseReport->Wheel = -ny; led_error(); } else { MouseReport->X = 2*abs(nx)*nx; MouseReport->Y = 2*abs(ny)*ny; } *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(); } }