- added interface IPatternUnit and his implementation PatternUnit.

- deleted createPatternUnit-function in AppCustom and AppManual, used now class PatternUnit to create.
- deleted consoles in AppManual.
- updated dependencies.
This commit is contained in:
Eugene Serb 2022-08-11 13:59:33 +03:00
parent d340a6e81d
commit 34e3db0d02
5 changed files with 65 additions and 43 deletions

24
package-lock.json generated
View File

@ -2219,9 +2219,9 @@
"dev": true
},
"node_modules/@types/node": {
"version": "18.6.5",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.6.5.tgz",
"integrity": "sha512-Xjt5ZGUa5WusGZJ4WJPbOT8QOqp6nDynVFRKcUt32bOgvXEoc6o085WNkYTMO7ifAj2isEfQQ2cseE+wT6jsRw==",
"version": "18.7.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.1.tgz",
"integrity": "sha512-GKX1Qnqxo4S+Z/+Z8KKPLpH282LD7jLHWJcVryOflnsnH+BtSDfieR6ObwBMwpnNws0bUK8GI7z0unQf9bARNQ==",
"dev": true
},
"node_modules/@types/normalize-package-data": {
@ -5186,9 +5186,9 @@
"dev": true
},
"node_modules/electron-to-chromium": {
"version": "1.4.213",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.213.tgz",
"integrity": "sha512-+3DbGHGOCHTVB/Ms63bGqbyC1b8y7Fk86+7ltssB8NQrZtSCvZG6eooSl9U2Q0yw++fL2DpHKOdTU0NVEkFObg==",
"version": "1.4.215",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.215.tgz",
"integrity": "sha512-vqZxT8C5mlDZ//hQFhneHmOLnj1LhbzxV0+I1yqHV8SB1Oo4Y5Ne9+qQhwHl7O1s9s9cRuo2l5CoLEHdhMTwZg==",
"dev": true
},
"node_modules/emoji-regex": {
@ -13592,9 +13592,9 @@
"dev": true
},
"@types/node": {
"version": "18.6.5",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.6.5.tgz",
"integrity": "sha512-Xjt5ZGUa5WusGZJ4WJPbOT8QOqp6nDynVFRKcUt32bOgvXEoc6o085WNkYTMO7ifAj2isEfQQ2cseE+wT6jsRw==",
"version": "18.7.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.1.tgz",
"integrity": "sha512-GKX1Qnqxo4S+Z/+Z8KKPLpH282LD7jLHWJcVryOflnsnH+BtSDfieR6ObwBMwpnNws0bUK8GI7z0unQf9bARNQ==",
"dev": true
},
"@types/normalize-package-data": {
@ -15802,9 +15802,9 @@
"dev": true
},
"electron-to-chromium": {
"version": "1.4.213",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.213.tgz",
"integrity": "sha512-+3DbGHGOCHTVB/Ms63bGqbyC1b8y7Fk86+7ltssB8NQrZtSCvZG6eooSl9U2Q0yw++fL2DpHKOdTU0NVEkFObg==",
"version": "1.4.215",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.215.tgz",
"integrity": "sha512-vqZxT8C5mlDZ//hQFhneHmOLnj1LhbzxV0+I1yqHV8SB1Oo4Y5Ne9+qQhwHl7O1s9s9cRuo2l5CoLEHdhMTwZg==",
"dev": true
},
"emoji-regex": {

View File

@ -37,6 +37,7 @@
import { defineComponent } from 'vue';
import store from '@/store/index';
import TPatternUnit from '@/models/TPatternUnit';
import PatternUnit from '@/models/PatternUnit';
export default defineComponent({
name: 'AppCustom',
@ -49,17 +50,14 @@
};
},
methods: {
createPatternUnit: function (): TPatternUnit[] {
const patternUnit: TPatternUnit[] = [{
startDelay: this.startDelay,
duration: this.duration,
weakMagnitude: this.weakMagnitude,
strongMagnitude: this.strongMagnitude,
}];
return patternUnit as TPatternUnit[];
},
start: function (): void {
store.dispatch('startCustom', this.createPatternUnit());
const patterns: TPatternUnit[] = [new PatternUnit(
this.startDelay,
this.duration,
this.weakMagnitude,
this.strongMagnitude,
)];
store.dispatch('startCustom', patterns);
},
stop: function (): void {
store.dispatch('reset');

View File

@ -42,19 +42,20 @@
import store from '@/store/index';
import Vibrator from '@/models/Vibrator';
import TPatternUnit from '@/models/TPatternUnit';
import PatternUnit from '@/models/PatternUnit';
export default defineComponent({
name: 'AppCustom',
data: () => {
return {
startDelay: 0 as number,
duration: 260 as number,
weakMagnitude: 0 as number,
strongMagnitude: 0 as number,
timestamp: 0 as number,
interval: 0 as number,
mode: 0 as number,
lock: false as boolean,
startDelay: 0 as number,
duration: 260 as number,
weakMagnitude: 0 as number,
strongMagnitude: 0 as number,
};
},
computed: {
@ -68,17 +69,14 @@
},
},
methods: {
createPatternUnit: function (): TPatternUnit {
const patternUnit: TPatternUnit = {
startDelay: this.startDelay,
duration: this.duration,
weakMagnitude: this.weakMagnitude,
strongMagnitude: this.strongMagnitude,
};
return patternUnit as TPatternUnit;
},
start: function (): void {
store.dispatch('startCustom', this.createPatternUnit());
const pattern: TPatternUnit = new PatternUnit(
this.startDelay,
this.duration,
this.weakMagnitude,
this.strongMagnitude,
);
store.dispatch('vibrate', pattern);
},
stop: function (): void {
store.dispatch('setIsActive', false);
@ -98,20 +96,16 @@
if (this.gamepads.length > 0) {
if (this.gamepads[0].unit.buttons[1].pressed === true) {
this.lock = !this.lock;
console.log('B', this.lock);
}
if (this.lock === false) {
if (this.gamepads[0].unit.buttons[0].pressed === true) {
this.mode = 0;
console.log('A', this.mode);
}
if (this.gamepads[0].unit.buttons[2].pressed === true) {
this.mode = 1;
console.log('X', this.mode);
}
if (this.gamepads[0].unit.buttons[3].pressed === true) {
this.mode = 2;
console.log('Y', this.mode);
}
}
}
@ -137,9 +131,8 @@
handle: function (): void {
if (this.gamepads.length > 0) {
this.gamepads.forEach((gamepad) => {
if (gamepad.unit.buttons[7].value > 0
|| this.lock === true) {
gamepad.unit.vibrationActuator.playEffect('dual-rumble', this.createPatternUnit());
if (gamepad.unit.buttons[7].value > 0 || this.lock === true) {
this.start();
} else {
this.stop();
}

View File

@ -0,0 +1,9 @@
interface IPatternUnit {
startDelay: number;
duration: number;
weakMagnitude: number;
strongMagnitude: number;
}
export default IPatternUnit;

22
src/models/PatternUnit.ts Normal file
View File

@ -0,0 +1,22 @@
import IPatternUnit from "@/models/IPatternUnit";
class PatternUnit implements IPatternUnit {
startDelay: number;
duration: number;
weakMagnitude: number;
strongMagnitude: number;
constructor(
startDelay: number, duration: number,
weakMagnitude: number, strongMagnitude: number
) {
this.startDelay = startDelay;
this.duration = duration;
this.weakMagnitude = weakMagnitude;
this.strongMagnitude = strongMagnitude;
}
}
export default PatternUnit;