xref: /haiku/src/add-ons/kernel/drivers/input/hid_shared/HIDReportItem.h (revision 4c8e85b316c35a9161f5a1c50ad70bc91c83a76f)
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 
27 		uint16					UsagePage();
28 		uint16					UsageID();
29 
30 		uint32					Usage() { return fUsage; };
31 
32 		status_t				Extract();
33 		status_t				Insert();
34 
35 		status_t				SetData(uint32 data);
36 		uint32					Data() { return fData; };
37 
38 		uint32					ScaledData(uint8 scaleToBits, bool toBeSigned);
39 		uint32					ScaledRangeData(uint32 minimum, uint32 maximum);
40 		float					ScaledFloatData();
41 
42 		bool					Valid() { return fValid; };
43 
44 		void					PrintToStream(uint32 indentLevel = 0);
45 private:
46 		HIDReport *				fReport;
47 		uint32					fByteOffset;
48 		uint8					fShift;
49 		uint32					fMask;
50 		uint8					fBitCount;
51 		uint8					fByteCount;
52 		bool					fHasData;
53 		bool					fArray;
54 		bool					fRelative;
55 		uint32					fMinimum;
56 		uint32					fMaximum;
57 		uint32					fUsage;
58 
59 		uint32					fData;
60 		bool					fValid;
61 };
62 
63 #endif // HID_REPORT_ITEM_H
64