only call 'libusb_set_interface_alt_setting' when value is changed
@@ -465,7 +465,7 @@ static LIBUSB_DEVICE_DESCRIPTOR* udev_new_descript(URBDRC_PLUGIN* urbdrc, LIBUSB
static int libusb_udev_select_interface(IUDEVICE* idev, BYTE InterfaceNumber, BYTE AlternateSetting)
{
- int error = 0, diff = 1;
+ int error = 0, diff = 0;
UDEVICE* pdev = (UDEVICE*)idev;
URBDRC_PLUGIN* urbdrc;
MSUSB_CONFIG_DESCRIPTOR* MsConfig;
@@ -480,10 +480,17 @@ static int libusb_udev_select_interface(IUDEVICE* idev, BYTE InterfaceNumber, BY
if (MsConfig)
{
MsInterfaces = MsConfig->MsInterfaces;
+ if (MsInterfaces)
+ {
+ WLog_Print(urbdrc->log, WLOG_INFO,
+ "select Interface(%" PRIu8 ") curr AlternateSetting(%" PRIu8
+ ") new AlternateSetting(" PRIu8 ")",
+ InterfaceNumber, MsInterfaces[InterfaceNumber]->AlternateSetting,
+ AlternateSetting);
- if ((MsInterfaces) && (MsInterfaces[InterfaceNumber]->AlternateSetting == AlternateSetting))
+ if (MsInterfaces[InterfaceNumber]->AlternateSetting != AlternateSetting)
{
- diff = 0;
+ diff = 1;
}
}
@@ -494,7 +501,9 @@ static int libusb_udev_select_interface(IUDEVICE* idev, BYTE InterfaceNumber, BY
if (error < 0)
{
- WLog_Print(urbdrc->log, WLOG_ERROR, "Set interface altsetting get error num %d", error);
+ WLog_Print(urbdrc->log, WLOG_ERROR, "Set interface altsetting get error num %d",
+ error);
+ }
}
}
