Skip to content

Commit

Permalink
Merge pull request #15 from Plutoberth/bug/fixAsmOffOn
Browse files Browse the repository at this point in the history
Add support for Noise Cancelling and Wind mode
  • Loading branch information
Plutoberth authored Aug 17, 2020
2 parents 0b4e668 + 0813847 commit 759aaf2
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 7 deletions.
23 changes: 21 additions & 2 deletions Client/CommandSerializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ constexpr unsigned char ESCAPED_BYTE_SENTRY = 61;
constexpr unsigned char ESCAPED_60 = 44;
constexpr unsigned char ESCAPED_61 = 45;
constexpr unsigned char ESCAPED_62 = 46;
constexpr unsigned int MAX_STEPS_WH_1000_XM3 = 19;

namespace CommandSerializer
{
Expand Down Expand Up @@ -152,14 +153,32 @@ namespace CommandSerializer
return ret;
}

Buffer serializeNcAndAsmSetting(NC_ASM_EFFECT ncAsmEffect, NC_ASM_SETTING_TYPE ncAsmSettingType, unsigned int unk, ASM_SETTING_TYPE asmSettingType, ASM_ID asmId, unsigned char asmLevel)
NC_DUAL_SINGLE_VALUE getDualSingleForAsmLevel(unsigned char asmLevel)
{
NC_DUAL_SINGLE_VALUE val = NC_DUAL_SINGLE_VALUE::OFF;
if (asmLevel > MAX_STEPS_WH_1000_XM3)
{
throw std::runtime_error("Exceeded max steps");
}
else if (asmLevel == 1)
{
val = NC_DUAL_SINGLE_VALUE::SINGLE;
}
else if (asmLevel == 0)
{
val = NC_DUAL_SINGLE_VALUE::DUAL;
}
return val;
}

Buffer serializeNcAndAsmSetting(NC_ASM_EFFECT ncAsmEffect, NC_ASM_SETTING_TYPE ncAsmSettingType, ASM_SETTING_TYPE asmSettingType, ASM_ID asmId, unsigned char asmLevel)
{
Buffer ret;
ret.push_back(static_cast<unsigned char>(COMMAND_TYPE::NCASM_SET_PARAM));
ret.push_back(static_cast<unsigned char>(NC_ASM_INQUIRED_TYPE::NOISE_CANCELLING_AND_AMBIENT_SOUND_MODE));
ret.push_back(static_cast<unsigned char>(ncAsmEffect));
ret.push_back(static_cast<unsigned char>(ncAsmSettingType));
ret.push_back(static_cast<unsigned char>(unk));
ret.push_back(static_cast<unsigned char>(getDualSingleForAsmLevel(asmLevel)));
ret.push_back(static_cast<unsigned char>(asmSettingType));
ret.push_back(static_cast<unsigned char>(asmId));
ret.push_back(asmLevel);
Expand Down
7 changes: 4 additions & 3 deletions Client/CommandSerializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <vector>
#include <stdexcept>


constexpr unsigned int MINIMUM_VOICE_FOCUS_STEP = 2;

namespace CommandSerializer
{
Expand Down Expand Up @@ -35,7 +35,8 @@ namespace CommandSerializer
Buffer packageDataForBt(const Buffer& src, DATA_TYPE dataType, unsigned int seqNumber);

Message unpackBtMessage(const Buffer& src);
//Probably set seqNumber to zero
Buffer serializeNcAndAsmSetting(NC_ASM_EFFECT ncAsmEffect, NC_ASM_SETTING_TYPE ncAsmSettingType, unsigned int unk, ASM_SETTING_TYPE asmSettingType, ASM_ID asmId, unsigned char asmLevel);

NC_DUAL_SINGLE_VALUE getDualSingleForAsmLevel(unsigned char asmLevel);
Buffer serializeNcAndAsmSetting(NC_ASM_EFFECT ncAsmEffect, NC_ASM_SETTING_TYPE ncAsmSettingType, ASM_SETTING_TYPE asmSettingType, ASM_ID asmId, unsigned char asmLevel);
}

7 changes: 7 additions & 0 deletions Client/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ enum class ASM_ID : char
VOICE = 1
};

enum class NC_DUAL_SINGLE_VALUE : char
{
OFF = 0,
SINGLE = 1,
DUAL = 2
};

enum class COMMAND_TYPE : char
{
NCASM_SET_PARAM = 104
Expand Down
11 changes: 9 additions & 2 deletions Client/GUI_Impls/CrossPlatformGUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,15 @@ void CrossPlatformGUI::_drawASMControls()

bool sliderActive = ImGui::IsItemActive();

ImGui::Checkbox("Focus on Voice", &focusOnVoice);
if (asmLevel >= MINIMUM_VOICE_FOCUS_STEP)
{
ImGui::Checkbox("Focus on Voice", &focusOnVoice);
}
else
{
ImGui::Text("Focus on Voice isn't enabled on this level.");
}


if (sentAsmLevel != asmLevel || sentFocusOnVoice != focusOnVoice)
{
Expand All @@ -168,7 +176,6 @@ void CrossPlatformGUI::_drawASMControls()
return this->_bt.sendCommand(CommandSerializer::serializeNcAndAsmSetting(
ncAsmEffect,
NC_ASM_SETTING_TYPE::LEVEL_ADJUSTMENT,
0,
ASM_SETTING_TYPE::LEVEL_ADJUSTMENT,
asmId,
asmLevel
Expand Down

0 comments on commit 759aaf2

Please sign in to comment.