Merge "[dynamic_sensor] correctly interpret HID data" am: dcbe8650b6
am: 69f047a046
Original change: https://android-review.googlesource.com/c/platform/hardware/libhardware/+/2213197 Change-Id: Id17fc1b60204e3d6b552763afaab6dd0680d6fa8 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
28bb4526f9
2 changed files with 8 additions and 3 deletions
|
@ -1066,7 +1066,10 @@ bool HidRawSensor::getHeadTrackerEventData(const std::vector<uint8_t> &message,
|
|||
bool HidRawSensor::getSensorEventData(const std::vector<uint8_t> &message,
|
||||
sensors_event_t *event) {
|
||||
for (const auto &rec : mTranslateTable) {
|
||||
int64_t v = (message[rec.byteOffset + rec.byteSize - 1] & 0x80) ? -1 : 0;
|
||||
int64_t v = 0;
|
||||
if (rec.minValue < 0) {
|
||||
v = (message[rec.byteOffset + rec.byteSize - 1] & 0x80) ? -1 : 0;
|
||||
}
|
||||
for (int i = static_cast<int>(rec.byteSize) - 1; i >= 0; --i) {
|
||||
v = (v << 8) | message[rec.byteOffset + i]; // HID is little endian
|
||||
}
|
||||
|
|
|
@ -154,9 +154,11 @@ private:
|
|||
bool getReportFieldValue(const std::vector<uint8_t> &message,
|
||||
ReportTranslateRecord* rec, ValueType* value) {
|
||||
bool valid = true;
|
||||
int64_t v;
|
||||
int64_t v = 0;
|
||||
if (rec->minValue < 0) {
|
||||
v = (message[rec->byteOffset + rec->byteSize - 1] & 0x80) ? -1 : 0;
|
||||
}
|
||||
|
||||
v = (message[rec->byteOffset + rec->byteSize - 1] & 0x80) ? -1 : 0;
|
||||
for (int i = static_cast<int>(rec->byteSize) - 1; i >= 0; --i) {
|
||||
v = (v << 8) | message[rec->byteOffset + i]; // HID is little endian
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue