1*2b4bf3eeSJérôme Duval /* 2*2b4bf3eeSJérôme Duval * Copyright 2011, Michael Lotz, mmlr@mlotz.ch. 3*2b4bf3eeSJérôme Duval * Distributed under the terms of the MIT License. 4*2b4bf3eeSJérôme Duval */ 5*2b4bf3eeSJérôme Duval #ifndef HID_WRITER_H 6*2b4bf3eeSJérôme Duval #define HID_WRITER_H 7*2b4bf3eeSJérôme Duval 8*2b4bf3eeSJérôme Duval #include "HIDDataTypes.h" 9*2b4bf3eeSJérôme Duval 10*2b4bf3eeSJérôme Duval 11*2b4bf3eeSJérôme Duval class HIDWriter { 12*2b4bf3eeSJérôme Duval public: 13*2b4bf3eeSJérôme Duval HIDWriter(size_t blockSize = 20); 14*2b4bf3eeSJérôme Duval ~HIDWriter(); 15*2b4bf3eeSJérôme Duval 16*2b4bf3eeSJérôme Duval // High Level 17*2b4bf3eeSJérôme Duval 18*2b4bf3eeSJérôme Duval status_t DefineInputPadding(uint8 count, 19*2b4bf3eeSJérôme Duval uint8 bitLength); 20*2b4bf3eeSJérôme Duval status_t DefineInputData(uint8 count, uint8 bitLength, 21*2b4bf3eeSJérôme Duval main_item_data data, uint32 logicalMinimum, 22*2b4bf3eeSJérôme Duval uint32 logicalMaximum, uint16 usagePage, 23*2b4bf3eeSJérôme Duval uint16 usageMinimum, 24*2b4bf3eeSJérôme Duval uint16 usageMaximum = 0xffff); 25*2b4bf3eeSJérôme Duval 26*2b4bf3eeSJérôme Duval status_t BeginCollection(uint8 collectionType, 27*2b4bf3eeSJérôme Duval uint16 usagePage, uint16 usageID); 28*2b4bf3eeSJérôme Duval status_t EndCollection(); 29*2b4bf3eeSJérôme Duval 30*2b4bf3eeSJérôme Duval // Low Level 31*2b4bf3eeSJérôme Duval 32*2b4bf3eeSJérôme Duval status_t SetUsagePage(uint16 usagePage); 33*2b4bf3eeSJérôme Duval status_t SetLogicalMinimum(uint32 logicalMinimum); 34*2b4bf3eeSJérôme Duval status_t SetLogicalMaximum(uint32 logicalMaximum); 35*2b4bf3eeSJérôme Duval status_t SetReportSize(uint8 reportSize); 36*2b4bf3eeSJérôme Duval status_t SetReportID(uint8 reportID); 37*2b4bf3eeSJérôme Duval status_t SetReportCount(uint8 reportCount); 38*2b4bf3eeSJérôme Duval 39*2b4bf3eeSJérôme Duval status_t LocalSetUsageID(uint16 usageID); 40*2b4bf3eeSJérôme Duval status_t LocalSetUsageMinimum(uint16 usageMinimum); 41*2b4bf3eeSJérôme Duval status_t LocalSetUsageMaximum(uint16 usageMaximum); 42*2b4bf3eeSJérôme Duval 43*2b4bf3eeSJérôme Duval status_t BeginCollection(uint8 collectionType); 44*2b4bf3eeSJérôme Duval 45*2b4bf3eeSJérôme Duval status_t Input(main_item_data data); 46*2b4bf3eeSJérôme Duval status_t Output(main_item_data data); 47*2b4bf3eeSJérôme Duval status_t Feature(main_item_data data); 48*2b4bf3eeSJérôme Duval 49*2b4bf3eeSJérôme Duval // Generic 50*2b4bf3eeSJérôme Duval 51*2b4bf3eeSJérôme Duval status_t WriteShortItem(uint8 type, uint8 tag, 52*2b4bf3eeSJérôme Duval uint32 value); 53*2b4bf3eeSJérôme Duval status_t Write(const void *data, size_t length); 54*2b4bf3eeSJérôme Duval BufferLength()55*2b4bf3eeSJérôme Duval size_t BufferLength() { return fBufferUsed; }; Buffer()56*2b4bf3eeSJérôme Duval const uint8 * Buffer() { return fBuffer; }; 57*2b4bf3eeSJérôme Duval 58*2b4bf3eeSJérôme Duval void Reset(); 59*2b4bf3eeSJérôme Duval 60*2b4bf3eeSJérôme Duval private: 61*2b4bf3eeSJérôme Duval size_t fBlockSize; 62*2b4bf3eeSJérôme Duval size_t fBufferAllocated; 63*2b4bf3eeSJérôme Duval size_t fBufferUsed; 64*2b4bf3eeSJérôme Duval uint8 * fBuffer; 65*2b4bf3eeSJérôme Duval status_t fStatus; 66*2b4bf3eeSJérôme Duval }; 67*2b4bf3eeSJérôme Duval 68*2b4bf3eeSJérôme Duval #endif // HID_WRITER_H 69