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 10 class HIDCollection; 11 class HIDDevice; 12 class HIDReport; 13 14 class HIDParser { 15 public: 16 HIDParser(HIDDevice *device); 17 ~HIDParser(); 18 19 HIDDevice * Device() { return fDevice; }; 20 21 status_t ParseReportDescriptor( 22 const uint8 *reportDescriptor, 23 size_t descriptorLength); 24 25 bool UsesReportIDs() { return fUsesReportIDs; }; 26 27 HIDReport * FindReport(uint8 type, uint8 id); 28 uint8 CountReports(uint8 type); 29 HIDReport * ReportAt(uint8 type, uint8 index); 30 size_t MaxReportSize(); 31 32 HIDCollection * RootCollection() { return fRootCollection; }; 33 34 void SetReport(status_t status, uint8 *report, 35 size_t length); 36 37 void PrintToStream(); 38 39 private: 40 HIDReport * _FindOrCreateReport(uint8 type, uint8 id); 41 float _CalculateResolution(global_item_state *state); 42 void _Reset(); 43 44 HIDDevice * fDevice; 45 bool fUsesReportIDs; 46 uint8 fReportCount; 47 HIDReport ** fReports; 48 HIDCollection * fRootCollection; 49 }; 50 51 #endif // HID_PARSER_H 52