12b4bf3eeSJérôme Duval /* 22b4bf3eeSJérôme Duval * Copyright 2009, Michael Lotz, mmlr@mlotz.ch. 32b4bf3eeSJérôme Duval * Distributed under the terms of the MIT License. 42b4bf3eeSJérôme Duval */ 52b4bf3eeSJérôme Duval #ifndef HID_REPORT_H 62b4bf3eeSJérôme Duval #define HID_REPORT_H 72b4bf3eeSJérôme Duval 82b4bf3eeSJérôme Duval #include "HIDParser.h" 98df86553SLt-Henry #include "util/Vector.h" 108df86553SLt-Henry 112b4bf3eeSJérôme Duval 122b4bf3eeSJérôme Duval #ifndef USERLAND_HID 132b4bf3eeSJérôme Duval #include <condition_variable.h> 142b4bf3eeSJérôme Duval #endif 152b4bf3eeSJérôme Duval 162b4bf3eeSJérôme Duval #define HID_REPORT_TYPE_INPUT 0x01 172b4bf3eeSJérôme Duval #define HID_REPORT_TYPE_OUTPUT 0x02 182b4bf3eeSJérôme Duval #define HID_REPORT_TYPE_FEATURE 0x04 192b4bf3eeSJérôme Duval #define HID_REPORT_TYPE_ANY 0x07 202b4bf3eeSJérôme Duval 212b4bf3eeSJérôme Duval class HIDCollection; 222b4bf3eeSJérôme Duval class HIDReportItem; 232b4bf3eeSJérôme Duval 242b4bf3eeSJérôme Duval class HIDReport { 252b4bf3eeSJérôme Duval public: 262b4bf3eeSJérôme Duval HIDReport(HIDParser *parser, uint8 type, 272b4bf3eeSJérôme Duval uint8 id); 282b4bf3eeSJérôme Duval ~HIDReport(); 292b4bf3eeSJérôme Duval Type()302b4bf3eeSJérôme Duval uint8 Type() { return fType; }; ID()312b4bf3eeSJérôme Duval uint8 ID() { return fReportID; }; ReportSize()322b4bf3eeSJérôme Duval size_t ReportSize() { return (fReportSize + 7) / 8; }; 332b4bf3eeSJérôme Duval Parser()342b4bf3eeSJérôme Duval HIDParser * Parser() { return fParser; }; Device()352b4bf3eeSJérôme Duval HIDDevice * Device() { return fParser->Device(); }; 362b4bf3eeSJérôme Duval 372b4bf3eeSJérôme Duval void AddMainItem(global_item_state &globalState, 382b4bf3eeSJérôme Duval local_item_state &localState, 392b4bf3eeSJérôme Duval main_item_data &mainData, 402b4bf3eeSJérôme Duval HIDCollection *collection); 412b4bf3eeSJérôme Duval 422b4bf3eeSJérôme Duval void SetReport(status_t status, uint8 *report, 432b4bf3eeSJérôme Duval size_t length); CurrentReport()442b4bf3eeSJérôme Duval uint8 * CurrentReport() { return fCurrentReport; }; 452b4bf3eeSJérôme Duval 462b4bf3eeSJérôme Duval #ifndef USERLAND_HID 472b4bf3eeSJérôme Duval status_t SendReport(); 482b4bf3eeSJérôme Duval #endif 492b4bf3eeSJérôme Duval CountItems()508df86553SLt-Henry uint32 CountItems() { return fItems.Count(); }; 512b4bf3eeSJérôme Duval HIDReportItem * ItemAt(uint32 index); 522b4bf3eeSJérôme Duval HIDReportItem * FindItem(uint16 usagePage, uint16 usageID); 532b4bf3eeSJérôme Duval 54*366e9a62SLt-Henry uint32 * Usages(); CountUsages()55*366e9a62SLt-Henry uint32 CountUsages() { return fUsages.Count(); }; 56*366e9a62SLt-Henry 572b4bf3eeSJérôme Duval #ifndef USERLAND_HID 582b4bf3eeSJérôme Duval status_t WaitForReport(bigtime_t timeout); 592b4bf3eeSJérôme Duval void DoneProcessing(); 602b4bf3eeSJérôme Duval #endif 612b4bf3eeSJérôme Duval 622b4bf3eeSJérôme Duval void PrintToStream(); 632b4bf3eeSJérôme Duval 642b4bf3eeSJérôme Duval private: 652b4bf3eeSJérôme Duval void _SignExtend(uint32 &minimum, uint32 &maximum); 662b4bf3eeSJérôme Duval 672b4bf3eeSJérôme Duval HIDParser * fParser; 682b4bf3eeSJérôme Duval 692b4bf3eeSJérôme Duval uint8 fType; 702b4bf3eeSJérôme Duval uint8 fReportID; 712b4bf3eeSJérôme Duval uint32 fReportSize; 722b4bf3eeSJérôme Duval 738df86553SLt-Henry Vector<HIDReportItem *> fItems; 742b4bf3eeSJérôme Duval 752b4bf3eeSJérôme Duval status_t fReportStatus; 762b4bf3eeSJérôme Duval uint8 * fCurrentReport; 772b4bf3eeSJérôme Duval int32 fBusyCount; 782b4bf3eeSJérôme Duval 79*366e9a62SLt-Henry Vector<uint32> fUsages; 80*366e9a62SLt-Henry 812b4bf3eeSJérôme Duval #ifndef USERLAND_HID 822b4bf3eeSJérôme Duval ConditionVariable fConditionVariable; 832b4bf3eeSJérôme Duval #endif 842b4bf3eeSJérôme Duval }; 852b4bf3eeSJérôme Duval 862b4bf3eeSJérôme Duval #endif // HID_REPORT_H 87