diff --git a/src/InputManager.cpp b/src/InputManager.cpp index 20e8a17e1..f64d07cc5 100644 --- a/src/InputManager.cpp +++ b/src/InputManager.cpp @@ -262,6 +262,9 @@ void InputManager::loadDefaultConfig() cfg->mapInput("select", Input(DEVICE_KEYBOARD, TYPE_KEY, SDLK_F2, 1, true)); cfg->mapInput("pageup", Input(DEVICE_KEYBOARD, TYPE_KEY, SDLK_RIGHTBRACKET, 1, true)); cfg->mapInput("pagedown", Input(DEVICE_KEYBOARD, TYPE_KEY, SDLK_LEFTBRACKET, 1, true)); + + cfg->mapInput("mastervolup", Input(DEVICE_KEYBOARD, TYPE_KEY, SDLK_PLUS, 1, true)); + cfg->mapInput("mastervoldown", Input(DEVICE_KEYBOARD, TYPE_KEY, SDLK_MINUS, 1, true)); } void InputManager::writeConfig() diff --git a/src/VolumeControl.cpp b/src/VolumeControl.cpp index 711a97d3b..5e60f254e 100644 --- a/src/VolumeControl.cpp +++ b/src/VolumeControl.cpp @@ -24,7 +24,7 @@ VolumeControl::VolumeControl() init(); //get original volume levels for system - getVolume(originalVolume); + originalVolume = getVolume(); } VolumeControl::~VolumeControl() @@ -212,9 +212,9 @@ void VolumeControl::deinit() #endif } -void VolumeControl::getVolume(uint8_t & volume) +int VolumeControl::getVolume() const { - volume = 0; + int volume = 0; #if defined (__APPLE__) #error TODO: Not implemented for MacOS yet!!! @@ -235,11 +235,6 @@ void VolumeControl::getVolume(uint8_t & volume) if (rawVolume > 0) { volume = (rawVolume * 100) / (maxVolume - minVolume); - //clamp to 0-100 range - if (volume > 100) - { - volume = 100; - } } //else volume = 0; } @@ -289,11 +284,25 @@ void VolumeControl::getVolume(uint8_t & volume) } #endif + //clamp to 0-100 range + if (volume < 0) + { + volume = 0; + } + if (volume > 100) + { + volume = 100; + } + return volume; } -void VolumeControl::setVolume(uint8_t volume) +void VolumeControl::setVolume(int volume) { //clamp to 0-100 range + if (volume < 0) + { + volume = 0; + } if (volume > 100) { volume = 100; diff --git a/src/VolumeControl.h b/src/VolumeControl.h index 08b9ac7d0..abfa4a556 100644 --- a/src/VolumeControl.h +++ b/src/VolumeControl.h @@ -36,8 +36,8 @@ class VolumeControl IAudioEndpointVolume * endpointVolume; #endif - uint8_t originalVolume; - uint8_t internalVolume; + int originalVolume; + int internalVolume; static std::shared_ptr sInstance; @@ -49,8 +49,8 @@ public: void init(); void deinit(); - void getVolume(uint8_t & volume); - void setVolume(uint8_t volume); + int getVolume() const; + void setVolume(int volume); virtual ~VolumeControl(); }; diff --git a/src/Window.cpp b/src/Window.cpp index 119ac9c5f..81ce134de 100644 --- a/src/Window.cpp +++ b/src/Window.cpp @@ -2,6 +2,7 @@ #include #include "Renderer.h" #include "AudioManager.h" +#include "VolumeControl.h" Window::Window() { @@ -73,7 +74,15 @@ void Window::deinit() void Window::input(InputConfig* config, Input input) { - if(peekGui()) + if(config->isMappedTo("mastervolup", input)) + { + VolumeControl::getInstance()->setVolume(VolumeControl::getInstance()->getVolume() + 5); + } + else if(config->isMappedTo("mastervoldown", input)) + { + VolumeControl::getInstance()->setVolume(VolumeControl::getInstance()->getVolume() - 5); + } + else if(peekGui()) this->peekGui()->input(config, input); } diff --git a/src/components/GuiInputConfig.cpp b/src/components/GuiInputConfig.cpp index d315c6489..9817cfd5a 100644 --- a/src/components/GuiInputConfig.cpp +++ b/src/components/GuiInputConfig.cpp @@ -5,9 +5,9 @@ #include "GuiGameList.h" #include "../Log.h" -static int inputCount = 10; -static std::string inputName[10] = { "Up", "Down", "Left", "Right", "A", "B", "Menu", "Select", "PageUp", "PageDown" }; -static std::string inputDispName[10] = { "Up", "Down", "Left", "Right", "Accept", "Back", "Menu", "Jump to Letter", "Page Up", "Page Down" }; +static int inputCount = 12; +static std::string inputName[12] = { "Up", "Down", "Left", "Right", "A", "B", "Menu", "Select", "PageUp", "PageDown", "MasterVolUp", "MasterVolDown" }; +static std::string inputDispName[12] = { "Up", "Down", "Left", "Right", "Accept", "Back", "Menu", "Jump to Letter", "Page Up", "Page Down", "Master volume up", "Master volume down" }; GuiInputConfig::GuiInputConfig(Window* window, InputConfig* target) : Gui(window), mTargetConfig(target) {