xref: /haiku/src/add-ons/kernel/drivers/input/hid_shared/HIDParser.h (revision 3d4afef9cba2f328e238089d4609d00d4b1524f3)
1 /*
2  * Copyright 2009, Michael Lotz, mmlr@mlotz.ch.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef HID_PARSER_H
6 #define HID_PARSER_H
7 
8 #include "HIDDataTypes.h"
9 #include "util/Vector.h"
10 
11 
12 class HIDCollection;
13 class HIDDevice;
14 class HIDReport;
15 
16 class HIDParser {
17 public:
18 								HIDParser(HIDDevice *device);
19 								~HIDParser();
20 
21 		HIDDevice *				Device() { return fDevice; };
22 
23 		status_t				ParseReportDescriptor(
24 									const uint8 *reportDescriptor,
25 									size_t descriptorLength);
26 
27 		bool					UsesReportIDs() { return fUsesReportIDs; };
28 
29 		HIDReport *				FindReport(uint8 type, uint8 id);
30 		uint8					CountReports(uint8 type);
31 		HIDReport *				ReportAt(uint8 type, uint8 index);
32 		size_t					MaxReportSize();
33 
34 		HIDCollection *			RootCollection() { return fRootCollection; };
35 
36 		void					SetReport(status_t status, uint8 *report,
37 									size_t length);
38 
39 		void					PrintToStream();
40 
41 private:
42 		HIDReport *				_FindOrCreateReport(uint8 type, uint8 id);
43 		float					_CalculateResolution(global_item_state *state);
44 		void					_Reset();
45 
46 		HIDDevice *				fDevice;
47 		bool					fUsesReportIDs;
48 		Vector<HIDReport *>		fReports;
49 		HIDCollection *			fRootCollection;
50 };
51 
52 #endif // HID_PARSER_H
53