mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-28 12:58:05 +03:00
Merge ef8b9a0dcd
into 8ee64a84c7
This commit is contained in:
commit
a23a85985e
9 changed files with 26 additions and 24 deletions
|
@ -160,7 +160,7 @@ void SerialInterfaceManager::RunSIBuffer(u64 user_data, s64 cycles_late)
|
|||
if (actual_response_length > 0 && expected_response_length != actual_response_length)
|
||||
{
|
||||
std::ostringstream ss;
|
||||
for (u8 b : request_copy)
|
||||
for (const u8 b : request_copy)
|
||||
{
|
||||
ss << std::hex << std::setw(2) << std::setfill('0') << (int)b << ' ';
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ void SerialInterfaceManager::DoState(PointerWrap& p)
|
|||
p.Do(m_channel[i].out.hex);
|
||||
p.Do(m_channel[i].has_recent_device_change);
|
||||
|
||||
std::unique_ptr<ISIDevice>& device = m_channel[i].device;
|
||||
const std::unique_ptr<ISIDevice>& device = m_channel[i].device;
|
||||
SIDevices type = device->GetDeviceType();
|
||||
p.Do(type);
|
||||
|
||||
|
@ -225,7 +225,7 @@ void SerialInterfaceManager::DoState(PointerWrap& p)
|
|||
template <int device_number>
|
||||
void SerialInterfaceManager::DeviceEventCallback(Core::System& system, u64 userdata, s64 cyclesLate)
|
||||
{
|
||||
auto& si = system.GetSerialInterface();
|
||||
const auto& si = system.GetSerialInterface();
|
||||
si.m_channel[device_number].device->OnEvent(userdata, cyclesLate);
|
||||
}
|
||||
|
||||
|
@ -282,7 +282,7 @@ void SerialInterfaceManager::Init()
|
|||
}
|
||||
else if (movie.IsUsingPad(i))
|
||||
{
|
||||
SIDevices current = Config::Get(Config::GetInfoForSIDevice(i));
|
||||
const SIDevices current = Config::Get(Config::GetInfoForSIDevice(i));
|
||||
// GC pad-compatible devices can be used for both playing and recording
|
||||
if (movie.IsUsingBongo(i))
|
||||
m_desired_device_types[i] = SIDEVICE_GC_TARUKONGA;
|
||||
|
@ -331,7 +331,7 @@ void SerialInterfaceManager::RegisterMMIO(MMIO::Mapping* mmio, u32 base)
|
|||
const u32 address = base | static_cast<u32>(io_buffer_base + i);
|
||||
|
||||
mmio->Register(address, MMIO::ComplexRead<u32>([i](Core::System& system, u32) {
|
||||
auto& si = system.GetSerialInterface();
|
||||
const auto& si = system.GetSerialInterface();
|
||||
u32 val;
|
||||
std::memcpy(&val, &si.m_si_buffer[i], sizeof(val));
|
||||
return Common::swap32(val);
|
||||
|
@ -347,7 +347,7 @@ void SerialInterfaceManager::RegisterMMIO(MMIO::Mapping* mmio, u32 base)
|
|||
const u32 address = base | static_cast<u32>(io_buffer_base + i);
|
||||
|
||||
mmio->Register(address, MMIO::ComplexRead<u16>([i](Core::System& system, u32) {
|
||||
auto& si = system.GetSerialInterface();
|
||||
const auto& si = system.GetSerialInterface();
|
||||
u16 val;
|
||||
std::memcpy(&val, &si.m_si_buffer[i], sizeof(val));
|
||||
return Common::swap16(val);
|
||||
|
@ -487,7 +487,7 @@ void SerialInterfaceManager::RemoveDevice(int device_number)
|
|||
|
||||
void SerialInterfaceManager::AddDevice(std::unique_ptr<ISIDevice> device)
|
||||
{
|
||||
int device_number = device->GetDeviceNumber();
|
||||
const int device_number = device->GetDeviceNumber();
|
||||
|
||||
// Delete the old device
|
||||
RemoveDevice(device_number);
|
||||
|
|
|
@ -92,7 +92,7 @@ int SIDevice_GetGBATransferTime(const SystemTimers::SystemTimersManager& timers,
|
|||
{
|
||||
u64 gc_bytes_transferred = 1;
|
||||
u64 gba_bytes_transferred = 1;
|
||||
u64 stop_bits_ns = GC_STOP_BIT_NS + GBA_STOP_BIT_NS;
|
||||
const u64 stop_bits_ns = GC_STOP_BIT_NS + GBA_STOP_BIT_NS;
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
|
|
|
@ -24,7 +24,7 @@ int CSIDevice_DanceMat::RunBuffer(u8* buffer, int request_length)
|
|||
{
|
||||
ISIDevice::RunBuffer(buffer, request_length);
|
||||
|
||||
u32 id = Common::swap32(SI_DANCEMAT);
|
||||
const u32 id = Common::swap32(SI_DANCEMAT);
|
||||
std::memcpy(buffer, &id, sizeof(id));
|
||||
return sizeof(id);
|
||||
}
|
||||
|
|
|
@ -146,7 +146,7 @@ void GBASockServer::ClockSync(Core::System& system)
|
|||
if (!(m_clock_sync = GetNextClock()))
|
||||
return;
|
||||
|
||||
auto& core_timing = system.GetCoreTiming();
|
||||
const auto& core_timing = system.GetCoreTiming();
|
||||
|
||||
u32 time_slice = 0;
|
||||
|
||||
|
@ -169,7 +169,7 @@ void GBASockServer::ClockSync(Core::System& system)
|
|||
bytes[2] = (time_slice >> 8) & 0xff;
|
||||
bytes[3] = time_slice & 0xff;
|
||||
|
||||
sf::Socket::Status status = m_clock_sync->send(bytes, 4);
|
||||
const sf::Socket::Status status = m_clock_sync->send(bytes, 4);
|
||||
if (status == sf::Socket::Status::Disconnected)
|
||||
{
|
||||
m_clock_sync->disconnect();
|
||||
|
@ -228,7 +228,7 @@ int GBASockServer::Receive(u8* si_buffer, u8 bytes)
|
|||
|
||||
size_t num_received = 0;
|
||||
std::array<u8, RECV_MAX_SIZE> recv_data;
|
||||
sf::Socket::Status recv_stat = m_client->receive(recv_data.data(), bytes, num_received);
|
||||
const sf::Socket::Status recv_stat = m_client->receive(recv_data.data(), bytes, num_received);
|
||||
if (recv_stat == sf::Socket::Status::Disconnected)
|
||||
{
|
||||
Disconnect();
|
||||
|
@ -256,7 +256,7 @@ void GBASockServer::Flush()
|
|||
u8 byte;
|
||||
while (num_received)
|
||||
{
|
||||
sf::Socket::Status recv_stat = m_client->receive(&byte, 1, num_received);
|
||||
const sf::Socket::Status recv_stat = m_client->receive(&byte, 1, num_received);
|
||||
if (recv_stat != sf::Socket::Status::Done)
|
||||
break;
|
||||
}
|
||||
|
@ -296,7 +296,8 @@ int CSIDevice_GBA::RunBuffer(u8* buffer, int request_length)
|
|||
|
||||
case NextAction::WaitTransferTime:
|
||||
{
|
||||
int elapsed_time = static_cast<int>(m_system.GetCoreTiming().GetTicks() - m_timestamp_sent);
|
||||
const int elapsed_time =
|
||||
static_cast<int>(m_system.GetCoreTiming().GetTicks() - m_timestamp_sent);
|
||||
// Tell SI to ask again after TransferInterval() cycles
|
||||
if (SIDevice_GetGBATransferTime(m_system.GetSystemTimers(), m_last_cmd) > elapsed_time)
|
||||
return 0;
|
||||
|
@ -319,7 +320,7 @@ int CSIDevice_GBA::RunBuffer(u8* buffer, int request_length)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
int num_data_received = m_sock_server.Receive(buffer, bytes);
|
||||
const int num_data_received = m_sock_server.Receive(buffer, bytes);
|
||||
|
||||
m_next_action = NextAction::SendCommand;
|
||||
if (num_data_received == 0)
|
||||
|
|
|
@ -78,7 +78,8 @@ int CSIDevice_GBAEmu::RunBuffer(u8* buffer, int request_length)
|
|||
|
||||
case NextAction::WaitTransferTime:
|
||||
{
|
||||
int elapsed_time = static_cast<int>(m_system.GetCoreTiming().GetTicks() - m_timestamp_sent);
|
||||
const int elapsed_time =
|
||||
static_cast<int>(m_system.GetCoreTiming().GetTicks() - m_timestamp_sent);
|
||||
// Tell SI to ask again after TransferInterval() cycles
|
||||
if (TransferInterval() > elapsed_time)
|
||||
return 0;
|
||||
|
|
|
@ -61,7 +61,7 @@ int CSIDevice_GCAdapter::RunBuffer(u8* buffer, int request_length)
|
|||
// into this port on the hardware gc adapter, exposing it to the game.
|
||||
if (!GCAdapter::DeviceConnected(m_device_number))
|
||||
{
|
||||
u32 device = Common::swap32(SI_NONE);
|
||||
const u32 device = Common::swap32(SI_NONE);
|
||||
memcpy(buffer, &device, sizeof(device));
|
||||
return 4;
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ int CSIDevice_GCController::RunBuffer(u8* buffer, int request_length)
|
|||
// For debug logging only
|
||||
ISIDevice::RunBuffer(buffer, request_length);
|
||||
|
||||
GCPadStatus pad_status = GetPadStatus();
|
||||
const GCPadStatus pad_status = GetPadStatus();
|
||||
if (!pad_status.isConnected)
|
||||
return -1;
|
||||
|
||||
|
@ -57,7 +57,7 @@ int CSIDevice_GCController::RunBuffer(u8* buffer, int request_length)
|
|||
case EBufferCommands::CMD_STATUS:
|
||||
case EBufferCommands::CMD_RESET:
|
||||
{
|
||||
u32 id = Common::swap32(SI_GC_CONTROLLER);
|
||||
const u32 id = Common::swap32(SI_GC_CONTROLLER);
|
||||
std::memcpy(buffer, &id, sizeof(id));
|
||||
return sizeof(id);
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ int CSIDevice_GCController::RunBuffer(u8* buffer, int request_length)
|
|||
{
|
||||
INFO_LOG_FMT(SERIALINTERFACE, "PAD - Get Origin");
|
||||
|
||||
u8* calibration = reinterpret_cast<u8*>(&m_origin);
|
||||
const u8* calibration = reinterpret_cast<u8*>(&m_origin);
|
||||
for (int i = 0; i < (int)sizeof(SOrigin); i++)
|
||||
{
|
||||
buffer[i] = *calibration++;
|
||||
|
@ -92,7 +92,7 @@ int CSIDevice_GCController::RunBuffer(u8* buffer, int request_length)
|
|||
{
|
||||
INFO_LOG_FMT(SERIALINTERFACE, "PAD - Recalibrate");
|
||||
|
||||
u8* calibration = reinterpret_cast<u8*>(&m_origin);
|
||||
const u8* calibration = reinterpret_cast<u8*>(&m_origin);
|
||||
for (int i = 0; i < (int)sizeof(SOrigin); i++)
|
||||
{
|
||||
buffer[i] = *calibration++;
|
||||
|
|
|
@ -34,7 +34,7 @@ int CSIDevice_GCSteeringWheel::RunBuffer(u8* buffer, int request_length)
|
|||
case EBufferCommands::CMD_STATUS:
|
||||
case EBufferCommands::CMD_RESET:
|
||||
{
|
||||
u32 id = Common::swap32(SI_GC_STEERING);
|
||||
const u32 id = Common::swap32(SI_GC_STEERING);
|
||||
std::memcpy(buffer, &id, sizeof(id));
|
||||
return sizeof(id);
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ DataResponse CSIDevice_GCSteeringWheel::GetData(u32& hi, u32& low)
|
|||
{
|
||||
if (m_mode == 6)
|
||||
{
|
||||
GCPadStatus pad_status = GetPadStatus();
|
||||
const GCPadStatus pad_status = GetPadStatus();
|
||||
|
||||
hi = (u32)((u8)pad_status.stickX); // Steering
|
||||
hi |= 0x800; // Pedal connected flag
|
||||
|
|
|
@ -35,7 +35,7 @@ int CSIDevice_Keyboard::RunBuffer(u8* buffer, int request_length)
|
|||
case EBufferCommands::CMD_STATUS:
|
||||
case EBufferCommands::CMD_RESET:
|
||||
{
|
||||
u32 id = Common::swap32(SI_GC_KEYBOARD);
|
||||
const u32 id = Common::swap32(SI_GC_KEYBOARD);
|
||||
std::memcpy(buffer, &id, sizeof(id));
|
||||
return sizeof(id);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue