-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
197 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,52 @@ | ||
import QtQuick 2.7 | ||
import dslul.devicecomm 1.0 | ||
|
||
Page1Form { | ||
property bool settingsLoaded: false | ||
|
||
switchDpiLed.onCheckedChanged: { | ||
if(settingsLoaded === true) | ||
devcomm.toggleDPILed() | ||
DevCom.toggleDPILed() | ||
} | ||
|
||
checkBoxGlow.onCheckedChanged: { | ||
if(settingsLoaded === true) { | ||
if(checkBoxGlow.checked === true) { | ||
sliderGlow.enabled = true | ||
devcomm.setLogoGlow(sliderGlow.value) | ||
DevCom.setLogoGlow(sliderGlow.value) | ||
} else { | ||
sliderGlow.enabled = false | ||
devcomm.disableGlow() | ||
DevCom.disableGlow() | ||
} | ||
} | ||
} | ||
|
||
sliderBrightness.onValueChanged: { | ||
if(settingsLoaded === true) | ||
devcomm.setLogoBrightness(sliderBrightness.value) | ||
DevCom.setLogoBrightness(sliderBrightness.value) | ||
} | ||
|
||
sliderGlow.onValueChanged: { | ||
if(settingsLoaded === true) | ||
devcomm.setLogoGlow(sliderGlow.value) | ||
DevCom.setLogoGlow(sliderGlow.value) | ||
} | ||
|
||
|
||
|
||
Component.onCompleted: { | ||
if(devcomm.isDPILedOn()) | ||
if(DevCom.isDPILedOn()) | ||
switchDpiLed.checked = true | ||
else | ||
switchDpiLed.checked = false | ||
if(devcomm.isBreathingEnabled()) { | ||
if(DevCom.isBreathingEnabled()) { | ||
checkBoxGlow.checked = true | ||
sliderGlow.enabled = true | ||
} else { | ||
checkBoxGlow.checked = false | ||
sliderGlow.enabled = false | ||
} | ||
sliderBrightness.value = devcomm.getBreathingIntensity() | ||
sliderGlow.value = devcomm.getBreathingRate() | ||
sliderBrightness.value = DevCom.getBreathingIntensity() | ||
sliderGlow.value = DevCom.getBreathingRate() | ||
settingsLoaded = true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import QtQuick 2.7 | ||
import dslul.devicecomm 1.0 | ||
|
||
Page2Form { | ||
property int resNum: resNumSpinBox.value | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,78 @@ | ||
#include <iostream> | ||
|
||
#include <misc/Log.h> | ||
#include <hidpp/SimpleDispatcher.h> | ||
#include <hidpp/Device.h> | ||
#include <hidpp10/Error.h> | ||
#include <hidpp20/Error.h> | ||
|
||
#include "devicemanager.h" | ||
/* | ||
DeviceManager::DeviceManager(): | ||
dev(nullptr) | ||
{ | ||
}*/ | ||
|
||
DeviceManager::DeviceManager() | ||
|
||
std::string DeviceManager::getDevicePath() | ||
{ | ||
return pathdev; | ||
} | ||
|
||
|
||
|
||
void DeviceManager::addDevice(const char *path) { | ||
try { | ||
HIDPP::SimpleDispatcher dispatcher(path); | ||
bool has_receiver_index = false; | ||
for(HIDPP::DeviceIndex index: { | ||
HIDPP::DefaultDevice, | ||
HIDPP::CordedDevice, | ||
HIDPP::WirelessDevice1, | ||
HIDPP::WirelessDevice2, | ||
HIDPP::WirelessDevice3, | ||
HIDPP::WirelessDevice4, | ||
HIDPP::WirelessDevice5, | ||
HIDPP::WirelessDevice6 }) { | ||
// Skip wireless devices, if the default index(used by the receiver) already failed. | ||
if(!has_receiver_index && index == HIDPP::WirelessDevice1) | ||
break; | ||
try { | ||
HIDPP::Device dev(&dispatcher, index); | ||
auto version = dev.protocolVersion(); | ||
std::cout << path << std::endl; | ||
pathdev = path; | ||
if(index == HIDPP::DefaultDevice && version == std::make_tuple(1, 0)) | ||
has_receiver_index = true; | ||
//TODO: implement a list of compatible devices | ||
break; | ||
} | ||
catch(HIDPP10::Error e) { | ||
if(e.errorCode() != HIDPP10::Error::UnknownDevice && e.errorCode() != HIDPP10::Error::InvalidSubID) { | ||
Log::error().printf("Error while querying %s wireless device %d: %s\n", | ||
path, index, e.what()); | ||
} | ||
} | ||
catch(HIDPP20::Error e) { | ||
if(e.errorCode() != HIDPP20::Error::UnknownDevice) { | ||
Log::error().printf("Error while querying %s device %d: %s\n", | ||
path, index, e.what()); | ||
} | ||
} | ||
catch(HIDPP::Dispatcher::TimeoutError e) { | ||
Log::warning().printf("Device %s(index %d) timed out\n", | ||
path, index); | ||
} | ||
} | ||
|
||
} | ||
catch(HIDPP::Dispatcher::NoHIDPPReportException e) { | ||
} | ||
catch(std::system_error e) { | ||
Log::warning().printf("Failed to open %s: %s\n", path, e.what()); | ||
} | ||
} | ||
|
||
void DeviceManager::removeDevice(const char *path) { | ||
return; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,25 @@ | ||
#ifndef DEVICEMANAGER_H | ||
#define DEVICEMANAGER_H | ||
|
||
#include <QQuickItem> | ||
#include <hidpp20/Device.h> | ||
#include <hid/DeviceMonitor.h> | ||
|
||
class DeviceManager : public QQuickItem | ||
class DeviceManager : public HID::DeviceMonitor | ||
{ | ||
Q_OBJECT | ||
public: | ||
DeviceManager(); | ||
std::string getDevicePath(); | ||
//DeviceManager(); | ||
|
||
signals: | ||
private: | ||
std::string pathdev; | ||
|
||
public slots: | ||
|
||
|
||
|
||
|
||
protected: | ||
void addDevice(const char *path); | ||
void removeDevice(const char *path); | ||
}; | ||
|
||
#endif // DEVICEMANAGER_H | ||
#endif // DEVICEMANAGER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.