xref: /haiku/src/add-ons/kernel/drivers/input/hid_shared/HIDReportItem.h (revision 82bfaa954dcfd90582fb2c1a0e918971eea57091)
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 usage);
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 		uint32					Minimum() { return fMinimum; }
27 
28 		uint16					UsagePage();
29 		uint16					UsageID();
30 
31 		uint32					Usage() { return fUsage; };
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					fUsage;
59 
60 		uint32					fData;
61 		bool					fValid;
62 };
63 
64 #endif // HID_REPORT_ITEM_H
65