Skip to content

Commit

Permalink
jvs: fix analog axes values encoding
Browse files Browse the repository at this point in the history
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
  • Loading branch information
flyinghead committed Sep 1, 2024
1 parent 8cb8479 commit 1223154
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion core/hw/maple/maple_jvs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
Expand Down

0 comments on commit 1223154

Please sign in to comment.