@@ -369,27 +369,27 @@ export class RatBagButton extends DBusObject {
369
369
*/
370
370
public async mapping ( ) : Promise < RatBagMapping > {
371
371
// eslint-disable-next-line @typescript-eslint/no-explicit-any
372
- const raw : [ number , any ] = ( await this . getProperty ( "org.freedesktop.ratbag1.Button" , "Mapping" ) ) . value ;
372
+ const raw : [ number , Variant ] = ( await this . getProperty ( "org.freedesktop.ratbag1.Button" , "Mapping" ) ) . value ;
373
373
if ( raw [ 0 ] === 0 ) {
374
374
return {
375
375
type : "none" ,
376
376
} ;
377
377
} else if ( raw [ 0 ] === 1 ) {
378
378
return {
379
379
type : "button" ,
380
- button : raw [ 1 ] ,
380
+ button : raw [ 1 ] . value ,
381
381
} ;
382
382
} else if ( raw [ 0 ] === 2 ) {
383
383
const id = Object . keys ( RatBagButton . SPECIAL_ACTION_MAP ) . find (
384
- ( key ) => RatBagButton . SPECIAL_ACTION_MAP [ key as RatBagSpecialAction ] === raw [ 1 ] ,
384
+ ( key ) => RatBagButton . SPECIAL_ACTION_MAP [ key as RatBagSpecialAction ] === raw [ 1 ] . value ,
385
385
) as RatBagSpecialAction | undefined ;
386
386
return {
387
387
type : "special" ,
388
388
action : id === undefined ? "unknown" : id ,
389
389
} ;
390
390
} else if ( raw [ 0 ] === 3 ) {
391
391
const macro : RatBagMacroAction [ ] = [ ] ;
392
- for ( const entry of raw [ 1 ] as [ number , number ] [ ] ) {
392
+ for ( const entry of raw [ 1 ] . value as [ number , number ] [ ] ) {
393
393
macro . push ( {
394
394
type : entry [ 0 ] === 0 ? "release" : "press" ,
395
395
keyCode : entry [ 1 ] ,
@@ -410,22 +410,27 @@ export class RatBagButton extends DBusObject {
410
410
* Binds this button to the given action.
411
411
*/
412
412
public async setMapping ( mapping : RatBagMapping ) : Promise < void > {
413
- let variant : Variant = new Variant < [ number , number ] > ( "(uu)" , [ 1000 , 0 ] ) ;
413
+ let id = 1000 ;
414
+ let variant : Variant = new Variant < number > ( "u" , 0 ) ;
414
415
if ( mapping . type === "none" ) {
415
- variant = new Variant < [ number , number ] > ( "(uu)" , [ 0 , 0 ] ) ;
416
+ id = 1000 ;
417
+ variant = new Variant < number > ( "u" , 0 ) ;
416
418
} else if ( mapping . type === "button" ) {
417
- variant = new Variant < [ number , number ] > ( "(uu)" , [ 1 , mapping . button ] ) ;
419
+ id = 1 ;
420
+ variant = new Variant < number > ( "u" , mapping . button ) ;
418
421
} else if ( mapping . type === "special" ) {
422
+ id = 2 ;
419
423
const func = RatBagButton . SPECIAL_ACTION_MAP [ mapping . action ] ;
420
- variant = new Variant < [ number , number ] > ( "(uu) " , [ 2 , func === undefined ? 0x40000000 : func ] ) ;
424
+ variant = new Variant < number > ( "u " , func === undefined ? 0x40000000 : func ) ;
421
425
} else if ( mapping . type === "macro" ) {
426
+ id = 3 ;
422
427
const actions : [ number , number ] [ ] = [ ] ;
423
428
for ( const action of mapping . macro ) {
424
429
actions . push ( [ action . type === "press" ? 1 : 0 , action . keyCode ] ) ;
425
430
}
426
- variant = new Variant < [ number , [ number , number ] [ ] ] > ( "(ua( uu)) " , [ 3 , actions ] ) ;
431
+ variant = new Variant < [ number , number ] [ ] > ( "a( uu)" , actions ) ;
427
432
}
428
- await this . setProperty ( "org.freedesktop.ratbag1.Button" , "Mapping" , variant ) ;
433
+ await this . setProperty ( "org.freedesktop.ratbag1.Button" , "Mapping" , new Variant ( "(uv)" , [ id , variant ] ) ) ;
429
434
}
430
435
}
431
436
0 commit comments