xref: /haiku/src/add-ons/kernel/drivers/input/hid_shared/HIDReportItem.h (revision 4a32f48e70297d9a634646f01e08c2f451ecd6bd)
1 /*
2  * Copyright 2009-2011, Michael Lotz, mmlr@mlotz.ch.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef HID_REPORT_ITEM_H
6 #define HID_REPORT_ITEM_H
7 
8 #include <SupportDefs.h>
9 
10 class HIDReport;
11 
12 class HIDReportItem {
13 public:
14 								HIDReportItem(HIDReport *report,
15 									uint32 bitOffset, uint8 bitLength,
16 									bool hasData, bool isArray, bool isRelative,
17 									uint32 minimum, uint32 maximum,
18 									uint32 usageMinimum, uint32 usageMaximum);
19 
20 		HIDReport *				Report() { return fReport; };
21 
22 		bool					HasData() { return fHasData; };
23 		bool					Relative() { return fRelative; };
24 		bool					Array() { return fArray; };
25 		bool					Signed() { return fMinimum > fMaximum; };
26 
27 		uint16					UsagePage();
28 		uint16					UsageID();
29 
30 		uint32					UsageMinimum() { return fUsageMinimum; };
31 		uint32					UsageMaximum() { return fUsageMaximum; };
32 
33 		status_t				Extract();
34 		status_t				Insert();
35 
36 		status_t				SetData(uint32 data);
37 		uint32					Data() { return fData; };
38 
39 		uint32					ScaledData(uint8 scaleToBits, bool toBeSigned);
40 		uint32					ScaledRangeData(uint32 minimum, uint32 maximum);
41 		float					ScaledFloatData();
42 
43 		bool					Valid() { return fValid; };
44 
45 		void					PrintToStream(uint32 indentLevel = 0);
46 private:
47 		HIDReport *				fReport;
48 		uint32					fByteOffset;
49 		uint8					fShift;
50 		uint32					fMask;
51 		uint8					fBitCount;
52 		uint8					fByteCount;
53 		bool					fHasData;
54 		bool					fArray;
55 		bool					fRelative;
56 		uint32					fMinimum;
57 		uint32					fMaximum;
58 		uint32					fUsageMinimum;
59 		uint32					fUsageMaximum;
60 
61 		uint32					fData;
62 		bool					fValid;
63 };
64 
65 #endif // HID_REPORT_ITEM_H
66