From 8ebd69f2394619b288e6d88370a74e5fc5a79d3d Mon Sep 17 00:00:00 2001 From: AVA Date: Fri, 18 Nov 2016 16:12:31 +0400 Subject: [PATCH 1/3] Added save settings button. All settings saved when clicked and settings are reloaded next time the app is run. Added firefly modes. Now contains Single-color, Upper-bottom and Bottom-up visualization modes. Added Blackwidow modes. Now caintains the pre-existing EQ Visualizer and new Single-color, Bottom-up, Upper-bottom, Mid-to-side and Side-to-Mid modes Added LED strip position control to select where the single color and upper-bottom, bottom-up, mid-to-side and side-to-mid visualization would be selected from the spectrum Added visual indicator for this last strip position control. Draws a red line where it will be pulling the data from on the preview. --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7f0ed07 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +################################################################################ +# This .gitignore file was automatically created by Microsoft(R) Visual Studio. +################################################################################ + +/Debug From 1bc3f4c82d4fb1741a9f6fcca7cbaee8b10d469b Mon Sep 17 00:00:00 2001 From: AVA Date: Fri, 18 Nov 2016 16:13:56 +0400 Subject: [PATCH 2/3] More modes and save settings Added save settings button. All settings saved when clicked and settings are reloaded next time the app is run. Added firefly modes. Now contains Single-color, Upper-bottom and Bottom-up visualization modes. Added Blackwidow modes. Now caintains the pre-existing EQ Visualizer and new Single-color, Bottom-up, Upper-bottom, Mid-to-side and Side-to-Mid modes Added LED strip position control to select where the single color and upper-bottom, bottom-up, mid-to-side and side-to-mid visualization would be selected from the spectrum Added visual indicator for this last strip position control. Draws a red line where it will be pulling the data from on the preview. --- KeyboardVisualizerVC/AppSettings.cpp | 96 +++++ KeyboardVisualizerVC/AppSettings.h | 44 ++ KeyboardVisualizerVC/KeyboardVisDlg.cpp | 378 +++++++++++------- KeyboardVisualizerVC/KeyboardVisDlg.h | 14 +- .../KeyboardVisualizerVC.vcxproj | 2 + KeyboardVisualizerVC/RazerChroma.cpp | 108 ++++- KeyboardVisualizerVC/RazerChroma.h | 3 + KeyboardVisualizerVC/Resource.aps | Bin 0 -> 27528 bytes KeyboardVisualizerVC/Resource.rc | Bin 8926 -> 10084 bytes KeyboardVisualizerVC/Visualizer.cpp | 71 ++-- KeyboardVisualizerVC/Visualizer.h | 28 ++ KeyboardVisualizerVC/resource.h | Bin 2740 -> 3200 bytes KeyboardVisualizerVC/settings.txt | 17 + 13 files changed, 561 insertions(+), 200 deletions(-) create mode 100644 KeyboardVisualizerVC/AppSettings.cpp create mode 100644 KeyboardVisualizerVC/AppSettings.h create mode 100644 KeyboardVisualizerVC/Resource.aps create mode 100644 KeyboardVisualizerVC/settings.txt diff --git a/KeyboardVisualizerVC/AppSettings.cpp b/KeyboardVisualizerVC/AppSettings.cpp new file mode 100644 index 0000000..d4c675e --- /dev/null +++ b/KeyboardVisualizerVC/AppSettings.cpp @@ -0,0 +1,96 @@ +#include +#include +using namespace std; +using std::string; + +#include "AppSettings.h" +string path = "settings.txt"; + +AppSettings::AppSettings() { } + +void AppSettings::defaultSettings() { + rememberSettingsOnExit = true; + amplitude = 100; + avg_mode = 0; + avg_size = 8; + bkgd_step = 0; + bkgd_bright = 10; + bkgd_mode = 0; + delay = 50; + window_mode = 1; + decay = 80; + frgd_mode = 8; + ldstrp_pos = 0; + nrml_ofst = 0.04f; + nrml_scl = 0.5f; + single_color_mode = 1; + fireflymode = 0; + blkwdwmode = 0; +} + +void AppSettings::saveSettings() { + ofstream fout(path); + if (fout.is_open()) { + fout + << rememberSettingsOnExit << endl + << amplitude << endl + << avg_mode << endl + << avg_size << endl + << bkgd_step << endl + << bkgd_bright << endl + << bkgd_mode << endl + << delay << endl + << window_mode << endl + << decay << endl + << frgd_mode << endl + << ldstrp_pos << endl + << nrml_ofst << endl + << nrml_scl << endl + << single_color_mode << endl + << fireflymode << endl + << blkwdwmode << endl; + fout.close(); + } +} + +void AppSettings::loadSettings() { + ifstream fin; + try { + fin.open(path); + if (fin.is_open()) { + fin + >> rememberSettingsOnExit + >> amplitude + >> avg_mode + >> avg_size + >> bkgd_step + >> bkgd_bright + >> bkgd_mode + >> delay + >> window_mode + >> decay + >> frgd_mode + >> ldstrp_pos + >> nrml_ofst + >> nrml_scl + >> single_color_mode + >> fireflymode + >> blkwdwmode; + fin.close(); + } else { + initSettingsFile(); + } + } catch (...) { + defaultSettings(); + } +} + +void AppSettings::initSettingsFile() { + defaultSettings(); + saveSettings(); +} + +bool is_file_exist(const char *fileName) { + std::ifstream infile(fileName); + return infile.good(); +} \ No newline at end of file diff --git a/KeyboardVisualizerVC/AppSettings.h b/KeyboardVisualizerVC/AppSettings.h new file mode 100644 index 0000000..8746ea4 --- /dev/null +++ b/KeyboardVisualizerVC/AppSettings.h @@ -0,0 +1,44 @@ +#pragma once + +class AppSettings { +public: + AppSettings(); + + //Initialize default settings + void defaultSettings(); + + //Creates a default settings file if it does not exist + void initSettingsFile(); + + //Loads settings from file + void loadSettings(); + + //Saves settings to file + void saveSettings(); + + //_____ Settings _____// + //Amplitude of input waveform + int amplitude; + int avg_mode; + int avg_size; + int window_mode; + int decay; + int delay; + int ldstrp_pos; + //Background Variables + int bkgd_bright; + int bkgd_mode; + int bkgd_step; + //Single Color Mode + int single_color_mode; + //Normalization Offset and Scale + float nrml_ofst; + float nrml_scl; + //Foreground Variables + int frgd_mode; + //Device specific modes + int fireflymode; + int blkwdwmode; + //App settings + bool rememberSettingsOnExit; +}; \ No newline at end of file diff --git a/KeyboardVisualizerVC/KeyboardVisDlg.cpp b/KeyboardVisualizerVC/KeyboardVisDlg.cpp index 6eba2f0..9905a13 100644 --- a/KeyboardVisualizerVC/KeyboardVisDlg.cpp +++ b/KeyboardVisualizerVC/KeyboardVisDlg.cpp @@ -24,51 +24,52 @@ boolean startminimized; boolean firstrun; KeyboardVisDlg::KeyboardVisDlg(CWnd* pParent) - : CDialogEx(IDD_RAZER_CHROMA_DLG, pParent) + : CDialogEx(IDD_RAZER_CHROMA_DLG, pParent) { - startminimized = FALSE; + startminimized = FALSE; } -void KeyboardVisDlg::SetVisualizer(Visualizer* v) +void KeyboardVisDlg::SetVisualizer(Visualizer* v) { vis = v; } -KeyboardVisDlg::~KeyboardVisDlg() -{ +KeyboardVisDlg::~KeyboardVisDlg() +{ } -void KeyboardVisDlg::DoDataExchange(CDataExchange* pDX) +void KeyboardVisDlg::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); } -BOOL KeyboardVisDlg::OnInitDialog() +BOOL KeyboardVisDlg::OnInitDialog() { - NOTIFYICONDATA Tray; - Tray.cbSize = sizeof(Tray); - Tray.hIcon = (HICON)::LoadImage(GetModuleHandle(0), MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, 16, 16, LR_SHARED);//LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_ICON)); - Tray.hWnd = GetSafeHwnd(); - strcpy(Tray.szTip, "Keyboard Visualizer"); - Tray.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE; - Tray.uID = ID_SYSTEMTRAY; - Tray.uCallbackMessage = WM_TRAYICON_EVENT; + NOTIFYICONDATA Tray; + Tray.cbSize = sizeof(Tray); + Tray.hIcon = (HICON)::LoadImage(GetModuleHandle(0), MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, 16, 16, LR_SHARED);//LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_ICON)); + Tray.hWnd = GetSafeHwnd(); + strcpy(Tray.szTip, "Keyboard Visualizer"); + Tray.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE; + Tray.uID = ID_SYSTEMTRAY; + Tray.uCallbackMessage = WM_TRAYICON_EVENT; - Shell_NotifyIcon(NIM_ADD, &Tray); + Shell_NotifyIcon(NIM_ADD, &Tray); - char nrml_ofst_str[64]; - char nrml_scl_str[64]; + char nrml_ofst_str[64]; + char nrml_scl_str[64]; - snprintf(nrml_ofst_str, 64, "%f", vis->nrml_ofst); - snprintf(nrml_scl_str, 64, "%f", vis->nrml_scl); + snprintf(nrml_ofst_str, 64, "%f", vis->nrml_ofst); + snprintf(nrml_scl_str, 64, "%f", vis->nrml_scl); SetDlgItemInt(IDC_EDIT_AMPLITUDE, vis->amplitude); SetDlgItemInt(IDC_EDIT_BACKGROUND_BRIGHTNESS, vis->bkgd_bright); SetDlgItemInt(IDC_EDIT_AVERAGE_SIZE, vis->avg_size); SetDlgItemInt(IDC_EDIT_DECAY, vis->decay); SetDlgItemInt(IDC_EDIT_DELAY, vis->delay); - SetDlgItemText(IDC_EDIT_NRML_OFST, nrml_ofst_str); - SetDlgItemText(IDC_EDIT_NRML_SCL, nrml_scl_str); + SetDlgItemText(IDC_EDIT_NRML_OFST, nrml_ofst_str); + SetDlgItemText(IDC_EDIT_NRML_SCL, nrml_scl_str); + SetDlgItemInt(IDC_EDIT_LEDPOS, vis->ldstrp_pos); CComboBox* windowBox = (CComboBox*)GetDlgItem(IDC_COMBO_WINDOW); windowBox->AddString("None"); @@ -81,129 +82,137 @@ BOOL KeyboardVisDlg::OnInitDialog() bkgdModeBox->AddString("None"); bkgdModeBox->AddString("Original"); bkgdModeBox->AddString("Rainbow"); - bkgdModeBox->AddString("Color Wheel"); - bkgdModeBox->AddString("Follow Foreground"); - bkgdModeBox->AddString("White"); - bkgdModeBox->AddString("Red"); - bkgdModeBox->AddString("Orange"); - bkgdModeBox->AddString("Yellow"); - bkgdModeBox->AddString("Green"); - bkgdModeBox->AddString("Cyan"); - bkgdModeBox->AddString("Blue"); - bkgdModeBox->AddString("Purple"); + bkgdModeBox->AddString("Color Wheel"); + bkgdModeBox->AddString("Follow Foreground"); + bkgdModeBox->AddString("White"); + bkgdModeBox->AddString("Red"); + bkgdModeBox->AddString("Orange"); + bkgdModeBox->AddString("Yellow"); + bkgdModeBox->AddString("Green"); + bkgdModeBox->AddString("Cyan"); + bkgdModeBox->AddString("Blue"); + bkgdModeBox->AddString("Purple"); bkgdModeBox->SetCurSel(vis->bkgd_mode); - CComboBox* frgdModeBox = (CComboBox*)GetDlgItem(IDC_COMBO_FRGD_MODE); - frgdModeBox->AddString("White"); - frgdModeBox->AddString("Red"); - frgdModeBox->AddString("Orange"); - frgdModeBox->AddString("Yellow"); - frgdModeBox->AddString("Green"); - frgdModeBox->AddString("Cyan"); - frgdModeBox->AddString("Blue"); - frgdModeBox->AddString("Purple"); - frgdModeBox->AddString("Green/Yellow/Red"); - frgdModeBox->AddString("Green/White/Red"); - frgdModeBox->AddString("Blue/Cyan/White"); - frgdModeBox->AddString("Red/White/Blue"); - frgdModeBox->AddString("Rainbow"); - frgdModeBox->AddString("Rainbow Inverse"); - frgdModeBox->SetCurSel(vis->frgd_mode); - - CComboBox* snglClrModeBox = (CComboBox*)GetDlgItem(IDC_COMBO_SNGL_CLR_MODE); - snglClrModeBox->AddString("None"); - snglClrModeBox->AddString("Follow Foreground"); - snglClrModeBox->AddString("Follow Background"); - snglClrModeBox->AddString("White"); - snglClrModeBox->AddString("Red"); - snglClrModeBox->AddString("Orange"); - snglClrModeBox->AddString("Yellow"); - snglClrModeBox->AddString("Green"); - snglClrModeBox->AddString("Cyan"); - snglClrModeBox->AddString("Blue"); - snglClrModeBox->AddString("Purple"); - snglClrModeBox->SetCurSel(vis->single_color_mode); - - CComboBox* avgModeBox = (CComboBox*)GetDlgItem(IDC_COMBO_AVG_MODE); - avgModeBox->AddString("Binning"); - avgModeBox->AddString("Low Pass"); - avgModeBox->SetCurSel(vis->avg_mode); + CComboBox* frgdModeBox = (CComboBox*)GetDlgItem(IDC_COMBO_FRGD_MODE); + frgdModeBox->AddString("White"); + frgdModeBox->AddString("Red"); + frgdModeBox->AddString("Orange"); + frgdModeBox->AddString("Yellow"); + frgdModeBox->AddString("Green"); + frgdModeBox->AddString("Cyan"); + frgdModeBox->AddString("Blue"); + frgdModeBox->AddString("Purple"); + frgdModeBox->AddString("Green/Yellow/Red"); + frgdModeBox->AddString("Green/White/Red"); + frgdModeBox->AddString("Blue/Cyan/White"); + frgdModeBox->AddString("Red/White/Blue"); + frgdModeBox->AddString("Rainbow"); + frgdModeBox->AddString("Rainbow Inverse"); + frgdModeBox->SetCurSel(vis->frgd_mode); + + CComboBox* snglClrModeBox = (CComboBox*)GetDlgItem(IDC_COMBO_SNGL_CLR_MODE); + snglClrModeBox->AddString("None"); + snglClrModeBox->AddString("Follow Foreground"); + snglClrModeBox->AddString("Follow Background"); + snglClrModeBox->AddString("White"); + snglClrModeBox->AddString("Red"); + snglClrModeBox->AddString("Orange"); + snglClrModeBox->AddString("Yellow"); + snglClrModeBox->AddString("Green"); + snglClrModeBox->AddString("Cyan"); + snglClrModeBox->AddString("Blue"); + snglClrModeBox->AddString("Purple"); + snglClrModeBox->SetCurSel(vis->single_color_mode); + + CComboBox* avgModeBox = (CComboBox*)GetDlgItem(IDC_COMBO_AVG_MODE); + avgModeBox->AddString("Binning"); + avgModeBox->AddString("Low Pass"); + avgModeBox->SetCurSel(vis->avg_mode); + + CComboBox* frflyModeBox = (CComboBox*)GetDlgItem(IDC_COMBO_FRFLY_MODE); + frflyModeBox->AddString("Bottom-Up"); + frflyModeBox->AddString("Upper-Bottom"); + frflyModeBox->AddString("Single Color"); + frflyModeBox->SetCurSel(vis->fireflymode); + + CComboBox* blckwdModeBox = (CComboBox*)GetDlgItem(IDC_COMBO_BLCKWD_MODE); + blckwdModeBox->AddString("EQ Visualizer"); + blckwdModeBox->AddString("Single Color"); + blckwdModeBox->AddString("Bottom-up"); + blckwdModeBox->AddString("Upper-bottom"); + blckwdModeBox->AddString("Mid-to-Side"); + blckwdModeBox->AddString("Side-to-Mid"); + blckwdModeBox->SetCurSel(vis->blkwdwmode); timer = SetTimer(1, 25, NULL); - firstrun = TRUE; + firstrun = TRUE; return TRUE; } -void KeyboardVisDlg::StartMinimized(boolean startmin) +void KeyboardVisDlg::StartMinimized(boolean startmin) { - startminimized = startmin; + startminimized = startmin; } -void KeyboardVisDlg::OnDestroy() +void KeyboardVisDlg::OnDestroy() { - NOTIFYICONDATA Tray; + NOTIFYICONDATA Tray; - Tray.cbSize = sizeof(Tray); - Tray.hIcon = LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_ICON)); - Tray.hWnd = GetSafeHwnd(); - strcpy(Tray.szTip, "Keyboard Visualizer"); - Tray.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE; - Tray.uID = ID_SYSTEMTRAY; - Tray.uCallbackMessage = WM_TRAYICON_EVENT; + Tray.cbSize = sizeof(Tray); + Tray.hIcon = LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_ICON)); + Tray.hWnd = GetSafeHwnd(); + strcpy(Tray.szTip, "Keyboard Visualizer"); + Tray.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE; + Tray.uID = ID_SYSTEMTRAY; + Tray.uCallbackMessage = WM_TRAYICON_EVENT; - Shell_NotifyIcon(NIM_DELETE, &Tray); + Shell_NotifyIcon(NIM_DELETE, &Tray); } -void KeyboardVisDlg::OnTimer(UINT nIDEvent) +void KeyboardVisDlg::OnTimer(UINT nIDEvent) { - if (startminimized && firstrun) - { - firstrun = FALSE; - ShowWindow(SW_HIDE); - } - - COLORREF pixels_bgr[64][256]; - - //CreateBitmap uses BGR color layout, convert from RGB - for (int x = 0; x < 256; x++) - { - for (int y = 0; y < 64; y++) - { - pixels_bgr[y][x] = RGB2BGR(vis->pixels[y][x]); - } - } + if (startminimized && firstrun) { + firstrun = FALSE; + ShowWindow(SW_HIDE); + } + + COLORREF pixels_bgr[64][256]; + + //CreateBitmap uses BGR color layout, convert from RGB + for (int x = 0; x < 256; x++) { + for (int y = 0; y < 64; y++) { + pixels_bgr[y][x] = RGB2BGR(vis->pixels[y][x]); + } + } HBITMAP hBitmap = CreateBitmap(256, 64, 1, 32, pixels_bgr); ((CStatic *)GetDlgItem(IDC_IMAGE_VISUALIZATION))->SetBitmap(hBitmap); DeleteObject(hBitmap); } -LRESULT KeyboardVisDlg::OnTrayIconEvent(WPARAM wParam, LPARAM lParam) +LRESULT KeyboardVisDlg::OnTrayIconEvent(WPARAM wParam, LPARAM lParam) { - if ((UINT)wParam != ID_SYSTEMTRAY) - return ERROR_SUCCESS; - - switch ((UINT)lParam) - { - case WM_LBUTTONUP: - { - if (IsWindowVisible()) - { - KillTimer(timer); - ShowWindow(SW_HIDE); - } - else - { - ShowWindow(SW_SHOW); - timer = SetTimer(1, 25, NULL); - } - break; - } - } - - return ERROR_SUCCESS; + if ((UINT)wParam != ID_SYSTEMTRAY) + return ERROR_SUCCESS; + + switch ((UINT)lParam) { + case WM_LBUTTONUP: + { + if (IsWindowVisible()) { + KillTimer(timer); + ShowWindow(SW_HIDE); + } else { + ShowWindow(SW_SHOW); + timer = SetTimer(1, 25, NULL); + } + break; + } + } + + return ERROR_SUCCESS; } BEGIN_MESSAGE_MAP(KeyboardVisDlg, CDialogEx) @@ -219,82 +228,149 @@ BEGIN_MESSAGE_MAP(KeyboardVisDlg, CDialogEx) ON_WM_DESTROY() ON_MESSAGE(WM_TRAYICON_EVENT, OnTrayIconEvent) ON_CBN_SELCHANGE(IDC_COMBO_AVG_MODE, &KeyboardVisDlg::OnCbnSelchangeComboAvgMode) - ON_CBN_SELCHANGE(IDC_COMBO_SNGL_CLR_MODE, &KeyboardVisDlg::OnCbnSelchangeComboSnglClrMode) + ON_CBN_SELCHANGE(IDC_COMBO_SNGL_CLR_MODE, &KeyboardVisDlg::OnCbnSelchangeComboSnglClrMode) + ON_CBN_SELCHANGE(IDC_COMBO_FRFLY_MODE, &KeyboardVisDlg::OnCbnSelchangeComboFireflyMode) + ON_CBN_SELCHANGE(IDC_COMBO_BLCKWD_MODE, &KeyboardVisDlg::OnCbnSelchangeComboBlackwidowMode) ON_EN_CHANGE(IDC_EDIT_NRML_OFST, &KeyboardVisDlg::OnEnChangedEditNrmlOfst) ON_EN_CHANGE(IDC_EDIT_NRML_SCL, &KeyboardVisDlg::OnEnChangedEditNrmlScl) + ON_EN_CHANGE(IDC_EDIT_LEDPOS, &KeyboardVisDlg::OnEnChangeEditLEDPos) + ON_BN_CLICKED(IDC_SAVE_BTN, &KeyboardVisDlg::OnBnSaveClicked) END_MESSAGE_MAP() -void KeyboardVisDlg::OnEnChangeEditAmplitude() +void KeyboardVisDlg::OnEnChangeEditAmplitude() { - vis->amplitude = GetDlgItemInt(IDC_EDIT_AMPLITUDE, 0, 0); + int selected = GetDlgItemInt(IDC_EDIT_AMPLITUDE, 0, 0); + vis->amplitude = selected; + vis->appsettings.amplitude = selected; } -void KeyboardVisDlg::OnEnChangeEditBackgroundBrightness() +void KeyboardVisDlg::OnEnChangeEditBackgroundBrightness() { - vis->bkgd_bright = (int)((GetDlgItemInt(IDC_EDIT_BACKGROUND_BRIGHTNESS, 0, 0) / 100.0f) * 255.0f); + int selected = (int)((GetDlgItemInt(IDC_EDIT_BACKGROUND_BRIGHTNESS, 0, 0) / 100.0f) * 255.0f); + vis->bkgd_bright = selected; + vis->appsettings.bkgd_bright = selected; } -void KeyboardVisDlg::OnCbnSelchangeComboWindow() +void KeyboardVisDlg::OnCbnSelchangeComboWindow() { - vis->window_mode = ((CComboBox*)GetDlgItem(IDC_COMBO_WINDOW))->GetCurSel(); + int selected = ((CComboBox*)GetDlgItem(IDC_COMBO_WINDOW))->GetCurSel(); + vis->window_mode = selected; + vis->appsettings.window_mode = selected; } -void KeyboardVisDlg::OnEnChangeEditAverageSize() +void KeyboardVisDlg::OnEnChangeEditAverageSize() { - vis->avg_size = (int)GetDlgItemInt(IDC_EDIT_AVERAGE_SIZE, 0, 0); + int selected = (int)GetDlgItemInt(IDC_EDIT_AVERAGE_SIZE, 0, 0); + vis->avg_size = selected; + vis->appsettings.avg_size = selected; } -void KeyboardVisDlg::OnCbnSelchangeComboBkgdMode() +void KeyboardVisDlg::OnCbnSelchangeComboBkgdMode() { - vis->bkgd_mode = ((CComboBox*)GetDlgItem(IDC_COMBO_BKGD_MODE))->GetCurSel(); + int selected = ((CComboBox*)GetDlgItem(IDC_COMBO_BKGD_MODE))->GetCurSel(); + vis->bkgd_mode = selected; + vis->appsettings.bkgd_mode = selected; } -void KeyboardVisDlg::OnEnChangeEditDecay() +void KeyboardVisDlg::OnEnChangeEditDecay() { - vis->decay = (int)GetDlgItemInt(IDC_EDIT_DECAY, 0, 0); + int selected = (int)GetDlgItemInt(IDC_EDIT_DECAY, 0, 0); + vis->decay = selected; + vis->appsettings.decay = selected; } -void KeyboardVisDlg::OnEnChangeEditDelay() +void KeyboardVisDlg::OnEnChangeEditDelay() { - vis->delay = (int)GetDlgItemInt(IDC_EDIT_DELAY, 0, 0); + int selected = (int)GetDlgItemInt(IDC_EDIT_DELAY, 0, 0); + vis->delay = selected; + vis->appsettings.delay = selected; } -void KeyboardVisDlg::OnCbnSelchangeComboFrgdMode() +void KeyboardVisDlg::OnCbnSelchangeComboFrgdMode() { - vis->frgd_mode = ((CComboBox*)GetDlgItem(IDC_COMBO_FRGD_MODE))->GetCurSel(); + int selected = ((CComboBox*)GetDlgItem(IDC_COMBO_FRGD_MODE))->GetCurSel(); + vis->frgd_mode = selected; + vis->appsettings.frgd_mode = selected; } -void KeyboardVisDlg::OnCbnSelchangeComboAvgMode() +void KeyboardVisDlg::OnCbnSelchangeComboAvgMode() { - vis->avg_mode = ((CComboBox*)GetDlgItem(IDC_COMBO_AVG_MODE))->GetCurSel(); + int selected = ((CComboBox*)GetDlgItem(IDC_COMBO_AVG_MODE))->GetCurSel(); + vis->avg_mode = selected; + vis->appsettings.avg_mode = selected; } -void KeyboardVisDlg::OnCbnSelchangeComboSnglClrMode() +void KeyboardVisDlg::OnCbnSelchangeComboFireflyMode() +{ + int selected = ((CComboBox*)GetDlgItem(IDC_COMBO_FRFLY_MODE))->GetCurSel(); + vis->fireflymode = selected; + vis->appsettings.fireflymode = selected; + vis->rkb.updatedSettings(&vis->appsettings); +} + + +void KeyboardVisDlg::OnCbnSelchangeComboBlackwidowMode() +{ + int selected = ((CComboBox*)GetDlgItem(IDC_COMBO_BLCKWD_MODE))->GetCurSel(); + vis->blkwdwmode = selected; + vis->appsettings.blkwdwmode = selected; + vis->rkb.updatedSettings(&vis->appsettings); +} + + +void KeyboardVisDlg::OnCbnSelchangeComboSnglClrMode() +{ + int selected = ((CComboBox*)GetDlgItem(IDC_COMBO_SNGL_CLR_MODE))->GetCurSel(); + vis->single_color_mode = selected; + vis->appsettings.single_color_mode = selected; +} + +void KeyboardVisDlg::OnEnChangedEditNrmlOfst() +{ + char val[64]; + GetDlgItemText(IDC_EDIT_NRML_OFST, (LPTSTR)&val, 64); + vis->nrml_ofst = strtod(val, NULL); + vis->appsettings.nrml_ofst = strtod(val, NULL); + vis->SetNormalization(vis->nrml_ofst, vis->nrml_scl); +} + +void KeyboardVisDlg::OnEnChangedEditNrmlScl() { - vis->single_color_mode = ((CComboBox*)GetDlgItem(IDC_COMBO_SNGL_CLR_MODE))->GetCurSel(); + char val[64]; + GetDlgItemText(IDC_EDIT_NRML_SCL, (LPTSTR)&val, 64); + vis->nrml_scl = strtod(val, NULL); + vis->appsettings.nrml_scl = strtod(val, NULL); + vis->SetNormalization(vis->nrml_ofst, vis->nrml_scl); } -void KeyboardVisDlg::OnEnChangedEditNrmlOfst() +void KeyboardVisDlg::OnEnChangeEditLEDPos() { - char val[64]; - GetDlgItemText(IDC_EDIT_NRML_OFST, (LPTSTR)&val, 64); - vis->nrml_ofst = strtod(val, NULL); - vis->SetNormalization(vis->nrml_ofst, vis->nrml_scl); + bool changed = false; + int temp = (int)GetDlgItemInt(IDC_EDIT_LEDPOS, 0, 0); + if (temp > 255) { + temp = 255; + changed = true; + } else if (temp < 0) { + temp = 0; + changed = true; + } + + if (changed) + SetDlgItemInt(IDC_EDIT_LEDPOS, temp, 0); + vis->ldstrp_pos = temp; + vis->appsettings.ldstrp_pos = temp; } -void KeyboardVisDlg::OnEnChangedEditNrmlScl() +void KeyboardVisDlg::OnBnSaveClicked() { - char val[64]; - GetDlgItemText(IDC_EDIT_NRML_SCL, (LPTSTR)&val, 64); - vis->nrml_scl = strtod(val, NULL); - vis->SetNormalization(vis->nrml_ofst, vis->nrml_scl); + vis->saveAppSettings(); } \ No newline at end of file diff --git a/KeyboardVisualizerVC/KeyboardVisDlg.h b/KeyboardVisualizerVC/KeyboardVisDlg.h index 3ed0e75..38f6450 100644 --- a/KeyboardVisualizerVC/KeyboardVisDlg.h +++ b/KeyboardVisualizerVC/KeyboardVisDlg.h @@ -41,9 +41,13 @@ class KeyboardVisDlg : public CDialogEx afx_msg void OnCbnSelchangeComboBkgdMode(); afx_msg void OnEnChangeEditDecay(); afx_msg void OnEnChangeEditDelay(); - afx_msg void OnCbnSelchangeComboFrgdMode(); - afx_msg void OnCbnSelchangeComboAvgMode(); - afx_msg void OnCbnSelchangeComboSnglClrMode(); - afx_msg void OnEnChangedEditNrmlOfst(); - afx_msg void OnEnChangedEditNrmlScl(); + afx_msg void OnCbnSelchangeComboFrgdMode(); + afx_msg void OnCbnSelchangeComboAvgMode(); + afx_msg void OnCbnSelchangeComboSnglClrMode(); + afx_msg void OnEnChangedEditNrmlOfst(); + afx_msg void OnEnChangedEditNrmlScl(); + afx_msg void OnBnSaveClicked(); + afx_msg void OnEnChangeEditLEDPos(); + afx_msg void OnCbnSelchangeComboFireflyMode(); + afx_msg void OnCbnSelchangeComboBlackwidowMode(); }; diff --git a/KeyboardVisualizerVC/KeyboardVisualizerVC.vcxproj b/KeyboardVisualizerVC/KeyboardVisualizerVC.vcxproj index 4f345ca..ef5e8de 100644 --- a/KeyboardVisualizerVC/KeyboardVisualizerVC.vcxproj +++ b/KeyboardVisualizerVC/KeyboardVisualizerVC.vcxproj @@ -172,6 +172,7 @@ + @@ -184,6 +185,7 @@ + diff --git a/KeyboardVisualizerVC/RazerChroma.cpp b/KeyboardVisualizerVC/RazerChroma.cpp index a2bbe52..b6a6dfd 100644 --- a/KeyboardVisualizerVC/RazerChroma.cpp +++ b/KeyboardVisualizerVC/RazerChroma.cpp @@ -1,7 +1,10 @@ #include "RazerChroma.h" - +#include "Visualizer.h" #include +//Settings +AppSettings appset; + //Index lists for BlackWidow int BlackWidowXIndex[22]; int BlackWidowYIndex[6]; @@ -33,7 +36,6 @@ RazerChroma::RazerChroma() { } - RazerChroma::~RazerChroma() { if (hModule) @@ -46,6 +48,10 @@ RazerChroma::~RazerChroma() } } +void RazerChroma::updatedSettings(AppSettings *settings) { + appset = *settings; +} + void RazerChroma::Initialize() { @@ -200,16 +206,67 @@ bool RazerChroma::SetLEDs(COLORREF pixels[64][256]) //Blackwidow Chroma ChromaSDK::Keyboard::CUSTOM_EFFECT_TYPE BlackWidowEffect; - for (int x = 0; x < 22; x++) - { - for (int y = 0; y < 6; y++) - { - BlackWidowEffect.Color[y][x] = (pixels[BlackWidowYIndex[y]][BlackWidowXIndex[x]] & 0x00FFFFFF); - } - } - - //Set Razer "Three Headed Snake" logo to the background color of the 11th column - BlackWidowEffect.Color[0][20] = pixels[3][11 * (256 / 22)]; + switch (appset.blkwdwmode) { + case 0: + // Normal visualizer mode + for (int x = 0; x < 22; x++) { + for (int y = 0; y < 6; y++) { + BlackWidowEffect.Color[y][x] = (pixels[BlackWidowYIndex[y]][BlackWidowXIndex[x]] & 0x00FFFFFF); + } + } + + //Set Razer "Three Headed Snake" logo to the background color of the 11th column + BlackWidowEffect.Color[0][20] = pixels[3][11 * (256 / 22)]; + break; + case 1: + // Single color mode + for (int x = 0; x < 22; x++) { + for (int y = 0; y < 6; y++) { + BlackWidowEffect.Color[y][x] = (pixels[3][0] & 0x00FFFFFF); + } + } + BlackWidowEffect.Color[0][20] = pixels[3][0]; + break; + case 2: + // Bottom Up color mode + for (int x = 0; x < 22; x++) { + for (int y = 0; y < 6; y++) { + BlackWidowEffect.Color[y][x] = (pixels[0][FireflyIndex[y]] & 0x00FFFFFF); + } + } + BlackWidowEffect.Color[0][20] = pixels[3][0]; + break; + case 3: + // Upper Bottom color mode + for (int x = 0; x < 22; x++) { + for (int y = 0; y < 6; y++) { + BlackWidowEffect.Color[y][x] = (pixels[0][FireflyIndex[y + 9]] & 0x00FFFFFF); + } + } + BlackWidowEffect.Color[0][20] = pixels[3][0]; + break; + case 4: + // Mid to side color mode + for (int x = 0; x < 22; x++) { + for (int y = 0; y < 6; y++) { + BlackWidowEffect.Color[y][x] = (pixels[0][BlackWidowXIndex[x + 1]] & 0x00FFFFFF); + } + } + BlackWidowEffect.Color[0][20] = pixels[3][0]; + break; + case 5: + // Side to mid color mode + for (int x = 0; x < 22; x++) { + for (int y = 0; y < 6; y++) { + if (x <= 11) + BlackWidowEffect.Color[y][x] = (pixels[0][BlackWidowXIndex[x + 1 + 11]] & 0x00FFFFFF); + else if (x > 11) + BlackWidowEffect.Color[y][x] = (pixels[0][BlackWidowXIndex[x + 2 - 11]] & 0x00FFFFFF); + } + } + BlackWidowEffect.Color[0][20] = pixels[3][0]; + break; + } CreateEffect(ChromaSDK::BLACKWIDOW_CHROMA, ChromaSDK::CHROMA_CUSTOM, &BlackWidowEffect, NULL); @@ -251,10 +308,29 @@ bool RazerChroma::SetLEDs(COLORREF pixels[64][256]) //Firefly Chroma ChromaSDK::Mousepad::CUSTOM_EFFECT_TYPE FireflyEffect = {}; - for (int x = 0; x < 15; x++) - { - FireflyEffect.Color[x] = pixels[0][FireflyIndex[x]]; - } + switch (appset.fireflymode) { + case 0: + // Normal bottom-up led strip mode + for (int x = 0; x < 15; x++) + FireflyEffect.Color[x] = pixels[0][FireflyIndex[x]]; + break; + case 1: + // Normal upper-bottom led strip mode + for (int x = 0; x < 15; x++) { + if (x == 7) + FireflyEffect.Color[x] = pixels[0][20]; + else if (x < 7) + FireflyEffect.Color[x] = pixels[0][FireflyIndex[x + 8]]; + else + FireflyEffect.Color[x] = pixels[0][FireflyIndex[x - 8]]; + } + break; + case 2: + // Single color mode + for (int x = 0; x < 15; x++) + FireflyEffect.Color[x] = pixels[3][0]; + break; + } CreateEffect(ChromaSDK::FIREFLY_CHROMA, ChromaSDK::CHROMA_CUSTOM, &FireflyEffect, NULL); diff --git a/KeyboardVisualizerVC/RazerChroma.h b/KeyboardVisualizerVC/RazerChroma.h index 2ce5b17..ac954ce 100644 --- a/KeyboardVisualizerVC/RazerChroma.h +++ b/KeyboardVisualizerVC/RazerChroma.h @@ -5,6 +5,7 @@ #include "RzChromaSDKDefines.h" #include "RzChromaSDKTypes.h" #include "RzErrors.h" +#include "AppSettings.h" using namespace ChromaSDK::Keyboard; @@ -25,10 +26,12 @@ class RazerChroma { public: RazerChroma(); + RazerChroma(AppSettings*); ~RazerChroma(); void Initialize(); bool SetLEDs(COLORREF pixels[64][256]); + void updatedSettings(AppSettings*); private: HMODULE hModule = NULL; diff --git a/KeyboardVisualizerVC/Resource.aps b/KeyboardVisualizerVC/Resource.aps new file mode 100644 index 0000000000000000000000000000000000000000..940148b94450dd710aad37b1e0a6687dabd9d86d GIT binary patch literal 27528 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 @@ -12,12 +8,6 @@ #include #include -RazerChroma rkb; -CorsairKeyboard ckb; -MSIKeyboard mkb; -std::vector str; -std::vector xmas; - //WASAPI objects IMMDeviceEnumerator *pMMDeviceEnumerator; IMMDevice *pMMDevice; @@ -91,33 +81,49 @@ void Visualizer::Initialize() pAudioClient->GetService(__uuidof(IAudioCaptureClient), (void**)&pAudioCaptureClient); pAudioClient->Start(); + + initializeAppSettings(); - rkb.Initialize(); + rkb.Initialize(); ckb.Initialize(); mkb.Initialize(); - amplitude = 100; - avg_mode = 0; - avg_size = 8; - bkgd_step = 0; - bkgd_bright = 10; - bkgd_mode = 0; - delay = 50; - window_mode = 1; - decay = 80; - frgd_mode = 8; - single_color_mode = 1; + //Passing settings + rkb.updatedSettings(&appsettings); hanning(win_hanning, 256); hamming(win_hamming, 256); blackman(win_blackman, 256); - nrml_ofst = 0.04f; - nrml_scl = 0.5f; - SetNormalization(nrml_ofst, nrml_scl); } +void Visualizer::saveAppSettings() { + appsettings.saveSettings(); +} + +void Visualizer::initializeAppSettings() { + appsettings.loadSettings(); + + rememberSettingsOnExit = appsettings.rememberSettingsOnExit; + amplitude = appsettings.amplitude; + avg_mode = appsettings.avg_mode; + avg_size = appsettings.avg_size; + bkgd_step = appsettings.bkgd_step; + bkgd_bright = appsettings.bkgd_bright; + bkgd_mode = appsettings.bkgd_mode; + delay = appsettings.delay; + window_mode = appsettings.window_mode; + decay = appsettings.decay; + frgd_mode = appsettings.frgd_mode; + single_color_mode = appsettings.single_color_mode; + ldstrp_pos = appsettings.ldstrp_pos; + fireflymode = appsettings.fireflymode; + blkwdwmode = appsettings.blkwdwmode; + nrml_ofst = appsettings.nrml_ofst; + nrml_scl = appsettings.nrml_scl; +} + void Visualizer::SetNormalization(float offset, float scale) { for (int i = 0; i < 256; i++) @@ -655,18 +661,19 @@ void Visualizer::VisThread() } } + //Draw LED Strip if (y < 2) { if (x < 128) { - if ((fft[5] - 0.05f) >((1 / 128.0f)*(127-x))) + if ((fft[ldstrp_pos] - 0.05f) >((1 / 128.0f)*(127-x))) { pixels[y][x] = GetAmplitudeColor(x, 128, 255); } } else { - if ((fft[5] - 0.05f) >((1 / 128.0f)*((x-128)))) + if ((fft[ldstrp_pos] - 0.05f) >((1 / 128.0f)*((x-128)))) { pixels[y][x] = GetAmplitudeColor(127-(x-128), 128, 255); } @@ -676,7 +683,7 @@ void Visualizer::VisThread() //Draw brightness based visualizer for single LED devices if (y == 3) { - float brightness = fft[5] * 255; + float brightness = fft[ldstrp_pos] * 255; switch (single_color_mode) { //None @@ -737,6 +744,8 @@ void Visualizer::VisThread() } } + drawLEDStripLine(); + //Increment background step bkgd_step++; @@ -744,6 +753,12 @@ void Visualizer::VisThread() } } +void Visualizer::drawLEDStripLine() { + for (int y = 3; y < 64; y++) { + pixels[y][ldstrp_pos] = RGB(255, 0, 0); + } +} + void Visualizer::RazerChromaUpdateThread() { while (rkb.SetLEDs(pixels)) diff --git a/KeyboardVisualizerVC/Visualizer.h b/KeyboardVisualizerVC/Visualizer.h index 63f41d5..9d40b2c 100644 --- a/KeyboardVisualizerVC/Visualizer.h +++ b/KeyboardVisualizerVC/Visualizer.h @@ -4,6 +4,11 @@ #include #include "chuck_fft.h" #include "hsv.h" +#include "AppSettings.h" +#include "RazerChroma.h" +#include "CorsairKeyboard.h" +#include "LEDStrip.h" +#include "MSIKeyboard.h" #include #include @@ -22,6 +27,13 @@ class Visualizer //Visualizer Thread void VisThread(); + //for visibility + RazerChroma rkb; + CorsairKeyboard ckb; + MSIKeyboard mkb; + std::vector str; + std::vector xmas; + //Keyboard Update Thread void RazerChromaUpdateThread(); void CorsairKeyboardUpdateThread(); @@ -41,6 +53,11 @@ class Visualizer //Compute normalization line void SetNormalization(float offset, float scale); + //Visualizer settings + AppSettings appsettings; + void initializeAppSettings(); + void saveAppSettings(); + //Calculated FFT float fft[256]; @@ -69,6 +86,17 @@ class Visualizer //Foreground Variables int frgd_mode; + //Settings + bool rememberSettingsOnExit; + + //LED Strip offset position and indicator fucntion + int ldstrp_pos; + void drawLEDStripLine(); + + //Device specific display mode + int fireflymode; + int blkwdwmode; + private: //Background Step int bkgd_step; diff --git a/KeyboardVisualizerVC/resource.h b/KeyboardVisualizerVC/resource.h index fc46d521c39d68f3e2f1c8947c158494d79ccb61..0190c9ab8547060d436239097a2fe58f20841634 100644 GIT binary patch delta 140 zcmdlY+90_hfMc>6r@-U}R-wtu*n}oeVwIVEfR$~s6SD@l4}&X%3qt^dKSS{3Kt^>& z!^w`!^8CRJjtpTynRo^#h7bn7$qN}Z!8$H6%1w4)r|WCJ%yj}L=0gEvF? Date: Fri, 20 Jan 2017 02:42:23 +0400 Subject: [PATCH 3/3] added new modes to readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fcf4ef2..8c187a0 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ https://drive.google.com/folderview?id=0B1Fq0HEJolPtWDNsNV93NVl5Vms&usp=sharing * Razer Chroma Keyboards - - BlackWidow Chroma (spectrograph) + - BlackWidow Chroma (spectrograph, single color, bar, reverse bar, mid-to-side bar, side-to-mid bar) - BlackWidow Chroma Tournament Edition (spectrograph) - DeathStalker Chroma (horizontal bar) @@ -31,7 +31,7 @@ https://drive.google.com/folderview?id=0B1Fq0HEJolPtWDNsNV93NVl5Vms&usp=sharing - Kraken 7.1 Chroma (single color) Mouse Mats - - Firefly (bar) + - Firefly (single color, bar, reverse bar) * Corsair RGB