X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/713670043a1edb714461fc83c2b8817f3db99961..9d733d44b402ce33c3c41e45b497c2f92be393f5:/Demos/Device/ClassDriver/Joystick/Joystick.c diff --git a/Demos/Device/ClassDriver/Joystick/Joystick.c b/Demos/Device/ClassDriver/Joystick/Joystick.c index c759e1346..3a8897fa8 100644 --- a/Demos/Device/ClassDriver/Joystick/Joystick.c +++ b/Demos/Device/ClassDriver/Joystick/Joystick.c @@ -1,21 +1,21 @@ /* LUFA Library - Copyright (C) Dean Camera, 2010. - + Copyright (C) Dean Camera, 2011. + dean [at] fourwalledcubicle [dot] com - www.fourwalledcubicle.com + www.lufa-lib.org */ /* - Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + 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 + 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 + 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 disclaim all warranties with regard to this @@ -37,7 +37,7 @@ #include "Joystick.h" /** Buffer to hold the previously generated HID report, for comparison purposes inside the HID class driver. */ -uint8_t PrevJoystickHIDReportBuffer[sizeof(USB_JoystickReport_Data_t)]; +static uint8_t PrevJoystickHIDReportBuffer[sizeof(USB_JoystickReport_Data_t)]; /** LUFA HID Class driver interface configuration and state information. This structure is * passed to all HID Class driver functions, so that multiple instances of the same class @@ -58,16 +58,17 @@ USB_ClassInfo_HID_Device_t Joystick_HID_Interface = }, }; + /** Main program entry point. This routine contains the overall program flow, including initial * setup of all components and the main program loop. */ int main(void) { SetupHardware(); - + LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); sei(); - + for (;;) { HID_Device_USBTask(&Joystick_HID_Interface); @@ -116,8 +117,8 @@ void EVENT_USB_Device_ConfigurationChanged(void) LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR); } -/** Event handler for the library USB Unhandled Control Request event. */ -void EVENT_USB_Device_UnhandledControlRequest(void) +/** Event handler for the library USB Control Request reception event. */ +void EVENT_USB_Device_ControlRequest(void) { HID_Device_ProcessControlRequest(&Joystick_HID_Interface); } @@ -145,7 +146,7 @@ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDIn uint16_t* const ReportSize) { USB_JoystickReport_Data_t* JoystickReport = (USB_JoystickReport_Data_t*)ReportData; - + uint8_t JoyStatus_LCL = Joystick_GetStatus(); uint8_t ButtonStatus_LCL = Buttons_GetStatus(); @@ -160,11 +161,11 @@ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDIn JoystickReport->X = 100; if (JoyStatus_LCL & JOY_PRESS) - JoystickReport->Button = (1 << 1); - + JoystickReport->Button |= (1 << 1); + if (ButtonStatus_LCL & BUTTONS_BUTTON1) JoystickReport->Button |= (1 << 0); - + *ReportSize = sizeof(USB_JoystickReport_Data_t); return false; } @@ -185,3 +186,4 @@ void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDI { // Unused (but mandatory for the HID class driver) in this demo, since there are no Host->Device reports } +