mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-07-29 06:26:15 -04:00
Get active effect and active settings during Valve Steam Machine initialization
This commit is contained in:
@@ -46,6 +46,14 @@ RGBController_ValveSteamMachine::RGBController_ValveSteamMachine(ValveSteamMachi
|
||||
unsigned int effect_flags;
|
||||
std::string effect_name = effects[effect_idx];
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Set active_mode if this effect is active |
|
||||
\*-------------------------------------------------*/
|
||||
if(effect_name == controller->GetEffect())
|
||||
{
|
||||
active_mode = effect_idx;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Determine flags and color mode for effect |
|
||||
\*-------------------------------------------------*/
|
||||
@@ -93,10 +101,10 @@ RGBController_ValveSteamMachine::RGBController_ValveSteamMachine(ValveSteamMachi
|
||||
new_mode.color_mode = effect_color_mode;
|
||||
new_mode.speed_min = 20;
|
||||
new_mode.speed_max = 0;
|
||||
new_mode.speed = 10;
|
||||
new_mode.speed = controller->GetDelay();
|
||||
new_mode.brightness_min = 0;
|
||||
new_mode.brightness_max = 0xFF;
|
||||
new_mode.brightness = 0x38;
|
||||
new_mode.brightness = controller->GetBrightness();
|
||||
modes.push_back(new_mode);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
#include "ValveSteamMachineController_Linux.h"
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
|
||||
ValveSteamMachineController::ValveSteamMachineController(std::string dev_name)
|
||||
@@ -116,6 +115,65 @@ std::vector<std::string> ValveSteamMachineController::GetAvailableEffects()
|
||||
return(available_effects);
|
||||
}
|
||||
|
||||
unsigned int ValveSteamMachineController::GetBrightness()
|
||||
{
|
||||
if(led_brightness_scale.is_open())
|
||||
{
|
||||
std::ifstream brightness_file(led_paths[0] + "brightness_scale");
|
||||
|
||||
if(brightness_file.good())
|
||||
{
|
||||
unsigned int brightness = 0;
|
||||
brightness_file >> std::hex >> brightness;
|
||||
brightness_file.close();
|
||||
return(brightness);
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
unsigned int ValveSteamMachineController::GetDelay()
|
||||
{
|
||||
if(led_delay.is_open())
|
||||
{
|
||||
std::ifstream delay_file(led_paths[0] + "delay");
|
||||
|
||||
if(delay_file.good())
|
||||
{
|
||||
unsigned int delay = 0;
|
||||
delay_file >> std::hex >> delay;
|
||||
delay_file.close();
|
||||
return(delay);
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
std::string ValveSteamMachineController::GetEffect()
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Reading the effect on one LED reflects the active |
|
||||
| effect for all LEDs on the device, so we only need to |
|
||||
| read it from the first LED. |
|
||||
\*-----------------------------------------------------*/
|
||||
if(led_effect.size() > 0)
|
||||
{
|
||||
std::ifstream effect_file(led_paths[0] + "effect");
|
||||
|
||||
if(effect_file.good())
|
||||
{
|
||||
std::string effect;
|
||||
std::getline(effect_file, effect);
|
||||
effect_file.close();
|
||||
return(effect);
|
||||
}
|
||||
}
|
||||
|
||||
return("");
|
||||
}
|
||||
|
||||
void ValveSteamMachineController::ReadAvailableEffects(std::string first_led_path)
|
||||
{
|
||||
std::ifstream effect_index_file(first_led_path + "effect_index");
|
||||
@@ -132,20 +190,9 @@ void ValveSteamMachineController::ReadAvailableEffects(std::string first_led_pat
|
||||
| read, and is used to set the active effect when |
|
||||
| written. |
|
||||
\*-----------------------------------------------------*/
|
||||
std::string content;
|
||||
std::string line;
|
||||
|
||||
while(std::getline(effect_index_file, line))
|
||||
{
|
||||
content += line + " ";
|
||||
}
|
||||
|
||||
effect_index_file.close();
|
||||
|
||||
std::istringstream stream(content);
|
||||
std::string token;
|
||||
|
||||
while(stream >> token)
|
||||
while(effect_index_file >> token)
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Add to list if not already present |
|
||||
@@ -176,22 +223,6 @@ void ValveSteamMachineController::SetLEDColor(unsigned int led_idx, unsigned cha
|
||||
led_multi_intensity[led_idx].flush();
|
||||
}
|
||||
|
||||
void ValveSteamMachineController::SetLEDEffect(unsigned int led_idx, std::string effect)
|
||||
{
|
||||
if(led_idx >= led_paths.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(led_effect.size() <= led_idx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
led_effect[led_idx].write(effect.c_str(), effect.length());
|
||||
led_effect[led_idx].flush();
|
||||
}
|
||||
|
||||
void ValveSteamMachineController::SetEffect(std::string effect)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
@@ -224,4 +255,4 @@ void ValveSteamMachineController::SetDelay(unsigned int delay)
|
||||
led_delay.write(delay_str.c_str(), delay_str.length());
|
||||
led_delay.flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,16 +29,20 @@ public:
|
||||
std::string GetLEDPath(unsigned int led_idx);
|
||||
|
||||
std::vector<std::string> GetAvailableEffects();
|
||||
unsigned int GetBrightness();
|
||||
unsigned int GetDelay();
|
||||
std::string GetEffect();
|
||||
|
||||
bool SupportsEffects();
|
||||
|
||||
void SetLEDColor(unsigned int led_idx, unsigned char red, unsigned char grn, unsigned char blu);
|
||||
void SetLEDEffect(unsigned int led_idx, std::string effect);
|
||||
void SetEffect(std::string effect);
|
||||
void SetBrightness(unsigned int brightness);
|
||||
void SetDelay(unsigned int delay);
|
||||
|
||||
private:
|
||||
std::string name;
|
||||
|
||||
std::vector<std::string> led_paths;
|
||||
std::vector<std::ofstream> led_brightness;
|
||||
std::vector<std::ofstream> led_multi_intensity;
|
||||
|
||||
Reference in New Issue
Block a user