Additional media keys with icons (#307)
* Add missing scancodes for media keystrokes * Use icons for media keys * Fix media scancodes.
This commit is contained in:
committed by
László Monda
parent
a8a659dadd
commit
1a456c2ced
@@ -11,12 +11,13 @@ export class MapperService {
|
||||
private basicScanCodeTextMap: Map<number, string[]>;
|
||||
private mediaScanCodeTextMap: Map<number, string[]>;
|
||||
|
||||
private scanCodeFileName: Map<number, string>;
|
||||
private basicScancodeIcons: Map<number, string>;
|
||||
private mediaScancodeIcons: Map<number, string>;
|
||||
private nameToFileName: Map<string, string>;
|
||||
|
||||
constructor() {
|
||||
this.initScanCodeTextMap();
|
||||
this.initScanCodeFileName();
|
||||
this.initScancodeIcons();
|
||||
this.initNameToFileNames();
|
||||
}
|
||||
|
||||
@@ -34,16 +35,36 @@ export class MapperService {
|
||||
return map.get(scanCode);
|
||||
}
|
||||
|
||||
public hasScancodeIcon(scancode: number): boolean {
|
||||
return this.scanCodeFileName.has(scancode);
|
||||
public hasScancodeIcon(scancode: number, type = KeystrokeType.basic): boolean {
|
||||
let map: Map<number, string>;
|
||||
switch (type) {
|
||||
case KeystrokeType.basic:
|
||||
map = this.basicScancodeIcons;
|
||||
break;
|
||||
case KeystrokeType.shortMedia:
|
||||
case KeystrokeType.longMedia:
|
||||
map = this.mediaScancodeIcons;
|
||||
break;
|
||||
default:
|
||||
map = new Map<number, string>();
|
||||
}
|
||||
return map.has(scancode);
|
||||
}
|
||||
|
||||
public scanCodeToSvgImagePath(scanCode: number): string {
|
||||
const fileName: string = this.scanCodeFileName.get(scanCode);
|
||||
if (fileName) {
|
||||
return 'assets/compiled_sprite.svg#' + fileName;
|
||||
public scanCodeToSvgImagePath(scanCode: number, type = KeystrokeType.basic): string {
|
||||
let map: Map<number, string>;
|
||||
switch (type) {
|
||||
case KeystrokeType.basic:
|
||||
map = this.basicScancodeIcons;
|
||||
break;
|
||||
case KeystrokeType.shortMedia:
|
||||
case KeystrokeType.longMedia:
|
||||
map = this.mediaScancodeIcons;
|
||||
break;
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
return undefined;
|
||||
return 'assets/compiled_sprite.svg#' + map.get(scanCode);
|
||||
}
|
||||
|
||||
public getIcon(iconName: string): string {
|
||||
@@ -174,27 +195,34 @@ export class MapperService {
|
||||
this.basicScanCodeTextMap.set(177, ['000']);
|
||||
|
||||
this.mediaScanCodeTextMap = new Map<number, string[]>();
|
||||
this.mediaScanCodeTextMap.set(138, ['WWW']);
|
||||
this.mediaScanCodeTextMap.set(176, ['Play']);
|
||||
this.mediaScanCodeTextMap.set(177, ['Pause']);
|
||||
this.mediaScanCodeTextMap.set(181, ['Next']);
|
||||
this.mediaScanCodeTextMap.set(182, ['Prev']);
|
||||
this.mediaScanCodeTextMap.set(183, ['Stop']);
|
||||
this.mediaScanCodeTextMap.set(184, ['Eject']);
|
||||
this.mediaScanCodeTextMap.set(204, ['Eject', 'Stop']);
|
||||
this.mediaScanCodeTextMap.set(205, ['Pause', 'Play']);
|
||||
this.mediaScanCodeTextMap.set(226, ['Mute']);
|
||||
this.mediaScanCodeTextMap.set(232, ['Play']);
|
||||
this.mediaScanCodeTextMap.set(233, ['Stop']);
|
||||
this.mediaScanCodeTextMap.set(234, ['Prev']);
|
||||
this.mediaScanCodeTextMap.set(235, ['Next']);
|
||||
this.mediaScanCodeTextMap.set(236, ['Eject']);
|
||||
this.mediaScanCodeTextMap.set(237, ['Vol +']);
|
||||
this.mediaScanCodeTextMap.set(238, ['Vol -']);
|
||||
this.mediaScanCodeTextMap.set(240, ['WWW']);
|
||||
this.mediaScanCodeTextMap.set(241, ['Bckwrd']);
|
||||
this.mediaScanCodeTextMap.set(242, ['Frwrd']);
|
||||
this.mediaScanCodeTextMap.set(243, ['Cancel']);
|
||||
this.mediaScanCodeTextMap.set(233, ['Vol +']);
|
||||
this.mediaScanCodeTextMap.set(234, ['Vol -']);
|
||||
}
|
||||
|
||||
private initScanCodeFileName(): void {
|
||||
this.scanCodeFileName = new Map<number, string>();
|
||||
this.scanCodeFileName.set(79, 'icon-kbd__mod--arrow-right');
|
||||
this.scanCodeFileName.set(80, 'icon-kbd__mod--arrow-left');
|
||||
this.scanCodeFileName.set(81, 'icon-kbd__mod--arrow-down');
|
||||
this.scanCodeFileName.set(82, 'icon-kbd__mod--arrow-up');
|
||||
this.scanCodeFileName.set(118, 'icon-kbd__mod--menu');
|
||||
private initScancodeIcons(): void {
|
||||
this.basicScancodeIcons = new Map<number, string>();
|
||||
this.basicScancodeIcons.set(79, 'icon-kbd__mod--arrow-right');
|
||||
this.basicScancodeIcons.set(80, 'icon-kbd__mod--arrow-left');
|
||||
this.basicScancodeIcons.set(81, 'icon-kbd__mod--arrow-down');
|
||||
this.basicScancodeIcons.set(82, 'icon-kbd__mod--arrow-up');
|
||||
this.basicScancodeIcons.set(118, 'icon-kbd__mod--menu');
|
||||
|
||||
this.mediaScancodeIcons = new Map<number, string>();
|
||||
this.mediaScancodeIcons.set(176, 'icon-kbd__media--play');
|
||||
this.mediaScancodeIcons.set(177, 'icon-kbd__media--pause');
|
||||
this.mediaScancodeIcons.set(181, 'icon-kbd__media--next');
|
||||
this.mediaScancodeIcons.set(182, 'icon-kbd__media--prev');
|
||||
this.mediaScancodeIcons.set(226, 'icon-kbd__media--mute');
|
||||
}
|
||||
|
||||
private initNameToFileNames(): void {
|
||||
|
||||
Reference in New Issue
Block a user