Removed the GC Adapter "Use Thread" option as it was not useful.

This commit is contained in:
skidau 2015-03-05 23:30:43 +11:00
parent e5277a5f49
commit 4cf4cee30e
5 changed files with 7 additions and 93 deletions

View file

@ -353,7 +353,6 @@ void SConfig::SaveCoreSettings(IniFile& ini)
core->Set("GFXBackend", m_LocalCoreStartupParameter.m_strVideoBackend);
core->Set("GPUDeterminismMode", m_LocalCoreStartupParameter.m_strGPUDeterminismMode);
core->Set("GameCubeAdapter", m_GameCubeAdapter);
core->Set("GameCubeAdapterThread", m_GameCubeAdapterThread);
}
void SConfig::SaveMovieSettings(IniFile& ini)
@ -595,7 +594,6 @@ void SConfig::LoadCoreSettings(IniFile& ini)
core->Get("GFXBackend", &m_LocalCoreStartupParameter.m_strVideoBackend, "");
core->Get("GPUDeterminismMode", &m_LocalCoreStartupParameter.m_strGPUDeterminismMode, "auto");
core->Get("GameCubeAdapter", &m_GameCubeAdapter, true);
core->Get("GameCubeAdapterThread", &m_GameCubeAdapterThread, true);
}
void SConfig::LoadMovieSettings(IniFile& ini)

View file

@ -114,7 +114,6 @@ struct SConfig : NonCopyable
// Input settings
bool m_BackgroundInput;
bool m_GameCubeAdapter;
bool m_GameCubeAdapterThread;
SysConf* m_SYSCONF;

View file

@ -43,26 +43,6 @@ static u8 s_endpoint_out = 0;
static u64 s_last_init = 0;
#if defined(_WIN32)
#define LIBUSB_CALL WINAPI
#else
#define LIBUSB_CALL
#endif
extern "C"
{
void LIBUSB_CALL read_callback(libusb_transfer* transfer);
}
static void HandleEvents()
{
timeval tv = {1, 0};
while (s_adapter_thread_running.IsSet())
{
libusb_handle_events_timeout_completed(s_libusb_context, &tv, NULL);
Common::YieldCPU();
}
}
static void Read()
{
while (s_adapter_thread_running.IsSet())
@ -225,28 +205,14 @@ void AddGCAdapter(libusb_device* device)
unsigned char payload = 0x13;
libusb_interrupt_transfer(s_handle, s_endpoint_out, &payload, sizeof(payload), &tmp, 16);
if (SConfig::GetInstance().m_GameCubeAdapterThread)
{
s_adapter_thread_running.Set(true);
s_adapter_thread = std::thread(Read);
}
else
{
s_irq_transfer_read = libusb_alloc_transfer(0);
s_irq_transfer_write = libusb_alloc_transfer(0);
libusb_fill_interrupt_transfer(s_irq_transfer_read, s_handle, s_endpoint_in, s_controller_payload_swap, sizeof(s_controller_payload_swap), read_callback, NULL, 0);
libusb_submit_transfer(s_irq_transfer_read);
s_adapter_thread_running.Set(true);
s_adapter_thread = std::thread(HandleEvents);
}
s_adapter_thread_running.Set(true);
s_adapter_thread = std::thread(Read);
s_detected = true;
}
void Shutdown()
{
Reset();
if (s_libusb_context)
@ -263,26 +229,11 @@ void Reset()
if (!SConfig::GetInstance().m_GameCubeAdapter)
return;
if (!SConfig::GetInstance().m_GameCubeAdapterThread)
{
if (s_irq_transfer_read)
libusb_cancel_transfer(s_irq_transfer_read);
if (s_irq_transfer_write)
libusb_cancel_transfer(s_irq_transfer_write);
}
if (s_adapter_thread_running.TestAndClear())
{
s_adapter_thread.join();
}
if (!SConfig::GetInstance().m_GameCubeAdapterThread)
{
libusb_free_transfer(s_irq_transfer_read);
libusb_free_transfer(s_irq_transfer_write);
}
if (s_handle)
{
libusb_release_interface(s_handle, 0);
@ -373,20 +324,12 @@ void Output(int chan, u8 rumble_command)
unsigned char rumble[5] = { 0x11, s_controller_rumble[0], s_controller_rumble[1], s_controller_rumble[2], s_controller_rumble[3] };
int size = 0;
if (SConfig::GetInstance().m_GameCubeAdapterThread)
libusb_interrupt_transfer(s_handle, s_endpoint_out, rumble, sizeof(rumble), &size, 16);
// Netplay sends invalid data which results in size = 0x00. Ignore it.
if (size != 0x05 && size != 0x00)
{
libusb_interrupt_transfer(s_handle, s_endpoint_out, rumble, sizeof(rumble), &size, 16);
// Netplay sends invalid data which results in size = 0x00. Ignore it.
if (size != 0x05 && size != 0x00)
{
INFO_LOG(SERIALINTERFACE, "error writing rumble (size: %d)", size);
Shutdown();
}
}
else
{
libusb_fill_interrupt_transfer(s_irq_transfer_write, s_handle, s_endpoint_out, rumble, sizeof(rumble), NULL, &size, 16);
libusb_submit_transfer(s_irq_transfer_write);
INFO_LOG(SERIALINTERFACE, "error writing rumble (size: %d)", size);
Shutdown();
}
}
}
@ -401,17 +344,4 @@ bool IsDriverDetected()
return !s_libusb_driver_not_supported;
}
void LIBUSB_CALL read_callback(libusb_transfer *transfer)
{
if (transfer->status == LIBUSB_TRANSFER_COMPLETED)
{
{
std::lock_guard<std::mutex> lk(s_mutex);
s_controller_payload_size = transfer->actual_length;
memcpy(s_controller_payload, s_controller_payload_swap, s_controller_payload_size);
}
libusb_submit_transfer(s_irq_transfer_read);
}
}
} // end of namespace SI_GCAdapter

View file

@ -152,11 +152,7 @@ wxStaticBoxSizer* ControllerConfigDiag::CreateGamecubeSizer()
wxCheckBox* const gamecube_adapter = new wxCheckBox(this, wxID_ANY, _("Direct Connect"));
gamecube_adapter->Bind(wxEVT_CHECKBOX, &ControllerConfigDiag::OnGameCubeAdapter, this);
wxCheckBox* const gamecube_adapter_thread = new wxCheckBox(this, wxID_ANY, _("Use Thread"));
gamecube_adapter_thread->Bind(wxEVT_CHECKBOX, &ControllerConfigDiag::OnGameCubeAdapterThread, this);
gamecube_adapter_sizer->Add(gamecube_adapter, 0, wxEXPAND);
gamecube_adapter_sizer->Add(gamecube_adapter_thread, 0, wxEXPAND);
gamecube_adapter_group->Add(gamecube_adapter_sizer, 0, wxEXPAND);
gamecube_static_sizer->Add(gamecube_adapter_group, 0, wxEXPAND);
@ -169,17 +165,13 @@ wxStaticBoxSizer* ControllerConfigDiag::CreateGamecubeSizer()
gamecube_adapter->SetLabelText(_("Adapter Not Detected"));
gamecube_adapter->SetValue(false);
gamecube_adapter->Disable();
gamecube_adapter_thread->SetValue(false);
gamecube_adapter_thread->Disable();
}
else
{
gamecube_adapter->SetValue(SConfig::GetInstance().m_GameCubeAdapter);
gamecube_adapter_thread->SetValue(SConfig::GetInstance().m_GameCubeAdapterThread);
if (Core::GetState() != Core::CORE_UNINITIALIZED)
{
gamecube_adapter->Disable();
gamecube_adapter_thread->Disable();
}
}
#endif

View file

@ -64,11 +64,6 @@ public:
SConfig::GetInstance().m_GameCubeAdapter = event.IsChecked();
event.Skip();
}
void OnGameCubeAdapterThread(wxCommandEvent& event)
{
SConfig::GetInstance().m_GameCubeAdapterThread = event.IsChecked();
event.Skip();
}
private:
wxStaticBoxSizer* CreateGamecubeSizer();