Merge branch 'choose_printer'
This commit is contained in:
commit
dc74c59287
4 changed files with 55 additions and 16 deletions
|
@ -20,7 +20,9 @@ const std::string PosPrinter::Command::FONT_SIZE_BIG = {0x1b, 0x21, 0x10};
|
|||
const std::string PosPrinter::Command::FONT_SIZE_NORMAL = {0x1b, 0x21, 0x00};
|
||||
const std::string PosPrinter::Command::FEED = {0x1b, 0x64, 0x03};
|
||||
|
||||
PosPrinter::PosPrinter()
|
||||
PosPrinter::PosPrinter() : PosPrinter(PrinterDevice()) {}
|
||||
|
||||
PosPrinter::PosPrinter(const PrinterDevice& printerDevice) : printerDevice_(printerDevice)
|
||||
{
|
||||
int retValue;
|
||||
|
||||
|
@ -35,12 +37,23 @@ 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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue