Change device demos to cache the board button values in the same manner as the board joystick to maintain consistency.

pull/1469/head
Dean Camera 16 years ago
parent 63a8f66d92
commit a908773a13

@ -153,9 +153,10 @@ EVENT_HANDLER(USB_UnhandledControlPacket)
*/ */
bool GetNextReport(USB_JoystickReport_Data_t* ReportData) bool GetNextReport(USB_JoystickReport_Data_t* ReportData)
{ {
static uint8_t PrevJoyStatus = 0; static uint8_t PrevJoyStatus = 0;
uint8_t JoyStatus_LCL = Joystick_GetStatus(); uint8_t JoyStatus_LCL = Joystick_GetStatus();
bool InputChanged = false; uint8_t ButtonStatus_LCL = Buttons_GetStatus();
bool InputChanged = false;
/* Clear the report contents */ /* Clear the report contents */
memset(ReportData, 0, sizeof(USB_JoystickReport_Data_t)); memset(ReportData, 0, sizeof(USB_JoystickReport_Data_t));
@ -173,14 +174,15 @@ bool GetNextReport(USB_JoystickReport_Data_t* ReportData)
if (JoyStatus_LCL & JOY_PRESS) if (JoyStatus_LCL & JOY_PRESS)
ReportData->Button = (1 << 1); ReportData->Button = (1 << 1);
if (Buttons_GetStatus() & BUTTONS_BUTTON1) if (ButtonStatus_LCL & BUTTONS_BUTTON1)
ReportData->Button |= (1 << 0); ReportData->Button |= (1 << 0);
/* Check if the new report is different to the previous report */ /* Check if the new report is different to the previous report */
InputChanged = (uint8_t)(PrevJoyStatus ^ JoyStatus_LCL); InputChanged = (uint8_t)(PrevJoyStatus ^ JoyStatus_LCL) | (uint8_t)(PrevButtonStatus ^ ButtonStatus_LCL);
/* Save the current joystick status for later comparison */ /* Save the current joystick status for later comparison */
PrevJoyStatus = JoyStatus_LCL; PrevJoyStatus = JoyStatus_LCL;
PrevButtonStatus = ButtonStatus_LCL;
/* Return whether the new report is different to the previous report or not */ /* Return whether the new report is different to the previous report or not */
return InputChanged; return InputChanged;

@ -287,7 +287,8 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK)
*/ */
void CreateMouseReport(USB_MouseReport_Data_t* ReportData) void CreateMouseReport(USB_MouseReport_Data_t* ReportData)
{ {
uint8_t JoyStatus_LCL = Joystick_GetStatus(); uint8_t JoyStatus_LCL = Joystick_GetStatus();
uint8_t ButtonStatus_LCL = Buttons_GetStatus();
/* Clear the report contents */ /* Clear the report contents */
memset(ReportData, 0, sizeof(USB_MouseReport_Data_t)); memset(ReportData, 0, sizeof(USB_MouseReport_Data_t));
@ -305,7 +306,7 @@ void CreateMouseReport(USB_MouseReport_Data_t* ReportData)
if (JoyStatus_LCL & JOY_PRESS) if (JoyStatus_LCL & JOY_PRESS)
ReportData->Button = (1 << 0); ReportData->Button = (1 << 0);
if (Buttons_GetStatus() & BUTTONS_BUTTON1) if (ButtonStatus_LCL & BUTTONS_BUTTON1)
ReportData->Button |= (1 << 1); ReportData->Button |= (1 << 1);
} }

@ -131,7 +131,7 @@ static void USB_Device_SetAddress(void)
static void USB_Device_SetConfiguration(void) static void USB_Device_SetConfiguration(void)
{ {
bool AlreadyConfigured = (USB_ConfigurationNumber != 0); bool AlreadyConfigured = (USB_ConfigurationNumber != 0);
#if defined(USE_SINGLE_DEVICE_CONFIGURATION) #if defined(USE_SINGLE_DEVICE_CONFIGURATION)
if ((uint8_t)USB_ControlRequest.wValue > 1) if ((uint8_t)USB_ControlRequest.wValue > 1)
@ -188,7 +188,7 @@ static void USB_Device_GetDescriptor(void)
#if defined(USE_RAM_DESCRIPTORS) #if defined(USE_RAM_DESCRIPTORS)
Endpoint_Write_Control_Stream_LE(DescriptorPointer, DescriptorSize); Endpoint_Write_Control_Stream_LE(DescriptorPointer, DescriptorSize);
#else #else
bool SendZLP; bool SendZLP;
if (USB_ControlRequest.wLength > DescriptorSize) if (USB_ControlRequest.wLength > DescriptorSize)
USB_ControlRequest.wLength = DescriptorSize; USB_ControlRequest.wLength = DescriptorSize;

Loading…
Cancel
Save