xref: /haiku/src/add-ons/kernel/drivers/input/hid_shared/HIDParser.h (revision 52c4471a3024d2eb81fe88e2c3982b9f8daa5e56)
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 		size_t					MaxReportSize(uint8 type);
34 
35 		HIDCollection *			RootCollection() { return fRootCollection; };
36 
37 		void					SetReport(status_t status, uint8 *report,
38 									size_t length);
39 
40 		void					PrintToStream();
41 
42 private:
43 		HIDReport *				_FindOrCreateReport(uint8 type, uint8 id);
44 		float					_CalculateResolution(global_item_state *state);
45 		void					_Reset();
46 
47 		HIDDevice *				fDevice;
48 		bool					fUsesReportIDs;
49 		Vector<HIDReport *>		fReports;
50 		HIDCollection *			fRootCollection;
51 };
52 
53 #endif // HID_PARSER_H
54