Skip to content

Commit

Permalink
Pass UserSettings to Controller constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
ferranpujolcamins committed Nov 11, 2019
1 parent fc22b25 commit 85a3762
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
14 changes: 7 additions & 7 deletions src/controllers/bulk/bulkcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ static QString get_string(libusb_device_handle *handle, u_int8_t id) {
return QString::fromLatin1((char*)buf);
}


BulkController::BulkController(libusb_context* context,
libusb_device_handle *handle,
struct libusb_device_descriptor *desc)
: m_context(context),
BulkController::BulkController(UserSettingsPointer pConfig,
libusb_context* context,
libusb_device_handle* handle,
struct libusb_device_descriptor* desc)
: Controller(pConfig),
m_context(context),
m_phandle(handle),
in_epaddr(0),
out_epaddr(0)
{
out_epaddr(0) {
vendor_id = desc->idVendor;
product_id = desc->idProduct;

Expand Down
6 changes: 4 additions & 2 deletions src/controllers/bulk/bulkcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ class BulkReader : public QThread {
class BulkController : public Controller {
Q_OBJECT
public:
BulkController(libusb_context* context, libusb_device_handle *handle,
struct libusb_device_descriptor *desc);
BulkController(UserSettingsPointer pConfig,
libusb_context* context,
libusb_device_handle* handle,
struct libusb_device_descriptor* desc);
~BulkController() override;

QString presetExtension() override;
Expand Down
8 changes: 4 additions & 4 deletions src/controllers/bulk/bulkenumerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
#include "controllers/bulk/bulkenumerator.h"
#include "controllers/bulk/bulksupported.h"

BulkEnumerator::BulkEnumerator()
: ControllerEnumerator(),
m_context(NULL) {
BulkEnumerator::BulkEnumerator(UserSettingsPointer pConfig)
: ControllerEnumerator(), m_context(NULL), m_pConfig(pConfig) {
libusb_init(&m_context);
}

Expand Down Expand Up @@ -55,7 +54,8 @@ QList<Controller*> BulkEnumerator::queryDevices() {
continue;
}

BulkController* currentDevice = new BulkController(m_context, handle, &desc);
BulkController* currentDevice =
new BulkController(m_pConfig, m_context, handle, &desc);
m_devices.push_back(currentDevice);
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/controllers/bulk/bulkenumerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ struct libusb_context;

class BulkEnumerator : public ControllerEnumerator {
public:
BulkEnumerator();
BulkEnumerator(UserSettingsPointer pConfig);
virtual ~BulkEnumerator();

QList<Controller*> queryDevices();

private:
QList<Controller*> m_devices;
libusb_context* m_context;
UserSettingsPointer m_pConfig;
};

#endif
2 changes: 1 addition & 1 deletion src/controllers/controllermanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void ControllerManager::slotInitialize() {
m_enumerators.append(new Hss1394Enumerator());
#endif
#ifdef __BULK__
m_enumerators.append(new BulkEnumerator());
m_enumerators.append(new BulkEnumerator(m_pConfig));
#endif
#ifdef __HID__
m_enumerators.append(new HidEnumerator(m_pConfig));
Expand Down

0 comments on commit 85a3762

Please sign in to comment.