- Added 5 new feedbacks

- Added callbacks for the new feedbacks

Known Issues:
- Feedbacks do not init with the current state of the buttons on startup.
This commit is contained in:
2023-12-22 23:20:37 -05:00
parent d1ef607952
commit 48db682ae5
3 changed files with 112 additions and 23 deletions

View File

@@ -35,6 +35,7 @@ module.exports = function (self) {
options: [], options: [],
callback: async (event) => { callback: async (event) => {
self.vm.internal.toggleVoiceChanger() self.vm.internal.toggleVoiceChanger()
self.checkFeedbacks('VoiceChangerState')
}, },
}, },
play_meme: { play_meme: {

View File

@@ -2,31 +2,69 @@ const { combineRgb } = require('@companion-module/base')
module.exports = async function (self) { module.exports = async function (self) {
self.setFeedbackDefinitions({ self.setFeedbackDefinitions({
ChannelState: { VoiceChangerState: {
name: 'Example Feedback', name: 'Voice Changer State',
type: 'boolean', type: 'boolean',
label: 'Channel State', label: 'Voice Changer State',
defaultStyle: { defaultStyle: {
bgcolor: combineRgb(255, 0, 0), bgcolor: combineRgb(255, 0, 0),
color: combineRgb(0, 0, 0), color: combineRgb(0, 0, 0),
}, },
options: [ options: [],
{ callback: (feedback, context) => {
id: 'num', return self.voiceChangerEnabled
type: 'number',
label: 'Test',
default: 5,
min: 0,
max: 10,
}, },
], },
callback: (feedback) => { BackgroundEffectState: {
console.log('Hello world!', feedback.options.num) name: 'Background Effect State',
if (feedback.options.num > 5) { type: 'boolean',
return true label: 'Background Effect Status',
} else { defaultStyle: {
return false bgcolor: combineRgb(255, 0, 0),
} color: combineRgb(0, 0, 0),
},
options: [],
callback: (feedback, context) => {
return self.backgroundEffectsEnabled
},
},
HearMyVoiceState: {
name: 'Hear My Voice State',
type: 'boolean',
label: 'Hear My Voice State',
defaultStyle: {
bgcolor: combineRgb(255, 0, 0),
color: combineRgb(0, 0, 0),
},
options: [],
callback: (feedback, context) => {
return self.hearMyVoiceEnabled
},
},
MicMutedState: {
name: 'Microphone Mute State',
type: 'boolean',
label: 'Microphone Mute State',
defaultStyle: {
bgcolor: combineRgb(255, 0, 0),
color: combineRgb(0, 0, 0),
},
options: [],
callback: (feedback, context) => {
return self.muteEnabled
},
},
MemesMutedForMeState: {
name: 'Soundboard - Mute For Me State',
type: 'boolean',
label: 'Soundboard Mute For Me State',
defaultStyle: {
bgcolor: combineRgb(255, 0, 0),
color: combineRgb(0, 0, 0),
},
options: [],
callback: (feedback, context) => {
return self.muteMemesEnabled
}, },
}, },
}) })

56
main.js
View File

@@ -11,6 +11,11 @@ class ModuleInstance extends InstanceBase {
this.config = {} this.config = {}
this.memes = [] this.memes = []
this.backgroundEffectsEnabled = false;
this.voiceChangerEnabled = false;
this.hearMyVoiceEnabled = false;
this.muteEnabled = false;
this.muteMemesEnabled = false;
} }
async init(config) { async init(config) {
@@ -22,6 +27,51 @@ class ModuleInstance extends InstanceBase {
try { try {
this.vm.init().then( this.vm.init().then(
async () => { async () => {
this.vm.internal.on('backgroundEffectsEnabledEvent', ( background ) => {
this.backgroundEffectsEnabled = true;
this.checkFeedbacks('BackgroundEffectState');
});
this.vm.internal.on('backgroundEffectsDisabledEvent', ( background ) => {
this.backgroundEffectsEnabled = false;
this.checkFeedbacks('BackgroundEffectState');
});
this.vm.internal.on('voiceChangerEnabledEvent', ( data ) => {
this.voiceChangerEnabled = true;
this.checkFeedbacks('VoiceChangerState');
});
this.vm.internal.on('voiceChangerDisabledEvent', ( data ) => {
this.voiceChangerEnabled = false;
this.checkFeedbacks('VoiceChangerState');
});
this.vm.internal.on('hearMySelfEnabledEvent', ( data ) => {
this.hearMyVoiceEnabled = true;
this.checkFeedbacks('HearMyVoiceState');
});
this.vm.internal.on('hearMySelfDisabledEvent', ( data ) => {
this.hearMyVoiceEnabled = false;
this.checkFeedbacks('HearMyVoiceState');
});
this.vm.internal.on('muteMicrophoneEnabledEvent', ( data ) => {
this.muteEnabled = true;
this.checkFeedbacks('MicMutedState');
});
this.vm.internal.on('muteMicrophoneDisabledEvent', ( data ) => {
this.muteEnabled = false;
this.checkFeedbacks('MicMutedState');
});
this.vm.internal.on('muteMemeForMeEnabledEvent', ( data ) => {
this.muteMemesEnabled = true;
this.checkFeedbacks('MemesMutedForMeState');
});
this.vm.internal.on('muteMemeForMeDisabledEvent', ( data ) => {
this.muteMemesEnabled = false;
this.checkFeedbacks('MemesMutedForMeState');
});
this.vm.internal.getVoiceChangerStatus()
this.vm.internal.getBackgroundEffectStatus()
this.vm.internal.getMuteMicStatus()
this.vm.internal.getMuteMemeForMeStatus()
this.updateStatus(InstanceStatus.Ok) this.updateStatus(InstanceStatus.Ok)
this.updateActionsFeedbacksVariables() this.updateActionsFeedbacksVariables()
@@ -69,12 +119,12 @@ class ModuleInstance extends InstanceBase {
updateActionsFeedbacksVariables() { updateActionsFeedbacksVariables() {
this.updateActions() // export actions this.updateActions() // export actions
// this.updateFeedbacks() // export feedbacks this.updateFeedbacks() // export feedbacks
this.updateVariableDefinitions() // export variable definitions this.updateVariableDefinitions() // export variable definitions
this.subscribeActions() this.subscribeActions()
// this.subscribeFeedbacks() this.subscribeFeedbacks()
// this.checkFeedbacks() this.checkFeedbacks()
} }
updateActions() { updateActions() {