Skip to content

Commit

Permalink
SI/GCAdapter: use origin from controllers
Browse files Browse the repository at this point in the history
GCAdapter controllers were just inheriting the "perfect" calibration of
the emulated GC controller.
  • Loading branch information
booto committed Aug 13, 2019
1 parent da6289b commit e0352ad
Show file tree
Hide file tree
Showing 4 changed files with 303 additions and 119 deletions.
6 changes: 0 additions & 6 deletions Source/Core/Core/HW/SI/SI.cpp
Expand Up @@ -660,7 +660,6 @@ static void RunSIBuffer(u64 user_data, s64 cycles_late)
if (s_com_csr.TSTART) if (s_com_csr.TSTART)
{ {
u32 request_length = ConvertSILengthField(s_com_csr.OUTLNGTH); u32 request_length = ConvertSILengthField(s_com_csr.OUTLNGTH);
u32 expected_response_length = ConvertSILengthField(s_com_csr.INLNGTH);
std::vector<u8> request_copy(s_si_buffer.data(), s_si_buffer.data() + request_length); std::vector<u8> request_copy(s_si_buffer.data(), s_si_buffer.data() + request_length);


std::unique_ptr<ISIDevice>& device = s_channel[s_com_csr.CHANNEL].device; std::unique_ptr<ISIDevice>& device = s_channel[s_com_csr.CHANNEL].device;
Expand All @@ -671,9 +670,6 @@ static void RunSIBuffer(u64 user_data, s64 cycles_late)
EstimateTicksForXfer(1, SI_MICROSECONDS_PER_STOP_BIT) - cycles_late, EstimateTicksForXfer(1, SI_MICROSECONDS_PER_STOP_BIT) - cycles_late,
s_get_response_event[s_com_csr.CHANNEL], SiGetMaskForChannel(s_com_csr.CHANNEL)); s_get_response_event[s_com_csr.CHANNEL], SiGetMaskForChannel(s_com_csr.CHANNEL));


INFO_LOG(SERIALINTERFACE,
"RunSIBuffer chan: %d request_length: %u expected_response_length: %u",
s_com_csr.CHANNEL, request_length, expected_response_length);
// TODO: // TODO:
// Wait a reasonable amount of time for the result to be available: // Wait a reasonable amount of time for the result to be available:
// request is N bytes, ends with a stop bit // request is N bytes, ends with a stop bit
Expand Down Expand Up @@ -1054,8 +1050,6 @@ void TriggerPoll(s64 cycles_late)
EstimateTicksForXfer(1, SI_MICROSECONDS_PER_STOP_BIT) - EstimateTicksForXfer(1, SI_MICROSECONDS_PER_STOP_BIT) -
cycles_late, cycles_late,
s_poll_get_response_event, user_data); s_poll_get_response_event, user_data);

INFO_LOG(SERIALINTERFACE, "TriggerPoll: user_data: %x", user_data);
} }


// Polling finished // Polling finished
Expand Down
23 changes: 23 additions & 0 deletions Source/Core/Core/HW/SI/SI_DeviceGCAdapter.cpp
Expand Up @@ -64,6 +64,29 @@ int CSIDevice_GCAdapter::RunBuffer(u8* buffer, int request_length)
return 0; return 0;
} }
} }
// Read the command
EBufferCommands command = static_cast<EBufferCommands>(buffer[0]);
switch (command)
{
case CMD_ORIGIN:
{
SOrigin origin = {};
GCAdapter::origin_data od;
GCAdapter::GetOrigin(m_device_number, &od);
origin.origin_stick_x = od.stickX;
origin.origin_stick_y = od.stickY;
origin.substick_x = od.substickX;
origin.substick_y = od.substickY;
origin.trigger_left = od.triggerL;
origin.trigger_right = od.triggerR;
u8* calibration = reinterpret_cast<u8*>(&origin);
for (int i = 0; i < (int)sizeof(SOrigin); i++)
{
buffer[i] = *calibration++;
}
return sizeof(SOrigin);
}
}
return CSIDevice_GCController::RunBuffer(buffer, request_length); return CSIDevice_GCController::RunBuffer(buffer, request_length);
} }


Expand Down

0 comments on commit e0352ad

Please sign in to comment.