This commit is contained in:
Nickiel12 2022-01-02 21:55:14 -08:00
commit 849d73d4a8
7 changed files with 71 additions and 72 deletions

View file

@ -8,10 +8,19 @@ SetTitleMatchMode, Fast
If WinExist(A_Args[1]) ; propresenter If WinExist(A_Args[1]) ; propresenter
{ ; if propresenter isn't active, switch and send clicker forward { ; if propresenter isn't active, switch and send clicker forward
if !WinActive(A_Args[1]){ if (A_Args[3]) { ; 1 for from_hotkey 0 for from app
WinActivate if !WinActive(A_Args[1]){
sleep 200 WinActivate
sleep 200
arg := A_Args[2]
Send {%arg%}
}
} else {
if !WinActive(A_Args[1]){
WinActivate
sleep 200
}
arg := A_Args[2]
Send {%arg%}
} }
arg := A_Args[2]
Send {%arg%}
} }

View file

@ -13,12 +13,12 @@ pub fn create_keyboard_hooks(channel_tx: crossbeam_channel::Sender<String>, clos
let tx_1 = channel_tx.clone(); let tx_1 = channel_tx.clone();
inputbot::KeybdKey::PageUpKey.bind(move || { inputbot::KeybdKey::PageUpKey.bind(move || {
tx_1.send(StateUpdate::ChangeSlide(SlideChange::Next).to_json().to_string()).unwrap(); tx_1.send(StateUpdate::ChangeSlide(SlideChange::PreviousHotkey).to_json().to_string()).unwrap();
}); });
let tx_2 = channel_tx.clone(); let tx_2 = channel_tx.clone();
inputbot::KeybdKey::PageDownKey.bind(move || { inputbot::KeybdKey::PageDownKey.bind(move || {
tx_2.send(StateUpdate::ChangeSlide(SlideChange::Previous).to_json().to_string()).unwrap(); tx_2.send(StateUpdate::ChangeSlide(SlideChange::NextHotkey).to_json().to_string()).unwrap();
}); });
inputbot::handle_input_events(close_flag); inputbot::handle_input_events(close_flag);
@ -49,6 +49,7 @@ impl Hotkeys {
pub fn send_obs(&self, hotkey: &str) { pub fn send_obs(&self, hotkey: &str) {
if cfg!(target_family = "windows") { if cfg!(target_family = "windows") {
println!("sending to obs");
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")
.args([self.hotkeys["windows"]["propresenter_re"].as_str().unwrap(), .args([self.hotkeys["windows"]["propresenter_re"].as_str().unwrap(),
self.hotkeys["windows"]["obs_re"].as_str().unwrap(), self.hotkeys["windows"]["obs_re"].as_str().unwrap(),
@ -61,11 +62,13 @@ impl Hotkeys {
}; };
} }
pub fn next_slide(&self) { pub fn next_slide(&self, from_hotkey: bool) {
let from_hotkey_str = {if from_hotkey {"1"} else {"0"}};
if cfg!(target_family = "windows") { if cfg!(target_family = "windows") {
Command::new(String::from(AHK_FILES_FOLDER) + "propre_send.exe") Command::new(String::from(AHK_FILES_FOLDER) + "propre_send.exe")
.args([self.hotkeys["windows"]["propresenter_re"].as_str().unwrap(), .args([self.hotkeys["windows"]["propresenter_re"].as_str().unwrap(),
self.hotkeys["general"]["clicker_forward"].as_str().unwrap()]) self.hotkeys["general"]["clicker_forward"].as_str().unwrap(),
from_hotkey_str])
.spawn() .spawn()
.expect("next_slide process call failed"); .expect("next_slide process call failed");
std::thread::sleep(std::time::Duration::from_millis(200)); std::thread::sleep(std::time::Duration::from_millis(200));
@ -74,11 +77,13 @@ impl Hotkeys {
}; };
} }
pub fn prev_slide(&self) { pub fn prev_slide(&self, from_hotkey: bool) {
let from_hotkey_str = {if from_hotkey {"1"} else {"0"}};
if cfg!(target_family = "windows") { if cfg!(target_family = "windows") {
Command::new(String::from(AHK_FILES_FOLDER) + "propre_send.exe") Command::new(String::from(AHK_FILES_FOLDER) + "propre_send.exe")
.args([self.hotkeys["windows"]["propresenter_re"].as_str().unwrap(), .args([self.hotkeys["windows"]["propresenter_re"].as_str().unwrap(),
self.hotkeys["general"]["clicker_backward"].as_str().unwrap()]) self.hotkeys["general"]["clicker_backward"].as_str().unwrap(),
from_hotkey_str])
.spawn() .spawn()
.expect("next_slide process call failed"); .expect("next_slide process call failed");
std::thread::sleep(std::time::Duration::from_millis(200)); std::thread::sleep(std::time::Duration::from_millis(200));
@ -88,6 +93,7 @@ impl Hotkeys {
} }
pub fn change_scene(&self, scene: Scenes, sub_scene: Option<SubScenes>) { pub fn change_scene(&self, scene: Scenes, sub_scene: Option<SubScenes>) {
println!("sending: {:?} : {:?}", scene, sub_scene);
let hotkey: &str; let hotkey: &str;
if scene == Scenes::Augmented { if scene == Scenes::Augmented {
hotkey = self.hotkeys["hotkeys"]["obs"]["camera_scene_augmented"].as_str().unwrap() hotkey = self.hotkeys["hotkeys"]["obs"]["camera_scene_augmented"].as_str().unwrap()
@ -148,8 +154,8 @@ fn hotkeys() {
hotkeys: settings_json, hotkeys: settings_json,
}; };
hk.change_scene(Scenes::Augmented, Some(SubScenes::CameraDefault)); hk.change_scene(Scenes::Augmented, Some(SubScenes::CameraDefault));
hk.next_slide(); hk.next_slide(false);
hk.prev_slide(); hk.prev_slide(false);
hk.send_obs("a hotkey"); hk.send_obs("a hotkey");
hk.toggle_computer_sound(true); hk.toggle_computer_sound(true);
hk.toggle_stream_sound(true); hk.toggle_stream_sound(true);

View file

@ -13,8 +13,9 @@ impl MessageHandler for StreamState {
fn handle_update(&mut self, update: StateUpdate, hotkey_handler: &Hotkeys) fn handle_update(&mut self, update: StateUpdate, hotkey_handler: &Hotkeys)
-> (Option<StateUpdate>, Option<Vec<StateUpdate>>) { -> (Option<StateUpdate>, Option<Vec<StateUpdate>>) {
if update != StateUpdate::UpdateClient && update != StateUpdate::ChangeSlide(SlideChange::Next) && if update != StateUpdate::UpdateClient && update != StateUpdate::ChangeSlide(SlideChange::NextApp) &&
update != StateUpdate::ChangeSlide(SlideChange::Previous){ update != StateUpdate::ChangeSlide(SlideChange::PreviousApp) && update != StateUpdate::ChangeSlide(SlideChange::PreviousHotkey)
&& update != StateUpdate::ChangeSlide(SlideChange::NextHotkey) {
self.update(update.clone()); self.update(update.clone());
} }
@ -29,12 +30,18 @@ impl MessageHandler for StreamState {
self.timer_start = SystemTime::now(); self.timer_start = SystemTime::now();
} }
match direction { match direction {
SlideChange::Next => { SlideChange::NextHotkey => {
hotkey_handler.next_slide(); hotkey_handler.next_slide(true);
},
SlideChange::NextApp => {
hotkey_handler.next_slide(false);
},
SlideChange::PreviousHotkey => {
hotkey_handler.prev_slide(true);
},
SlideChange::PreviousApp => {
hotkey_handler.prev_slide(false);
}, },
SlideChange::Previous => {
hotkey_handler.prev_slide();
}
} }
if self.change_scene_on_change_slide_hotkey { if self.change_scene_on_change_slide_hotkey {
let mut instructions = Vec::new(); let mut instructions = Vec::new();
@ -75,20 +82,20 @@ impl MessageHandler for StreamState {
StateUpdate::SubScene(value) => { StateUpdate::SubScene(value) => {
if value.get_type() == Scenes::Camera { if value.get_type() == Scenes::Camera {
if self.current_scene == Scenes::Camera { if self.current_scene == Scenes::Camera {
hotkey_handler.change_scene(Scenes::Camera, Some(self.camera_sub_scene)); hotkey_handler.change_scene(Scenes::Camera, Some(value));
} }
self.camera_sub_scene = value; self.camera_sub_scene = value;
return (Some(update), None) return (Some(update), None)
} else if value.get_type() == Scenes::Screen { } else if value.get_type() == Scenes::Screen {
if self.current_scene == Scenes::Screen{ if self.current_scene == Scenes::Screen{
hotkey_handler.change_scene(Scenes::Screen, Some(self.screen_sub_scene)); hotkey_handler.change_scene(Scenes::Screen, Some(value));
} }
self.screen_sub_scene = value; self.screen_sub_scene = value;
return (Some(update), None) return (Some(update), None)
} }
}, },
StateUpdate::Scene(value) => { StateUpdate::Scene(value) => {
println!("{:?}", value);
if value == Scenes::Screen { if value == Scenes::Screen {
if self.current_scene != Scenes::Screen { if self.current_scene != Scenes::Screen {
self.timer_start = SystemTime::now(); self.timer_start = SystemTime::now();
@ -98,9 +105,8 @@ impl MessageHandler for StreamState {
self.timer_finished = true; self.timer_finished = true;
} }
if self.current_scene != value { if self.current_scene != value {
match self.current_scene { match value {
Scenes::Camera => { Scenes::Camera => {
hotkey_handler.change_scene(Scenes::Camera, Some(self.camera_sub_scene)); hotkey_handler.change_scene(Scenes::Camera, Some(self.camera_sub_scene));
}, },
@ -108,6 +114,7 @@ impl MessageHandler for StreamState {
hotkey_handler.change_scene(Scenes::Screen, Some(self.screen_sub_scene)); hotkey_handler.change_scene(Scenes::Screen, Some(self.screen_sub_scene));
}, },
Scenes::Augmented => { Scenes::Augmented => {
println!("Augment!");
hotkey_handler.change_scene(Scenes::Augmented, None); hotkey_handler.change_scene(Scenes::Augmented, None);
} }
} }

View file

@ -60,6 +60,8 @@ impl Scenes {
#[derive(PartialEq, Debug, Clone, Copy)] #[derive(PartialEq, Debug, Clone, Copy)]
pub enum SlideChange { pub enum SlideChange {
Next, NextApp,
Previous, PreviousApp,
NextHotkey,
PreviousHotkey,
} }

View file

@ -72,8 +72,12 @@ impl StateUpdate {
"Stream_Running" => {StateUpdate::StreamRunning(incoming_json["data"].as_bool().unwrap())} "Stream_Running" => {StateUpdate::StreamRunning(incoming_json["data"].as_bool().unwrap())}
"Next_Slide" => {StateUpdate::ChangeSlide(SlideChange::Next)}, "Next_Slide" => {
"Prev_Slide" => {StateUpdate::ChangeSlide(SlideChange::Previous)} if incoming_json["data"] == "hotkey" {StateUpdate::ChangeSlide(SlideChange::NextHotkey)}
else {StateUpdate::ChangeSlide(SlideChange::NextApp)}},
"Prev_Slide" => {
if incoming_json["data"] == "hotkey" {StateUpdate::ChangeSlide(SlideChange::PreviousHotkey)}
else {StateUpdate::ChangeSlide(SlideChange::PreviousApp)}}
//Unimplemented //Unimplemented
_ => {panic!("trying to use a button type I don't know!: {}", value)} _ => {panic!("trying to use a button type I don't know!: {}", value)}
} }
@ -110,8 +114,10 @@ impl StateUpdate {
("Toggle_Computer_Volume", "".to_string())}, ("Toggle_Computer_Volume", "".to_string())},
StateUpdate::ChangeSlide(value) => { StateUpdate::ChangeSlide(value) => {
match value { match value {
SlideChange::Next => {("Next_Slide", "".to_string())}, SlideChange::NextApp => {("Next_Slide", "".to_string())},
SlideChange::Previous => {("Prev_Slide", "".to_string())}, SlideChange::NextHotkey => {("Next_Slide", "hotkey".to_string())},
SlideChange::PreviousApp => {("Prev_Slide", "".to_string())},
SlideChange::PreviousHotkey => {("Prev_Slide", "hotkey".to_string())},
} }
}, },
StateUpdate::UpdateClient => { StateUpdate::UpdateClient => {

View file

@ -64,43 +64,12 @@ impl StreamState {
StateUpdate::TimerCanRun(new_val) => {self.timer_can_run = new_val;}, StateUpdate::TimerCanRun(new_val) => {self.timer_can_run = new_val;},
StateUpdate::TimerLength(new_val) => {self.timer_length = new_val;}, StateUpdate::TimerLength(new_val) => {self.timer_length = new_val;},
StateUpdate::TimerText(new_val) => {self.timer_text = new_val;}, StateUpdate::TimerText(new_val) => {self.timer_text = new_val;},
StateUpdate::Scene(new_val) => {self.change_scene(&new_val)}, StateUpdate::SceneIsAugmented(new_val) => {self.scene_is_augmented = new_val;},
StateUpdate::SubScene(new_val) => {self.change_sub_scene(&new_val)}, StateUpdate::Scene(_) => {},
StateUpdate::SceneIsAugmented(new_val) => { StateUpdate::SubScene(_) => {},
self.scene_is_augmented = new_val; StateUpdate::ComputerMediaDoPause => {},
self.change_scene(&Scenes::Augmented)}, StateUpdate::ChangeSlide(_value) => {panic!("Stream_states_class is not supposed to get this update type");},
StateUpdate::ComputerMediaDoPause => {}, StateUpdate::UpdateClient => {},
StateUpdate::ChangeSlide(_value) => {panic!("Stream_states_class is not supposed to get this update type");},
StateUpdate::UpdateClient => {},
} }
} }
pub fn change_scene(&mut self, scene: &Scenes) {
match scene {
Scenes::Augmented => {self.current_scene = *scene;}
Scenes::Camera => {self.current_scene = *scene},
Scenes::Screen => {self.current_scene = *scene},
}
}
pub fn change_sub_scene(&mut self, scene: &SubScenes) {
match scene {
SubScenes::CameraDefault | SubScenes::CameraWithUpperRight |
SubScenes::CameraWithLargeUpperRight | SubScenes::CameraWithLowerRight
=> {StreamState::set_camera_scene(self, scene)},
SubScenes::ScreenDefault | SubScenes::ScreenWithUpperRight |
SubScenes::ScreenWithLowerRight
=> {StreamState::set_screen_scene(self, scene)},
}
}
fn set_camera_scene(&mut self, scene: &SubScenes) {
self.camera_sub_scene = scene.clone();
self.current_scene = Scenes::Camera;
}
fn set_screen_scene(&mut self, scene: &SubScenes) {
self.screen_sub_scene = scene.clone();
self.current_scene = Scenes::Screen;
}
} }

View file

@ -86,11 +86,11 @@ fn test_json_to_state_update() {
assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str( assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str(
"{\"type\": \"update\", \"update\": \"Next_Slide\"}" "{\"type\": \"update\", \"update\": \"Next_Slide\"}"
).unwrap()), StateUpdate::ChangeSlide(SlideChange::Next)); ).unwrap()), StateUpdate::ChangeSlide(SlideChange::NextHotkey));
assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str( assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str(
"{\"type\": \"update\", \"update\": \"Prev_Slide\"}" "{\"type\": \"update\", \"update\": \"Prev_Slide\"}"
).unwrap()), StateUpdate::ChangeSlide(SlideChange::Previous)); ).unwrap()), StateUpdate::ChangeSlide(SlideChange::PreviousHotkey));
assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str( assert_eq!(StateUpdate::json_to_state_update(serde_json::from_str(
"{\"type\": \"update\", \"update\":\"all\"}" "{\"type\": \"update\", \"update\":\"all\"}"
@ -131,8 +131,8 @@ fn test_state_update_to_json() {
assert_eq!(StateUpdate::SubScene(SubScenes::ScreenWithLowerRight), StateUpdate::json_to_state_update(StateUpdate::SubScene(SubScenes::ScreenWithLowerRight).to_json())); assert_eq!(StateUpdate::SubScene(SubScenes::ScreenWithLowerRight), StateUpdate::json_to_state_update(StateUpdate::SubScene(SubScenes::ScreenWithLowerRight).to_json()));
assert_eq!(StateUpdate::Scene(Scenes::Camera), StateUpdate::json_to_state_update(StateUpdate::Scene(Scenes::Camera).to_json())); assert_eq!(StateUpdate::Scene(Scenes::Camera), StateUpdate::json_to_state_update(StateUpdate::Scene(Scenes::Camera).to_json()));
assert_eq!(StateUpdate::Scene(Scenes::Screen), StateUpdate::json_to_state_update(StateUpdate::Scene(Scenes::Screen).to_json())); assert_eq!(StateUpdate::Scene(Scenes::Screen), StateUpdate::json_to_state_update(StateUpdate::Scene(Scenes::Screen).to_json()));
assert_eq!(StateUpdate::ChangeSlide(SlideChange::Next), StateUpdate::json_to_state_update(StateUpdate::ChangeSlide(SlideChange::Next).to_json())); assert_eq!(StateUpdate::ChangeSlide(SlideChange::NextHotkey), StateUpdate::json_to_state_update(StateUpdate::ChangeSlide(SlideChange::NextHotkey).to_json()));
assert_eq!(StateUpdate::ChangeSlide(SlideChange::Previous), StateUpdate::json_to_state_update(StateUpdate::ChangeSlide(SlideChange::Previous).to_json())); assert_eq!(StateUpdate::ChangeSlide(SlideChange::PreviousHotkey), StateUpdate::json_to_state_update(StateUpdate::ChangeSlide(SlideChange::PreviousHotkey).to_json()));
assert_eq!(StateUpdate::UpdateClient, StateUpdate::json_to_state_update(StateUpdate::UpdateClient.to_json())); assert_eq!(StateUpdate::UpdateClient, StateUpdate::json_to_state_update(StateUpdate::UpdateClient.to_json()));
} }