support specifying pos printer
This commit is contained in:
parent
4cd0b42072
commit
98ba6db5a3
2 changed files with 25 additions and 3 deletions
|
@ -35,14 +35,24 @@ PosPrinter::PosPrinter()
|
|||
libusb_exit(contextPtr_);
|
||||
throw std::runtime_error("Could not receive device list");
|
||||
}
|
||||
|
||||
int numDevice = -1;
|
||||
|
||||
for (int i = 0; i < devCount; ++i) {
|
||||
libusb_device_descriptor desc;
|
||||
libusb_get_device_descriptor(devList[i], &desc);
|
||||
for (const auto& supported : supportedPrinters_.models) {
|
||||
if (desc.idVendor == supported.first && desc.idProduct == supported.second) {
|
||||
|
||||
if (printerDevice_.idVendor == 0) {
|
||||
for (const auto& supported : supportedPrinters_.models) {
|
||||
if (desc.idVendor == supported.first && desc.idProduct == supported.second) {
|
||||
numDevice = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (desc.idVendor == printerDevice_.idVendor &&
|
||||
desc.idProduct == printerDevice_.idProduct) {
|
||||
numDevice = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -75,6 +85,11 @@ PosPrinter::PosPrinter()
|
|||
libusb_free_device_list(devList, 1);
|
||||
}
|
||||
|
||||
PosPrinter::PosPrinter(const PrinterDevice& printerDevice) : printerDevice_{printerDevice}
|
||||
{
|
||||
PosPrinter();
|
||||
}
|
||||
|
||||
PosPrinter::~PosPrinter()
|
||||
{
|
||||
if (devicePtr_) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue