Skip to content

Commit

Permalink
Merge pull request #236 from inada-s/cmb-button-support
Browse files Browse the repository at this point in the history
PS2 Like L2/R2 support
  • Loading branch information
inada-s authored Jul 31, 2023
2 parents 3762c2e + 60b0f43 commit 0845905
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
8 changes: 4 additions & 4 deletions core/input/mapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ button_list[] =
{ EMU_BTN_FFORWARD, "emulator", "btn_fforward" },
{ DC_AXIS_LT, "compat", "btn_trigger_left" },
{ DC_AXIS_RT, "compat", "btn_trigger_right" },
{ DC_AXIS_LT2, "compat", "btn_trigger_left2" },
{ DC_AXIS_RT2, "compat", "btn_trigger_right2" },
{ DC_AXIS_LT2, "compat", "btn_trigger2_left" },
{ DC_AXIS_RT2, "compat", "btn_trigger2_right" },
{ DC_AXIS_UP, "compat", "btn_analog_up" },
{ DC_AXIS_DOWN, "compat", "btn_analog_down" },
{ DC_AXIS_LEFT, "compat", "btn_analog_left" },
Expand Down Expand Up @@ -87,8 +87,8 @@ axis_list[] =
{ DC_AXIS3_DOWN, "", "axis3_down", "", "" },
{ DC_AXIS_LT, "dreamcast", "axis_trigger_left", "compat", "axis_trigger_left_inverted" },
{ DC_AXIS_RT, "dreamcast", "axis_trigger_right", "compat", "axis_trigger_right_inverted" },
{ DC_AXIS_LT2, "dreamcast", "axis_trigger_left2", "compat", "axis_trigger_left2_inverted" },
{ DC_AXIS_RT2, "dreamcast", "axis_trigger_right2", "compat", "axis_trigger_right2_inverted" },
{ DC_AXIS_LT2, "dreamcast", "axis_trigger2_left", "compat", "axis_trigger2_left_inverted" },
{ DC_AXIS_RT2, "dreamcast", "axis_trigger2_right", "compat", "axis_trigger2_right_inverted" },

// legacy (v2)
{ DC_AXIS_RIGHT, "dreamcast", "axis_x", "compat", "axis_x_inverted" },
Expand Down
11 changes: 11 additions & 0 deletions core/network/ggpo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include "cfg/option.h"
#include <algorithm>

#include "gdxsv/gdxsv_emu_hooks.h"

void UpdateInputState();

namespace ggpo
Expand Down Expand Up @@ -67,6 +69,11 @@ static void getLocalInput(MapleInputState inputState[4])
mo_x_delta[player] -= relX;
mo_y_delta[player] -= relY;
mo_wheel_delta[player] -= wheel;

if (gdxsv_enabled()) {
if (state.halfAxes[PJTI_L2] >= 64) state.kcode &= ~(DC_BTN_A | DC_BTN_X);
if (state.halfAxes[PJTI_R2] >= 64) state.kcode &= ~(DC_BTN_A | DC_BTN_Y);
}
}
}

Expand Down Expand Up @@ -803,6 +810,10 @@ bool nextFrame()
{
inputs.exInput = localExInput;
}
if (gdxsv_enabled()) {
if (lt2[0] >= 64) inputs.kcode |= DC_BTN_A | DC_BTN_X;
if (rt2[0] >= 64) inputs.kcode |= DC_BTN_A | DC_BTN_Y;
}
error = ggpo_add_local_input(ggpoSession, localPlayer, &inputs, inputSize);
if (error == GGPO_OK)
{
Expand Down

0 comments on commit 0845905

Please sign in to comment.