From a908773a13ee491f2f8907cdf57c26fb39e10658 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Wed, 6 May 2009 12:43:00 +0000 Subject: Change device demos to cache the board button values in the same manner as the board joystick to maintain consistency. --- Demos/Device/Joystick/Joystick.c | 14 ++++++++------ Demos/Device/Mouse/Mouse.c | 5 +++-- 2 files changed, 11 insertions(+), 8 deletions(-) (limited to 'Demos/Device') diff --git a/Demos/Device/Joystick/Joystick.c b/Demos/Device/Joystick/Joystick.c index b2de42fc2..cf136d076 100644 --- a/Demos/Device/Joystick/Joystick.c +++ b/Demos/Device/Joystick/Joystick.c @@ -153,9 +153,10 @@ EVENT_HANDLER(USB_UnhandledControlPacket) */ bool GetNextReport(USB_JoystickReport_Data_t* ReportData) { - static uint8_t PrevJoyStatus = 0; - uint8_t JoyStatus_LCL = Joystick_GetStatus(); - bool InputChanged = false; + static uint8_t PrevJoyStatus = 0; + uint8_t JoyStatus_LCL = Joystick_GetStatus(); + uint8_t ButtonStatus_LCL = Buttons_GetStatus(); + bool InputChanged = false; /* Clear the report contents */ memset(ReportData, 0, sizeof(USB_JoystickReport_Data_t)); @@ -173,14 +174,15 @@ bool GetNextReport(USB_JoystickReport_Data_t* ReportData) if (JoyStatus_LCL & JOY_PRESS) ReportData->Button = (1 << 1); - if (Buttons_GetStatus() & BUTTONS_BUTTON1) + if (ButtonStatus_LCL & BUTTONS_BUTTON1) ReportData->Button |= (1 << 0); /* 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 */ - PrevJoyStatus = JoyStatus_LCL; + PrevJoyStatus = JoyStatus_LCL; + PrevButtonStatus = ButtonStatus_LCL; /* Return whether the new report is different to the previous report or not */ return InputChanged; diff --git a/Demos/Device/Mouse/Mouse.c b/Demos/Device/Mouse/Mouse.c index 7fff291f4..763d366e9 100644 --- a/Demos/Device/Mouse/Mouse.c +++ b/Demos/Device/Mouse/Mouse.c @@ -287,7 +287,8 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK) */ 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 */ memset(ReportData, 0, sizeof(USB_MouseReport_Data_t)); @@ -305,7 +306,7 @@ void CreateMouseReport(USB_MouseReport_Data_t* ReportData) if (JoyStatus_LCL & JOY_PRESS) ReportData->Button = (1 << 0); - if (Buttons_GetStatus() & BUTTONS_BUTTON1) + if (ButtonStatus_LCL & BUTTONS_BUTTON1) ReportData->Button |= (1 << 1); } -- cgit v1.2.3