1aaeffcf7SMichael Lotz/*
2305aff3fSMichael Lotz * Copyright 2009-2011, Michael Lotz, mmlr@mlotz.ch.
3aaeffcf7SMichael Lotz * Distributed under the terms of the MIT License.
4aaeffcf7SMichael Lotz */
5e7fcf08dSMichael Lotz#ifndef HID_COLLECTION_H
6e7fcf08dSMichael Lotz#define HID_COLLECTION_H
7e7fcf08dSMichael Lotz
8e7fcf08dSMichael Lotz#include "HIDParser.h"
9e7fcf08dSMichael Lotz
10305aff3fSMichael Lotzclass HIDReport;
115ba33c51SMichael Lotzclass HIDReportItem;
125ba33c51SMichael Lotz
13e7fcf08dSMichael Lotzclass HIDCollection {
14e7fcf08dSMichael Lotzpublic:
15e7fcf08dSMichael Lotz								HIDCollection(HIDCollection *parent,
166e499760SMichael Lotz									uint8 type, local_item_state &localState);
17e7fcf08dSMichael Lotz								~HIDCollection();
18e7fcf08dSMichael Lotz
19305aff3fSMichael Lotz		uint8					Type() { return fType; };
20305aff3fSMichael Lotz
21305aff3fSMichael Lotz		uint16					UsagePage();
22305aff3fSMichael Lotz		uint16					UsageID();
23305aff3fSMichael Lotz
24e7fcf08dSMichael Lotz		HIDCollection *			Parent() { return fParent; };
25e7fcf08dSMichael Lotz
26e7fcf08dSMichael Lotz		status_t				AddChild(HIDCollection *child);
27e7fcf08dSMichael Lotz		uint32					CountChildren() { return fChildCount; };
28e7fcf08dSMichael Lotz		HIDCollection *			ChildAt(uint32 index);
29e7fcf08dSMichael Lotz
30305aff3fSMichael Lotz		uint32					CountChildrenFlat(uint8 type);
31305aff3fSMichael Lotz		HIDCollection *			ChildAtFlat(uint8 type, uint32 index);
32305aff3fSMichael Lotz
335ba33c51SMichael Lotz		void					AddItem(HIDReportItem *item);
345ba33c51SMichael Lotz		uint32					CountItems() { return fItemCount; };
355ba33c51SMichael Lotz		HIDReportItem *			ItemAt(uint32 index);
365ba33c51SMichael Lotz
37305aff3fSMichael Lotz		uint32					CountItemsFlat();
38305aff3fSMichael Lotz		HIDReportItem *			ItemAtFlat(uint32 index);
39305aff3fSMichael Lotz
40305aff3fSMichael Lotz		void					BuildReportList(uint8 reportType,
41305aff3fSMichael Lotz									HIDReport **reportList,
42305aff3fSMichael Lotz									uint32 &reportCount);
43305aff3fSMichael Lotz
445ba33c51SMichael Lotz		void					PrintToStream(uint32 indentLevel = 0);
45e7fcf08dSMichael Lotz
46e7fcf08dSMichael Lotzprivate:
47305aff3fSMichael Lotz		HIDCollection *			_ChildAtFlat(uint8 type, uint32 &index);
48305aff3fSMichael Lotz		HIDReportItem *			_ItemAtFlat(uint32 &index);
49305aff3fSMichael Lotz
50e7fcf08dSMichael Lotz		HIDCollection *			fParent;
51e7fcf08dSMichael Lotz
52e7fcf08dSMichael Lotz		uint8					fType;
53e7fcf08dSMichael Lotz		uint32					fUsage;
54e7fcf08dSMichael Lotz		uint8					fStringID;
55e7fcf08dSMichael Lotz		uint8					fPhysicalID;
56e7fcf08dSMichael Lotz
57e7fcf08dSMichael Lotz		uint32					fChildCount;
58e7fcf08dSMichael Lotz		HIDCollection **		fChildren;
595ba33c51SMichael Lotz
605ba33c51SMichael Lotz		uint32					fItemCount;
615ba33c51SMichael Lotz		uint32					fItemsAllocated;
625ba33c51SMichael Lotz		HIDReportItem **		fItems;
63e7fcf08dSMichael Lotz};
64e7fcf08dSMichael Lotz
65e7fcf08dSMichael Lotz#endif // HID_COLLECTION_H