diff --git a/src/add-ons/kernel/drivers/input/usb_hid/HIDReportItem.cpp b/src/add-ons/kernel/drivers/input/usb_hid/HIDReportItem.cpp index e014df2715..5f937a6c11 100644 --- a/src/add-ons/kernel/drivers/input/usb_hid/HIDReportItem.cpp +++ b/src/add-ons/kernel/drivers/input/usb_hid/HIDReportItem.cpp @@ -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 HIDReportItem::PrintToStream(uint32 indentLevel) { diff --git a/src/add-ons/kernel/drivers/input/usb_hid/HIDReportItem.h b/src/add-ons/kernel/drivers/input/usb_hid/HIDReportItem.h index ed1cf63501..23238b5bec 100644 --- a/src/add-ons/kernel/drivers/input/usb_hid/HIDReportItem.h +++ b/src/add-ons/kernel/drivers/input/usb_hid/HIDReportItem.h @@ -37,6 +37,7 @@ public: uint32 Data() { return fData; }; uint32 ScaledData(uint8 scaleToBits, bool toBeSigned); + float ScaledFloatData(); bool Valid() { return fValid; };