Add new system scan codes (#316)

Closes #304
This commit is contained in:
Attila Csanyi
2017-06-21 20:09:39 +02:00
committed by József Farkas
parent 6e23b2a91b
commit 2598109f8c
6 changed files with 66 additions and 1 deletions

View File

@@ -195,7 +195,8 @@ export class KeypressTabComponent extends Tab implements OnChanges {
}
private findScancodeOptionByScancode(scancode: number, type: KeystrokeType): Select2OptionData {
const typeToFind: string = type === KeystrokeType.shortMedia || KeystrokeType.longMedia ? 'media' : KeystrokeType[type];
const typeToFind: string =
(type === KeystrokeType.shortMedia || type === KeystrokeType.longMedia) ? 'media' : KeystrokeType[type];
return this.findScancodeOptionBy((option: Select2OptionData) => {
const additional = option.additional;
if (additional && additional.scancode === scancode && additional.type === typeToFind) {

View File

@@ -654,5 +654,34 @@
}
}
]
},
{
"text": "System Keys",
"children": [
{
"id": "139",
"text": "Power Down",
"additional": {
"type": "system",
"scancode": 129
}
},
{
"id": "140",
"text": "Sleep",
"additional": {
"type": "system",
"scancode": 130
}
},
{
"id": "141",
"text": "Wake Up",
"additional": {
"type": "system",
"scancode": 131
}
}
]
}
]

View File

@@ -10,9 +10,11 @@ export class MapperService {
private basicScanCodeTextMap: Map<number, string[]>;
private mediaScanCodeTextMap: Map<number, string[]>;
private sytemScanCodeTextMap: Map<number, string[]>;
private basicScancodeIcons: Map<number, string>;
private mediaScancodeIcons: Map<number, string>;
private systemScancodeIcons: Map<number, string>;
private nameToFileName: Map<string, string>;
constructor() {
@@ -28,6 +30,9 @@ export class MapperService {
case KeystrokeType.longMedia:
map = this.mediaScanCodeTextMap;
break;
case KeystrokeType.system:
map = this.sytemScanCodeTextMap;
break;
default:
map = this.basicScanCodeTextMap;
break;
@@ -45,6 +50,9 @@ export class MapperService {
case KeystrokeType.longMedia:
map = this.mediaScancodeIcons;
break;
case KeystrokeType.system:
map = this.systemScancodeIcons;
break;
default:
map = new Map<number, string>();
}
@@ -61,6 +69,9 @@ export class MapperService {
case KeystrokeType.longMedia:
map = this.mediaScancodeIcons;
break;
case KeystrokeType.system:
map = this.systemScancodeIcons;
break;
default:
return undefined;
}
@@ -207,6 +218,11 @@ export class MapperService {
this.mediaScanCodeTextMap.set(226, ['Mute']);
this.mediaScanCodeTextMap.set(233, ['Vol +']);
this.mediaScanCodeTextMap.set(234, ['Vol -']);
this.sytemScanCodeTextMap = new Map<number, string[]>();
this.sytemScanCodeTextMap.set(129, ['Power Down']);
this.sytemScanCodeTextMap.set(130, ['Sleep']);
this.sytemScanCodeTextMap.set(131, ['Wake Up']);
}
private initScancodeIcons(): void {
@@ -227,6 +243,11 @@ export class MapperService {
this.mediaScancodeIcons.set(226, 'icon-kbd__media--mute');
this.mediaScancodeIcons.set(233, 'icon-kbd__media--vol-up');
this.mediaScancodeIcons.set(234, 'icon-kbd__media--vol-down');
this.systemScancodeIcons = new Map<number, string>();
this.systemScancodeIcons.set(129, 'icon-kbd__system_power_down');
this.systemScancodeIcons.set(130, 'icon-kbd__system_sleep');
this.systemScancodeIcons.set(131, 'icon-kbd__system_wake_up');
}
private initNameToFileNames(): void {