Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
helgoboss committed Aug 21, 2024
1 parent 0d3c2fd commit 855dce7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
18 changes: 10 additions & 8 deletions main/src/domain/control_surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,11 @@ pub enum AdditionalFeedbackEvent {
/// depend on this (see https://github.com/helgoboss/helgobox/issues/663).
BeatChanged(BeatChangedEvent),
MappedFxParametersChanged,
/// This event is raised whenever switching between FX windows (something that REAPER's own FxFocused change
/// event detects as well), but also when an FX window loses focus and a non-FX window gains focus,
/// and vice versa (not notified FxFocused change event).
/// This event is raised when an FX window loses focus and a non-FX window gains focus,
/// and vice versa (not covered by FxFocused change event).
///
/// Attention: This will only be fired for REAPER 7+!
FocusSwitched,
FocusSwitchedBetweenMainAndFx,
/// Forwarded unit state event
///
/// Not all unit events are forwarded, only those that might matter for other
Expand Down Expand Up @@ -295,7 +294,7 @@ impl<EH: DomainEventHandler> RealearnControlSurfaceMiddleware<EH> {
self.process_instance_orchestration_events();
// Inform ReaLearn about various changes that are not relevant for target learning
self.detect_reaper_config_changes();
self.emit_focus_switch_as_feedback_event();
self.emit_focus_switch_between_main_and_fx_as_feedback_event();
self.emit_instance_events();
self.emit_beats_as_feedback_events();
self.detect_device_changes(timestamp);
Expand Down Expand Up @@ -607,7 +606,7 @@ impl<EH: DomainEventHandler> RealearnControlSurfaceMiddleware<EH> {
}
}

fn emit_focus_switch_as_feedback_event(&mut self) {
fn emit_focus_switch_between_main_and_fx_as_feedback_event(&mut self) {
let reaper = Reaper::get().medium_reaper();
if reaper.low().pointers().GetFocusedFX2.is_none() {
// Detection of unfocusing FX (without focusing a new one) not supported in REAPER versions < 7.
Expand All @@ -630,11 +629,14 @@ impl<EH: DomainEventHandler> RealearnControlSurfaceMiddleware<EH> {
true
}
(Some(last), Some(new)) => {
last.is_still_focused != new.is_still_focused || last.fx != new.fx
// Only fire if we changed from "no FX focused" to "FX focused" or vice versa (not when focusing
// between FX ... this is detected better by REAPER's built-in control surface FxFocused event,
// mainly because latter doesn't fire when an FX is removed - which would be too much)
last.is_still_focused != new.is_still_focused
}
};
if fire {
let event = AdditionalFeedbackEvent::FocusSwitched;
let event = AdditionalFeedbackEvent::FocusSwitchedBetweenMainAndFx;
for p in &mut *self.main_processors.borrow_mut() {
p.process_additional_feedback_event(&event);
}
Expand Down
8 changes: 2 additions & 6 deletions main/src/domain/reaper_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ impl ReaperTarget {
evt {
| FxClosed(_)
| FxOpened(_)
| FxFocused(_)
// For FX-to-preset links that also have preset name as criteria
| FxPresetChanged(_)
| ProjectSwitched(_)
Expand All @@ -302,11 +303,6 @@ impl ReaperTarget {
| HardwareOutputSendCountChanged(_)
| TrackSelectedChanged(_)
| TrackVisibilityChanged(_) => true,
FxFocused(_) => {
// This is only relevant if GetFocusedFX2 doesn't exist (REAPER < v7). For REAPER 7+,
// our own FocusSwitched event is the best. See below.
Reaper::get().medium_reaper().low().pointers().GetFocusedFX2.is_none()
},
_ => false,
}
}
Expand All @@ -316,7 +312,7 @@ impl ReaperTarget {
matches!(
evt,
// Auto-load should load other preset (REAPER 7+ only!)
FocusSwitched
FocusSwitchedBetweenMainAndFx
// Dynamic FX parameter expression should be re-resolved
| MappedFxParametersChanged
)
Expand Down

0 comments on commit 855dce7

Please sign in to comment.