Skip to content

Commit 9a5f397

Browse files
committed
Fix parsing signed bytes and incorrect byte reading for 4 bytes
1 parent 7cb59ce commit 9a5f397

File tree

1 file changed

+2
-2
lines changed
  • Packages/com.unity.inputsystem/InputSystem/Plugins/HID

1 file changed

+2
-2
lines changed

Packages/com.unity.inputsystem/InputSystem/Plugins/HID/HIDParser.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ private unsafe static int ReadData(int itemSize, byte* currentPtr, byte* endPtr)
267267
{
268268
if (currentPtr >= endPtr)
269269
return 0;
270-
return *currentPtr;
270+
return (sbyte)*currentPtr;
271271
}
272272

273273
// Read short.
@@ -291,7 +291,7 @@ private unsafe static int ReadData(int itemSize, byte* currentPtr, byte* endPtr)
291291
var data3 = *(currentPtr + 2);
292292
var data4 = *(currentPtr + 3);
293293

294-
return (data4 << 24) | (data3 << 24) | (data2 << 8) | data1;
294+
return (data4 << 24) | (data3 << 16) | (data2 << 8) | data1;
295295
}
296296

297297
Debug.Assert(false, "Should not reach here");

0 commit comments

Comments
 (0)