Skip to content

Commit

Permalink
adding toolbar icon and fix reacticate issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jparez committed Jun 26, 2024
1 parent 0f2f58b commit ca11d54
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 4 deletions.
12 changes: 12 additions & 0 deletions src/assets/images/ic_keymapping.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions src/assets/images/ic_keymapping_desactivate.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions src/assets/images/ic_keymapping_desactivate_hover.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions src/assets/images/ic_keymapping_disabled.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions src/assets/images/ic_keymapping_hover.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 7 additions & 4 deletions src/plugins/KeyboardMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,10 @@ module.exports = class KeyboardMapping {
break;
case 'isPaused':
if (value) {
this.toolbarBtnImage.classList.add('keymapping-paused');
this.state.isActive = false;
} else {
this.toolbarBtnImage.classList.remove('keymapping-paused');
this.state.isActive = true;
}
break;
Expand Down Expand Up @@ -334,7 +336,7 @@ module.exports = class KeyboardMapping {
const toolbar = toolbars.children[0];
this.toolbarBtn = document.createElement('li');
this.toolbarBtnImage = document.createElement('div');
this.toolbarBtnImage.className = 'gm-icon-button gm-fingerprint-button';
this.toolbarBtnImage.className = 'gm-icon-button gm-keymapping-button';
this.toolbarBtnImage.title = this.i18n.KEYMAPPING_TITLE || 'Key Mapping';
this.toolbarBtn.onclick = () => (this.state.isActive = !this.state.isActive);
this.toolbarBtn.appendChild(this.toolbarBtnImage);
Expand All @@ -357,7 +359,7 @@ module.exports = class KeyboardMapping {
// reset
this.state.workingMappedKeysConfig = {};

// Create a working version of the mappedKeysConfig, this will chane the structure to be more performant and avoid incepth loop
// Create a working version of the mappedKeysConfig, this will change the structure to be more performant and avoid incepth loop
Object.entries(this.state.mappedKeysConfig).forEach(([gestureType, gestureConfig]) => {
gestureConfig.forEach((gesture) => {
const groupId = generateUID();
Expand Down Expand Up @@ -420,7 +422,7 @@ module.exports = class KeyboardMapping {
.map((kConfig) => kConfig.key);
const dPadGroupKeysPressed = dPadGroupKeys.filter((k) => this.state.currentlyPressedKeys.includes(k));
if (!dPadGroupKeysPressed.length) {
this.dPadPushed = this.dPadPushed.filter((groupId) => groupId !== keyConfig.groupId);
this.dPadPushed = this.dPadPushed.filter((groupId) => groupId !== keyConfig.groupId);
}
}
}
Expand Down Expand Up @@ -566,6 +568,7 @@ module.exports = class KeyboardMapping {
this.keyboardCallbacks.forEach((item) => {
item.removeListener();
});
this.keyboardCallbacks.length = 0;
}

tilt() {
Expand Down Expand Up @@ -694,6 +697,6 @@ module.exports = class KeyboardMapping {
(videoSize.height - this.instance.coordinateUtils.getTopBorder() * 2) *
this.instance.coordinateUtils.getYRatio();

return {x: xFromPercent, y: yFromPercent};
return {x: Math.floor(xFromPercent), y: Math.floor(yFromPercent)};
}
};
16 changes: 16 additions & 0 deletions src/scss/components/_toolbar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,22 @@
}
}

&-keymapping-button {
background-image: url('../assets/images/ic_keymapping_desactivate.svg');
&:hover {
background-image: url('../assets/images/ic_keymapping_desactivate_hover.svg');
}
&.gm-active {
background-image: url('../assets/images/ic_keymapping.svg');
}
&.gm-active:hover {
background-image: url('../assets/images/ic_keymapping_hover.svg');
}
&.keymapping-paused {
background-image: url('../assets/images/ic_keymapping_disabled.svg');
}
}

&-default-turn-button {
background-image: url('../assets/images/ic_warning.svg');
}
Expand Down

0 comments on commit ca11d54

Please sign in to comment.