@@ -10,8 +10,7 @@ import type {
10
10
StreamDeckEvents ,
11
11
StreamDeckLcdStripService ,
12
12
} from '../types'
13
- import type { StreamdeckImageWriter } from '../services/imageWriter/types'
14
- import { ButtonLcdImagePacker , ButtonsLcdService } from '../services/buttonsLcd'
13
+ import type { ButtonsLcdService } from '../services/buttonsLcd'
15
14
import type { StreamDeckButtonControlDefinition , StreamDeckControlDefinition } from './controlDefinition'
16
15
17
16
export type EncodeJPEGHelper = ( buffer : Buffer , width : number , height : number ) => Promise < Buffer >
@@ -42,7 +41,7 @@ export type StreamDeckProperties = Readonly<{
42
41
KEY_SPACING_VERTICAL : number
43
42
} >
44
43
45
- export abstract class StreamDeckInputBase extends EventEmitter < StreamDeckEvents > implements StreamDeck {
44
+ export abstract class StreamDeckBase extends EventEmitter < StreamDeckEvents > implements StreamDeck {
46
45
get CONTROLS ( ) : Readonly < StreamDeckControlDefinition [ ] > {
47
46
return this . deviceProperties . CONTROLS
48
47
}
@@ -78,14 +77,21 @@ export abstract class StreamDeckInputBase extends EventEmitter<StreamDeckEvents>
78
77
79
78
protected readonly device : HIDDevice
80
79
protected readonly deviceProperties : Readonly < StreamDeckProperties >
80
+ private readonly buttonsLcdService : ButtonsLcdService
81
81
// private readonly options: Readonly<OpenStreamDeckOptions>
82
82
private readonly keyState : boolean [ ]
83
83
84
- constructor ( device : HIDDevice , _options : OpenStreamDeckOptions , properties : StreamDeckProperties ) {
84
+ constructor (
85
+ device : HIDDevice ,
86
+ _options : OpenStreamDeckOptions ,
87
+ properties : StreamDeckProperties ,
88
+ buttonsLcdService : ButtonsLcdService
89
+ ) {
85
90
super ( )
86
91
87
92
this . deviceProperties = properties
88
93
this . device = device
94
+ this . buttonsLcdService = buttonsLcdService
89
95
90
96
const maxButtonIndex = properties . CONTROLS . filter (
91
97
( control ) : control is StreamDeckButtonControlDefinition => control . type === 'button'
@@ -136,7 +142,9 @@ export abstract class StreamDeckInputBase extends EventEmitter<StreamDeckEvents>
136
142
}
137
143
}
138
144
139
- public abstract calculateFillPanelDimensions ( options ?: FillPanelDimensionsOptions ) : Dimension | null
145
+ public calculateFillPanelDimensions ( options ?: FillPanelDimensionsOptions ) : Dimension | null {
146
+ return this . buttonsLcdService . calculateFillPanelDimensions ( options )
147
+ }
140
148
141
149
public async close ( ) : Promise < void > {
142
150
return this . device . close ( )
@@ -153,32 +161,6 @@ export abstract class StreamDeckInputBase extends EventEmitter<StreamDeckEvents>
153
161
public abstract getFirmwareVersion ( ) : Promise < string >
154
162
public abstract getSerialNumber ( ) : Promise < string >
155
163
156
- public abstract fillKeyColor ( keyIndex : KeyIndex , r : number , g : number , b : number ) : Promise < void >
157
- public abstract fillKeyBuffer ( keyIndex : KeyIndex , imageBuffer : Buffer , options ?: FillImageOptions ) : Promise < void >
158
- public abstract fillPanelBuffer ( imageBuffer : Buffer , options ?: FillPanelOptions ) : Promise < void >
159
-
160
- public abstract clearKey ( keyIndex : KeyIndex ) : Promise < void >
161
- public abstract clearPanel ( ) : Promise < void >
162
- }
163
-
164
- export abstract class StreamDeckBase extends StreamDeckInputBase {
165
- protected readonly buttonsLcdService : ButtonsLcdService
166
-
167
- constructor (
168
- device : HIDDevice ,
169
- options : OpenStreamDeckOptions ,
170
- properties : StreamDeckProperties ,
171
- imageWriter : StreamdeckImageWriter ,
172
- imagePacker : ButtonLcdImagePacker
173
- ) {
174
- super ( device , options , properties )
175
- this . buttonsLcdService = new ButtonsLcdService ( imageWriter , imagePacker , device , properties )
176
- }
177
-
178
- public calculateFillPanelDimensions ( options ?: FillPanelDimensionsOptions ) : Dimension | null {
179
- return this . buttonsLcdService . calculateFillPanelDimensions ( options )
180
- }
181
-
182
164
public async fillKeyColor ( keyIndex : KeyIndex , r : number , g : number , b : number ) : Promise < void > {
183
165
this . checkValidKeyIndex ( keyIndex , null )
184
166
0 commit comments