main slider cbk, detected minor l_dcpp bug
This commit is contained in:
parent
a251b4cb6b
commit
679ad34f84
7 changed files with 49 additions and 22 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
GUID NGuidToGUID(NGuid* guid){
|
GUID NGuidToGUID(NGuid* guid) {
|
||||||
GUID msGuid = GUID();
|
GUID msGuid = GUID();
|
||||||
msGuid.Data1 = guid->data1;
|
msGuid.Data1 = guid->data1;
|
||||||
msGuid.Data2 = guid->data2;
|
msGuid.Data2 = guid->data2;
|
||||||
|
|
@ -6,12 +6,12 @@ GUID NGuidToGUID(NGuid* guid){
|
||||||
msGuid.Data1 = guid->data1;
|
msGuid.Data1 = guid->data1;
|
||||||
for (int i = 0; i < 8; i++){
|
for (int i = 0; i < 8; i++){
|
||||||
msGuid.Data4[i] = guid->data4[i];
|
msGuid.Data4[i] = guid->data4[i];
|
||||||
log_debugcpp("MSGUID DATA4 BYTE " << i << ": ");
|
//log_debugcpp("MSGUID DATA4 BYTE " << i << ": ");
|
||||||
log_debugcpp(print_as_binary(8, uint32_t, msGuid.Data4[i]));
|
//log_debugcpp(print_as_binary(8, uint32_t, msGuid.Data4[i]));
|
||||||
}
|
}
|
||||||
log_debugcpp("MSGUID DATA1: " << msGuid.Data1);
|
//log_debugcpp("MSGUID DATA1: " << msGuid.Data1);
|
||||||
log_debugcpp("MSGUID DATA2: " << msGuid.Data2);
|
//log_debugcpp("MSGUID DATA2: " << msGuid.Data2);
|
||||||
log_debugcpp("MSGUID DATA3: " << msGuid.Data3);
|
//log_debugcpp("MSGUID DATA3: " << msGuid.Data3);
|
||||||
|
|
||||||
return msGuid;
|
return msGuid;
|
||||||
}
|
}
|
||||||
|
|
@ -23,11 +23,11 @@ NGuid GUIDToNGuid(LPGUID msGuid){
|
||||||
guid.data3 = msGuid->Data3;
|
guid.data3 = msGuid->Data3;
|
||||||
for (int i = 0; i < 8; i++){
|
for (int i = 0; i < 8; i++){
|
||||||
guid.data4[i] = msGuid->Data4[i];
|
guid.data4[i] = msGuid->Data4[i];
|
||||||
log_debugcpp("GUID DATA4 BYTE " << i << ": ");
|
//log_debugcpp("GUID DATA4 BYTE " << i << ": ");
|
||||||
log_debugcpp(print_as_binary(8, uint32_t, guid.data4[i]));
|
//log_debugcpp(print_as_binary(8, uint32_t, guid.data4[i]));
|
||||||
}
|
}
|
||||||
log_debugcpp("GUID DATA1: " << guid.data1);
|
//log_debugcpp("GUID DATA1: " << guid.data1);
|
||||||
log_debugcpp("GUID DATA2: " << guid.data2);
|
//log_debugcpp("GUID DATA2: " << guid.data2);
|
||||||
log_debugcpp("GUID DATA3: " << guid.data3);
|
//log_debugcpp("GUID DATA3: " << guid.data3);
|
||||||
return guid;
|
return guid;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ HRESULT EndpointCallback::OnNotify(PAUDIO_VOLUME_NOTIFICATION_DATA pNotify) {
|
||||||
log_debugcpp("Onnanokotify says Stored: " << guid->data1);
|
log_debugcpp("Onnanokotify says Stored: " << guid->data1);
|
||||||
log_debugcpp("Onnanokotify says Grace of God: " << eventData.guidEventContext.Data1);
|
log_debugcpp("Onnanokotify says Grace of God: " << eventData.guidEventContext.Data1);
|
||||||
osh->updateMuteCallback(this->ep->getIndex(), eventData.bMuted);
|
osh->updateMuteCallback(this->ep->getIndex(), eventData.bMuted);
|
||||||
|
osh->updateMainVolumeCallback(this->ep->getIndex(), eventData.fMasterVolume);
|
||||||
}
|
}
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
|
@ -116,11 +117,12 @@ bool Endpoint::getMute(){
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
void Endpoint::setVolume(int channel, float volume) {
|
void Endpoint::setVolume(NGuid* guid, int channel, float volume) {
|
||||||
|
GUID tempMsGuid = NGuidToGUID(guid);
|
||||||
if (channel == ENDPOINT_MASTER_VOLUME) {
|
if (channel == ENDPOINT_MASTER_VOLUME) {
|
||||||
if(FAILED(endpointVolume->SetMasterVolumeLevelScalar(volume, NULL))) { log_debugcpp("si"); };
|
if(FAILED(endpointVolume->SetMasterVolumeLevelScalar(volume, &tempMsGuid))) { log_debugcpp("si"); };
|
||||||
} else {
|
} else {
|
||||||
if(FAILED(endpointVolume->SetChannelVolumeLevelScalar(channel, volume, NULL))) { log_debugcpp("si"); };
|
if(FAILED(endpointVolume->SetChannelVolumeLevelScalar(channel, volume, &tempMsGuid))) { log_debugcpp("si"); };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ class Endpoint {
|
||||||
Endpoint(IMMDevice* endpoint);
|
Endpoint(IMMDevice* endpoint);
|
||||||
uint64_t getIndex();
|
uint64_t getIndex();
|
||||||
void setIndex(uint64_t idx);
|
void setIndex(uint64_t idx);
|
||||||
void setVolume(int channel, float volume);
|
void setVolume(NGuid* guid, int channel, float volume);
|
||||||
/* float getLeftChannelVolume(); */
|
/* float getLeftChannelVolume(); */
|
||||||
/* float getRightChannelVolume(); */
|
/* float getRightChannelVolume(); */
|
||||||
float getVolume(int channel);
|
float getVolume(int channel);
|
||||||
|
|
|
||||||
|
|
@ -26,10 +26,10 @@ uint64_t EndpointHandler::getIndex(){
|
||||||
/*
|
/*
|
||||||
* -1 for master volume
|
* -1 for master volume
|
||||||
*/
|
*/
|
||||||
void EndpointHandler::setValue(int channel, int value){
|
void EndpointHandler::setVolume(NGuid* guid, int channel, int value){
|
||||||
if (channel == ENDPOINT_MASTER_VOLUME)
|
if (channel == ENDPOINT_MASTER_VOLUME)
|
||||||
ep->setVolume(channel, (float)value / 100);
|
ep->setVolume(guid, channel, (float)value / 100);
|
||||||
else ep->setVolume(channel, (float)value / 100);
|
else ep->setVolume(guid, channel, (float)value / 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EndpointHandler::setMute(NGuid* guid, bool muted){
|
void EndpointHandler::setMute(NGuid* guid, bool muted){
|
||||||
|
|
@ -114,3 +114,10 @@ void OverseerHandler::updateMuteCallback(uint64_t idx, bool muted){
|
||||||
epwMuteFunc f = &EndpointWidget::updateMute;
|
epwMuteFunc f = &EndpointWidget::updateMute;
|
||||||
std::invoke(f, endpointWidgets.at(idx), muted);
|
std::invoke(f, endpointWidgets.at(idx), muted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OverseerHandler::updateMainVolumeCallback(uint64_t idx, float newVal){
|
||||||
|
//int translatedNewVal = newVal * 100;
|
||||||
|
log_debugcpp("mainvolcallback float: " << newVal);
|
||||||
|
epwMainVolumeFunc f = &EndpointWidget::updateMainVolume;
|
||||||
|
std::invoke(f, endpointWidgets.at(idx), newVal);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ public:
|
||||||
float getVolume(int channel);
|
float getVolume(int channel);
|
||||||
bool getMute();
|
bool getMute();
|
||||||
|
|
||||||
void setValue(int channel, int value);
|
void setVolume(NGuid* guid, int channel, int value);
|
||||||
void setMute(NGuid* guid, bool muted);
|
void setMute(NGuid* guid, bool muted);
|
||||||
~EndpointHandler();
|
~EndpointHandler();
|
||||||
private:
|
private:
|
||||||
|
|
@ -61,6 +61,7 @@ public:
|
||||||
void reloadEndpointHandlers();
|
void reloadEndpointHandlers();
|
||||||
NGuid* getGuid();
|
NGuid* getGuid();
|
||||||
void updateMuteCallback(uint64_t idx, bool muted);
|
void updateMuteCallback(uint64_t idx, bool muted);
|
||||||
|
void updateMainVolumeCallback(uint64_t idx, float newVal);
|
||||||
|
|
||||||
//void parseExternalEndpointCallback(EndpointCallback *epc, PAUDIO_VOLUME_NOTIFICATION_DATA pNotify);
|
//void parseExternalEndpointCallback(EndpointCallback *epc, PAUDIO_VOLUME_NOTIFICATION_DATA pNotify);
|
||||||
//static Overseer* getOverseer();
|
//static Overseer* getOverseer();
|
||||||
|
|
|
||||||
|
|
@ -68,9 +68,9 @@ EndpointWidget::EndpointWidget(EndpointHandler* eph, QWidget *parent) : QWidget(
|
||||||
layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding), 3, 0);
|
layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding), 3, 0);
|
||||||
layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding), 3, 1);
|
layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding), 3, 1);
|
||||||
|
|
||||||
connect(mainSlider, &QSlider::valueChanged, [this](int newValue){this->eph->setValue(ENDPOINT_MASTER_VOLUME, newValue); });
|
connect<void(QSlider::*)(int), void(EndpointWidget::*)(int)>(mainSlider, &QSlider::valueChanged, this,&EndpointWidget::updateMainVolume);
|
||||||
connect(leftChannelSlider, &QSlider::valueChanged, [this](int newValue){ this->eph->setValue(ENDPOINT_LEFT_CHANNEL_VOLUME, newValue); this->leftChannelLabel->setText(QString::number(newValue)); });
|
connect(leftChannelSlider, &QSlider::valueChanged, [this](int newValue){ this->eph->setVolume(osh->getGuid(), ENDPOINT_LEFT_CHANNEL_VOLUME, newValue); this->leftChannelLabel->setText(QString::number(newValue)); });
|
||||||
connect(rightChannelSlider, &QSlider::valueChanged, [this](int newValue){ this->eph->setValue(ENDPOINT_RIGHT_CHANNEL_VOLUME, newValue); this->rightChannelLabel->setText(QString::number(newValue)); });
|
connect(rightChannelSlider, &QSlider::valueChanged, [this](int newValue){ this->eph->setVolume(osh->getGuid(), ENDPOINT_RIGHT_CHANNEL_VOLUME, newValue); this->rightChannelLabel->setText(QString::number(newValue)); });
|
||||||
connect<void(QCheckBox::*)(int), void(EndpointWidget::*)(int)>(muteButton, &QCheckBox::stateChanged, this, (&EndpointWidget::updateMute));
|
connect<void(QCheckBox::*)(int), void(EndpointWidget::*)(int)>(muteButton, &QCheckBox::stateChanged, this, (&EndpointWidget::updateMute));
|
||||||
/*
|
/*
|
||||||
* connect(muteButton, &QPushButton::clicked, [this](bool clicked){ log_debugcpp("cliqui" << clicked << "cloqui"); this->eph->setMute(osh->getGuid()); this->muteButton->setText(this->eph->getMute() ? STRING_UNMUTE : STRING_MUTE); });
|
* connect(muteButton, &QPushButton::clicked, [this](bool clicked){ log_debugcpp("cliqui" << clicked << "cloqui"); this->eph->setMute(osh->getGuid()); this->muteButton->setText(this->eph->getMute() ? STRING_UNMUTE : STRING_MUTE); });
|
||||||
|
|
@ -94,6 +94,20 @@ void EndpointWidget::updateMute(int checked){
|
||||||
this->muteButton->setText(this->eph->getMute() ? STRING_UNMUTE : STRING_MUTE);
|
this->muteButton->setText(this->eph->getMute() ? STRING_UNMUTE : STRING_MUTE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EndpointWidget::updateMainVolume(int newValue){
|
||||||
|
log_debugcpp("updateMainVolume slot");
|
||||||
|
this->eph->setVolume(osh->getGuid(), ENDPOINT_MASTER_VOLUME, newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EndpointWidget::updateMainVolume(float newValue){
|
||||||
|
int newVal = newValue * 100;
|
||||||
|
if(this->mainSlider->value() != newVal) {
|
||||||
|
this->mainSlider->setValue(newVal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void EndpointWidget::setIndex(uint64_t idx){
|
void EndpointWidget::setIndex(uint64_t idx){
|
||||||
this->idx = idx;
|
this->idx = idx;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,10 +68,12 @@ public:
|
||||||
QSlider *rightChannelSlider = nullptr;
|
QSlider *rightChannelSlider = nullptr;
|
||||||
QGridLayout *layout = nullptr;
|
QGridLayout *layout = nullptr;
|
||||||
QGridLayout *mainMuteLayout = nullptr;
|
QGridLayout *mainMuteLayout = nullptr;
|
||||||
|
void updateMainVolume(float newValue);
|
||||||
void updateMute(bool muted);
|
void updateMute(bool muted);
|
||||||
//void populateEndpointWidget(EndpointHandler *eph);
|
//void populateEndpointWidget(EndpointHandler *eph);
|
||||||
//void setEndpointHandlers(std::vector<EndpointHandler*> *ephs);
|
//void setEndpointHandlers(std::vector<EndpointHandler*> *ephs);
|
||||||
public slots:
|
public slots:
|
||||||
|
void updateMainVolume(int newValue);
|
||||||
void updateMute(int checked);
|
void updateMute(int checked);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -86,6 +88,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef void (EndpointWidget::*epwMuteFunc)(bool muted);
|
typedef void (EndpointWidget::*epwMuteFunc)(bool muted);
|
||||||
|
typedef void (EndpointWidget::*epwMainVolumeFunc)(float newValue);
|
||||||
|
|
||||||
class MainWindow : public QMainWindow {
|
class MainWindow : public QMainWindow {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue