Wiimote: (Re-)Connect a disconnected emulated Wiimote when a mapped button is pressed.
This commit is contained in:
parent
c54534ee3b
commit
e462422ef7
|
@ -114,22 +114,20 @@ void InterruptChannel(int _number, u16 _channelID, const void* _pData, u32 _Size
|
|||
// input: _number: [Description needed]
|
||||
// output: none
|
||||
//
|
||||
void Update(int _number)
|
||||
void Update(int _number, bool _connected)
|
||||
{
|
||||
//PanicAlert( "Wiimote_Update" );
|
||||
|
||||
// if we are on the next input cycle, update output and input
|
||||
static int _last_number = 4;
|
||||
if (_number <= _last_number)
|
||||
if (_connected)
|
||||
{
|
||||
g_controller_interface.UpdateInput();
|
||||
if (WIIMOTE_SRC_EMU & g_wiimote_sources[_number])
|
||||
((WiimoteEmu::Wiimote*)s_config.controllers[_number])->Update();
|
||||
else
|
||||
WiimoteReal::Update(_number);
|
||||
}
|
||||
_last_number = _number;
|
||||
|
||||
if (WIIMOTE_SRC_EMU & g_wiimote_sources[_number])
|
||||
((WiimoteEmu::Wiimote*)s_config.controllers[_number])->Update();
|
||||
else
|
||||
WiimoteReal::Update(_number);
|
||||
{
|
||||
if (WIIMOTE_SRC_EMU & g_wiimote_sources[_number])
|
||||
((WiimoteEmu::Wiimote*)s_config.controllers[_number])->ConnectOnInput();
|
||||
}
|
||||
}
|
||||
|
||||
// __________________________________________________________________________________________________
|
||||
|
|
|
@ -48,7 +48,7 @@ InputConfig* GetConfig();
|
|||
|
||||
void ControlChannel(int _number, u16 _channelID, const void* _pData, u32 _Size);
|
||||
void InterruptChannel(int _number, u16 _channelID, const void* _pData, u32 _Size);
|
||||
void Update(int _number);
|
||||
void Update(int _number, bool _connected);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -249,6 +249,7 @@ void Wiimote::Reset()
|
|||
|
||||
Wiimote::Wiimote( const unsigned int index )
|
||||
: m_index(index)
|
||||
, m_last_connect_request_counter(0)
|
||||
, ir_sin(0)
|
||||
, ir_cos(1)
|
||||
// , m_sound_stream( nullptr )
|
||||
|
@ -876,6 +877,27 @@ void Wiimote::InterruptChannel(const u16 _channelID, const void* _pData, u32 _Si
|
|||
}
|
||||
}
|
||||
|
||||
void Wiimote::ConnectOnInput()
|
||||
{
|
||||
if (m_last_connect_request_counter > 0)
|
||||
{
|
||||
--m_last_connect_request_counter;
|
||||
return;
|
||||
}
|
||||
|
||||
u16 buttons = 0;
|
||||
m_buttons->GetState(&buttons, button_bitmasks);
|
||||
m_dpad->GetState(&buttons, dpad_bitmasks);
|
||||
|
||||
if (buttons != 0)
|
||||
{
|
||||
Host_ConnectWiimote(m_index, true);
|
||||
// arbitrary value so it doesn't try to send multiple requests before Dolphin can react
|
||||
// if Wiimotes are polled at 200Hz then this results in one request being sent per 500ms
|
||||
m_last_connect_request_counter = 100;
|
||||
}
|
||||
}
|
||||
|
||||
void Wiimote::LoadDefaults(const ControllerInterface& ciface)
|
||||
{
|
||||
ControllerEmu::LoadDefaults(ciface);
|
||||
|
|
|
@ -121,6 +121,7 @@ public:
|
|||
void Update();
|
||||
void InterruptChannel(const u16 _channelID, const void* _pData, u32 _Size);
|
||||
void ControlChannel(const u16 _channelID, const void* _pData, u32 _Size);
|
||||
void ConnectOnInput();
|
||||
|
||||
void DoState(PointerWrap& p);
|
||||
void RealState();
|
||||
|
@ -239,6 +240,10 @@ private:
|
|||
u8 play;
|
||||
u8 unk_9;
|
||||
} m_reg_speaker;
|
||||
|
||||
// limits the amount of connect requests we send when a button is pressed in disconnected state
|
||||
u8 m_last_connect_request_counter;
|
||||
|
||||
#pragma pack(pop)
|
||||
};
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "Core/IPC_HLE/WII_IPC_HLE.h"
|
||||
#include "Core/IPC_HLE/WII_IPC_HLE_Device_usb.h"
|
||||
#include "Core/IPC_HLE/WII_IPC_HLE_WiiMote.h"
|
||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||
|
||||
|
||||
void CWII_IPC_HLE_Device_usb_oh1_57e_305::EnqueueReply(u32 CommandAddress)
|
||||
|
@ -490,11 +491,9 @@ u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update()
|
|||
|
||||
if (now - m_last_ticks > interval)
|
||||
{
|
||||
g_controller_interface.UpdateInput();
|
||||
for (unsigned int i = 0; i < m_WiiMotes.size(); i++)
|
||||
if (m_WiiMotes[i].IsConnected())
|
||||
{
|
||||
Wiimote::Update(i);
|
||||
}
|
||||
Wiimote::Update(i, m_WiiMotes[i].IsConnected());
|
||||
m_last_ticks = now;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue