mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
InputConfig: Clean up controller management
This commit is contained in:
@ -25,24 +25,20 @@ InputConfig* GetConfig()
|
||||
|
||||
void Shutdown()
|
||||
{
|
||||
for (const ControllerEmu* i : s_config.controllers)
|
||||
{
|
||||
delete i;
|
||||
}
|
||||
s_config.controllers.clear();
|
||||
s_config.ClearControllers();
|
||||
|
||||
WiimoteReal::Stop();
|
||||
|
||||
g_controller_interface.Shutdown();
|
||||
}
|
||||
|
||||
// if plugin isn't initialized, init and load config
|
||||
void Initialize(void* const hwnd, bool wait)
|
||||
{
|
||||
// add 4 Wiimotes
|
||||
if (s_config.controllers.empty())
|
||||
if (s_config.ControllersNeedToBeCreated())
|
||||
{
|
||||
for (unsigned int i = WIIMOTE_CHAN_0; i < MAX_BBMOTES; ++i)
|
||||
s_config.controllers.push_back(new WiimoteEmu::Wiimote(i));
|
||||
s_config.CreateController<WiimoteEmu::Wiimote>(i);
|
||||
}
|
||||
|
||||
g_controller_interface.Initialize(hwnd);
|
||||
|
||||
@ -50,7 +46,7 @@ void Initialize(void* const hwnd, bool wait)
|
||||
|
||||
WiimoteReal::Initialize(wait);
|
||||
|
||||
// reload Wiimotes with our settings
|
||||
// Reload Wiimotes with our settings
|
||||
if (Movie::IsMovieActive())
|
||||
Movie::ChangeWiiPads();
|
||||
}
|
||||
@ -72,104 +68,60 @@ void Pause()
|
||||
}
|
||||
|
||||
|
||||
// __________________________________________________________________________________________________
|
||||
// Function: ControlChannel
|
||||
// Purpose: An L2CAP packet is passed from the Core to the Wiimote,
|
||||
// on the HID CONTROL channel.
|
||||
//
|
||||
// Inputs: _number [Description needed]
|
||||
// _channelID [Description needed]
|
||||
// _pData [Description needed]
|
||||
// _Size [Description needed]
|
||||
//
|
||||
// Output: none
|
||||
//
|
||||
void ControlChannel(int _number, u16 _channelID, const void* _pData, u32 _Size)
|
||||
// An L2CAP packet is passed from the Core to the Wiimote on the HID CONTROL channel.
|
||||
void ControlChannel(int number, u16 channel_id, const void* data, u32 size)
|
||||
{
|
||||
if (WIIMOTE_SRC_HYBRID & g_wiimote_sources[_number])
|
||||
((WiimoteEmu::Wiimote*)s_config.controllers[_number])->ControlChannel(_channelID, _pData, _Size);
|
||||
if (WIIMOTE_SRC_HYBRID & g_wiimote_sources[number])
|
||||
static_cast<WiimoteEmu::Wiimote*>(s_config.GetController(number))->ControlChannel(channel_id, data, size);
|
||||
}
|
||||
|
||||
// __________________________________________________________________________________________________
|
||||
// Function: InterruptChannel
|
||||
// Purpose: An L2CAP packet is passed from the Core to the Wiimote,
|
||||
// on the HID INTERRUPT channel.
|
||||
//
|
||||
// Inputs: _number [Description needed]
|
||||
// _channelID [Description needed]
|
||||
// _pData [Description needed]
|
||||
// _Size [Description needed]
|
||||
//
|
||||
// Output: none
|
||||
//
|
||||
void InterruptChannel(int _number, u16 _channelID, const void* _pData, u32 _Size)
|
||||
// An L2CAP packet is passed from the Core to the Wiimote on the HID INTERRUPT channel.
|
||||
void InterruptChannel(int number, u16 channel_id, const void* data, u32 size)
|
||||
{
|
||||
if (WIIMOTE_SRC_HYBRID & g_wiimote_sources[_number])
|
||||
((WiimoteEmu::Wiimote*)s_config.controllers[_number])->InterruptChannel(_channelID, _pData, _Size);
|
||||
if (WIIMOTE_SRC_HYBRID & g_wiimote_sources[number])
|
||||
static_cast<WiimoteEmu::Wiimote*>(s_config.GetController(number))->InterruptChannel(channel_id, data, size);
|
||||
}
|
||||
|
||||
// __________________________________________________________________________________________________
|
||||
// Function: Update
|
||||
// Purpose: This function is called periodically by the Core. // TODO: Explain why.
|
||||
// input: _number: [Description needed]
|
||||
// output: none
|
||||
//
|
||||
void Update(int _number, bool _connected)
|
||||
// This function is called periodically by the Core to update Wiimote state.
|
||||
void Update(int number, bool connected)
|
||||
{
|
||||
if (_connected)
|
||||
if (connected)
|
||||
{
|
||||
if (WIIMOTE_SRC_EMU & g_wiimote_sources[_number])
|
||||
((WiimoteEmu::Wiimote*)s_config.controllers[_number])->Update();
|
||||
if (WIIMOTE_SRC_EMU & g_wiimote_sources[number])
|
||||
static_cast<WiimoteEmu::Wiimote*>(s_config.GetController(number))->Update();
|
||||
else
|
||||
WiimoteReal::Update(_number);
|
||||
WiimoteReal::Update(number);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (WIIMOTE_SRC_EMU & g_wiimote_sources[_number])
|
||||
((WiimoteEmu::Wiimote*)s_config.controllers[_number])->ConnectOnInput();
|
||||
if (WIIMOTE_SRC_REAL & g_wiimote_sources[_number])
|
||||
WiimoteReal::ConnectOnInput(_number);
|
||||
if (WIIMOTE_SRC_EMU & g_wiimote_sources[number])
|
||||
static_cast<WiimoteEmu::Wiimote*>(s_config.GetController(number))->ConnectOnInput();
|
||||
|
||||
if (WIIMOTE_SRC_REAL & g_wiimote_sources[number])
|
||||
WiimoteReal::ConnectOnInput(number);
|
||||
}
|
||||
}
|
||||
|
||||
// __________________________________________________________________________________________________
|
||||
// Function: GetAttached
|
||||
// Purpose: Get mask of attached pads (eg: controller 1 & 4 -> 0x9)
|
||||
// input: none
|
||||
// output: The number of attached pads
|
||||
//
|
||||
// Get a mask of attached the pads (eg: controller 1 & 4 -> 0x9)
|
||||
unsigned int GetAttached()
|
||||
{
|
||||
unsigned int attached = 0;
|
||||
for (unsigned int i=0; i<MAX_BBMOTES; ++i)
|
||||
for (unsigned int i = 0; i < MAX_BBMOTES; ++i)
|
||||
if (g_wiimote_sources[i])
|
||||
attached |= (1 << i);
|
||||
return attached;
|
||||
}
|
||||
|
||||
// ___________________________________________________________________________
|
||||
// Function: DoState
|
||||
// Purpose: Saves/load state
|
||||
// input/output: ptr: [Description Needed]
|
||||
// input: mode [Description needed]
|
||||
//
|
||||
// Save/Load state
|
||||
void DoState(PointerWrap& p)
|
||||
{
|
||||
// TODO:
|
||||
|
||||
for (unsigned int i=0; i<MAX_BBMOTES; ++i)
|
||||
((WiimoteEmu::Wiimote*)s_config.controllers[i])->DoState(p);
|
||||
for (int i = 0; i < MAX_BBMOTES; ++i)
|
||||
static_cast<WiimoteEmu::Wiimote*>(s_config.GetController(i))->DoState(p);
|
||||
}
|
||||
|
||||
// ___________________________________________________________________________
|
||||
// Function: EmuStateChange
|
||||
// Purpose: Notifies the plugin of a change in emulation state
|
||||
// input: newState - The new state for the Wiimote to change to.
|
||||
// output: none
|
||||
//
|
||||
// Notifies the plugin of a change in emulation state
|
||||
void EmuStateChange(EMUSTATE_CHANGE newState)
|
||||
{
|
||||
// TODO
|
||||
WiimoteReal::StateChange(newState);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user