From 3db9189cbb894d998c803e4b649b3b29fb716782 Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Sun, 22 Mar 2020 01:01:01 -0500 Subject: [PATCH] Fix current device ID in CLI --- cli.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/cli.cpp b/cli.cpp index 8ff573e72..c9bb335eb 100644 --- a/cli.cpp +++ b/cli.cpp @@ -258,19 +258,19 @@ void OptionListDevices() } } -bool OptionDevice(int currentDev, std::string argument, Options *res) +bool OptionDevice(int *currentDev, std::string argument, Options *res) { try { - currentDev = std::stoi(argument); + *currentDev = std::stoi(argument); - if (rgb_controllers.size() <= currentDev || currentDev < 0) + if (rgb_controllers.size() <= *currentDev || *currentDev < 0) { throw; } DeviceOptions newDev; - newDev.device = currentDev; + newDev.device = *currentDev; if(!res->hasDevice) { @@ -288,9 +288,9 @@ bool OptionDevice(int currentDev, std::string argument, Options *res) } } -bool OptionColor(int currentDev, std::string argument, Options *res) +bool OptionColor(int *currentDev, std::string argument, Options *res) { - DeviceOptions* currentDevOpts = GetDeviceOptionsForDevID(res, currentDev); + DeviceOptions* currentDevOpts = GetDeviceOptionsForDevID(res, *currentDev); if(ParseColors(argument, currentDevOpts)) { @@ -303,15 +303,15 @@ bool OptionColor(int currentDev, std::string argument, Options *res) } } -bool OptionMode(int currentDev, std::string argument, Options *res) +bool OptionMode(int *currentDev, std::string argument, Options *res) { - DeviceOptions* currentDevOpts = GetDeviceOptionsForDevID(res, currentDev); + DeviceOptions* currentDevOpts = GetDeviceOptionsForDevID(res, *currentDev); currentDevOpts->mode = argument; currentDevOpts->hasOption = true; return true; } -bool OptionProfile(int currentDev, std::string argument, Options *res) +bool OptionProfile(std::string argument) { /*---------------------------------------------------------*\ | Attempt to load profile | @@ -343,7 +343,7 @@ bool OptionProfile(int currentDev, std::string argument, Options *res) } } -bool OptionSaveProfile(int currentDev, std::string argument, Options *res) +bool OptionSaveProfile(std::string argument) { /*---------------------------------------------------------*\ | Set save profile filename | @@ -385,7 +385,7 @@ bool ProcessOptions(int argc, char *argv[], Options *res) \*---------------------------------------------------------*/ else if(option == "--device" || option == "-d") { - if(!OptionDevice(currentDev, argument, res)) + if(!OptionDevice(¤tDev, argument, res)) { return false; } @@ -396,7 +396,7 @@ bool ProcessOptions(int argc, char *argv[], Options *res) \*---------------------------------------------------------*/ else if(option == "--color" || option == "-c") { - if(!OptionColor(currentDev, argument, res)) + if(!OptionColor(¤tDev, argument, res)) { return false; } @@ -407,7 +407,7 @@ bool ProcessOptions(int argc, char *argv[], Options *res) \*---------------------------------------------------------*/ else if(option == "--mode" || option == "-m") { - if(!OptionMode(currentDev, argument, res)) + if(!OptionMode(¤tDev, argument, res)) { return false; } @@ -418,7 +418,7 @@ bool ProcessOptions(int argc, char *argv[], Options *res) \*---------------------------------------------------------*/ else if(option == "--profile" || option == "-p") { - OptionProfile(currentDev, argument, res); + OptionProfile(argument); exit(0); } @@ -427,7 +427,7 @@ bool ProcessOptions(int argc, char *argv[], Options *res) \*---------------------------------------------------------*/ else if(option == "--save-profile" || option == "-sp") { - OptionSaveProfile(currentDev, argument, res); + OptionSaveProfile(argument); } /*---------------------------------------------------------*\