diff --git a/backend/genesys/genesys.cpp b/backend/genesys/genesys.cpp index 41c106acd..1629355e5 100644 --- a/backend/genesys/genesys.cpp +++ b/backend/genesys/genesys.cpp @@ -4845,25 +4845,24 @@ static Genesys_Device* attach_device_by_name(SANE_String_Const devname, bool may usb_dev.open(devname); DBG(DBG_info, "%s: device `%s' successfully opened\n", __func__, devname); - int vendor, product; - usb_dev.get_vendor_product(vendor, product); + auto vendor_id = usb_dev.get_vendor_id(); + auto product_id = usb_dev.get_product_id(); usb_dev.close(); /* KV-SS080 is an auxiliary device which requires a master device to be here */ - if(vendor == 0x04da && product == 0x100f) - { + if (vendor_id == 0x04da && product_id == 0x100f) { present = false; - sanei_usb_find_devices (vendor, 0x1006, check_present); - sanei_usb_find_devices (vendor, 0x1007, check_present); - sanei_usb_find_devices (vendor, 0x1010, check_present); + sanei_usb_find_devices(vendor_id, 0x1006, check_present); + sanei_usb_find_devices(vendor_id, 0x1007, check_present); + sanei_usb_find_devices(vendor_id, 0x1010, check_present); if (present == false) { throw SaneException("master device not present"); } } - Genesys_Device* dev = attach_usb_device(devname, vendor, product); + Genesys_Device* dev = attach_usb_device(devname, vendor_id, product_id); - DBG(DBG_info, "%s: found %u flatbed scanner %u at %s\n", __func__, vendor, product, + DBG(DBG_info, "%s: found %u flatbed scanner %u at %s\n", __func__, vendor_id, product_id, dev->file_name.c_str()); return dev; diff --git a/backend/genesys/test_usb_device.cpp b/backend/genesys/test_usb_device.cpp index 19a1dc62f..1612eae6e 100644 --- a/backend/genesys/test_usb_device.cpp +++ b/backend/genesys/test_usb_device.cpp @@ -96,12 +96,18 @@ void TestUsbDevice::close() name_ = ""; } -void TestUsbDevice::get_vendor_product(int& vendor, int& product) +std::uint16_t TestUsbDevice::get_vendor_id() { DBG_HELPER(dbg); assert_is_open(); - vendor = vendor_; - product = product_; + return vendor_; +} + +std::uint16_t TestUsbDevice::get_product_id() +{ + DBG_HELPER(dbg); + assert_is_open(); + return product_; } std::uint16_t TestUsbDevice::get_bcd_device() diff --git a/backend/genesys/test_usb_device.h b/backend/genesys/test_usb_device.h index 4682792ff..03b49ccb7 100644 --- a/backend/genesys/test_usb_device.h +++ b/backend/genesys/test_usb_device.h @@ -63,7 +63,8 @@ public: void reset() override; void close() override; - void get_vendor_product(int& vendor, int& product) override; + std::uint16_t get_vendor_id() override; + std::uint16_t get_product_id() override; std::uint16_t get_bcd_device() override; void control_msg(int rtype, int reg, int value, int index, int length, diff --git a/backend/genesys/usb_device.cpp b/backend/genesys/usb_device.cpp index 05d6a7cb0..d6cbaed6a 100644 --- a/backend/genesys/usb_device.cpp +++ b/backend/genesys/usb_device.cpp @@ -101,11 +101,24 @@ void UsbDevice::close() sanei_usb_close(device_num); } -void UsbDevice::get_vendor_product(int& vendor, int& product) +std::uint16_t UsbDevice::get_vendor_id() { DBG_HELPER(dbg); assert_is_open(); + int vendor = 0; + int product = 0; TIE(sanei_usb_get_vendor_product(device_num_, &vendor, &product)); + return static_cast(vendor); +} + +std::uint16_t UsbDevice::get_product_id() +{ + DBG_HELPER(dbg); + assert_is_open(); + int vendor = 0; + int product = 0; + TIE(sanei_usb_get_vendor_product(device_num_, &vendor, &product)); + return static_cast(product); } std::uint16_t UsbDevice::get_bcd_device() diff --git a/backend/genesys/usb_device.h b/backend/genesys/usb_device.h index 9c9469bd5..aa8b89ab2 100644 --- a/backend/genesys/usb_device.h +++ b/backend/genesys/usb_device.h @@ -71,7 +71,8 @@ public: virtual void reset() = 0; virtual void close() = 0; - virtual void get_vendor_product(int& vendor, int& product) = 0; + virtual std::uint16_t get_vendor_id() = 0; + virtual std::uint16_t get_product_id() = 0; virtual std::uint16_t get_bcd_device() = 0; virtual void control_msg(int rtype, int reg, int value, int index, int length, @@ -97,7 +98,8 @@ public: void reset() override; void close() override; - void get_vendor_product(int& vendor, int& product) override; + std::uint16_t get_vendor_id() override; + std::uint16_t get_product_id() override; std::uint16_t get_bcd_device() override; void control_msg(int rtype, int reg, int value, int index, int length,