Input: fix infinite loop

Right shift on a signed value can extend the sign bit, which would make
this function do an infinite loop if passed a negative value. Use an
unsigned instead to get the behavior we want.

Fixes #15957, but this means we're using undefined data from the
settings file. I assumed it would have the unused button values set to 0
but this isn't apparently the case. Preetpal is already working on that
as we noticed the problem when testing her patch for adding a 6th
button.

Change-Id: I62fdc778ff3b9da92f3aa5570163dc60baf8cf2c
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2560
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
Adrien Destugues
2020-05-03 15:41:49 +00:00
committed by waddlesplash
parent 28b3438ecd
commit 3268566c20
+1 -1
View File
@@ -64,7 +64,7 @@ getButtonOffsets(int32 type)
static uint32
getMappingNumber(int32 mapping)
getMappingNumber(uint32 mapping)
{
if (mapping == 0)
return 0;