Add HIDReportItem::ScaledFloatData() which scales the data into a float range
from 0.0 to 1.0. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41948 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
21f237c0af
commit
6eabc83386
@ -146,6 +146,18 @@ HIDReportItem::ScaledData(uint8 scaleToBits, bool toBeSigned)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float
|
||||||
|
HIDReportItem::ScaledFloatData()
|
||||||
|
{
|
||||||
|
if (Signed()) {
|
||||||
|
return (double)((int32)fData - (int32)fMinimum)
|
||||||
|
/ (fMaximum - (int32)fMinimum);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (double)(fData - fMinimum) / (fMaximum - fMinimum);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
HIDReportItem::PrintToStream(uint32 indentLevel)
|
HIDReportItem::PrintToStream(uint32 indentLevel)
|
||||||
{
|
{
|
||||||
|
@ -37,6 +37,7 @@ public:
|
|||||||
uint32 Data() { return fData; };
|
uint32 Data() { return fData; };
|
||||||
|
|
||||||
uint32 ScaledData(uint8 scaleToBits, bool toBeSigned);
|
uint32 ScaledData(uint8 scaleToBits, bool toBeSigned);
|
||||||
|
float ScaledFloatData();
|
||||||
|
|
||||||
bool Valid() { return fValid; };
|
bool Valid() { return fValid; };
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user