mirror of
https://github.com/eugene-serb/wavelovers.git
synced 2023-09-09 23:41:16 +03:00
- made mixin ComputedGamepads.
- added mixin ComputedGamepads to AppDiagnostic. - added mixin ComputedGamepads to AppManual. - updated version.
This commit is contained in:
parent
b2ad331909
commit
3c892aa372
@ -2,7 +2,7 @@
|
|||||||
"name": "wavelovers",
|
"name": "wavelovers",
|
||||||
"description": "Wavelovers. Use your device vibration correctly. Make a massager out of a gamepad.",
|
"description": "Wavelovers. Use your device vibration correctly. Make a massager out of a gamepad.",
|
||||||
"keywords": [ "wavelovers", "gamepad-vibrator", "gamepad-test-tool", "gamepad-vibration-test-tool" ],
|
"keywords": [ "wavelovers", "gamepad-vibrator", "gamepad-test-tool", "gamepad-vibration-test-tool" ],
|
||||||
"version": "1.0.5",
|
"version": "1.0.6",
|
||||||
"license": "GNU GPL v3",
|
"license": "GNU GPL v3",
|
||||||
"homepage": "https://wavelovers.ru/",
|
"homepage": "https://wavelovers.ru/",
|
||||||
"author": {
|
"author": {
|
||||||
|
@ -13,48 +13,21 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
import store from '@/store/index';
|
|
||||||
import NavigationList from '@/components/NavigationList.vue';
|
import NavigationList from '@/components/NavigationList.vue';
|
||||||
import GamepadList from '@/components/GamepadList.vue';
|
import GamepadList from '@/components/GamepadList.vue';
|
||||||
import MessageItem from '@/components/MessageItem.vue';
|
import MessageItem from '@/components/MessageItem.vue';
|
||||||
import DiagnosticItem from '@/components/DiagnosticItem.vue';
|
import DiagnosticItem from '@/components/DiagnosticItem.vue';
|
||||||
import Vibrator from '@/models/Vibrator';
|
import ComputedGamepads from '@/mixins/ComputedGamepads.vue';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'AppDiagnostic',
|
name: 'AppDiagnostic',
|
||||||
|
mixins: [ComputedGamepads],
|
||||||
components: {
|
components: {
|
||||||
DiagnosticItem: DiagnosticItem,
|
DiagnosticItem: DiagnosticItem,
|
||||||
NavigationList: NavigationList,
|
NavigationList: NavigationList,
|
||||||
GamepadList: GamepadList,
|
GamepadList: GamepadList,
|
||||||
MessageItem: MessageItem,
|
MessageItem: MessageItem,
|
||||||
},
|
},
|
||||||
data: () => {
|
|
||||||
return {
|
|
||||||
timestamp: 0 as number,
|
|
||||||
interval: 0 as number,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
gamepads: function (): Vibrator[] {
|
|
||||||
const timestamp: number = this.timestamp;
|
|
||||||
const result: Vibrator[] = store.getters.gamepads as Vibrator[];
|
|
||||||
result.forEach((item) => {
|
|
||||||
item.interval = timestamp;
|
|
||||||
});
|
|
||||||
return result;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
updateComputed: function (): void {
|
|
||||||
this.timestamp = Date.now();
|
|
||||||
},
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.interval = setInterval(this.updateComputed, 1);
|
|
||||||
},
|
|
||||||
unmounted() {
|
|
||||||
clearInterval(this.interval);
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -47,12 +47,14 @@
|
|||||||
import NavigationList from '@/components/NavigationList.vue';
|
import NavigationList from '@/components/NavigationList.vue';
|
||||||
import GamepadList from '@/components/GamepadList.vue';
|
import GamepadList from '@/components/GamepadList.vue';
|
||||||
import MessageItem from '@/components/MessageItem.vue';
|
import MessageItem from '@/components/MessageItem.vue';
|
||||||
|
import ComputedGamepads from '@/mixins/ComputedGamepads.vue';
|
||||||
import Vibrator from '@/models/Vibrator';
|
import Vibrator from '@/models/Vibrator';
|
||||||
import TPatternUnit from '@/models/TPatternUnit';
|
import TPatternUnit from '@/models/TPatternUnit';
|
||||||
import PatternUnit from '@/models/PatternUnit';
|
import PatternUnit from '@/models/PatternUnit';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'AppCustom',
|
name: 'AppCustom',
|
||||||
|
mixins: [ComputedGamepads],
|
||||||
components: {
|
components: {
|
||||||
NavigationList: NavigationList,
|
NavigationList: NavigationList,
|
||||||
GamepadList: GamepadList,
|
GamepadList: GamepadList,
|
||||||
@ -60,8 +62,6 @@
|
|||||||
},
|
},
|
||||||
data: () => {
|
data: () => {
|
||||||
return {
|
return {
|
||||||
timestamp: 0 as number,
|
|
||||||
interval: 0 as number,
|
|
||||||
mode: 0 as number,
|
mode: 0 as number,
|
||||||
lock: false as boolean,
|
lock: false as boolean,
|
||||||
startDelay: 0 as number,
|
startDelay: 0 as number,
|
||||||
@ -70,16 +70,6 @@
|
|||||||
strongMagnitude: 0 as number,
|
strongMagnitude: 0 as number,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
|
||||||
gamepads: function (): Vibrator[] {
|
|
||||||
const timestamp: number = this.timestamp;
|
|
||||||
const result: Vibrator[] = store.getters.gamepads as Vibrator[];
|
|
||||||
result.forEach((item) => {
|
|
||||||
item.interval = timestamp;
|
|
||||||
})
|
|
||||||
return result;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
start: function (): void {
|
start: function (): void {
|
||||||
const pattern: TPatternUnit = new PatternUnit(
|
const pattern: TPatternUnit = new PatternUnit(
|
||||||
@ -101,9 +91,6 @@
|
|||||||
this.updatePattern();
|
this.updatePattern();
|
||||||
this.handle();
|
this.handle();
|
||||||
},
|
},
|
||||||
updateComputed: function (): void {
|
|
||||||
this.timestamp = Date.now();
|
|
||||||
},
|
|
||||||
updateMode: function (): void {
|
updateMode: function (): void {
|
||||||
if (this.gamepads.length > 0) {
|
if (this.gamepads.length > 0) {
|
||||||
if (this.gamepads[0].unit.buttons[1].pressed === true) {
|
if (this.gamepads[0].unit.buttons[1].pressed === true) {
|
||||||
@ -142,7 +129,7 @@
|
|||||||
},
|
},
|
||||||
handle: function (): void {
|
handle: function (): void {
|
||||||
if (this.gamepads.length > 0) {
|
if (this.gamepads.length > 0) {
|
||||||
this.gamepads.forEach((gamepad) => {
|
this.gamepads.forEach((gamepad: Vibrator) => {
|
||||||
if (gamepad.unit.buttons[7].value > 0 || this.lock === true) {
|
if (gamepad.unit.buttons[7].value > 0 || this.lock === true) {
|
||||||
this.start();
|
this.start();
|
||||||
} else {
|
} else {
|
||||||
@ -155,9 +142,6 @@
|
|||||||
mounted() {
|
mounted() {
|
||||||
this.interval = setInterval(this.eventLoop, 250);
|
this.interval = setInterval(this.eventLoop, 250);
|
||||||
},
|
},
|
||||||
unmounted() {
|
|
||||||
clearInterval(this.interval);
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
36
src/mixins/ComputedGamepads.vue
Normal file
36
src/mixins/ComputedGamepads.vue
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { defineComponent } from 'vue';
|
||||||
|
import store from '@/store/index';
|
||||||
|
import Vibrator from '@/models/Vibrator';
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
name: 'ComputedGamepads',
|
||||||
|
data: () => {
|
||||||
|
return {
|
||||||
|
timestamp: 0 as number,
|
||||||
|
interval: 0 as number,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
gamepads: function (): Vibrator[] {
|
||||||
|
const timestamp: number = this.timestamp;
|
||||||
|
const result: Vibrator[] = store.getters.gamepads as Vibrator[];
|
||||||
|
result.forEach((item) => {
|
||||||
|
item.interval = timestamp;
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
updateComputed: function (): void {
|
||||||
|
this.timestamp = Date.now();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.interval = setInterval(this.updateComputed, 1);
|
||||||
|
},
|
||||||
|
unmounted() {
|
||||||
|
clearInterval(this.interval);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
Loading…
Reference in New Issue
Block a user