diff --git a/packages/uhk-web/src/app/components/macro/list/macro-list.component.html b/packages/uhk-web/src/app/components/macro/list/macro-list.component.html
index c6db3039..00e41235 100644
--- a/packages/uhk-web/src/app/components/macro/list/macro-list.component.html
+++ b/packages/uhk-web/src/app/components/macro/list/macro-list.component.html
@@ -25,13 +25,15 @@
-
\ No newline at end of file
+
diff --git a/packages/uhk-web/src/app/components/macro/list/macro-list.component.scss b/packages/uhk-web/src/app/components/macro/list/macro-list.component.scss
index 98c6ad91..d8c0bf88 100644
--- a/packages/uhk-web/src/app/components/macro/list/macro-list.component.scss
+++ b/packages/uhk-web/src/app/components/macro/list/macro-list.component.scss
@@ -1,4 +1,5 @@
@import '../../../../styles/variables';
+@import '../../../../styles/common';
:host {
display: flex;
@@ -112,7 +113,6 @@ h1 {
&--link {
width: 50%;
float: left;
- padding: 10px 5px;
text-align: center;
color: $icon-hover;
@@ -124,6 +124,10 @@ h1 {
text-decoration: none;
background: #e6e6e6;
}
+
+ button.btn-link {
+ @extend %btn-link;
+ }
}
.fa-circle {
diff --git a/packages/uhk-web/src/app/components/macro/list/macro-list.component.ts b/packages/uhk-web/src/app/components/macro/list/macro-list.component.ts
index ae41d72d..748a38f2 100644
--- a/packages/uhk-web/src/app/components/macro/list/macro-list.component.ts
+++ b/packages/uhk-web/src/app/components/macro/list/macro-list.component.ts
@@ -1,8 +1,9 @@
import { Component, EventEmitter, Input, Output, QueryList, ViewChildren, forwardRef } from '@angular/core';
import { animate, state, style, transition, trigger } from '@angular/animations';
import { DragulaService } from 'ng2-dragula/ng2-dragula';
-import { Macro, MacroAction } from 'uhk-common';
+import { Macro, MacroAction, KeyMacroAction, KeystrokeAction, MacroSubAction } from 'uhk-common';
+import { MapperService } from '../../../services/mapper.service';
import { MacroItemComponent } from '../item';
@Component({
@@ -46,7 +47,10 @@ export class MacroListComponent {
private activeEdit: number = undefined;
private dragIndex: number;
- constructor(dragulaService: DragulaService) {
+ constructor(
+ private mapper: MapperService,
+ private dragulaService: DragulaService
+ ) {
/* tslint:disable:no-unused-variable: Used by Dragula. */
dragulaService.setOptions('macroActions', {
moves: function (el: any, container: any, handle: any) {
@@ -121,6 +125,27 @@ export class MacroListComponent {
this.hideActiveEditor();
}
+ onKeysCapture(event: { code: number, left: boolean[], right: boolean[] }) {
+ const keyMacroAction = Object.assign(new KeyMacroAction(), this.toKeyAction(event));
+ keyMacroAction.action = MacroSubAction.press;
+
+ this.add.emit({
+ macroId: this.macro.id,
+ action: keyMacroAction
+ });
+ }
+
+ private toKeyAction(event: { code: number, left: boolean[], right: boolean[] }): KeystrokeAction {
+ const keystrokeAction: KeystrokeAction = new KeystrokeAction();
+ keystrokeAction.scancode = event.code;
+ keystrokeAction.modifierMask = 0;
+ const modifiers = event.left.concat(event.right).map(x => x ? 1 : 0);
+ for (let i = 0; i < modifiers.length; ++i) {
+ keystrokeAction.modifierMask |= modifiers[i] << this.mapper.modifierMapper(i);
+ }
+ return keystrokeAction;
+ }
+
private hideActiveEditor() {
if (this.activeEdit !== undefined) {
this.macroItems.toArray()[this.activeEdit].cancelEdit();
diff --git a/packages/uhk-web/src/app/components/popover/widgets/capture-keystroke/capture-keystroke-button.component.html b/packages/uhk-web/src/app/components/popover/widgets/capture-keystroke/capture-keystroke-button.component.html
index f9df04bf..e739e608 100644
--- a/packages/uhk-web/src/app/components/popover/widgets/capture-keystroke/capture-keystroke-button.component.html
+++ b/packages/uhk-web/src/app/components/popover/widgets/capture-keystroke/capture-keystroke-button.component.html
@@ -1,12 +1,15 @@
-
\ No newline at end of file
+