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:
Michael Lotz 2011-06-05 23:53:04 +00:00
parent 21f237c0af
commit 6eabc83386
2 changed files with 13 additions and 0 deletions

View File

@ -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)
{ {

View File

@ -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; };