Skip to content
Permalink
Browse files

SI/GCAdapter: use origin from controllers

GCAdapter controllers were just inheriting the "perfect" calibration of
the emulated GC controller.
  • Loading branch information...
booto committed Aug 7, 2019
1 parent da6289b commit 4a0628bad6000b9e68f75da47ff56920fd8b51f0
@@ -671,9 +671,6 @@ static void RunSIBuffer(u64 user_data, s64 cycles_late)
EstimateTicksForXfer(1, SI_MICROSECONDS_PER_STOP_BIT) - cycles_late,
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:
// Wait a reasonable amount of time for the result to be available:
// request is N bytes, ends with a stop bit
@@ -1054,8 +1051,6 @@ void TriggerPoll(s64 cycles_late)
EstimateTicksForXfer(1, SI_MICROSECONDS_PER_STOP_BIT) -
cycles_late,
s_poll_get_response_event, user_data);

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

// Polling finished
@@ -64,6 +64,29 @@ int CSIDevice_GCAdapter::RunBuffer(u8* buffer, int request_length)
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);
}

0 comments on commit 4a0628b

Please sign in to comment.
You can’t perform that action at this time.