Skip to content

Commit

Permalink
Merge pull request #5092 from lioncash/namespace
Browse files Browse the repository at this point in the history
SI: Namespace device classes
  • Loading branch information
Parlane committed Mar 18, 2017
2 parents b7f605e + f0eeb3c commit 8669426
Show file tree
Hide file tree
Showing 26 changed files with 112 additions and 50 deletions.
6 changes: 3 additions & 3 deletions Source/Core/Core/BootManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ struct ConfigCache
std::string sBackend;
std::string m_strGPUDeterminismMode;
std::array<int, MAX_BBMOTES> iWiimoteSource;
std::array<SIDevices, SerialInterface::MAX_SI_CHANNELS> Pads;
std::array<SerialInterface::SIDevices, SerialInterface::MAX_SI_CHANNELS> Pads;
std::array<TEXIDevices, ExpansionInterface::MAX_EXI_CHANNELS> m_EXIDevice;
};

Expand Down Expand Up @@ -283,9 +283,9 @@ bool BootCore(const std::string& _rFilename)
{
int source;
controls_section->Get(StringFromFormat("PadType%u", i), &source, -1);
if (source >= SIDEVICE_NONE && source < SIDEVICE_COUNT)
if (source >= SerialInterface::SIDEVICE_NONE && source < SerialInterface::SIDEVICE_COUNT)
{
StartUp.m_SIDevice[i] = static_cast<SIDevices>(source);
StartUp.m_SIDevice[i] = static_cast<SerialInterface::SIDevices>(source);
config_cache.bSetPads[i] = true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ void SConfig::LoadCoreSettings(IniFile& ini)
for (int i = 0; i < SerialInterface::MAX_SI_CHANNELS; ++i)
{
core->Get(StringFromFormat("SIDevice%i", i), (u32*)&m_SIDevice[i],
(i == 0) ? SIDEVICE_GC_CONTROLLER : SIDEVICE_NONE);
(i == 0) ? SerialInterface::SIDEVICE_GC_CONTROLLER : SerialInterface::SIDEVICE_NONE);
core->Get(StringFromFormat("AdapterRumble%i", i), &m_AdapterRumble[i], true);
core->Get(StringFromFormat("SimulateKonga%i", i), &m_AdapterKonga[i], false);
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/ConfigManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ struct SConfig : NonCopyable
std::string m_strGbaCartA;
std::string m_strGbaCartB;
TEXIDevices m_EXIDevice[3];
SIDevices m_SIDevice[4];
SerialInterface::SIDevices m_SIDevice[4];
std::string m_bba_mac;

// interface language
Expand Down
6 changes: 4 additions & 2 deletions Source/Core/Core/HW/SI/SI.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@
#include "Common/CommonTypes.h"

class PointerWrap;
class ISIDevice;
enum SIDevices : int;

namespace MMIO
{
class Mapping;
}

namespace SerialInterface
{
class ISIDevice;
enum SIDevices : int;

// SI number of channels
enum
{
Expand Down
3 changes: 3 additions & 0 deletions Source/Core/Core/HW/SI/SI_Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include "Core/HW/SI/SI_DeviceKeyboard.h"
#include "Core/HW/SI/SI_DeviceNull.h"

namespace SerialInterface
{
ISIDevice::ISIDevice(SIDevices device_type, int device_number)
: m_device_number(device_number), m_device_type(device_type)
{
Expand Down Expand Up @@ -120,3 +122,4 @@ std::unique_ptr<ISIDevice> SIDevice_Create(const SIDevices device, const int por
return std::make_unique<CSIDevice_Null>(device, port_number);
}
}
} // namespace SerialInterface
3 changes: 3 additions & 0 deletions Source/Core/Core/HW/SI/SI_Device.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

class PointerWrap;

namespace SerialInterface
{
// Devices can reply with these
enum
{
Expand Down Expand Up @@ -100,3 +102,4 @@ class ISIDevice
bool SIDevice_IsGCController(SIDevices type);

std::unique_ptr<ISIDevice> SIDevice_Create(SIDevices device, int port_number);
} // namespace SerialInterface
3 changes: 3 additions & 0 deletions Source/Core/Core/HW/SI/SI_DeviceDanceMat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "Common/CommonTypes.h"
#include "InputCommon/GCPadStatus.h"

namespace SerialInterface
{
CSIDevice_DanceMat::CSIDevice_DanceMat(SIDevices device, int device_number)
: CSIDevice_GCController(device, device_number)
{
Expand Down Expand Up @@ -68,3 +70,4 @@ bool CSIDevice_DanceMat::GetData(u32& hi, u32& low)

return true;
}
} // namespace SerialInterface
3 changes: 3 additions & 0 deletions Source/Core/Core/HW/SI/SI_DeviceDanceMat.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

struct GCPadStatus;

namespace SerialInterface
{
class CSIDevice_DanceMat : public CSIDevice_GCController
{
public:
Expand All @@ -18,3 +20,4 @@ class CSIDevice_DanceMat : public CSIDevice_GCController
u32 MapPadStatus(const GCPadStatus& pad_status) override;
bool GetData(u32& hi, u32& low) override;
};
} // namespace SerialInterface
3 changes: 3 additions & 0 deletions Source/Core/Core/HW/SI/SI_DeviceGBA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include "Core/HW/SI/SI_Device.h"
#include "Core/HW/SystemTimers.h"

namespace SerialInterface
{
namespace
{
std::thread s_connection_thread;
Expand Down Expand Up @@ -375,3 +377,4 @@ bool CSIDevice_GBA::GetData(u32& hi, u32& low)
void CSIDevice_GBA::SendCommand(u32 command, u8 poll)
{
}
} // namespace SerialInterface
3 changes: 3 additions & 0 deletions Source/Core/Core/HW/SI/SI_DeviceGBA.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

// GameBoy Advance "Link Cable"

namespace SerialInterface
{
u8 GetNumConnected();
int GetTransferTime(u8 cmd);
void GBAConnectionWaiter_Shutdown();
Expand Down Expand Up @@ -61,3 +63,4 @@ class CSIDevice_GBA : public ISIDevice, private GBASockServer
u64 m_timestamp_sent = 0;
bool m_waiting_for_response = false;
};
} // namespace SerialInterface
3 changes: 3 additions & 0 deletions Source/Core/Core/HW/SI/SI_DeviceGCAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include "Core/NetPlayProto.h"
#include "InputCommon/GCAdapter.h"

namespace SerialInterface
{
CSIDevice_GCAdapter::CSIDevice_GCAdapter(SIDevices device, int device_number)
: CSIDevice_GCController(device, device_number)
{
Expand Down Expand Up @@ -68,3 +70,4 @@ void CSIDevice_GCController::Rumble(int pad_num, ControlState strength)
else if (SIDevice_IsGCController(device))
Pad::Rumble(pad_num, strength);
}
} // namespace SerialInterface
3 changes: 3 additions & 0 deletions Source/Core/Core/HW/SI/SI_DeviceGCAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "Core/HW/SI/SI_DeviceGCController.h"
#include "InputCommon/GCPadStatus.h"

namespace SerialInterface
{
class CSIDevice_GCAdapter : public CSIDevice_GCController
{
public:
Expand All @@ -16,3 +18,4 @@ class CSIDevice_GCAdapter : public CSIDevice_GCController
GCPadStatus GetPadStatus() override;
int RunBuffer(u8* buffer, int length) override;
};
} // namespace SerialInterface
3 changes: 3 additions & 0 deletions Source/Core/Core/HW/SI/SI_DeviceGCController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "Core/NetPlayProto.h"
#include "InputCommon/GCPadStatus.h"

namespace SerialInterface
{
// --- standard GameCube controller ---
CSIDevice_GCController::CSIDevice_GCController(SIDevices device, int device_number)
: ISIDevice(device, device_number)
Expand Down Expand Up @@ -327,3 +329,4 @@ void CSIDevice_GCController::DoState(PointerWrap& p)
p.Do(m_timer_button_combo);
p.Do(m_last_button_combo);
}
} // namespace SerialInterface
3 changes: 3 additions & 0 deletions Source/Core/Core/HW/SI/SI_DeviceGCController.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "Core/HW/SI/SI_Device.h"
#include "InputCommon/GCPadStatus.h"

namespace SerialInterface
{
class CSIDevice_GCController : public ISIDevice
{
protected:
Expand Down Expand Up @@ -126,3 +128,4 @@ class CSIDevice_TaruKonga : public CSIDevice_GCController
m_simulate_konga = true;
}
};
} // namespace SerialInterface
3 changes: 3 additions & 0 deletions Source/Core/Core/HW/SI/SI_DeviceGCSteeringWheel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "Common/Logging/Log.h"
#include "Core/HW/GCPad.h"

namespace SerialInterface
{
CSIDevice_GCSteeringWheel::CSIDevice_GCSteeringWheel(SIDevices device, int device_number)
: CSIDevice_GCController(device, device_number)
{
Expand Down Expand Up @@ -111,3 +113,4 @@ void CSIDevice_GCSteeringWheel::SendCommand(u32 command, u8 poll)
return CSIDevice_GCController::SendCommand(command, poll);
}
}
} // namespace SerialInterface
3 changes: 3 additions & 0 deletions Source/Core/Core/HW/SI/SI_DeviceGCSteeringWheel.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include "Core/HW/SI/SI_DeviceGCController.h"

namespace SerialInterface
{
class CSIDevice_GCSteeringWheel : public CSIDevice_GCController
{
public:
Expand All @@ -31,3 +33,4 @@ class CSIDevice_GCSteeringWheel : public CSIDevice_GCController
CMD_WRITE = 0x40
};
};
} // namespace SerialInterface
3 changes: 3 additions & 0 deletions Source/Core/Core/HW/SI/SI_DeviceKeyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include "Core/HW/GCKeyboard.h"
#include "InputCommon/KeyboardStatus.h"

namespace SerialInterface
{
// --- GameCube keyboard ---
CSIDevice_Keyboard::CSIDevice_Keyboard(SIDevices device, int device_number)
: ISIDevice(device, device_number)
Expand Down Expand Up @@ -617,3 +619,4 @@ void CSIDevice_Keyboard::MapKeys(const KeyboardStatus& key_status, u8* key)
return;
}
}
} // namespace SerialInterface
3 changes: 3 additions & 0 deletions Source/Core/Core/HW/SI/SI_DeviceKeyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
class PointerWrap;
struct KeyboardStatus;

namespace SerialInterface
{
class CSIDevice_Keyboard : public ISIDevice
{
public:
Expand Down Expand Up @@ -65,3 +67,4 @@ class CSIDevice_Keyboard : public ISIDevice
// Internal counter synchonizing GC and keyboard
u8 m_counter = 0;
};
} // namespace SerialInterface
3 changes: 3 additions & 0 deletions Source/Core/Core/HW/SI/SI_DeviceNull.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include <cstring>

namespace SerialInterface
{
CSIDevice_Null::CSIDevice_Null(SIDevices device, int device_number)
: ISIDevice{device, device_number}
{
Expand All @@ -27,3 +29,4 @@ bool CSIDevice_Null::GetData(u32& hi, u32& low)
void CSIDevice_Null::SendCommand(u32 command, u8 poll)
{
}
} // namespace SerialInterface
3 changes: 3 additions & 0 deletions Source/Core/Core/HW/SI/SI_DeviceNull.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "Common/CommonTypes.h"
#include "Core/HW/SI/SI_Device.h"

namespace SerialInterface
{
// Stub class for saying nothing is attached, and not having to deal with null pointers :)
class CSIDevice_Null final : public ISIDevice
{
Expand All @@ -17,3 +19,4 @@ class CSIDevice_Null final : public ISIDevice
bool GetData(u32& hi, u32& low) override;
void SendCommand(u32 command, u8 poll) override;
};
} // namespace SerialInterface
21 changes: 15 additions & 6 deletions Source/Core/Core/Movie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ std::string GetInputDisplay()
s_controllers = 0;
for (int i = 0; i < 4; ++i)
{
if (SerialInterface::GetDeviceType(i) != SIDEVICE_NONE)
if (SerialInterface::GetDeviceType(i) != SerialInterface::SIDEVICE_NONE)
s_controllers |= (1 << i);
if (g_wiimote_sources[i] != WIIMOTE_SRC_NONE)
s_controllers |= (1 << (i + 4));
Expand Down Expand Up @@ -485,21 +485,28 @@ void ChangePads(bool instantly)
int controllers = 0;

for (int i = 0; i < SerialInterface::MAX_SI_CHANNELS; ++i)
if (SIDevice_IsGCController(SConfig::GetInstance().m_SIDevice[i]))
{
if (SerialInterface::SIDevice_IsGCController(SConfig::GetInstance().m_SIDevice[i]))
controllers |= (1 << i);
}

if (instantly && (s_controllers & 0x0F) == controllers)
return;

for (int i = 0; i < SerialInterface::MAX_SI_CHANNELS; ++i)
{
SIDevices device = SIDEVICE_NONE;
SerialInterface::SIDevices device = SerialInterface::SIDEVICE_NONE;
if (IsUsingPad(i))
{
if (SIDevice_IsGCController(SConfig::GetInstance().m_SIDevice[i]))
if (SerialInterface::SIDevice_IsGCController(SConfig::GetInstance().m_SIDevice[i]))
{
device = SConfig::GetInstance().m_SIDevice[i];
}
else
device = IsUsingBongo(i) ? SIDEVICE_GC_TARUKONGA : SIDEVICE_GC_CONTROLLER;
{
device = IsUsingBongo(i) ? SerialInterface::SIDEVICE_GC_TARUKONGA :
SerialInterface::SIDEVICE_GC_CONTROLLER;
}
}

if (instantly) // Changes from savestates need to be instantaneous
Expand Down Expand Up @@ -564,8 +571,10 @@ bool BeginRecordingInput(int controllers)
s_rerecords = 0;

for (int i = 0; i < SerialInterface::MAX_SI_CHANNELS; ++i)
if (SConfig::GetInstance().m_SIDevice[i] == SIDEVICE_GC_TARUKONGA)
{
if (SConfig::GetInstance().m_SIDevice[i] == SerialInterface::SIDEVICE_GC_TARUKONGA)
s_bongos |= (1 << i);
}

if (Core::IsRunningAndStarted())
{
Expand Down
16 changes: 8 additions & 8 deletions Source/Core/Core/NetPlayClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -851,23 +851,23 @@ void NetPlayClient::UpdateDevices()
// exotic devices are not supported on netplay.
if (player_id == m_local_player->pid)
{
if (SIDevice_IsGCController(SConfig::GetInstance().m_SIDevice[local_pad]))
if (SerialInterface::SIDevice_IsGCController(SConfig::GetInstance().m_SIDevice[local_pad]))
{
SerialInterface::AddDevice(SConfig::GetInstance().m_SIDevice[local_pad], pad);
}
else
{
SerialInterface::AddDevice(SIDEVICE_GC_CONTROLLER, pad);
SerialInterface::AddDevice(SerialInterface::SIDEVICE_GC_CONTROLLER, pad);
}
local_pad++;
}
else if (player_id > 0)
{
SerialInterface::AddDevice(SIDEVICE_GC_CONTROLLER, pad);
SerialInterface::AddDevice(SerialInterface::SIDEVICE_GC_CONTROLLER, pad);
}
else
{
SerialInterface::AddDevice(SIDEVICE_NONE, pad);
SerialInterface::AddDevice(SerialInterface::SIDEVICE_NONE, pad);
}
pad++;
}
Expand Down Expand Up @@ -967,10 +967,10 @@ bool NetPlayClient::GetNetPads(const int pad_nb, GCPadStatus* pad_status)
{
switch (SConfig::GetInstance().m_SIDevice[local_pad])
{
case SIDEVICE_WIIU_ADAPTER:
case SerialInterface::SIDEVICE_WIIU_ADAPTER:
*pad_status = GCAdapter::Input(local_pad);
break;
case SIDEVICE_GC_CONTROLLER:
case SerialInterface::SIDEVICE_GC_CONTROLLER:
default:
*pad_status = Pad::GetStatus(local_pad);
break;
Expand Down Expand Up @@ -1255,7 +1255,7 @@ void NetPlayClient::ComputeMD5(const std::string& file_identifier)

// called from ---CPU--- thread
// Actual Core function which is called on every frame
bool CSIDevice_GCController::NetPlay_GetInput(int numPAD, GCPadStatus* PadStatus)
bool SerialInterface::CSIDevice_GCController::NetPlay_GetInput(int numPAD, GCPadStatus* PadStatus)
{
std::lock_guard<std::mutex> lk(crit_netplay_client);

Expand Down Expand Up @@ -1291,7 +1291,7 @@ u64 CEXIIPL::NetPlay_GetEmulatedTime()

// called from ---CPU--- thread
// return the local pad num that should rumble given a ingame pad num
int CSIDevice_GCController::NetPlay_InGamePadToLocalPad(int numPAD)
int SerialInterface::CSIDevice_GCController::NetPlay_InGamePadToLocalPad(int numPAD)
{
std::lock_guard<std::mutex> lk(crit_netplay_client);

Expand Down

0 comments on commit 8669426

Please sign in to comment.