File tree 1 file changed +11
-3
lines changed
examples/webengine/hello-sdl
1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 171
171
} ;
172
172
173
173
if ( ! this . _isButtonSubscriptionRequested && isRpcAllowed ( SDL . rpc . enums . FunctionID . SubscribeButton ) ) {
174
+ const availableButtons = this . _sdlManager . getRegisterAppInterfaceResponse ( ) . getButtonCapabilities ( ) . map ( function ( capability ) {
175
+ return capability . getNameParam ( ) ;
176
+ } ) ;
177
+
174
178
// add button listeners
175
179
const screenManager = this . _sdlManager . getScreenManager ( ) ;
176
180
const ButtonName = SDL . rpc . enums . ButtonName ;
180
184
ButtonName . TUNEUP , ButtonName . TUNEDOWN ] ;
181
185
182
186
for ( const buttonName of buttonNames ) {
183
- await screenManager . addButtonListener ( buttonName , this . _onButtonListener . bind ( this ) )
184
- . catch ( ( reason ) => {
185
- this . _logRegularMessage ( `Unable to subscribe to button: ${ reason } ` ) ;
187
+ if ( availableButtons . indexOf ( buttonName ) > 0 ) {
188
+ console . log ( 'Subscribing to' , buttonName ) ;
189
+ await screenManager . addButtonListener ( buttonName , this . _onButtonListener . bind ( this ) ) . catch ( function ( err ) {
190
+ console . error ( err ) ;
186
191
} ) ;
192
+ } else {
193
+ console . log ( 'No capability found for button' , buttonName ) ;
194
+ }
187
195
}
188
196
189
197
this . _isButtonSubscriptionRequested = true ;
You can’t perform that action at this time.
0 commit comments