mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-26 04:32:35 +01:00
Xinput/MMjoy: Fix connection status
This commit is contained in:
parent
65696bf6a3
commit
f4a0ff19d5
@ -54,7 +54,7 @@ void MMJoystickHandler::Init(const u32 max_connect)
|
||||
{
|
||||
g_mmjoystick_config.load();
|
||||
m_pads.emplace_back(
|
||||
CELL_PAD_STATUS_ASSIGN_CHANGES,
|
||||
CELL_PAD_STATUS_DISCONNECTED,
|
||||
CELL_PAD_SETTING_PRESS_OFF | CELL_PAD_SETTING_SENSOR_OFF,
|
||||
CELL_PAD_CAPABILITY_PS3_CONFORMITY | CELL_PAD_CAPABILITY_PRESS_MODE,
|
||||
CELL_PAD_DEV_TYPE_STANDARD
|
||||
@ -114,6 +114,8 @@ void MMJoystickHandler::Close()
|
||||
|
||||
DWORD MMJoystickHandler::ThreadProcedure()
|
||||
{
|
||||
// holds internal controller state change
|
||||
std::array<bool, CELL_PAD_MAX_PORT_NUM> last_connection_status = {};
|
||||
while (active)
|
||||
{
|
||||
MMRESULT status;
|
||||
@ -128,11 +130,17 @@ DWORD MMJoystickHandler::ThreadProcedure()
|
||||
switch (status)
|
||||
{
|
||||
case JOYERR_UNPLUGGED:
|
||||
if (last_connection_status[i] == true)
|
||||
pad.m_port_status |= CELL_PAD_STATUS_ASSIGN_CHANGES;
|
||||
last_connection_status[i] = false;
|
||||
pad.m_port_status &= ~CELL_PAD_STATUS_CONNECTED;
|
||||
break;
|
||||
|
||||
case JOYERR_NOERROR:
|
||||
++online;
|
||||
if (last_connection_status[i] == false)
|
||||
pad.m_port_status |= CELL_PAD_STATUS_ASSIGN_CHANGES;
|
||||
last_connection_status[i] = true;
|
||||
pad.m_port_status |= CELL_PAD_STATUS_CONNECTED;
|
||||
for (DWORD j = 0; j <= 12; j++)
|
||||
{
|
||||
|
@ -66,7 +66,7 @@ void XInputPadHandler::Init(const u32 max_connect)
|
||||
for (u32 i = 0, max = std::min(max_connect, u32(MAX_GAMEPADS)); i != max; ++i)
|
||||
{
|
||||
m_pads.emplace_back(
|
||||
CELL_PAD_STATUS_ASSIGN_CHANGES,
|
||||
CELL_PAD_STATUS_DISCONNECTED,
|
||||
CELL_PAD_SETTING_PRESS_OFF | CELL_PAD_SETTING_SENSOR_OFF,
|
||||
CELL_PAD_CAPABILITY_PS3_CONFORMITY | CELL_PAD_CAPABILITY_PRESS_MODE,
|
||||
CELL_PAD_DEV_TYPE_STANDARD
|
||||
@ -126,6 +126,9 @@ void XInputPadHandler::Close()
|
||||
|
||||
DWORD XInputPadHandler::ThreadProcedure()
|
||||
{
|
||||
// holds internal controller state change
|
||||
std::array<bool, MAX_GAMEPADS> last_connection_status = {};
|
||||
|
||||
while (active)
|
||||
{
|
||||
XINPUT_STATE state;
|
||||
@ -140,12 +143,19 @@ DWORD XInputPadHandler::ThreadProcedure()
|
||||
switch (result)
|
||||
{
|
||||
case ERROR_DEVICE_NOT_CONNECTED:
|
||||
if (last_connection_status[i] == true)
|
||||
pad.m_port_status |= CELL_PAD_STATUS_ASSIGN_CHANGES;
|
||||
last_connection_status[i] = false;
|
||||
pad.m_port_status &= ~CELL_PAD_STATUS_CONNECTED;
|
||||
break;
|
||||
|
||||
case ERROR_SUCCESS:
|
||||
++online;
|
||||
if (last_connection_status[i] == false)
|
||||
pad.m_port_status |= CELL_PAD_STATUS_ASSIGN_CHANGES;
|
||||
last_connection_status[i] = true;
|
||||
pad.m_port_status |= CELL_PAD_STATUS_CONNECTED;
|
||||
|
||||
for (DWORD j = 0; j != XINPUT_GAMEPAD_BUTTONS; ++j)
|
||||
{
|
||||
bool pressed = state.Gamepad.wButtons & (1 << j);
|
||||
|
Loading…
Reference in New Issue
Block a user