jvs: fix analog axes values encoding

The least significant byte of analog axis values seems to be handled as
signed.
Fixes crazy taxi going right when turning full left.
Issue #1627
This commit is contained in:
Flyinghead 2024-09-01 18:38:58 +02:00
parent 8cb847940b
commit 1223154665
1 changed files with 6 additions and 1 deletions

View File

@ -2267,7 +2267,7 @@ u32 jvs_io_board::handle_jvs_message(u8 *buffer_in, u32 length_in, u8 *buffer_ou
}
else
{
axis_value = read_analog_axis(player_num, axisDesc.axis, axisDesc.inverted);
axis_value = read_analog_axis(player_num, axisDesc.axis, axisDesc.inverted);
}
}
else
@ -2280,6 +2280,11 @@ u32 jvs_io_board::handle_jvs_message(u8 *buffer_in, u32 length_in, u8 *buffer_ou
axis_value = read_analog_axis(player_num, player_axis, false);
}
LOGJVS("%d:%4x ", axis, axis_value);
// Strangely, the least significant byte appears to be handled as signed,
// so we compensate when it's negative.
// This might overflow but the value is still read correctly.
if (axis_value & 0x80)
axis_value += 0x100;
JVS_OUT(axis_value >> 8);
JVS_OUT(axis_value);
}