From 6e499760b3237ba6706ad54c6cf4143e12a00e50 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Mon, 14 Mar 2011 20:21:38 +0000 Subject: [PATCH] * Since the usages of the local state are now processed also for collections there is no need to do the usage page and usage id handling anymore. * As this also removes the only use of the global state it is removed as well. * Try the usage maximum as a fallback as well and print something if none of the usage sources are valid and the collection ends up without a proper usage. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40954 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../drivers/input/usb_hid/HIDCollection.cpp | 21 ++++++++----------- .../drivers/input/usb_hid/HIDCollection.h | 3 +-- .../drivers/input/usb_hid/HIDParser.cpp | 2 +- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/add-ons/kernel/drivers/input/usb_hid/HIDCollection.cpp b/src/add-ons/kernel/drivers/input/usb_hid/HIDCollection.cpp index 155f4f1965..f0a24c473e 100644 --- a/src/add-ons/kernel/drivers/input/usb_hid/HIDCollection.cpp +++ b/src/add-ons/kernel/drivers/input/usb_hid/HIDCollection.cpp @@ -18,7 +18,7 @@ HIDCollection::HIDCollection(HIDCollection *parent, uint8 type, - global_item_state &globalState, local_item_state &localState) + local_item_state &localState) : fParent(parent), fType(type), fStringID(localState.string_index), @@ -30,17 +30,14 @@ HIDCollection::HIDCollection(HIDCollection *parent, uint8 type, fItems(NULL) { usage_value usageValue; - usageValue.u.s.usage_page = globalState.usage_page; - if (localState.usage_stack != NULL && localState.usage_stack_used > 0) { - if (localState.usage_stack[0].is_extended) - usageValue.u.extended = localState.usage_stack[0].u.extended; - else - usageValue.u.s.usage_id = localState.usage_stack[0].u.s.usage_id; - } else if (localState.usage_minimum_set) { - if (localState.usage_minimum.is_extended) - usageValue.u.extended = localState.usage_minimum.u.extended; - else - usageValue.u.s.usage_id = localState.usage_minimum.u.s.usage_id; + if (localState.usage_stack != NULL && localState.usage_stack_used > 0) + usageValue.u.extended = localState.usage_stack[0].u.extended; + else if (localState.usage_minimum_set) + usageValue.u.extended = localState.usage_minimum.u.extended; + else if (localState.usage_maximum_set) + usageValue.u.extended = localState.usage_maximum.u.extended; + else { + TRACE_ALWAYS("non of the possible usages for the collection are set\n"); } fUsage = usageValue.u.extended; diff --git a/src/add-ons/kernel/drivers/input/usb_hid/HIDCollection.h b/src/add-ons/kernel/drivers/input/usb_hid/HIDCollection.h index badef89fa8..917ebc3503 100644 --- a/src/add-ons/kernel/drivers/input/usb_hid/HIDCollection.h +++ b/src/add-ons/kernel/drivers/input/usb_hid/HIDCollection.h @@ -12,8 +12,7 @@ class HIDReportItem; class HIDCollection { public: HIDCollection(HIDCollection *parent, - uint8 type, global_item_state &globalState, - local_item_state &localState); + uint8 type, local_item_state &localState); ~HIDCollection(); HIDCollection * Parent() { return fParent; }; diff --git a/src/add-ons/kernel/drivers/input/usb_hid/HIDParser.cpp b/src/add-ons/kernel/drivers/input/usb_hid/HIDParser.cpp index 0d1cc9f5d2..5461b9b7bf 100644 --- a/src/add-ons/kernel/drivers/input/usb_hid/HIDParser.cpp +++ b/src/add-ons/kernel/drivers/input/usb_hid/HIDParser.cpp @@ -132,7 +132,7 @@ HIDParser::ParseReportDescriptor(const uint8 *reportDescriptor, if (item->tag == ITEM_TAG_MAIN_COLLECTION) { HIDCollection *newCollection = new(std::nothrow) HIDCollection(collection, - (uint8)data, globalState, localState); + (uint8)data, localState); if (newCollection == NULL) { TRACE_ALWAYS("no memory to allocate new collection\n"); break;