Skip to content

Commit 7284ed1

Browse files
authored
feat: exposed controller to allow for detection if its a key or encoder device (#21)
1 parent 3cfb597 commit 7284ed1

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

src/abstracts/stream-deck-plugin-handler.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,8 @@ export abstract class StreamDeckPluginHandler<
206206
userDesiredState,
207207
action,
208208
context,
209-
device;
209+
device,
210+
controller;
210211
action = eventData?.action;
211212
context = eventData?.context;
212213
device = eventData?.device;
@@ -217,6 +218,7 @@ export abstract class StreamDeckPluginHandler<
217218
isInMultiAction = payload?.isInMultiAction;
218219
column = payload?.coordinates?.column;
219220
row = payload?.coordinates?.row;
221+
controller = payload?.controller;
220222

221223
const actionClass = this._actionManager.addOrGetAction(
222224
context,
@@ -235,6 +237,7 @@ export abstract class StreamDeckPluginHandler<
235237
actionClass.userDesiredState = userDesiredState;
236238
if (isInMultiAction !== undefined)
237239
actionClass.isInMultiAction = isInMultiAction;
240+
if (controller !== undefined) actionClass.controller = controller;
238241
}
239242

240243
super._eventHandler(ev);

src/classes/stream-deck-action.class.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export class StreamDeckActionClass {
1919
private _isInMultiAction: boolean = false;
2020
private _state: StateType;
2121
private _userDesiredState: StateType;
22+
private _controller: string;
2223

2324
constructor(private _handler: StreamDeckPluginHandler) {}
2425

@@ -200,6 +201,22 @@ export class StreamDeckActionClass {
200201
this._userDesiredState = value;
201202
}
202203

204+
/**
205+
* Sets the controller
206+
* @param {string} value
207+
*/
208+
public set controller(value: string) {
209+
this._controller = value;
210+
}
211+
212+
/**
213+
* Gets the controller
214+
* @returns {string} value
215+
*/
216+
public get controller(): string {
217+
return this._controller;
218+
}
219+
203220
/**
204221
* Disables automatic save
205222
*/
@@ -336,6 +353,7 @@ export class StreamDeckActionClass {
336353
_settings,
337354
_state,
338355
_userDesiredState,
356+
_controller
339357
} = self;
340358

341359
this._action = _action ?? this._action;
@@ -350,5 +368,6 @@ export class StreamDeckActionClass {
350368
this._settings = _settings ?? this._settings;
351369
this._state = _state ?? this._state;
352370
this._userDesiredState = _userDesiredState ?? this._userDesiredState;
371+
this._controller = _controller ?? this._controller;
353372
}
354373
}

src/interfaces/events/appearance/will-appear.event.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ export interface WillAppearEvent<Settings = any> extends AcdData {
1313
coordinates: Coordinates;
1414
state: StateType;
1515
isInMultiAction: boolean;
16+
controller: string;
1617
};
1718
}

src/interfaces/events/settings/did-receive-settings.event.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ export interface DidReceiveSettingsEvent<Settings = any> extends AcdData {
1111
settings: Settings;
1212
coordinates: Coordinates;
1313
isInMultiAction: boolean;
14+
controller: string;
1415
};
1516
}

0 commit comments

Comments
 (0)