added new() constructor

This commit is contained in:
Nickiel12 2022-01-02 19:39:20 -08:00
parent 6a1f512db4
commit 55921ca08f

View file

@ -29,6 +29,12 @@ pub struct Hotkeys {
} }
impl Hotkeys { impl Hotkeys {
pub fn new(hotkeys: serde_json::Value) -> Self {
Hotkeys {
hotkeys
}
}
pub fn get_hotkey_from_scene(&self, scene: SubScenes) -> &str { pub fn get_hotkey_from_scene(&self, scene: SubScenes) -> &str {
match scene { match scene {
SubScenes::CameraDefault => {self.hotkeys["hotkeys"]["obs"]["camera_scene_hotkey"].as_str().unwrap()}, SubScenes::CameraDefault => {self.hotkeys["hotkeys"]["obs"]["camera_scene_hotkey"].as_str().unwrap()},
@ -40,6 +46,7 @@ impl Hotkeys {
SubScenes::ScreenWithLowerRight => {self.hotkeys["hotkeys"]["obs"]["Screen_Bottom_Right"].as_str().unwrap()}, SubScenes::ScreenWithLowerRight => {self.hotkeys["hotkeys"]["obs"]["Screen_Bottom_Right"].as_str().unwrap()},
} }
} }
pub fn send_obs(&self, hotkey: &str) { pub fn send_obs(&self, hotkey: &str) {
if cfg!(target_family = "windows") { if cfg!(target_family = "windows") {
Command::new(String::from(AHK_FILES_FOLDER) + "send_obs_back_to_propre.exe") Command::new(String::from(AHK_FILES_FOLDER) + "send_obs_back_to_propre.exe")