switchToProfile
This commit is contained in:
parent
8de6987465
commit
a1f237c1c8
4 changed files with 66 additions and 71 deletions
|
|
@ -4,63 +4,60 @@
|
||||||
/**
|
/**
|
||||||
* The first event fired when Stream Deck starts
|
* The first event fired when Stream Deck starts
|
||||||
*/
|
*/
|
||||||
$SD.onConnected(({ actionInfo, appInfo, connection, messageType, port, uuid }) => {
|
$SD.onConnected(({ actionInfo, appInfo, connection, messageType, port, uuid }) => {
|
||||||
// TODO: Remove this test logging code and replace with simple action
|
// TODO: Remove this test logging code and replace with simple action
|
||||||
console.log({ object: 'stream-deck', event: 'onConnected' });
|
console.log({ object: 'stream-deck', event: 'onConnected' });
|
||||||
|
})
|
||||||
new Action('com.elgato.template.action')
|
.onDeviceDidConnect(() => {
|
||||||
.onDidReceiveGlobalSettings(() => {
|
|
||||||
console.log({ object: 'action', event: 'onDidReceiveGlobalSettings' });
|
|
||||||
})
|
|
||||||
.onDidReceiveSettings(() => {
|
|
||||||
console.log({ object: 'action', event: 'onDidReceiveSettings' });
|
|
||||||
})
|
|
||||||
.onKeyDown(({context, device}) => {
|
|
||||||
console.log(jsn);
|
|
||||||
console.log({ object: 'action', event: 'onKeyDown' });
|
|
||||||
$SD.switchToProfile(device, 'HUD XL');
|
|
||||||
})
|
|
||||||
.onKeyUp(() => {
|
|
||||||
console.log({ object: 'action', event: 'onKeyUp' });
|
|
||||||
})
|
|
||||||
.onWillAppear(() => {
|
|
||||||
console.log({ object: 'action', event: 'onWillAppear' });
|
|
||||||
})
|
|
||||||
.onWillDisappear(() => {
|
|
||||||
console.log({ object: 'action', event: 'onWillDisappear' });
|
|
||||||
})
|
|
||||||
.onTitleParametersDidChange(() => {
|
|
||||||
console.log({ object: 'action', event: 'onTitleParametersDidChange' });
|
|
||||||
})
|
|
||||||
.onPropertyInspectorDidAppear(() => {
|
|
||||||
console.log({ object: 'action', event: 'onPropertyInspectorDidAppear' });
|
|
||||||
})
|
|
||||||
.onPropertyInspectorDidDisappear(() => {
|
|
||||||
console.log({ object: 'action', event: 'onPropertyInspectorDidDisappear' });
|
|
||||||
})
|
|
||||||
.onSendToPlugin(() => {
|
|
||||||
console.log({ object: 'action', event: 'onSendToPlugin' });
|
|
||||||
})
|
|
||||||
.onSendToPropertyInspector(() => {
|
|
||||||
console.log({ object: 'action', event: 'onSendToPropertyInspector' });
|
|
||||||
});
|
|
||||||
|
|
||||||
$SD.onDeviceDidConnect(() => {
|
|
||||||
console.log({ object: 'stream-deck', event: 'onDeviceDidConnect' });
|
console.log({ object: 'stream-deck', event: 'onDeviceDidConnect' });
|
||||||
})
|
})
|
||||||
.onDeviceDidDisconnect(() => {
|
.onDeviceDidDisconnect(() => {
|
||||||
console.log({ object: 'stream-deck', event: 'onDeviceDidDisconnect' });
|
console.log({ object: 'stream-deck', event: 'onDeviceDidDisconnect' });
|
||||||
})
|
})
|
||||||
.onSendToPropertyInspector(() => {
|
.onSendToPropertyInspector(() => {
|
||||||
console.log({ object: 'stream-deck', event: 'onSendToPropertyInspector' });
|
console.log({ object: 'stream-deck', event: 'onSendToPropertyInspector' });
|
||||||
})
|
})
|
||||||
.onApplicationDidLaunch(() => {
|
.onApplicationDidLaunch(() => {
|
||||||
console.log({ object: 'stream-deck', event: 'onApplicationDidLaunch' });
|
console.log({ object: 'stream-deck', event: 'onApplicationDidLaunch' });
|
||||||
})
|
})
|
||||||
.onApplicationDidTerminate(() => {
|
.onApplicationDidTerminate(() => {
|
||||||
console.log({ object: 'stream-deck', event: 'onApplicationDidTerminate' });
|
console.log({ object: 'stream-deck', event: 'onApplicationDidTerminate' });
|
||||||
})
|
})
|
||||||
.onSystemDidWakeUp(() => {
|
.onSystemDidWakeUp(() => {
|
||||||
console.log({ object: 'stream-deck', event: 'onSystemDidWakeUp' });
|
console.log({ object: 'stream-deck', event: 'onSystemDidWakeUp' });
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
new Action('com.elgato.template.action')
|
||||||
|
.onDidReceiveGlobalSettings(() => {
|
||||||
|
console.log({ object: 'action', event: 'onDidReceiveGlobalSettings' });
|
||||||
|
})
|
||||||
|
.onDidReceiveSettings(() => {
|
||||||
|
console.log({ object: 'action', event: 'onDidReceiveSettings' });
|
||||||
|
})
|
||||||
|
.onKeyDown(() => {
|
||||||
|
console.log({ object: 'action', event: 'onKeyDown' });
|
||||||
|
})
|
||||||
|
.onKeyUp(() => {
|
||||||
|
console.log({ object: 'action', event: 'onKeyUp' });
|
||||||
|
})
|
||||||
|
.onWillAppear(() => {
|
||||||
|
console.log({ object: 'action', event: 'onWillAppear' });
|
||||||
|
})
|
||||||
|
.onWillDisappear(() => {
|
||||||
|
console.log({ object: 'action', event: 'onWillDisappear' });
|
||||||
|
})
|
||||||
|
.onTitleParametersDidChange(() => {
|
||||||
|
console.log({ object: 'action', event: 'onTitleParametersDidChange' });
|
||||||
|
})
|
||||||
|
.onPropertyInspectorDidAppear(() => {
|
||||||
|
console.log({ object: 'action', event: 'onPropertyInspectorDidAppear' });
|
||||||
|
})
|
||||||
|
.onPropertyInspectorDidDisappear(() => {
|
||||||
|
console.log({ object: 'action', event: 'onPropertyInspectorDidDisappear' });
|
||||||
|
})
|
||||||
|
.onSendToPlugin(() => {
|
||||||
|
console.log({ object: 'action', event: 'onSendToPlugin' });
|
||||||
|
})
|
||||||
|
.onSendToPropertyInspector(() => {
|
||||||
|
console.log({ object: 'action', event: 'onSendToPropertyInspector' });
|
||||||
|
});
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ class ELGSDAction {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a callback function for the didReceiveSettings event, which fires when calling getSettings
|
* Registers a callback function for the didReceiveSettings event, which fires when calling getSettings
|
||||||
* @param {*} fn
|
* @param {function} fn
|
||||||
*/
|
*/
|
||||||
onDidReceiveSettings(fn) {
|
onDidReceiveSettings(fn) {
|
||||||
this.#on(`${this.UUID}.${Events.didReceiveSettings}`, (jsn) => fn(jsn));
|
this.#on(`${this.UUID}.${Events.didReceiveSettings}`, (jsn) => fn(jsn));
|
||||||
|
|
@ -23,7 +23,7 @@ class ELGSDAction {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a callback function for the didReceiveGlobalSettings event, which fires when calling getGlobalSettings
|
* Registers a callback function for the didReceiveGlobalSettings event, which fires when calling getGlobalSettings
|
||||||
* @param {*} fn
|
* @param {function} fn
|
||||||
*/
|
*/
|
||||||
onDidReceiveGlobalSettings(fn) {
|
onDidReceiveGlobalSettings(fn) {
|
||||||
this.#on(Events.didReceiveGlobalSettings, (jsn) => fn(jsn));
|
this.#on(Events.didReceiveGlobalSettings, (jsn) => fn(jsn));
|
||||||
|
|
@ -32,7 +32,7 @@ class ELGSDAction {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a callback function for the keyDown event, which fires when pressing a key down
|
* Registers a callback function for the keyDown event, which fires when pressing a key down
|
||||||
* @param {*} fn
|
* @param {function} fn
|
||||||
*/
|
*/
|
||||||
onKeyDown(fn) {
|
onKeyDown(fn) {
|
||||||
this.#on(`${this.UUID}.${Events.keyDown}`, (jsn) => fn(jsn));
|
this.#on(`${this.UUID}.${Events.keyDown}`, (jsn) => fn(jsn));
|
||||||
|
|
@ -41,7 +41,7 @@ class ELGSDAction {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a callback function for the keyUp event, which fires when releasing a key
|
* Registers a callback function for the keyUp event, which fires when releasing a key
|
||||||
* @param {*} fn
|
* @param {function} fn
|
||||||
*/
|
*/
|
||||||
onKeyUp(fn) {
|
onKeyUp(fn) {
|
||||||
this.#on(`${this.UUID}.${Events.keyUp}`, (jsn) => fn(jsn));
|
this.#on(`${this.UUID}.${Events.keyUp}`, (jsn) => fn(jsn));
|
||||||
|
|
@ -50,7 +50,7 @@ class ELGSDAction {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a callback function for the willAppear event, which fires when an action appears on the canvas
|
* Registers a callback function for the willAppear event, which fires when an action appears on the canvas
|
||||||
* @param {*} fn
|
* @param {function} fn
|
||||||
*/
|
*/
|
||||||
onWillAppear(fn) {
|
onWillAppear(fn) {
|
||||||
this.#on(`${this.UUID}.${Events.willAppear}`, (jsn) => fn(jsn));
|
this.#on(`${this.UUID}.${Events.willAppear}`, (jsn) => fn(jsn));
|
||||||
|
|
@ -59,7 +59,7 @@ class ELGSDAction {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a callback function for the willAppear event, which fires when an action disappears on the canvas
|
* Registers a callback function for the willAppear event, which fires when an action disappears on the canvas
|
||||||
* @param {*} fn
|
* @param {function} fn
|
||||||
*/
|
*/
|
||||||
onWillDisappear(fn) {
|
onWillDisappear(fn) {
|
||||||
this.#on(`${this.UUID}.${Events.willDisappear}`, (jsn) => fn(jsn));
|
this.#on(`${this.UUID}.${Events.willDisappear}`, (jsn) => fn(jsn));
|
||||||
|
|
@ -68,7 +68,7 @@ class ELGSDAction {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a callback function for the titleParametersDidChange event, which fires when a user changes the key title
|
* Registers a callback function for the titleParametersDidChange event, which fires when a user changes the key title
|
||||||
* @param {*} fn
|
* @param {function} fn
|
||||||
*/
|
*/
|
||||||
onTitleParametersDidChange(fn) {
|
onTitleParametersDidChange(fn) {
|
||||||
this.#on(`${this.UUID}.${Events.titleParametersDidChange}`, (jsn) => fn(jsn));
|
this.#on(`${this.UUID}.${Events.titleParametersDidChange}`, (jsn) => fn(jsn));
|
||||||
|
|
@ -77,7 +77,7 @@ class ELGSDAction {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a callback function for the propertyInspectorDidAppear event, which fires when the property inspector is displayed
|
* Registers a callback function for the propertyInspectorDidAppear event, which fires when the property inspector is displayed
|
||||||
* @param {*} fn
|
* @param {function} fn
|
||||||
*/
|
*/
|
||||||
onPropertyInspectorDidAppear(fn) {
|
onPropertyInspectorDidAppear(fn) {
|
||||||
this.#on(`${this.UUID}.${Events.propertyInspectorDidAppear}`, (jsn) => fn(jsn));
|
this.#on(`${this.UUID}.${Events.propertyInspectorDidAppear}`, (jsn) => fn(jsn));
|
||||||
|
|
@ -86,7 +86,7 @@ class ELGSDAction {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a callback function for the propertyInspectorDidDisappear event, which fires when the property inspector is closed
|
* Registers a callback function for the propertyInspectorDidDisappear event, which fires when the property inspector is closed
|
||||||
* @param {*} fn
|
* @param {function} fn
|
||||||
*/
|
*/
|
||||||
onPropertyInspectorDidDisappear(fn) {
|
onPropertyInspectorDidDisappear(fn) {
|
||||||
this.#on(`${this.UUID}.${Events.propertyInspectorDidDisappear}`, (jsn) => fn(jsn));
|
this.#on(`${this.UUID}.${Events.propertyInspectorDidDisappear}`, (jsn) => fn(jsn));
|
||||||
|
|
@ -95,7 +95,7 @@ class ELGSDAction {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a callback function for the sendToPlugin event, which fires when the property inspector uses the sendToPlugin api
|
* Registers a callback function for the sendToPlugin event, which fires when the property inspector uses the sendToPlugin api
|
||||||
* @param {*} fn
|
* @param {function} fn
|
||||||
*/
|
*/
|
||||||
onSendToPlugin(fn) {
|
onSendToPlugin(fn) {
|
||||||
this.#on(`${this.UUID}.${Events.sendToPlugin}`, (jsn) => fn(jsn));
|
this.#on(`${this.UUID}.${Events.sendToPlugin}`, (jsn) => fn(jsn));
|
||||||
|
|
@ -104,7 +104,7 @@ class ELGSDAction {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a callback function for the sendToPropertyInspector event, which fires when the plugin uses the sendToPropertyInspector api
|
* Registers a callback function for the sendToPropertyInspector event, which fires when the plugin uses the sendToPropertyInspector api
|
||||||
* @param {*} fn
|
* @param {function} fn
|
||||||
*/
|
*/
|
||||||
onSendToPropertyInspector(fn) {
|
onSendToPropertyInspector(fn) {
|
||||||
this.#on(`${this.UUID}.${Events.sendToPropertyInspector}`, (jsn) => fn(jsn));
|
this.#on(`${this.UUID}.${Events.sendToPropertyInspector}`, (jsn) => fn(jsn));
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
/// <reference path="event-emitter.js" />
|
/// <reference path="event-emitter.js" />
|
||||||
/// <reference path="constants.js" />
|
/// <reference path="constants.js" />
|
||||||
|
|
||||||
// TODO: switchToProfile (see https://elgato.slack.com/archives/D02LPKC0M9D/p1645183819000839 )
|
|
||||||
// TODO: See if we can add params for the call back function, so that the IDE will provide the jsn object with "context, device, etc"
|
// TODO: See if we can add params for the call back function, so that the IDE will provide the jsn object with "context, device, etc"
|
||||||
// TODO: https://stackoverflow.com/questions/24214962/whats-the-proper-way-to-document-callbacks-with-jsdoc
|
// TODO: https://stackoverflow.com/questions/24214962/whats-the-proper-way-to-document-callbacks-with-jsdoc
|
||||||
|
|
||||||
|
|
@ -307,9 +306,8 @@ class ELGSDStreamDeck {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: fix profile switch not working
|
|
||||||
/**
|
/**
|
||||||
* Switches to profile or returns to previous profile
|
* Switches to a readonly profile or returns to previous profile
|
||||||
* @param {string} device
|
* @param {string} device
|
||||||
* @param {string} [profile]
|
* @param {string} [profile]
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ class Utils {
|
||||||
/**
|
/**
|
||||||
* This provides a slight delay before processing rapid events
|
* This provides a slight delay before processing rapid events
|
||||||
* @param {*} wait - delay before processing function (recommended time 150ms)
|
* @param {*} wait - delay before processing function (recommended time 150ms)
|
||||||
* @param {*} fn
|
* @param {function} fn
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
static debounce(wait, fn) {
|
static debounce(wait, fn) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue