diff options
| author | Dean <Dean@d5102386-fcda-11dd-9fdb-3debd5008f28> | 2010-08-09 12:04:52 +0000 |
|---|---|---|
| committer | Dean <Dean@d5102386-fcda-11dd-9fdb-3debd5008f28> | 2010-08-09 12:04:52 +0000 |
| commit | ef9fa0dc3a6d633ecf7502f3792e0d1c099a7bfd (patch) | |
| tree | ba8722f487a1da31044cdf06caab6def812f6530 /Demos/Host/ClassDriver/JoystickHostWithParser | |
| parent | 1825f1f0c7c35827b76f841d4e075766a8055d1e (diff) | |
Tighten up the code in the delta movement detection code in the MouseHostWithParser and JoystickHostWithParser demos. Make the ClassDriver JoystickHostWithParser demo use the HID_ALIGN_DATA() macro instead of manual shifting and casting.
git-svn-id: http://lufa-lib.googlecode.com/svn/trunk@1439 d5102386-fcda-11dd-9fdb-3debd5008f28
Diffstat (limited to 'Demos/Host/ClassDriver/JoystickHostWithParser')
| -rw-r--r-- | Demos/Host/ClassDriver/JoystickHostWithParser/JoystickHostWithParser.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/Demos/Host/ClassDriver/JoystickHostWithParser/JoystickHostWithParser.c b/Demos/Host/ClassDriver/JoystickHostWithParser/JoystickHostWithParser.c index f1b4cac7..8420d05a 100644 --- a/Demos/Host/ClassDriver/JoystickHostWithParser/JoystickHostWithParser.c +++ b/Demos/Host/ClassDriver/JoystickHostWithParser/JoystickHostWithParser.c @@ -148,16 +148,13 @@ int main(void) (ReportItem->Attributes.Usage.Usage == USAGE_Y)) && (ReportItem->ItemType == REPORT_ITEM_TYPE_In)) { - int16_t DeltaMovement = (int16_t)(ReportItem->Value << (16 - ReportItem->Attributes.BitSize)); + int16_t DeltaMovement = HID_ALIGN_DATA(ReportItem, int16_t); - if (ReportItem->Attributes.Usage.Usage == USAGE_X) + if (DeltaMovement) { - if (DeltaMovement) + if (ReportItem->Attributes.Usage.Usage == USAGE_X) LEDMask |= ((DeltaMovement > 0) ? LEDS_LED1 : LEDS_LED2); - } - else - { - if (DeltaMovement) + else LEDMask |= ((DeltaMovement > 0) ? LEDS_LED3 : LEDS_LED4); } } |
