InputCommon: replace SerialInterface log with ControllerInterface

where appropriate. SerialInterface was a leftover from the past,
and makes no sense to be used on actual/real controllers.
This commit is contained in:
Filoppi
2021-05-04 23:37:06 +03:00
parent a8c40eb510
commit 81092cf7e4
12 changed files with 65 additions and 60 deletions

View File

@ -88,7 +88,8 @@ static void Read()
int err = libusb_interrupt_transfer(s_handle, s_endpoint_in, s_controller_payload_swap,
sizeof(s_controller_payload_swap), &payload_size, 16);
if (err)
ERROR_LOG_FMT(SERIALINTERFACE, "adapter libusb read failed: err={}", libusb_error_name(err));
ERROR_LOG_FMT(CONTROLLERINTERFACE, "adapter libusb read failed: err={}",
libusb_error_name(err));
{
std::lock_guard<std::mutex> lk(s_mutex);
@ -121,7 +122,8 @@ static void Write()
const int err =
libusb_interrupt_transfer(s_handle, s_endpoint_out, payload, sizeof(payload), &size, 16);
if (err != 0)
ERROR_LOG_FMT(SERIALINTERFACE, "adapter libusb write failed: err={}", libusb_error_name(err));
ERROR_LOG_FMT(CONTROLLERINTERFACE, "adapter libusb write failed: err={}",
libusb_error_name(err));
}
}
@ -154,7 +156,7 @@ static int HotplugCallback(libusb_context* ctx, libusb_device* dev, libusb_hotpl
static void ScanThreadFunc()
{
Common::SetCurrentThreadName("GC Adapter Scanning Thread");
NOTICE_LOG_FMT(SERIALINTERFACE, "GC Adapter scanning thread started");
NOTICE_LOG_FMT(CONTROLLERINTERFACE, "GC Adapter scanning thread started");
#if defined(LIBUSB_API_VERSION) && LIBUSB_API_VERSION >= 0x01000102
#ifndef __FreeBSD__
@ -170,7 +172,7 @@ static void ScanThreadFunc()
nullptr, &s_hotplug_handle) != LIBUSB_SUCCESS)
s_libusb_hotplug_enabled = false;
if (s_libusb_hotplug_enabled)
NOTICE_LOG_FMT(SERIALINTERFACE, "Using libUSB hotplug detection");
NOTICE_LOG_FMT(CONTROLLERINTERFACE, "Using libUSB hotplug detection");
}
#endif
@ -187,7 +189,7 @@ static void ScanThreadFunc()
else
Common::SleepCurrentThread(500);
}
NOTICE_LOG_FMT(SERIALINTERFACE, "GC Adapter scanning thread stopped");
NOTICE_LOG_FMT(CONTROLLERINTERFACE, "GC Adapter scanning thread stopped");
}
void SetAdapterCallback(std::function<void()> func)
@ -265,7 +267,7 @@ static bool CheckDeviceAccess(libusb_device* device)
if (ret != 0)
{
// could not acquire the descriptor, no point in trying to use it.
ERROR_LOG_FMT(SERIALINTERFACE, "libusb_get_device_descriptor failed with error: {}", ret);
ERROR_LOG_FMT(CONTROLLERINTERFACE, "libusb_get_device_descriptor failed with error: {}", ret);
return false;
}
@ -275,7 +277,7 @@ static bool CheckDeviceAccess(libusb_device* device)
return false;
}
NOTICE_LOG_FMT(SERIALINTERFACE, "Found GC Adapter with Vendor: {:X} Product: {:X} Devnum: {}",
NOTICE_LOG_FMT(CONTROLLERINTERFACE, "Found GC Adapter with Vendor: {:X} Product: {:X} Devnum: {}",
desc.idVendor, desc.idProduct, 1);
// In case of failure, capture the libusb error code into the adapter status
@ -287,14 +289,14 @@ static bool CheckDeviceAccess(libusb_device* device)
if (ret == LIBUSB_ERROR_ACCESS)
{
ERROR_LOG_FMT(
SERIALINTERFACE,
CONTROLLERINTERFACE,
"Dolphin does not have access to this device: Bus {:03d} Device {:03d}: ID {:04X}:{:04X}.",
bus, port, desc.idVendor, desc.idProduct);
return false;
}
if (ret != 0)
{
ERROR_LOG_FMT(SERIALINTERFACE, "libusb_open failed to open device with error = {}", ret);
ERROR_LOG_FMT(CONTROLLERINTERFACE, "libusb_open failed to open device with error = {}", ret);
return false;
}
@ -303,14 +305,14 @@ static bool CheckDeviceAccess(libusb_device* device)
{
ret = libusb_detach_kernel_driver(s_handle, 0);
if (ret != 0 && ret != LIBUSB_ERROR_NOT_SUPPORTED)
ERROR_LOG_FMT(SERIALINTERFACE, "libusb_detach_kernel_driver failed with error: {}", ret);
ERROR_LOG_FMT(CONTROLLERINTERFACE, "libusb_detach_kernel_driver failed with error: {}", ret);
}
// This call makes Nyko-brand (and perhaps other) adapters work.
// However it returns LIBUSB_ERROR_PIPE with Mayflash adapters.
const int transfer = libusb_control_transfer(s_handle, 0x21, 11, 0x0001, 0, nullptr, 0, 1000);
if (transfer < 0)
WARN_LOG_FMT(SERIALINTERFACE, "libusb_control_transfer failed with error: {}", transfer);
WARN_LOG_FMT(CONTROLLERINTERFACE, "libusb_control_transfer failed with error: {}", transfer);
// this split is needed so that we don't avoid claiming the interface when
// detaching the kernel driver is successful
@ -324,7 +326,7 @@ static bool CheckDeviceAccess(libusb_device* device)
ret = libusb_claim_interface(s_handle, 0);
if (ret != 0)
{
ERROR_LOG_FMT(SERIALINTERFACE, "libusb_claim_interface failed with error: {}", ret);
ERROR_LOG_FMT(CONTROLLERINTERFACE, "libusb_claim_interface failed with error: {}", ret);
libusb_close(s_handle);
s_handle = nullptr;
return false;
@ -410,7 +412,7 @@ static void Reset()
}
if (s_detect_callback != nullptr)
s_detect_callback();
NOTICE_LOG_FMT(SERIALINTERFACE, "GC Adapter detached");
NOTICE_LOG_FMT(CONTROLLERINTERFACE, "GC Adapter detached");
}
GCPadStatus Input(int chan)
@ -436,8 +438,8 @@ GCPadStatus Input(int chan)
controller_payload_copy[0] != LIBUSB_DT_HID)
{
// This can occur for a few frames on initialization.
ERROR_LOG_FMT(SERIALINTERFACE, "error reading payload (size: {}, type: {:02x})", payload_size,
controller_payload_copy[0]);
ERROR_LOG_FMT(CONTROLLERINTERFACE, "error reading payload (size: {}, type: {:02x})",
payload_size, controller_payload_copy[0]);
}
else
{
@ -446,8 +448,8 @@ GCPadStatus Input(int chan)
if (type != ControllerTypes::CONTROLLER_NONE &&
s_controller_type[chan] == ControllerTypes::CONTROLLER_NONE)
{
NOTICE_LOG_FMT(SERIALINTERFACE, "New device connected to Port {} of Type: {:02x}", chan + 1,
controller_payload_copy[1 + (9 * chan)]);
NOTICE_LOG_FMT(CONTROLLERINTERFACE, "New device connected to Port {} of Type: {:02x}",
chan + 1, controller_payload_copy[1 + (9 * chan)]);
get_origin = true;
}
@ -551,7 +553,7 @@ static void ResetRumbleLockNeeded()
int size = 0;
libusb_interrupt_transfer(s_handle, s_endpoint_out, rumble, sizeof(rumble), &size, 16);
INFO_LOG_FMT(SERIALINTERFACE, "Rumble state reset");
INFO_LOG_FMT(CONTROLLERINTERFACE, "Rumble state reset");
}
void Output(int chan, u8 rumble_command)