implemented untested fucntion for everything
This commit is contained in:
parent
85cb8d5728
commit
156c3e8475
1 changed files with 109 additions and 15 deletions
|
@ -1,6 +1,7 @@
|
||||||
|
use std::process::Command;
|
||||||
use super::stream_states::{state_update::StateUpdate, enums::{SlideChange, SubScenes, Scenes}};
|
use super::stream_states::{state_update::StateUpdate, enums::{SlideChange, SubScenes, Scenes}};
|
||||||
|
|
||||||
const AHK_FILES_FOLDER: &str = "./src/ahk_files";
|
const AHK_FILES_FOLDER: &str = "./src/ahk_files/";
|
||||||
pub const OPTIONS_PATH: &str = "./options.json";
|
pub const OPTIONS_PATH: &str = "./options.json";
|
||||||
|
|
||||||
pub fn create_keyboard_hooks(channel_tx: crossbeam_channel::Sender<String>) {
|
pub fn create_keyboard_hooks(channel_tx: crossbeam_channel::Sender<String>) {
|
||||||
|
@ -23,27 +24,120 @@ pub struct Hotkeys {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Hotkeys {
|
impl Hotkeys {
|
||||||
pub fn next_slide(&self, ) {
|
pub fn get_hotkey_from_scene(&self, scene: SubScenes) -> String {
|
||||||
todo!()
|
match scene {
|
||||||
|
SubScenes::CameraDefault => {self.hotkeys["hotkeys"]["obs"]["camera_scene_hotkey"].to_string()},
|
||||||
|
SubScenes::CameraWithUpperRight => {self.hotkeys["hotkeys"]["obs"]["Camera_Top_Right"].to_string()},
|
||||||
|
SubScenes::CameraWithLargeUpperRight => {self.hotkeys["hotkeys"]["obs"]["Camera_Large_Top_Right"].to_string()},
|
||||||
|
SubScenes::CameraWithLowerRight => {self.hotkeys["hotkeys"]["obs"]["Camera_Bottom_Right"].to_string()},
|
||||||
|
SubScenes::ScreenDefault => {self.hotkeys["hotkeys"]["obs"]["screen_scene_hotkey"].to_string()},
|
||||||
|
SubScenes::ScreenWithUpperRight => {self.hotkeys["hotkeys"]["obs"]["Screen_Top_Right"].to_string()},
|
||||||
|
SubScenes::ScreenWithLowerRight => {self.hotkeys["hotkeys"]["obs"]["Screen_Bottom_Right"].to_string()},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn send_obs(&self, hotkey: String) {
|
||||||
|
if cfg!(target_os = "windows") {
|
||||||
|
Command::new(String::from(AHK_FILES_FOLDER) + "send_obs_back_to_propre.exe")
|
||||||
|
.args([self.hotkeys["windows"]["propresenter_re"].to_string(),
|
||||||
|
self.hotkeys["windows"]["obs_re"].to_string(),
|
||||||
|
hotkey])
|
||||||
|
.spawn()
|
||||||
|
.expect("next_slide process call failed");
|
||||||
|
} else {
|
||||||
|
println!("pretend linux is sending obs send: {}", hotkey)
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn prev_slide(&self, ) {
|
pub fn next_slide(&self) {
|
||||||
todo!()
|
if cfg!(target_os = "windows") {
|
||||||
|
Command::new(String::from(AHK_FILES_FOLDER) + "switch_and_send.exe")
|
||||||
|
.args([self.hotkeys["windows"]["propresenter_re"].to_string(),
|
||||||
|
self.hotkeys["general"]["clicker_forward"].to_string()])
|
||||||
|
.spawn()
|
||||||
|
.expect("next_slide process call failed");
|
||||||
|
} else {
|
||||||
|
println!("pretend linux is sending prosenter next: {}", self.hotkeys["general"]["clicker_forward"].to_string())
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn toggle_stream_sound(&self, value: bool) {
|
pub fn prev_slide(&self) {
|
||||||
todo!()
|
if cfg!(target_os = "windows") {
|
||||||
|
Command::new(String::from(AHK_FILES_FOLDER) + "switch_and_send.exe")
|
||||||
|
.args([self.hotkeys["windows"]["propresenter_re"].to_string(),
|
||||||
|
self.hotkeys["general"]["clicker_backward"].to_string()])
|
||||||
|
.spawn()
|
||||||
|
.expect("next_slide process call failed");
|
||||||
|
} else {
|
||||||
|
println!("pretend linux is sending prosenter next: {}", self.hotkeys["general"]["clicker_backward"].to_string())
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn change_scene(&self, _scene: Scenes, sub_scene: Option<SubScenes>) {
|
||||||
|
let hotkey: String;
|
||||||
|
if sub_scene.is_none() {
|
||||||
|
hotkey = self.hotkeys["hotkeys"]["obs"]["camera_scene_augmented"].to_string()
|
||||||
|
} else {
|
||||||
|
hotkey = self.get_hotkey_from_scene(sub_scene.unwrap())
|
||||||
|
};
|
||||||
|
self.send_obs(hotkey);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn toggle_stream_sound(&self, turn_on: bool) {
|
||||||
|
let hotkey: String;
|
||||||
|
if turn_on {
|
||||||
|
hotkey = self.hotkeys["hotkeys"]["obs"]["unmute_stream"].to_string();
|
||||||
|
} else {
|
||||||
|
hotkey = self.hotkeys["hotkeys"]["obs"]["mute_stream"].to_string();
|
||||||
|
}
|
||||||
|
self.send_obs(hotkey);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn toggle_computer_sound(&self, value: bool) {
|
pub fn toggle_computer_sound(&self, value: bool) {
|
||||||
todo!()
|
let direction: u8 = if value {1} else {0};
|
||||||
|
let time_delay = self.hotkeys["general"]["music_fade_time"].as_i64().unwrap();
|
||||||
|
if cfg!(target_os = "windows") {
|
||||||
|
Command::new(String::from(AHK_FILES_FOLDER) + "music_toggle.exe")
|
||||||
|
.arg(direction.to_string())
|
||||||
|
.arg(time_delay.to_string())
|
||||||
|
.spawn()
|
||||||
|
.expect("next_slide process call failed");
|
||||||
|
} else {
|
||||||
|
println!("pretend linux is sending prosenter next: {}", self.hotkeys["general"]["clicker_backward"].to_string())
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn toggle_media_play_pause(&self, value: bool) {
|
pub fn toggle_media_play_pause(&self, _value: bool) {
|
||||||
todo!()
|
if cfg!(target_os = "windows") {
|
||||||
}
|
Command::new(String::from(AHK_FILES_FOLDER) + "music_toggle.exe")
|
||||||
|
.arg(self.hotkeys["windows"]["propresenter_re"].to_string())
|
||||||
pub fn change_scene(&self, scene: Scenes, sub_scene: Option<SubScenes>) {
|
.spawn()
|
||||||
todo!()
|
.expect("next_slide process call failed");
|
||||||
|
} else {
|
||||||
|
println!("pretend linux is sending prosenter next: {}", self.hotkeys["general"]["clicker_backward"].to_string())
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn hotkeys() {
|
||||||
|
use std::io::Read;
|
||||||
|
let settings_json: serde_json::Value;
|
||||||
|
{
|
||||||
|
let mut settings_file = std::fs::File::open(OPTIONS_PATH).unwrap();
|
||||||
|
let mut settings_str = String::new();
|
||||||
|
settings_file.read_to_string(&mut settings_str).unwrap();
|
||||||
|
settings_json = serde_json::from_str(settings_str.as_str()).unwrap();
|
||||||
|
drop(settings_file);
|
||||||
|
}
|
||||||
|
let hk = Hotkeys {
|
||||||
|
hotkeys: settings_json,
|
||||||
|
};
|
||||||
|
hk.change_scene(Scenes::Augmented, Some(SubScenes::CameraDefault));
|
||||||
|
hk.next_slide();
|
||||||
|
hk.prev_slide();
|
||||||
|
hk.send_obs(String::from("a hotkey"));
|
||||||
|
hk.toggle_computer_sound(true);
|
||||||
|
hk.toggle_stream_sound(true);
|
||||||
|
hk.toggle_media_play_pause(false);
|
||||||
|
}
|
Loading…
Reference in a new issue