Skip to content

Commit

Permalink
feat: add silent mode and remove check for creator mode
Browse files Browse the repository at this point in the history
Signed-off-by: Dimitar Atanasov <datanasov@cpdbg.com>
  • Loading branch information
phush0 committed Apr 28, 2024
1 parent f9aa514 commit 290c403
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
5 changes: 3 additions & 2 deletions razer_control_gui/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ enum WriteAttr {
struct PowerParams {
/// battery/plugged in
ac_state: AcState,
/// power mode (0, 1, 2 or 4)
/// power mode (0, 1, 2, 3 or 4)
pwr: u8,
/// cpu boost (0, 1, 2 or 3)
cpu_mode: Option<u8>,
Expand Down Expand Up @@ -569,6 +569,7 @@ fn read_power_mode(ac: usize) {
0 => "Balanced",
1 => "Gaming",
2 => "Creator",
3 => "Silent",
4 => "Custom",
_ => "Unknown",
};
Expand Down Expand Up @@ -607,7 +608,7 @@ fn read_power_mode(ac: usize) {
fn write_pwr_mode(ac: usize, pwr_mode: u8, cpu_mode: Option<u8>, gpu_mode: Option<u8>) {
if pwr_mode > 4 {
Cli::command()
.error(ErrorKind::InvalidValue, "Power mode must be 0, 1, 2 or 4")
.error(ErrorKind::InvalidValue, "Power mode must be 0, 1, 2, 3 or 4")
.exit()
}

Expand Down
9 changes: 3 additions & 6 deletions razer_control_gui/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -767,11 +767,8 @@ impl RazerLaptop {
return false;
}

pub fn set_power_mode(&mut self, mut mode: u8, cpu_boost: u8, gpu_boost: u8) -> bool {
if mode <= 2 {
if mode == 2 && self.have_feature("creator_mode".to_string()) == false {
mode = 1;
}
pub fn set_power_mode(&mut self, mode: u8, cpu_boost: u8, gpu_boost: u8) -> bool {
if mode <= 3 {
self.power = mode;
self.set_power(0x01);
self.set_power(0x02);
Expand Down Expand Up @@ -981,4 +978,4 @@ fn bho_to_byte(is_on: bool, threshold: u8) -> u8 {
return threshold | 0b1000_0000;
}
return threshold;
}
}

0 comments on commit 290c403

Please sign in to comment.