Skip to content

Commit

Permalink
Merge pull request #396 from neilenns/neilenns/issue395
Browse files Browse the repository at this point in the history
Add mute on long press option
  • Loading branch information
neilenns authored Jan 16, 2025
2 parents 4560566 + bfe6dbd commit 505907b
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 5 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"streamdeck",
"trackaudio",
"Typeguard",
"UNICOM",
"vatsim"
]
}
9 changes: 8 additions & 1 deletion com.neil-enns.trackaudio.sdPlugin/pi/stationStatus.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,14 @@
<sdpi-item>
<sdpi-checkbox
setting="toggleMuteOnPress"
label="Toggle mute when pressed"
label="Toggle mute on press"
></sdpi-checkbox>
</sdpi-item>

<sdpi-item>
<sdpi-checkbox
setting="toggleMuteOnLongPress"
label="Toggle mute on long press"
></sdpi-checkbox>
</sdpi-item>

Expand Down
1 change: 1 addition & 0 deletions src/actions/stationStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export interface StationStatusSettings {
showListenTo?: boolean;
showTitle?: boolean;
title?: string;
toggleMuteOnLongPress?: boolean;
toggleMuteOnPress?: boolean;
unavailableImagePath?: string;
[key: string]: JsonValue;
Expand Down
8 changes: 8 additions & 0 deletions src/controllers/stationStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,14 @@ export class StationStatusController extends BaseController {
return this.settings.listenTo ?? "rx";
}

/**
* Gets the toggleMuteOnLongPress value from settings.
* @returns {boolean} The value. Defaults to false.
*/
get toggleMuteOnLongPress(): boolean {
return this.settings.toggleMuteOnLongPress ?? false;
}

/**
* Gets the toggleMuteOnPress value from settings.
* @returns {boolean} The value. Defaults to false.
Expand Down
22 changes: 20 additions & 2 deletions src/events/streamDeck/stationStatus/stationStatusLongPress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import trackAudioManager from "@managers/trackAudio";
import { handleAsyncException } from "@utils/handleAsyncException";

/**
* Called when a station status action has a long press. Resets the
* station status and refreshses its state.
* Called when a station status action has a long press.
* Either toggles mute or refreshes the station status depending on the user's setting.
* @param actionId The ID of the action that had the long press
*/
export const handleStationStatusLongPress = (action: KeyAction) => {
Expand All @@ -17,6 +17,24 @@ export const handleStationStatusLongPress = (action: KeyAction) => {
return;
}

// Mute if that's the requested action.
if (savedAction.toggleMuteOnLongPress) {
trackAudioManager.sendMessage({
type: "kSetStationState",
value: {
frequency: savedAction.frequency,
isOutputMuted: "toggle",
rx: undefined,
tx: undefined,
xc: undefined,
xca: undefined,
headset: undefined,
},
});
return;
}

// If mute toggle isn't enabled, refresh the station state.
savedAction.reset();
trackAudioManager.refreshStationState(savedAction.callsign);

Expand Down
8 changes: 6 additions & 2 deletions src/managers/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,12 @@ class ActionManager extends EventEmitter {

// Add on all the hotline action callsigns
this.getHotlineControllers().forEach((hotline) => {
trackedCallsignsSet.add(hotline.primaryCallsign);
trackedCallsignsSet.add(hotline.hotlineCallsign);
if (hotline.primaryCallsign) {
trackedCallsignsSet.add(hotline.primaryCallsign);
}
if (hotline.hotlineCallsign) {
trackedCallsignsSet.add(hotline.hotlineCallsign);
}
});

// Auto-add all tracked callsigns with a 250ms delay between each message
Expand Down

0 comments on commit 505907b

Please sign in to comment.