added differentiation of hotkey and app
This commit is contained in:
parent
686d7b8237
commit
480f5b0c11
3 changed files with 27 additions and 22 deletions
|
@ -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);
|
||||||
|
@ -42,6 +42,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(),
|
||||||
|
@ -54,11 +55,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));
|
||||||
|
@ -67,11 +70,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));
|
||||||
|
@ -142,8 +147,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);
|
||||||
|
|
|
@ -60,16 +60,10 @@ impl Scenes {
|
||||||
|
|
||||||
#[derive(PartialEq, Debug, Clone, Copy)]
|
#[derive(PartialEq, Debug, Clone, Copy)]
|
||||||
pub enum SlideChange {
|
pub enum SlideChange {
|
||||||
Next,
|
NextApp,
|
||||||
Previous,
|
PreviousApp,
|
||||||
|
NextHotkey,
|
||||||
|
PreviousHotkey,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SlideChange {
|
|
||||||
pub fn to_string(&self) -> String {
|
|
||||||
match self {
|
|
||||||
SlideChange::Next => {String::from_str("Next_Slide").unwrap()},
|
|
||||||
SlideChange::Previous => {String::from_str("Prev_Slide").unwrap()},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -73,8 +73,12 @@ impl StateUpdate {
|
||||||
|
|
||||||
"Stream_Running" => {StateUpdate::StreamRunning(string_to_bool(incoming_json["data"].as_str().unwrap()))}
|
"Stream_Running" => {StateUpdate::StreamRunning(string_to_bool(incoming_json["data"].as_str().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)}
|
||||||
}
|
}
|
||||||
|
@ -111,8 +115,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 => {
|
||||||
|
|
Loading…
Reference in a new issue