hid: Shift usage values to LSB.
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com> Signed-off-by: Aric Stewart <aric@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
ec7bdf6154
commit
daa9906cce
|
@ -49,32 +49,27 @@ static NTSTATUS get_report_data(BYTE *report, INT reportLength, INT startBit, IN
|
||||||
ULONG byte_index = startBit / 8;
|
ULONG byte_index = startBit / 8;
|
||||||
ULONG bit_index = startBit - (byte_index * 8);
|
ULONG bit_index = startBit - (byte_index * 8);
|
||||||
INT mask = (1 << bit_index);
|
INT mask = (1 << bit_index);
|
||||||
*value = (report[byte_index] & mask);
|
*value = !!(report[byte_index] & mask);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
ULONG remaining_bits = valueSize;
|
||||||
ULONG byte_index = startBit / 8;
|
ULONG byte_index = startBit / 8;
|
||||||
|
ULONG bit_index = startBit % 8;
|
||||||
ULONG data = 0;
|
ULONG data = 0;
|
||||||
ULONG remainingBits = valueSize;
|
|
||||||
ULONG shift = 0;
|
ULONG shift = 0;
|
||||||
ULONG begin_offset = startBit % 8;
|
while (remaining_bits)
|
||||||
while (remainingBits)
|
|
||||||
{
|
{
|
||||||
if (remainingBits >= 8)
|
ULONG copy_bits = 8 - bit_index;
|
||||||
{
|
if (remaining_bits < copy_bits)
|
||||||
BYTE mask = 0xff << begin_offset;
|
copy_bits = remaining_bits;
|
||||||
data |= (report[byte_index] & mask) << shift;
|
|
||||||
byte_index ++;
|
data |= ((report[byte_index] >> bit_index) & ((2 << copy_bits) - 1)) << shift;
|
||||||
remainingBits -= (8-begin_offset);
|
|
||||||
shift += (8-begin_offset);
|
shift += copy_bits;
|
||||||
begin_offset = 0;
|
bit_index = 0;
|
||||||
}
|
byte_index++;
|
||||||
else if (remainingBits > 0)
|
remaining_bits -= copy_bits;
|
||||||
{
|
|
||||||
BYTE mask = (0xff >> (8-remainingBits)) << begin_offset;
|
|
||||||
data |= (report[byte_index] & mask) << shift;
|
|
||||||
remainingBits = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
*value = data;
|
*value = data;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue