Support for analog L2/R2 values when a DS3 controller is used with PS Vita. (#17261)

This commit is contained in:
zoltanvb 2024-12-15 18:24:13 +01:00 committed by GitHub
parent 7be52caff8
commit 5cfaf09f55
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 4 deletions

View File

@ -57,7 +57,7 @@ static SceCtrlActuator actuators[DEFAULT_MAX_PADS] = {0};
/* TODO/FIXME - static globals */
static uint64_t pad_state[DEFAULT_MAX_PADS];
static int16_t analog_state[DEFAULT_MAX_PADS][2][2];
static int16_t analog_state[DEFAULT_MAX_PADS][3][2];
/* TODO/FIXME - global referenced outside */
extern uint64_t lifecycle_state;
@ -136,7 +136,7 @@ static void psp_joypad_get_buttons(unsigned port, input_bits_t *state)
static int16_t psp_joypad_axis_state(unsigned port, uint32_t joyaxis)
{
if (AXIS_NEG_GET(joyaxis) < 4)
if (AXIS_NEG_GET(joyaxis) < 6)
{
int16_t val = 0;
int16_t axis = AXIS_NEG_GET(joyaxis);
@ -150,11 +150,15 @@ static int16_t psp_joypad_axis_state(unsigned port, uint32_t joyaxis)
case 3:
val = analog_state[port][1][axis - 2];
break;
case 4:
case 5:
val = analog_state[port][2][axis - 4];
break;
}
if (val < 0)
return val;
}
else if (AXIS_POS_GET(joyaxis) < 4)
else if (AXIS_POS_GET(joyaxis) < 6)
{
int16_t val = 0;
int16_t axis = AXIS_POS_GET(joyaxis);
@ -168,6 +172,10 @@ static int16_t psp_joypad_axis_state(unsigned port, uint32_t joyaxis)
case 3:
val = analog_state[port][1][axis - 2];
break;
case 4:
case 5:
val = analog_state[port][2][axis - 4];
break;
}
if (val > 0)
return val;
@ -290,7 +298,8 @@ static void psp_joypad_poll(void)
pad_state[i] = 0;
analog_state[i][0][0] = analog_state[i][0][1] =
analog_state[i][1][0] = analog_state[i][1][1] = 0;
analog_state[i][1][0] = analog_state[i][1][1] =
analog_state[i][2][0] = analog_state[i][2][1] = 0;
#if defined(SN_TARGET_PSP2) || defined(VITA)
if (ret < 0)
@ -342,6 +351,8 @@ static void psp_joypad_poll(void)
pad_state[i] |= (STATE_BUTTON(state_tmp) & PSP_CTRL_L2) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_L2) : 0;
pad_state[i] |= (STATE_BUTTON(state_tmp) & PSP_CTRL_R3) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_R3) : 0;
pad_state[i] |= (STATE_BUTTON(state_tmp) & PSP_CTRL_L3) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_L3) : 0;
analog_state[i][RETRO_DEVICE_INDEX_ANALOG_BUTTON] [0] = (int16_t)(STATE_ANALOGL2(state_tmp)-128) * 256;
analog_state[i][RETRO_DEVICE_INDEX_ANALOG_BUTTON] [1] = (int16_t)(STATE_ANALOGR2(state_tmp)-128) * 256;
#endif
analog_state[i][RETRO_DEVICE_INDEX_ANALOG_LEFT] [RETRO_DEVICE_ID_ANALOG_X] = (int16_t)(STATE_ANALOGLX(state_tmp)-128) * 256;

View File

@ -100,6 +100,8 @@ int sceClibPrintf ( const char * format, ... );
#define PSP_CTRL_R2 SCE_CTRL_RTRIGGER
#define PSP_CTRL_L3 SCE_CTRL_L3
#define PSP_CTRL_R3 SCE_CTRL_R3
#define STATE_ANALOGL2(state) ((state).lt)
#define STATE_ANALOGR2(state) ((state).rt)
#else
#define DEFAULT_SAMPLING_MODE (SCE_CTRL_MODE_DIGITALANALOG)