-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #340 from neilenns/neilenns/issue331
Add main volume action
- Loading branch information
Showing
24 changed files
with
582 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
com.neil-enns.trackaudio.sdPlugin/images/actions/mainVolume/template.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head lang="en"> | ||
<meta charset="utf-8" /> | ||
<script src="https://cdn.jsdelivr.net/gh/geekyeggo/sdpi-components@v2/dist/sdpi-components.js"></script> | ||
</head> | ||
<body> | ||
<sdpi-item label="Change amount"> | ||
<sdpi-range | ||
setting="changeAmount" | ||
min="1" | ||
max="10" | ||
default="1" | ||
showlabels | ||
required | ||
></sdpi-range> | ||
</sdpi-item> | ||
|
||
<sdpi-item label="Connected"> | ||
<sdpi-file | ||
setting="connectedImagePath" | ||
accept="image/png, image/jpeg, image/svg+xml" | ||
></sdpi-file> | ||
</sdpi-item> | ||
|
||
<sdpi-item label="Not connected"> | ||
<sdpi-file | ||
setting="notConnectedImagePath" | ||
accept="image/png, image/jpeg, image/svg+xml" | ||
></sdpi-file> | ||
</sdpi-item> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { | ||
action, | ||
DialAction, | ||
DialRotateEvent, | ||
DidReceiveSettingsEvent, | ||
JsonValue, | ||
SingletonAction, | ||
WillAppearEvent, | ||
WillDisappearEvent, | ||
} from "@elgato/streamdeck"; | ||
import { handleAddMainVolume } from "@events/streamDeck/mainVolume/addMainVolume"; | ||
import { handleRemove } from "@events/streamDeck/remove"; | ||
import { handleMainVolumeDialRotate } from "@events/streamDeck/mainVolume/mainVolumeDialRotate"; | ||
import debounce from "debounce"; | ||
import { handleUpdateMainVolumeSettings } from "@events/streamDeck/mainVolume/updateMainVolumeSettings"; | ||
|
||
@action({ UUID: "com.neil-enns.trackaudio.mainvolume" }) | ||
/** | ||
* Represents the volume of a TrackAudio station | ||
*/ | ||
export class MainVolume extends SingletonAction<MainVolumeSettings> { | ||
debouncedUpdate = debounce( | ||
(action: DialAction, settings: MainVolumeSettings) => { | ||
handleUpdateMainVolumeSettings(action, settings); | ||
}, | ||
300 | ||
); | ||
|
||
override onWillAppear( | ||
ev: WillAppearEvent<MainVolumeSettings> | ||
): Promise<void> | void { | ||
// This should never happen. Typeguard to ensure the rest of the code can just use | ||
// DialAction. | ||
if (!ev.action.isDial()) { | ||
return; | ||
} | ||
|
||
handleAddMainVolume(ev.action, ev.payload.settings); | ||
} | ||
|
||
override onDialRotate( | ||
ev: DialRotateEvent<MainVolumeSettings> | ||
): Promise<void> | void { | ||
handleMainVolumeDialRotate(ev.action, ev.payload.ticks); | ||
} | ||
|
||
override onDidReceiveSettings( | ||
ev: DidReceiveSettingsEvent<MainVolumeSettings> | ||
): Promise<void> | void { | ||
// This should never happen. Typeguard to ensure the rest of the code can just use | ||
// DialAction. | ||
if (!ev.action.isDial()) { | ||
return; | ||
} | ||
|
||
this.debouncedUpdate(ev.action, ev.payload.settings); | ||
} | ||
|
||
override onWillDisappear( | ||
ev: WillDisappearEvent<MainVolumeSettings> | ||
): Promise<void> | void { | ||
handleRemove(ev.action); | ||
} | ||
} | ||
|
||
export interface MainVolumeSettings { | ||
changeAmount?: number; | ||
connectedImagePath?: string; | ||
notConnectedImagePath?: string; | ||
[key: string]: JsonValue; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.